Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Added new test case for a 'readInputRegisters' response.

  • Loading branch information...
commit 5f16a8a1e464363d3a95d3cd106263401c341a09 1 parent 5f0492f
Nathan Rajlich authored

Showing 1 changed file with 22 additions and 0 deletions. Show diff stats Hide diff stats

  1. +22 0 test/test-response-readInputRegisters.js
22 test/test-response-readInputRegisters.js
... ... @@ -0,0 +1,22 @@
  1 +var fs = require('fs');
  2 +var assert = require('assert');
  3 +var modbus = require('modbus-stack');
  4 +
  5 +exports['readInputRegisters response'] = function() {
  6 + var dump = fs.createReadStream(__dirname + "/responses/readInputRegisters.start0.count4.dump");
  7 + var req = new modbus.ModbusRequestStack(dump);
  8 + var gotResponse = false;
  9 + req.on('response', function(res) {
  10 + gotResponse = true;
  11 + assert.equal(res.functionCode, modbus.FUNCTION_CODES.READ_INPUT_REGISTERS, "response Function Code is not '" + modbus.FUNCTION_CODES.READ_INPUT_REGISTERS + "'");
  12 + assert.equal(res.byteLength, 8, "Expected byte length of 8");
  13 + assert.ok(Array.isArray(res), "response should be an Array");
  14 + assert.equal(res[0], 732);
  15 + assert.equal(res[1], 737);
  16 + assert.equal(res[2], 744);
  17 + assert.equal(res[3], 716);
  18 + });
  19 + dump.on('close', function() {
  20 + assert.ok(gotResponse, "The 'response' event was never fired");
  21 + });
  22 +}

0 comments on commit 5f16a8a

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