Permalink
Browse files

Added new test case for a 'readInputRegisters' request.

  • Loading branch information...
TooTallNate committed Dec 31, 2010
1 parent 98e6e62 commit 3bd25419fbb490c0603520ce2e1ba75bd1290720
Showing with 19 additions and 0 deletions.
  1. +19 −0 test/test-request-readInputRegisters.js
@@ -0,0 +1,19 @@
+var fs = require('fs');
+var assert = require('assert');
+var modbus = require('modbus-stack');
+var Stream = require('stream').Stream;
+
+exports['readInputRegisters request'] = function() {
+ var dump = fs.createReadStream(__dirname + "/requests/readInputRegisters.start0.count4.dump");
+ var res = new modbus.ModbusResponseStack(dump);
+ var gotRequest = false;
+ res.on('request', function(req) {
+ gotRequest = true;
+ assert.equal(req.functionCode, modbus.FUNCTION_CODES.READ_INPUT_REGISTERS, "request Function Code is not '" + modbus.FUNCTION_CODES.READ_INPUT_REGISTERS + "'");
+ assert.equal(req.startAddress, 0);
+ assert.equal(req.quantity, 4);
+ });
+ dump.on('close', function() {
+ assert.ok(gotRequest, "The 'request' event was never fired");
+ });
+}

0 comments on commit 3bd2541

Please sign in to comment.