Skip to content

Commit

Permalink
Fixed raw return propoerties of WriteSingleRegisterClient
Browse files Browse the repository at this point in the history
+ extended the test to catch the bug
  • Loading branch information
psorowka committed Nov 22, 2016
1 parent 731a704 commit 40530e7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/handler/client/WriteSingleRegister.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@ module.exports = Stampit()
fc : fc,
registerAddress : registerAddress,
registerValue : registerValue,
registerAddressRaw: pdu.slice(1,2),
registerValueRaw: pdu.slice(3,2)
registerAddressRaw: pdu.slice(1,3),
registerValueRaw: pdu.slice(3,5)
};

if (fc !== 6) {
Expand Down
4 changes: 4 additions & 0 deletions test/modbus-client-core.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,9 @@ describe("Modbus Serial Client", function () {

assert.equal(resp.fc, 6);
assert.equal(resp.registerAddress, 3);
assert.deepEqual(resp.registerAddressRaw, Buffer.from([0x00,0x03]));
assert.equal(resp.registerValue, 123);
assert.deepEqual(resp.registerValueRaw, Buffer.from([0x00,0x7b]));

done();

Expand Down Expand Up @@ -349,6 +351,8 @@ describe("Modbus Serial Client", function () {
assert.equal(resp.fc, 6);
assert.equal(resp.registerAddress, 3);
assert.equal(resp.registerValue, 123);
assert.deepEqual(resp.registerAddressRaw, Buffer.from([0x00,0x03]));
assert.deepEqual(resp.registerValueRaw, Buffer.from([0x00,0x7b]));

done();

Expand Down

0 comments on commit 40530e7

Please sign in to comment.