This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Zephyr MODBUS samples

Hi

We wan't use in our project some MODBUS sensors and I found, that Nordic Connect SDK (I use version 1.9.1) with Zephyr has support for MODBUS. I tried the samples (rtu- server and rtu-client), but I don't get  them work. They  compile OK and if I look with logic analyzer, client is asking and the server is answering with right data and frames, but client shows always:

Everything is connected as it should (server is answering). Has anyone tried the MODBUS samples and get them to work?

I add also logic analyzer images:

That is the client asking

And server answers:

Tiit

Parents
  • If I try to read our sensor (I modified the client sample to read some registers with modbus_read_input_regs() function) I see an answer from sensor on logic analyzer with right data, The client app says: invalid frame length and straight after that Client wait-for-RX timeout. 

    I tried to raise the rx_timeout value on interface parameters, but that only raised timeslot before the RX timeout message appears.

    Tiit

Reply
  • If I try to read our sensor (I modified the client sample to read some registers with modbus_read_input_regs() function) I see an answer from sensor on logic analyzer with right data, The client app says: invalid frame length and straight after that Client wait-for-RX timeout. 

    I tried to raise the rx_timeout value on interface parameters, but that only raised timeslot before the RX timeout message appears.

    Tiit

Children
  • Hi Tiit,

    Tiit said:
    The client app says: invalid frame length and straight after that Client wait-for-RX timeout. 


    Can you share full error message including both "invalid frame length" and "Client wait-for-RX timeout"?

    Best regards,
    Dejan

  • Actually there are not much more messages there. I am very new to Zephyr .. can I enable deeper logging as that is on old SDK and sdk_config.h on Zephyr?

    The RTU timeout ise longer, because the sensor is using 9600 baud.

    Tiit

  • Hi Tiit,

    For more information about logging in Zephyr take a loook at the Zephyr logging page.

    Best regards,
    Dejan

  • Hi

    I enabled CONFIG_MODBUS_SERIAL from prj.conf and added CONFIG_MODBUS_LOG_LEVEL_DBG, got a little more logging to terminal:

    But still no luck.. RX timeout.

    Tiit

  • Hi Tiit,

    I haven't been able to reproduce the problem you reported. I used the same MODBUS example and nRF Connect SDK v1.9.1. I have also tried with nRF Connect SDK v1.8.0 and that also worked well. I haven't observed warnings neither for frame size nor for timeout. The communication was working well as observed in the output of the COM ports.
    In my setup the error which you reported shows up only when I disconnect one of the Tx/Rx lines which connect two boards. In this case OFF/ON sequence was needed on the client side. After that everything started to work as expected.

    I would suggest you to try the same example without sensors and see if you get any errors. Ensure that everything is properly connected. Later, if you change for example pins in prj.conf file, make sure that you also change pins when physically connecting the boards together.

    Best regards,
    Dejan

Related