Description
In src/bus/i2c/i2c.c, the I2C_CommandWriteBulk() function reads bytes directly from UART1_Read() and immediately passes them to I2C_Transmit() inside a tight loop.
Since the host transmits UART data significantly faster than the I2C bus can transmit bytes, the PIC microcontroller's 4-byte hardware UART FIFO overflows during large transfers (for example, 128-byte OLED frame updates).
As a result:
- UART bytes are dropped.
- I2C payloads become corrupted.
- The firmware enters an inconsistent communication state.
- Mobile and desktop clients eventually encounter persistent
TimeoutException errors.
Expected Behavior
The firmware should decouple UART reception from I2C transmission by buffering the incoming payload before starting the I2C transfer.
A possible implementation is:
- Allocate a RAM buffer (up to 255 bytes, depending on the protocol limit
Description
In
src/bus/i2c/i2c.c, theI2C_CommandWriteBulk()function reads bytes directly fromUART1_Read()and immediately passes them toI2C_Transmit()inside a tight loop.Since the host transmits UART data significantly faster than the I2C bus can transmit bytes, the PIC microcontroller's 4-byte hardware UART FIFO overflows during large transfers (for example, 128-byte OLED frame updates).
As a result:
TimeoutExceptionerrors.Expected Behavior
The firmware should decouple UART reception from I2C transmission by buffering the incoming payload before starting the I2C transfer.
A possible implementation is: