smarmengol / Modbus-Master-Slave-for-Arduino

Modbus Master-Slave library for Arduino
GNU Lesser General Public License v2.1
473 stars 328 forks source link

Receive missing data CRC - STM32 - Sofware serial #74

Closed NgHieuPickon closed 10 months ago

NgHieuPickon commented 10 months ago

Hello, I recently used your library for my project with STM32G030K8T6 and Software serial. (https://github.com/stm32duino/Arduino_Core_STM32/wiki) when I receive the data, all packet data is missing the last CRC byte at Baurate 9600 - 8N1. I don't know real reason, but adding "delay(2)" after "while ( u32overTimeCountDown-- > 0);", that work well. Look like: void Modbus::sendTxBuffer() { ..........

if (u8txenpin > 1)
{
..........
    volatile uint32_t u32overTimeCountDown = u32overTime;
    while ( u32overTimeCountDown-- > 0);
    delay(2);       //Hieu edit
    digitalWrite( u8txenpin, LOW );
..........

} I think this issue needs to be researched and fixed in the latest update.

smarmengol commented 10 months ago

Hi, This library wasn't intented for software serial, so these issues may happen. I discourage the use of delay instructions, because they could affect its performance, particularly in huge networks. Regards