Skip to content

Commit

Permalink
Fixed ReadInputRegisters Server Function
Browse files Browse the repository at this point in the history
+ fixed the test so it catches the bug I introduced earlier
  • Loading branch information
psorowka committed Nov 22, 2016
1 parent 195dd32 commit 731a704
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 4 deletions.
3 changes: 1 addition & 2 deletions src/handler/server/ReadInputRegisters.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ module.exports = stampit()
head.writeUInt8(0x04, 0);
head.writeUInt8(quantity * 2, 1);

var response = Buffer.concat([head, mem.slice(byteStart * 2, byteStart * 2 + quantity * 2)]);

var response = Buffer.concat([head, mem.slice(byteStart, byteStart + quantity * 2)]);

cb(response);

Expand Down
4 changes: 2 additions & 2 deletions test/modbus-server-core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,8 @@ describe("Modbus Server Core Tests.", function () {
it('should handle a read input registers request just fine.', function (done) {

var core = Core(),
request = Buffer.from([0x04,0x00,0,0x00,5]),
exResponse = Buffer.from([0x04,10,0x00,5,0x00,4,0x00,3,0x00,2,0x00,1]);
request = Buffer.from([0x04,0x00,0x01,0x00,0x04]),
exResponse = Buffer.from([0x04,0x08,0x00,4,0x00,3,0x00,2,0x00,1]);
core.getInput().writeUInt16BE(0x05, 0);
core.getInput().writeUInt16BE(0x04, 2);
core.getInput().writeUInt16BE(0x03, 4);
Expand Down

0 comments on commit 731a704

Please sign in to comment.