Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Standard modbus programs work but mine doesn't #517

Open
CromaBAR opened this issue Oct 13, 2023 · 0 comments
Open

Standard modbus programs work but mine doesn't #517

CromaBAR opened this issue Oct 13, 2023 · 0 comments

Comments

@CromaBAR
Copy link

CromaBAR commented Oct 13, 2023

Hello everyone,
We're trying to query holding registers from a device connected to a Windows PC through a serial port DB9 Halfduplex ( Dual wire RS-485 <--> Dual wire RS485).
The program that I used was working successfully in a Linux PC.
When we used the same program on Windows, it didn't work at first. Then, we tried other standard programs and they can poll holding registers successfully with different configurations.

The configuration in both is almost the same except for one thing: In ModScan I do not activate DSR nor CTS. In ModbusPoll I have to activate 'RTS Toggle'.
I supposed that I had to toggle RTS manually everytime that I send a request for holding registers but I don't really know how to do it with this library (Or even if it's necessary)

This is the basic program for testing that we were using:

const ModbusRTU = require("modbus-serial")
const client = new ModbusRTU();

client.setID(1);
client.setTimeout(10000);

async function connectRTU(){
    return await client.connectRTU("COM1", {
        baudrate: 9600,
        parity: 'None',
        stopBits: 1,
        dataBits: 8,
        //rtscts: true,
        //rtsMode: 'Toggle',
        //flowControl: true,
        //xon: true,
        //xoff: true,
        //xany: true,
        //hupcl: true,
        //lock: true
    }, read)
}

async function read(){
    console.log('Reading...')
    await client.readHoldingRegisters(0, 10).then(function(d) {
        console.log(d)
    }).catch(function(e){
        console.log(e.message)
    });
}

var port = connectRTU();

The problem with this code is that always gives 'Timeout'.

We tried running on shell: set DEBUG=* && node myProgram.js
And the output was:

  serialport/bindings-cpp loading WindowsBinding +0ms
  serialport/stream opening path: COM1 +0ms
  serialport/bindings-cpp open +0ms
  serialport/stream opened path: COM1 +7ms
Reading...
  serialport/stream _write 8 bytes of data +3ms
  serialport/bindings-cpp write 8 bytes +7ms
  serialport/stream _read reading { start: 0, toRead: 65536} +2ms
  serialport/bindings-cpp read +3ms
  serialport/stream binding.write write finished +2ms
Timed out

What more can we test? We tried a lot of combinations with the portOptions, but we almost always get the same results.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant