Comparing version 0.3.0 to 0.4.0
{ | ||
"name": "jsmodbus", | ||
"version": "0.3.0", | ||
"version": "0.4.0", | ||
"description": "Implementation for the Serial/TCP Modbus protocol.", | ||
@@ -12,3 +12,4 @@ "author": "Stefan Poeter <stefan.poeter@cloud-automation.de>", | ||
"dependencies": { | ||
"put": "0.0.6" | ||
"put": "0.0.6", | ||
"q" : "1.0.1" | ||
}, | ||
@@ -15,0 +16,0 @@ "devDependencies": { |
var Put = require('put'); | ||
var util = require('util'); | ||
var Put = require('put'), | ||
util = require('util'), | ||
log = function (msg) { }; | ||
var log = function (msg) { }; | ||
exports.setLogger = function (logger) { | ||
@@ -151,3 +150,3 @@ log = logger; | ||
// ReadCoils | ||
1 : function (pdu, cb) { | ||
1 : function (pdu, cb, defer) { | ||
@@ -177,6 +176,7 @@ log("handeling read coils response."); | ||
cb(resp); | ||
defer.resolve(resp); | ||
}, | ||
// ReadInputRegister | ||
4 : function (pdu, cb) { | ||
4 : function (pdu, cb, defer) { | ||
@@ -201,4 +201,6 @@ log("handling read input register response."); | ||
cb(resp); | ||
defer.resolve(resp); | ||
}, | ||
5 : function (pdu, cb) { | ||
5 : function (pdu, cb, defer) { | ||
@@ -218,4 +220,6 @@ log("handling write single coil response."); | ||
cb(resp); | ||
defer.resolve(resp); | ||
}, | ||
6 : function (pdu, cb) { | ||
6 : function (pdu, cb, defer) { | ||
@@ -235,2 +239,4 @@ log("handling write single register response."); | ||
cb(resp); | ||
defer.resolve(resp); | ||
} | ||
@@ -237,0 +243,0 @@ |
var util = require('util'), | ||
Put = require('put'); | ||
Put = require('put'), | ||
Q = require('q'); | ||
@@ -56,6 +57,7 @@ var Handler = require('./handler'); | ||
readCoils: function (start, quantity, cb) { | ||
var fc = 1, | ||
pdu = that.pduWithTwoParameter(fc, start, quantity); | ||
var fc = 1, | ||
defer = Q.defer(), | ||
pdu = that.pduWithTwoParameter(fc, start, quantity); | ||
that.makeRequest(fc, pdu, !cb?dummy:cb); | ||
return that.makeRequest(fc, pdu, !cb?dummy:cb, defer); | ||
}, | ||
@@ -66,5 +68,6 @@ | ||
var fc = 4, | ||
defer = Q.defer(), | ||
pdu = that.pduWithTwoParameter(fc, start, quantity); | ||
that.makeRequest(fc, pdu, !cb?dummy:cb); | ||
return that.makeRequest(fc, pdu, !cb?dummy:cb, defer); | ||
@@ -75,6 +78,7 @@ }, | ||
var fc = 5, | ||
pdu = that.pduWithTwoParameter(fc, address, value?0xff00:0x0000); | ||
var fc = 5, | ||
defer = Q.defer(), | ||
pdu = that.pduWithTwoParameter(fc, address, value?0xff00:0x0000); | ||
that.makeRequest(fc, pdu, !cb?dummy:cb); | ||
return that.makeRequest(fc, pdu, !cb?dummy:cb, defer); | ||
@@ -84,6 +88,7 @@ }, | ||
writeSingleRegister: function (address, value, cb) { | ||
var fc = 6, | ||
pdu = that.pduWithTwoParameter(fc, address, value); | ||
var fc = 6, | ||
defer = Q.defer(), | ||
pdu = that.pduWithTwoParameter(fc, address, value); | ||
that.makeRequest(fc, pdu, !cb?dummy:cb); | ||
return that.makeRequest(fc, pdu, !cb?dummy:cb, defer); | ||
}, | ||
@@ -118,5 +123,5 @@ | ||
*/ | ||
proto.makeRequest = function (fc, pdu, cb) { | ||
proto.makeRequest = function (fc, pdu, cb, defer) { | ||
var req = { fc: fc, cb: cb, pdu: pdu }; | ||
var req = { fc: fc, cb: cb, pdu: pdu, defer: defer }; | ||
@@ -129,2 +134,4 @@ this.pipe.push(req); | ||
return defer.promise; | ||
}; | ||
@@ -193,3 +200,3 @@ | ||
} | ||
handler(pdu, that.current.cb); | ||
handler(pdu, that.current.cb, that.current.defer); | ||
@@ -196,0 +203,0 @@ that.current = null; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
65842
18
1864
2