Permalink
Browse files

Add test case for server request 'Read Discrete Inputs'.

  • Loading branch information...
1 parent e5232d7 commit c14defdc6ed5f255307b9d74feadba94ebca321a @TooTallNate committed Dec 31, 2010
Binary file not shown.
@@ -0,0 +1,18 @@
+var fs = require('fs');
+var assert = require('assert');
+var modbus = require('modbus-stack');
+
+exports['readDiscreteInputs request'] = function() {
+ var dump = fs.createReadStream(__dirname + "/requests/readDiscreteInputs.start197.count22.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_DISCRETE_INPUTS, "request Function Code is not '" + modbus.FUNCTION_CODES.READ_DISCRETE_INPUTS + "'");
+ assert.equal(req.startAddress, 196);
+ assert.equal(req.quantity, 22);
+ });
+ dump.on('close', function() {
+ assert.ok(gotRequest, "The 'request' event was never fired");
+ });
+}

0 comments on commit c14defd

Please sign in to comment.