node-modbus
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -140,3 +140,2 @@ /** | ||
// handle pdu | ||
var handler = responseHandler[currentRequest.fc] | ||
@@ -143,0 +142,0 @@ if (!handler) { |
@@ -18,2 +18,7 @@ /** | ||
var receiveBuffer = Buffer.alloc(256) | ||
var receivedBytes | ||
var expectedBytes | ||
var exeptionMessageLength = 5 | ||
if (!this.connectionDelay) { | ||
@@ -108,6 +113,28 @@ if (process.platform === 'win32') { | ||
var onData = function (pdu) { | ||
this.log.debug('received data ' + JSON.stringify(pdu)) | ||
if (pdu.length !== 0) { // at least one byte has been received | ||
this.log.debug('received data ' + JSON.stringify(pdu)) | ||
if (crc.crc16modbus(pdu) === 0) { /* PDU is valid if CRC across whole PDU equals 0, else ignore and do nothing */ | ||
this.emit('data', pdu.slice(1)) | ||
if ((pdu.length + receivedBytes) <= receiveBuffer.length) { | ||
pdu.copy(receiveBuffer, receivedBytes, 0) | ||
receivedBytes += pdu.length | ||
if (receivedBytes >= exeptionMessageLength) { | ||
if (receivedBytes === exeptionMessageLength) { | ||
if (receiveBuffer[1] >= 128 && | ||
crc.crc16modbus(receiveBuffer.slice(0, receivedBytes)) === 0) { | ||
this.emit('data', receiveBuffer.slice(1, receivedBytes - 1)) | ||
} | ||
} else { | ||
if (receivedBytes === expectedBytes) { | ||
if (crc.crc16modbus(receiveBuffer.slice(0, receivedBytes)) === 0) { | ||
this.emit('data', receiveBuffer.slice(1, receivedBytes - 1)) | ||
} | ||
} else { | ||
this.log.debug('received bytes ' + expectedBytes + ' differ from expected bytes ' + receivedBytes) | ||
} | ||
} | ||
} else { | ||
this.log.debug('received bytes to less to do more -> receivedBytes:' + receivedBytes) | ||
} | ||
} | ||
} | ||
@@ -114,0 +141,0 @@ }.bind(this) |
@@ -8,4 +8,6 @@ /** | ||
var stampit = require('stampit') | ||
var ModbusCore = require('./modbus-client-core.js') | ||
module.exports = stampit() | ||
.compose(ModbusCore) | ||
.init(function () { | ||
@@ -12,0 +14,0 @@ var reqId = 0 |
@@ -7,4 +7,6 @@ /** | ||
var stampit = require('stampit') | ||
var log = require('stampit-log') | ||
module.exports = stampit() | ||
.compose(log) | ||
.init(function () { | ||
@@ -11,0 +13,0 @@ let buffer = Buffer.alloc(0) |
{ | ||
"name": "node-modbus", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "Sum of implementations for the Serial/TCP Modbus protocol.", | ||
@@ -5,0 +5,0 @@ "author": "Klaus Landsdorf <klaus.landsdorf@bianco-royal.de>", |
[![NPM download](https://img.shields.io/npm/dm/node-modbus.svg)](http://www.npm-stats.com/~packages/node-modbus) [![NPM version](https://badge.fury.io/js/node-modbus.png)](http://badge.fury.io/js/node-modbus) | ||
**NOT ready - just for development with node-red-contrib-modbus for now!** | ||
**Please help with your contribution to the package!** | ||
**You can help with your contribution to the package!** | ||
[![nodemodbus64](images/modbus-icon64.png)](https://www.npmjs.com/package/node-red-contrib-modbus) | ||
@@ -7,0 +8,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
81258
1630
48