Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2 from inindev/patch-2

Update client.js
  • Loading branch information...
commit a296871190c49077e42fbfe1576ed88844e90f7c 2 parents 4aa7803 + b56a51e
@TooTallNate authored
Showing with 14 additions and 2 deletions.
  1. +14 −2 client.js
View
16 client.js
@@ -50,7 +50,7 @@ Client.REQUESTS = {
3: putTwoWord16be,
// READ_INPUT_REGISTERS
4: putTwoWord16be,
- // WRITE_SINGLE_REGISTER:
+ // WRITE_SINGLE_COIL
5: function(address, value) {
if (typeof value !== 'boolean') throw new Error('"Write Single Coil" expects a \'boolean\' value');
return putTwoWord16be(address, value ? 0xff00 : 0x0000);
@@ -69,5 +69,17 @@ Client.RESPONSES = {
rtn.push(binary.end().vars.val);
}
return rtn;
- }
+ },
+ // WRITE_SINGLE_COIL
+ 5: function(bufferlist) {
+ var rtn = [];
+ var binary = Binary(bufferlist)
+ .getWord8('byteLength').end();
+ rtn.byteLength = binary.vars.byteLength;
+ for (var i=0, l=binary.vars.byteLength/2; i<l; i++) {
+ binary.getWord16be("val");
+ rtn.push(binary.end().vars.val);
+ }
+ return rtn;
+ },
};
Please sign in to comment.
Something went wrong with that request. Please try again.