jsmodbus
Advanced tools
Comparing version 1.2.2 to 1.2.3
{ | ||
"name": "jsmodbus", | ||
"version": "1.2.2", | ||
"version": "1.2.3", | ||
"description": "Implementation for the Serial/TCP Modbus protocol.", | ||
@@ -5,0 +5,0 @@ "author": "Stefan Poeter <stefan.poeter@cloud-automation.de>", |
@@ -45,3 +45,3 @@ var stampit = require('stampit'), | ||
.word8(fc) | ||
.word16be(startAddress) | ||
.word16be(startAddress); | ||
@@ -52,3 +52,3 @@ if (coils instanceof Buffer) { | ||
.word8(coils.length) | ||
.put(coils) | ||
.put(coils); | ||
} else if (coils instanceof Array) { | ||
@@ -63,3 +63,3 @@ | ||
curByte = 0, | ||
cntr = 0 | ||
cntr = 0; | ||
@@ -76,4 +76,4 @@ pdu.word16be(coils.length) | ||
if (cntr === 0 || i === coils.length - 1 ) { | ||
pdu.word8(curByte) | ||
curByte = 0 | ||
pdu.word8(curByte); | ||
curByte = 0; | ||
} | ||
@@ -80,0 +80,0 @@ } |
@@ -42,2 +42,3 @@ var stampit = require('stampit'), | ||
// error response | ||
if (start > mem.length * 8 || start + quantity > mem.length * 8) { | ||
@@ -55,4 +56,7 @@ | ||
// reading old value from the coils register | ||
oldValue = mem.readUInt8(Math.floor(i / 8)); | ||
// apply new value | ||
if (Math.pow(2, j % 8) & current) { | ||
@@ -64,8 +68,10 @@ newValue = oldValue | Math.pow(2, i % 8); | ||
mem.writeUInt8(newValue, Math.floor(start / 8)); | ||
// write to buffer | ||
mem.writeUInt8(newValue, Math.floor(i / 8)); | ||
// read new value from request pdu | ||
j += 1; | ||
if (j % 8 === 0) { | ||
if (j % 8 === 0 && j < quantity) { | ||
current = pdu.readUInt8(6 + Math.floor(j / 8)); | ||
@@ -72,0 +78,0 @@ |
111255
2402