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 5.2.6 to 5.2.7

26

examples/logger.js

@@ -7,3 +7,4 @@ /* eslint-disable no-console, spaced-comment */

var client = new ModbusRTU();
var timeoutRef = null;
var timeoutRunRef = null;
var timeoutConnectRef = null;

@@ -17,5 +18,2 @@ var networkErrors = ["ESOCKETTIMEDOUT", "ETIMEDOUT", "ECONNRESET", "ECONNREFUSED"];

// stop reading loop
clearTimeout(timeoutRef);
// close port

@@ -26,3 +24,3 @@ client.close();

client = new ModbusRTU();
setTimeout(connect, 3000);
timeoutConnectRef = setTimeout(connect, 1000);
}

@@ -32,4 +30,12 @@ }

// open connection to a serial port
//client.connectRTU("/dev/ttyUSB0", {baudrate: 9600})
function connect() {
// clear pending timeouts
clearTimeout(timeoutConnectRef);
// if client already open, just run
if (client.isOpen()) {
run();
}
// if client closed, open a new connection
client.connectTCP("127.0.0.1", { port: 8502 })

@@ -55,2 +61,5 @@ .then(setClient)

function run() {
// clear pending timeouts
clearTimeout(timeoutRunRef);
// read the 4 registers starting at address 5

@@ -60,6 +69,7 @@ client.readHoldingRegisters(5, 4)

console.log("Receive:", d.data); })
.then(function() {
timeoutRunRef = setTimeout(run, 1000); })
.catch(function(e) {
checkError(e);
console.log(e.message); })
.then(function() { timeoutRef = setTimeout(run, 1000); });
console.log(e.message); });
}

@@ -66,0 +76,0 @@

@@ -11,4 +11,4 @@ /* eslint-disable no-console, spaced-comment */

// open connection to a serial port
//client.connectRTU("/dev/ttyUSB0", {baudrate: 9600})
client.connectTCP("127.0.0.1", { port: 8502 })
client.connectRTU("/dev/ttyUSB0", { baudrate: 115200 })
//client.connectTCP("modbus.local", { port: 502 })
.then(setClient)

@@ -32,6 +32,6 @@ .then(function() {

// run program
run();
readRegisters();
}
function run() {
function readRegisters() {
// read the 4 registers starting at address 5

@@ -43,2 +43,12 @@ client.readHoldingRegisters(5, 4)

console.log(e.message); })
.then(readCoils);
}
function readCoils() {
// read the 4 registers starting at address 5
client.readCoils(1, 20)
.then(function(d) {
console.log("Receive:", d.data); })
.catch(function(e) {
console.log(e.message); })
.then(close);

@@ -45,0 +55,0 @@ }

@@ -141,3 +141,5 @@ "use strict";

this._port.write(buffer);
transaction._timeoutHandle = _startTimeout(this._timeout, transaction.next);
if (transaction) {
transaction._timeoutHandle = _startTimeout(this._timeout, transaction.next);
}
}

@@ -220,4 +222,6 @@

/* cancel the timeout */
_cancelTimeout(transaction._timeoutHandle);
transaction._timeoutHandle = undefined;
if (transaction) {
_cancelTimeout(transaction._timeoutHandle);
transaction._timeoutHandle = undefined;
}

@@ -224,0 +228,0 @@ /* check incoming data

{
"name": "modbus-serial",
"version": "5.2.6",
"version": "5.2.7",
"description": "A pure JavaScript implemetation of MODBUS-RTU (Serial and TCP) for NodeJS.",

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

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