Modbus(RS485) communication using UART1 on Nrf9160

Hi,

I am working on nRF Connect sdk version1.9.0.
I am using Zephyr Modbus Server and Client Example to setup communication between two nRF9160dk .
i have 2  Arduino shield(https://www.digikey.ie/en/products/detail/dfrobot/DFR0259/6588575)  to convert RS485 to  UART .


I run server application on one Dk and Client on another.
i am getting following error on client side.

i tried to debug this error .it originates from this function in  modbus_core.c

int modbus_tx_wait_rx_adu(struct modbus_context *ctx)
{
    modbus_tx_adu(ctx);

   if (k_sem_take(&ctx->client_wait_sem, K_USEC(ctx->rxwait_to)) != 0) {
   LOG_WRN("Client wait-for-RX timeout");
     return -ETIMEDOUT;
}

return ctx->rx_adu_err;
}

Please assist us.

Regards,
Waqar Ahmed

Parents Reply
  • Yes,

    for the above problem i found a way there is bug in zephyr api.

    At no parity mode. Zephyr use 2 stop bits.that y i am getting this error.

    with nrf9160 dk i am able to communicate with modbus server.

    now i am facing an other issue which is related to UART1 on my custom board.

    i am getting the same error.

    on my custom board the tx and Rx pins  numbers are different.

    i have makes changes accordingly.

    but i am unable to communicate with modbus.

    please guide regarding to UART1 setup.

Children
  • Hello Waqar,

    Sorry for the late reply.

    I have been reading up on the modbus samples to try to help you along. The function casting the error is modbus_write_holding_regs which has a two options for the reason for the error: no device (ENODEV) and no buffer space (ENOBUFS). Finding which one is causing the error will help you move forward.

    Setting up the UART1 in the devicetree or overlay for your board and making sure that the status is "okay" is the way to enable using UART1.

    Waqar Ahmed said:

    on my custom board the tx and Rx pins  numbers are different.

    i have makes changes accordingly.

    Have you made the changes in a .dts or .overlay file? Sharing your code may also be helpful. This ticket can be made private if your code contains sensitive information.

    BR,

    Maria

Related