Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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 3.4.5 to 3.4.6

2

package.json
{
"name": "modbus-serial",
"version": "3.4.5",
"version": "3.4.6",
"description": "A pure JavaScript implemetation of MODBUS-RTU (and TCP) for NodeJS.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -18,3 +18,3 @@ 'use strict';

var tmp;
// calculate crc16

@@ -32,3 +32,3 @@ for (var i = 0; i < length; i++) {

}
return crc;

@@ -49,3 +49,3 @@ }

var crcIn = buf.readUInt16LE(buf.length - 2);
// check buffer unit-id, command and crc

@@ -63,10 +63,10 @@ return (buf[0] == modbus._id &&

this.ip = ip;
// options
if (typeof(options) == 'undefined') options = {};
this.port = options.port || C701_PORT; // C701 port
// create a socket
this._client = dgram.createSocket("udp4");
// wait for answer

@@ -76,12 +76,12 @@ this._client.on('message', function(data) {

if (modbus.length < 6) return;
// check message length
if (data.length < (116 + modbus.length)) return;
// check the C701 packet magic
if (data.readUInt16LE(2) != 602) return;
// get the serial data from the C701 packet
var buffer = data.slice(data.length - modbus._length);
//check the serial data

@@ -123,7 +123,7 @@ if (checkData(modbus, buffer)) {

}
// remember current unit and command
this._id = data[0];
this._cmd = data[1];
// calculate expected answer length

@@ -142,2 +142,3 @@ switch (this._cmd) {

case 5:
case 6:
case 16:

@@ -151,3 +152,3 @@ this._length = 6 + 2;

}
// build C701 header

@@ -161,6 +162,6 @@ var buffer = new Buffer(data.length + 116);

buffer.writeUInt16LE(data.length, 104); // serial data length
// add serial line data
data.copy(buffer, 116);
// send buffer to C701 UDP to serial bridge

@@ -167,0 +168,0 @@ this._client.send(buffer, 0, buffer.length, this.port, this.ip);

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