Misbehave: Failed to Read Input/holding Register

45 views
Skip to first unread message

Krunal Chauhan

unread,
Feb 4, 2021, 6:17:46 AM2/4/21
to libmodbus

## libmodbus version

libmodbus-3.1.6

## OS and/or distribution

Linux

## Environment

armv7l GNU/Linux

## Description

Setup: Connected in Daisy Chain
Master : My Linux Board
Slave1: Energy Meter Selec
Slave2: Energy Meter Eastron
Slave3: Energy Meter Rishabh

RTU Configuration :
Baud rate:  9600
Parity: N
Data Size: 8
Stop Bit: 1

## Expected behaviour

Every time Read Register Successfully.

## Actual behaviour
When my application start for near about 8-9 time read register is failed.
After that it will not fail to read register. It is strange that when I turn on debug  using modbus_set_debug(ctx ,true) It will work fine.


## Steps to reproduce the behavior (commands or source code)


From Linux Board send every time request one by one to each slave at every 1 second

One Request Steps Like below. So every time send below request one by one.
========================================================================
modbus_new_rtu(pData->driver_name, pData->baudrate, pData->parity, pData->databit, pData->stopbit);

modbus_set_byte_timeout(ctx, 0, 0)

modbus_set_response_timeout(ctx, 0, 200000);

modbus_set_error_recovery(ctx,
                                        MODBUS_ERROR_RECOVERY_LINK |
                                        MODBUS_ERROR_RECOVERY_PROTOCOL)

modbus_set_slave(ctx, pData->slave_address)

modbus_rtu_set_rts(ctx, MODBUS_RTU_RTS_UP)

modbus_connect(ctx)

/*read input register*/
modbus_read_input_registers(ctx, 0, 10, 0)

modbus_close(ctx);
modbus_free(ctx);
========================================================================


## libmodbus output with debug mode enabled
Issue is not generated in debug mode. So first I have disable log and just add manually  only printf in "_error_print" function. It will give below Error message.

ERROR Connection timed out:select




Please Help Me Out, If I am missing anything or correction


Thanks in advance
Reply all
Reply to author
Forward
0 new messages