Skip to content

Commit c7c48b7

Browse files
committed
In rxBits(), check for no new intermediate ISR data, inserting extraneous stop bits breaks rx.
Fixes plerup#210.
1 parent d9f6cd1 commit c7c48b7

File tree

3 files changed

+7
-5
lines changed

3 files changed

+7
-5
lines changed

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "EspSoftwareSerial",
3-
"version": "6.12.5",
3+
"version": "6.12.6",
44
"description": "Implementation of the Arduino software serial for ESP8266/ESP32.",
55
"keywords": [
66
"serial", "io", "softwareserial"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=EspSoftwareSerial
2-
version=6.12.5
2+
version=6.12.6
33
author=Dirk Kaar, Peter Lerup
44
maintainer=Dirk Kaar <dok@dok-net.net>
55
sentence=Implementation of the Arduino software serial for ESP8266/ESP32.

src/SoftwareSerial.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -427,11 +427,13 @@ void SoftwareSerial::rxBits() {
427427

428428
m_isrBuffer->for_each(m_isrBufferForEachDel);
429429

430-
// stop bit can go undetected if leading data bits are at same level
431-
// and there was also no next start bit yet, so one byte may be pending.
430+
// A stop bit can go undetected if leading data bits are at same level
431+
// and there was also no next start bit yet, so one word may be pending.
432+
// Check that there was no new ISR data received in the meantime, inserting an
433+
// extraneous stop level bit out of sequence breaks rx.
432434
if (m_rxCurBit > -1 && m_rxCurBit < m_pduBits - m_stopBits) {
433435
const uint32_t detectionCycles = (m_pduBits - m_stopBits - m_rxCurBit) * m_bitCycles;
434-
if (ESP.getCycleCount() - m_isrLastCycle > detectionCycles) {
436+
if (!m_isrBuffer->available() && ESP.getCycleCount() - m_isrLastCycle > detectionCycles) {
435437
// Produce faux stop bit level, prevents start bit maldetection
436438
// cycle's LSB is repurposed for the level bit
437439
rxBits(((m_isrLastCycle + detectionCycles) | 1) ^ m_invert);

0 commit comments

Comments
 (0)