Skip to content

RTU Master cannot keep up with (very) responsive slave or bus spikes/faulty bytes (EPROT-16) #145

@Wisje

Description

@Wisje

Checklist

  • Checked the issue tracker for similar issues to ensure this is not a duplicate
  • Read the documentation to confirm the issue is not addressed there and your configuration is set correctly
  • Tested with the latest version to ensure the issue hasn't been fixed

How often does this bug occurs?

often

Expected behavior

Normal operation, transmit request and receive fast response.
When a faulty byte is detected, ignore and continue.

Actual behavior (suspected bug)

Two things happen:

  1. When the slave response is too fast, the semaphore in not released in mb_port_ser_send_data before a frame is received. mb_port_ser_task receives UART_DATA event, semaphore is not free, data is flushed.
  2. On a bus spike/faulty byte received, UART_DATA event drops the short package, but also flushes the fifo and uart queue which could hold the correct data.

Both result in ESP_ERR_TIMEOUT because data is flushed.

Error logs or terminal output

I (1612982) mb_port.serial: mbm_rtu@0x3ffd454c, fragmented packet 13 byte(s)
E (1613982) MB_CONTROLLER_MASTER: mbc_master_get_parameter(131): Master get parameter failure, error=(0x107) (ESP_ERR_TIMEOUT).
E (1613982) MODBUS: Characteristic #10 MainRead (read), read parameter read fail.

E (92902) MB_CONTROLLER_MASTER: mbc_master_get_parameter(131): Master get parameter failure, error=(0x107) (ESP_ERR_TIMEOUT).
E (92902) MODBUS: Characteristic #10 MainRead (read), read parameter read fail.

Steps to reproduce the behavior

Two devices with bus-driver with DE & RE connected, so no echo on Rx.
Slave should respond directly when request is received.

Faulty byte happens sometimes in this setup as well, always a 0x00 byte. But could be introduced externally on the bus as well.

Project release version

v2.2.1

System architecture

Intel/AMD 64-bit (modern PC, older Mac)

Operating system

Windows

Operating system version

Windows 11

Shell

PowerShell

Additional context

The faulty 0x00 byte can be suppressed when setting bit UART_RS485TX_RX_EN. Byte could from the switching? 0x00 faulty byte is not seen on the bus, just received internal.

Proposed modification for mb_port_ser_task:

  • Do not flush. Just read the data length from the current event to throw away and break. This means other queued events are handled accordingly.
  • Option to remove mb_port_ser_bus_sema_is_busy check on systems without echo.

The slave device sometime is even faster than the RTS release. Looking to change to using DTR as api says this is done by hardware. I think this is outside the modbus. A topic is started on the esp forum (ESP32 RS485 DTR Pin).

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions