
Description
Describe the bug
Problem is the way how ring buffer is used.
erpc/erpc_c/transports/erpc_uart_zephyr_transport.cpp
Lines 65 to 91 in f9af0f6
A call to ring_buf_put_claim()
does not return the free space in the buffer, but the number of bytes that can be written into the also returned buffer pointer until the wrap around point it hit.
In my case the ERPC packets are 26 bytes long, the default buffer size appears to be 256 bytes.
When sending the 1st packet ring_buf_put_claim()
will return 256. When the 2nd packet is received however it will only return 230. On the next packet 204 and so on.
The problem now is that when the 10th packet arrives ring_buf_put_claim()
will only return 22 and the current implementation thus does not empty the receive fifo.
The problematic condition is actually even tested for, but the 'Error' is not handled
erpc/erpc_c/transports/erpc_uart_zephyr_transport.cpp
Lines 91 to 97 in f9af0f6
As a consequence the erpc server on the device will stop responding - with the given example of 26 byte sized service requests this will happen at the 10th invocation.
With a 'regular' UART this current implementation should normally not be a problem as you get an Interrupt per single byte received, but of course that depends on actual HW used.
To Reproduce
Create an erpc server on MCU running ZephyrRTOS, create a service that results in packets with size
Expected behavior
Client should be able to invoke the service on the device indefinltely as many times as desired
Screenshots
n/a
Desktop (please complete the following information)
- OS:
- Linux (Ubuntu23.10) on Host PC running erpc client.
- Zephyr RTOS v3.6.0 on MCU
- eRPC Version
- PC: Using python 3.10, erpc installed from pypi (v3.12.0)
- MCU: latest on develop branch (commit f9af0f6). Can't use 3.12.0 due to [BUG] Zephyr UART transport does not works with CDC ACM transport #409
Steps you didn't forgot to do
- [ x] I checked if there is no related issue opened/closed.
- [ x] I checked that there doesn't exist opened PR which is solving this issue.
Activity