Skip to content
Browse files

Ensure the quantity is satisfied for "Read Input Registers". This sho…

…uld be done for all REQUEST / RESPONSE functions.
  • Loading branch information...
1 parent 28d8d4f commit 7239888663548047ea8175431869bdf72501dc98 @TooTallNate committed Jan 1, 2011
Showing with 3 additions and 1 deletion.
  1. +3 −1 lib/server.js
View
4 lib/server.js
@@ -79,7 +79,9 @@ Server.REQUESTS = {
Server.RESPONSES = {
// READ_INPUT_REGISTERS
4: function(registers) {
- if (!Array.isArray(registers)) throw new Error('"Read Input Registers" expects to write an Array of Numbers');
+ if (!Array.isArray(registers) || registers.length != this.request.quantity) {
+ throw new Error('Expected to write an "Array" of length "'+this.request.quantity+'"');
+ }
var i=0, l=registers.length, put = Put()
.word8(registers.length*2);
for (; i<l; i++) {

0 comments on commit 7239888

Please sign in to comment.
Something went wrong with that request. Please try again.