Issue with software serial - Code crash while reading data

abanik
Posts: 4
Joined: Tue Aug 11, 2020 7:45 am

Issue with software serial - Code crash while reading data

Postby abanik » Thu Nov 26, 2020 4:55 am

Hello,
Lately I have been working with ESP32 and started using Serial2 (software Serial to read data from RS232) and Serial1 (Hardware Serial to read data from RS232). Initially it works fine for few hours(as observed during testing) but later the code crashes while reading data through Hardware serial[NOT SOFTWARE SERIAL!!!], the code continues to crash(SW reset) at same point after restarting from previous crash. This cycle continues until the ESP32 board is restarted manually by disconnecting the power and reconnecting it, now the code runs fine without any issue.
After studying the library for Software Serial, it was assumed that if the destructor for Software Serial was called after the use of Software Serial might solve the issue, but it resulted in code crash too(SW reset). Then after experimenting, I found that if (Software Serial object).enableRx(false) was used while reading data from Serial 1, then the code did not crashed like before and ran fine for few hours. But the issue occurred after few hours with same backtrace as before which pointed to RxRead() function for the Software Serial.
Any help on how to solve this issue would be appreciated.
Also, if possible any suggestion for how to clear the buffer for software serial and disable the serial when the reading through software Serial is completed.

Who is online

Users browsing this forum: No registered users and 161 guests