Skip to content

Truncated modbus messages #55

Open
@andreaghezzi-servitly

Description

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

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions