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

TransactionTimedOutError with USB2Serial Driver

Open Daschmi opened this issue 4 years ago • 3 comments

Hi,

i have a Solair 3100 (https://www.manualslib.com/manual/1732979/Lighthouse-Solair-3100.html?page=150) and wan't to communicate over usb with the device. The device uses the modbus protocol and i try the driver from the manufacturer.

I try to read register 40001 (2 Bytes?)

var client = new ModbusRTU();

function run(error) {

    console.log("RUN", error);
    
    client.setID(1);
    client.setTimeout(2000);
     
    client._debugEnabled = true;
 
    client.writeFC3(1, 40001, 2, function(err, data) {

        console.log(err, data);

    });
 
}

/* <Buffer 01 03 9c 41 00 c8 3a 18> */

client.connectAsciiSerial(
    "COM7", 
    { 
        baudRate: 19200, dataBits: 8, stopBits: 1, parity: 'none'
    },
    run
);

I could open the connection, but i don't recive any bytes. Output with debug:

RUN null
TransactionTimedOutError {
  name: 'TransactionTimedOutError',
  message: 'Timed out',
  errno: 'ETIMEDOUT',
  modbusRequest: <Buffer 01 03 9c 41 00 02 ba 4f>,
  modbusResponses: []
} undefined

Does anyone have any idea what I am doing wrong?

Daschmi avatar Jul 14 '21 13:07 Daschmi

note: we have another issue about ascii port: https://github.com/yaacov/node-modbus-serial/pull/236/files may be related.

yaacov avatar Jul 14 '21 14:07 yaacov

Thanks for your quick reply, but unfortunately the _asciiDecodeResponseBuffer function is not called at all.

Daschmi avatar Jul 14 '21 14:07 Daschmi

You made a mistake with the register address. If you want to access register 40001 the address is 0. Please calculate the address as follows: <register number> - 40001. Consider using readHoldingRegisters(0,2) as shown in the README file.

ThKls avatar Oct 26 '21 18:10 ThKls