Skip to content

Commit

Permalink
Merge pull request #2 from inindev/patch-2
Browse files Browse the repository at this point in the history
Update client.js
  • Loading branch information
TooTallNate committed Oct 5, 2012
2 parents 4aa7803 + b56a51e commit a296871
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions client.js
Expand Up @@ -50,7 +50,7 @@ Client.REQUESTS = {
3: putTwoWord16be, 3: putTwoWord16be,
// READ_INPUT_REGISTERS // READ_INPUT_REGISTERS
4: putTwoWord16be, 4: putTwoWord16be,
// WRITE_SINGLE_REGISTER: // WRITE_SINGLE_COIL
5: function(address, value) { 5: function(address, value) {
if (typeof value !== 'boolean') throw new Error('"Write Single Coil" expects a \'boolean\' value'); if (typeof value !== 'boolean') throw new Error('"Write Single Coil" expects a \'boolean\' value');
return putTwoWord16be(address, value ? 0xff00 : 0x0000); return putTwoWord16be(address, value ? 0xff00 : 0x0000);
Expand All @@ -69,5 +69,17 @@ Client.RESPONSES = {
rtn.push(binary.end().vars.val); rtn.push(binary.end().vars.val);
} }
return rtn; 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;
},
}; };

0 comments on commit a296871

Please sign in to comment.