node-modbus-serial icon indicating copy to clipboard operation
node-modbus-serial copied to clipboard

Error reading Discrete Inputs

Open kmfmengineering opened this issue 3 years ago • 0 comments

Hello,

I'm doing a simple recall of some discrete inputs for GPI:

// create an empty modbus client
var ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();
var data = null;

// open connection to a tcp line
client.connectTCP("10.10.0.116", { port: 502 });
client.setID(1);

setInterval(function() {
    client.readDiscreteInputs(1, function(err, data) {
        console.log(data.data);
    });
}, 1000);

However, get the error:

Error: Data length error, expected NaN got 8

Could you help me understand why my device is feeding back a different data length than that you're expecting?

In the manual of the device it states the data address for the discrete input; with a size of '1' (https://numato.com/docs/prodigy-rtu-tcp-modbus-gpio-modules-with-analog-inputs-din-rail-compatible/)

Am I missing something very obvious?

Thanks Marc

kmfmengineering avatar Mar 11 '22 11:03 kmfmengineering