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

Truncated modbus messages #55

Open
andreaghezzi-servitly opened this issue Oct 27, 2020 · 0 comments
Open

Truncated modbus messages #55

andreaghezzi-servitly opened this issue Oct 27, 2020 · 0 comments

Comments

@andreaghezzi-servitly
Copy link

andreaghezzi-servitly commented Oct 27, 2020

I have the following configuration:

Modbus poll application running on a Windows machine connected to a Linux embedded device through an usb-serial adapter:

slaveId=10,
serialBaudRate=38400,
serialDataBits=8,
serialParity=EVEN,
serialStopBits=1,
serialPortFactory=JSerialComm,
serialPortId=/dev/ttymxc1,

With Modbus poll (emulating the modbus master) I'm trying to write with the 'write multiple registers' function 123 registers every 10 ms. In the Linux device I'm running a java class that uses jLibModbus v1.2.9.7 library (it will be the modbus slave) and jSerialComm v2.6.2 which reads correctly first 10-20 messages, then I see continuously in log:

INFO: Frame recv: 0000
WARNING: null

I've edited the 'open' method of SerialPortJSerialComm class as following:

public void open() throws SerialPortException {
    SerialParameters sp = getSerialParameters();
    port = com.fazecast.jSerialComm.SerialPort.getCommPort(sp.getDevice());
    port.openPort();
    
    port.setComPortParameters(sp.getBaudRate(), sp.getDataBits(), sp.getStopBits(), sp.getParity().getValue(), true);
    port.setFlowControl(com.fazecast.jSerialComm.SerialPort.FLOW_CONTROL_DISABLED);
    port.setComPortTimeouts(com.fazecast.jSerialComm.SerialPort.TIMEOUT_READ_SEMI_BLOCKING
        | com.fazecast.jSerialComm.SerialPort.TIMEOUT_WRITE_BLOCKING, 0, 0);

    in = port.getInputStream();
    out = port.getOutputStream();
}

I've also tried playing around with different timeouts configuration without any luck.
What could be possible wrong?
Thank you, regards.
Andrea

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