Socket
Socket
Sign inDemoInstall

modbus-serial

Package Overview
Dependencies
Maintainers
1
Versions
123
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

modbus-serial - npm Package Compare versions

Comparing version 4.0.1 to 4.0.2

t.js

2

package.json
{
"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 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc