Socket
Socket
Sign inDemoInstall

node-modbus

Package Overview
Dependencies
164
Maintainers
1
Versions
36
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.2.2 to 3.2.3

14

node-modbus/modbus-client-core.js

@@ -21,3 +21,2 @@ /**

0x0B: 'GATEWAY TARGET DEVICE FAILED TO RESPOND'
}

@@ -66,8 +65,8 @@

currentRequest = this.reqFifo.shift()
setRequestTimeout()
this.setState('waiting')
this.emit('send', currentRequest.pdu)
this.log.debug('Data flushed.')
if (currentRequest && currentRequest.pdu) {
this.setState('waiting')
this.emit('send', currentRequest.pdu, setRequestTimeout)
this.log.debug('Data flushed.')
}
}.bind(this)

@@ -174,5 +173,4 @@

this.reqFifo.push(req)
if (this.inState('ready')) {
this.reqFifo.push(req) /* just in ready state - think about running machines */
flush()

@@ -179,0 +177,0 @@ }

@@ -29,5 +29,5 @@ /**

if (process.platform === 'win32') {
this.connectionDelay = 250 // ms
this.connectionDelay = 1000 // ms
} else {
this.connectionDelay = 100 // ms
this.connectionDelay = 500 // ms
}

@@ -101,4 +101,4 @@ }

let onOpen = function () {
this.emit('connect')
this.setState('ready')
this.setState('connecting')
timerID = setTimeout(onTimeoutDelay, this.connectionDelay)
}.bind(this)

@@ -129,4 +129,5 @@

crc.crc16modbus(receiveBuffer.slice(0, receivedBytes)) === 0) {
this.emit('data', receiveBuffer.slice(3, receivedBytes - crcBytes))
this.emit('data', receiveBuffer.slice(1, receivedBytes - crcBytes))
receivedBytes = 0
receiveBuffer.fill(' ')
}

@@ -137,4 +138,5 @@ } else {

if (crc.crc16modbus(receiveBuffer.slice(0, receivedBytes)) === 0) {
this.emit('data', receiveBuffer.slice(3, receivedBytes - crcBytes))
this.emit('data', receiveBuffer.slice(1, receivedBytes - crcBytes))
receivedBytes = 0
receiveBuffer.fill(' ')
}

@@ -164,3 +166,3 @@ } else {

let onSend = function (pdu) {
let onSend = function (pdu, setRequestTimeout) {
this.log.debug('PDU data' + JSON.stringify(pdu))

@@ -172,4 +174,2 @@

this.log.debug('crcModbus JSON: ' + JSON.stringify(crc.crc16modbus(buf)))
let crcModbus = crc.crc16modbus(buf)

@@ -211,10 +211,13 @@ let crcBufModbus = Buffer.allocUnsafe(2)

serialport.write(bufWithCRC, function (err) {
if (err) {
this.log.error('PDU with CRC error on write to serial. ' + JSON.stringify(err))
this.emit('error', err)
} else {
this.log.debug('PDU with CRC written to serial')
}
}.bind(this))
if (serialport.isOpen()) {
setRequestTimeout()
serialport.write(bufWithCRC, function (err) {
if (err) {
this.log.error('error on write to serial:' + JSON.stringify(err))
this.emit('error', err)
} else {
this.log.debug('package written to serial')
}
}.bind(this))
}
}.bind(this)

@@ -228,8 +231,7 @@

// some delay needed on windows systems serial reconnect
init()
this.emit('connect')
this.setState('ready')
}.bind(this)
this.setState('connecting')
timerID = setTimeout(onTimeoutDelay, this.connectionDelay)
init()
})

@@ -131,3 +131,3 @@ /**

let onSend = function (pdu) {
let onSend = function (pdu, setRequestTimeout) {
this.log.debug('Sending pdu to the socket.')

@@ -143,7 +143,6 @@

head.writeUInt8(this.unitId, 6)
let pkt = Buffer.concat([head, pdu])
currentRequestId = reqId
setRequestTimeout()
socket.write(pkt)

@@ -150,0 +149,0 @@ }.bind(this)

{
"name": "node-modbus",
"version": "3.2.2",
"tag": "3.2.0-alpha-6",
"version": "3.2.3",
"tag": "3.2.0-alpha-7",
"description": "Sum of implementations for the Serial/TCP Modbus protocol.",

@@ -6,0 +6,0 @@ "author": "Klaus Landsdorf <klaus.landsdorf@bianco-royal.de>",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc