STM32GENERIC
STM32GENERIC copied to clipboard
Serial.available() not working properly
Looking on SerialUART.cpp the function is returning a bool condition instead os number of available bytes, a lot of libs use that like Nexion. This is the current code:
int HardwareSerial::available() {
return rxEnd != rxStart;
}
This is the fix:
int HardwareSerial::available() {
//return rxEnd != rxStart;
int size = (rxEnd % BUFFER_SIZE) - (rxStart % BUFFER_SIZE);
if (size < 0) size += BUFFER_SIZE;
return size;
}
Tested and working properly now.
Updated code, now working with Nextion
Hi, The current version does not have this fix yet. Manually adding the this code to the core works fine! I had problems with a project and this little thing. Can you please add the fix to the master branch?
int HardwareSerial::available() { if (rxEnd >= rxStart) return (rxEnd - rxStart); return BUFFER_SIZE + rxEnd - rxStart; }
That work better