modbus-serial
Advanced tools
Comparing version 4.0.1 to 4.0.2
{ | ||
"name": "modbus-serial", | ||
"version": "4.0.1", | ||
"version": "4.0.2", | ||
"description": "A pure JavaScript implemetation of MODBUS-RTU (and TCP) for NodeJS.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -70,7 +70,2 @@ 'use strict'; | ||
this._buffer = this._buffer.slice(start + length); | ||
// reset internal vars | ||
this._id = 0; | ||
this._cmd = 0; | ||
this._length = 0; | ||
}; | ||
@@ -77,0 +72,0 @@ |
@@ -17,2 +17,3 @@ 'use strict'; | ||
this.openFlag = false; | ||
this.callback = null; | ||
@@ -23,2 +24,11 @@ // options | ||
// handle callback - call a callback function only once, for the first event | ||
// it will triger | ||
var handleCallback = function(had_error) { | ||
if (modbus.callback) { | ||
modbus.callback(had_error); | ||
modbus.callback = null; | ||
} | ||
} | ||
// create a socket | ||
@@ -45,2 +55,3 @@ this._client = new net.Socket(); | ||
modbus.openFlag = true; | ||
handleCallback(); | ||
}); | ||
@@ -50,4 +61,10 @@ | ||
modbus.openFlag = false; | ||
handleCallback(had_error); | ||
}); | ||
this._client.on('error', function(had_error) { | ||
modbus.openFlag = false; | ||
handleCallback(had_error); | ||
}); | ||
events.call(this); | ||
@@ -61,3 +78,4 @@ }; | ||
TcpPort.prototype.open = function (callback) { | ||
this._client.connect(this.port, this.ip, callback); | ||
this.callback = callback; | ||
this._client.connect(this.port, this.ip); | ||
}; | ||
@@ -69,5 +87,4 @@ | ||
TcpPort.prototype.close = function (callback) { | ||
this.callback = callback; | ||
this._client.end(); | ||
if (callback) | ||
callback(null); | ||
}; | ||
@@ -74,0 +91,0 @@ |
@@ -16,2 +16,3 @@ 'use strict'; | ||
this.openFlag = false; | ||
this.callback = null; | ||
@@ -28,2 +29,11 @@ // options | ||
// handle callback - call a callback function only once, for the first event | ||
// it will triger | ||
var handleCallback = function(had_error) { | ||
if (self.callback) { | ||
self.callback(had_error); | ||
self.callback = null; | ||
} | ||
} | ||
// create a socket | ||
@@ -65,2 +75,3 @@ this._client = new net.Socket(); | ||
self.openFlag = true; | ||
handleCallback(); | ||
}); | ||
@@ -70,4 +81,10 @@ | ||
self.openFlag = false; | ||
handleCallback(had_error); | ||
}); | ||
this._client.on('error', function(had_error) { | ||
self.openFlag = false; | ||
handleCallback(had_error); | ||
}); | ||
events.call(this); | ||
@@ -97,3 +114,4 @@ }; | ||
TelnetPort.prototype.open = function (callback) { | ||
this._client.connect(this.port, this.ip, callback); | ||
this.callback = callback; | ||
this._client.connect(this.port, this.ip); | ||
}; | ||
@@ -105,5 +123,4 @@ | ||
TelnetPort.prototype.close = function (callback) { | ||
this.callback = callback; | ||
this._client.end(); | ||
if (callback) | ||
callback(null); | ||
}; | ||
@@ -110,0 +127,0 @@ |
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
108962
37
2671