Skip to content

Commit

Permalink
fixes write multiple coils request package
Browse files Browse the repository at this point in the history
  • Loading branch information
dresende committed Apr 17, 2017
1 parent 1fb417f commit bba4e40
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions lib/protocol/WRITE_MULTIPLE_COILS.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,11 @@ var pack = require("./tools").pack2uint16;

exports.request = function (transactionId, unitId, startAddress, endAddress, status) {
var bits = packbits(status);
var buf = new Buffer(bits.length + 5);
var buf = new Buffer(bits.length + 4);

buf.writeUInt16BE(startAddress, 0);
buf.writeUInt16BE(endAddress - startAddress + 1, 2);
buf.writeUInt8(Math.ceil((endAddress - startAddress + 1) / 8), 4);
bits.copy(buf, 5);
bits.copy(buf, 4);

return new Package(
transactionId,
Expand Down

0 comments on commit bba4e40

Please sign in to comment.