Skip to content

Error in Software Serial Documentation - halfBitDelay should be placed before if (low) check #1315

Closed
@iUnknwn

Description

@iUnknwn

In the software serial documentation of the SWread function, the description says it ways for a low, then waits half a bit before re-checking to ensure that the low was not line noise.

However, the code performs the delay after the for loop already starts:

 while (digitalRead(rx));
  //wait for start bit
  if (digitalRead(rx) == LOW) {
    delayMicroseconds(halfBit9600Delay);

Shouldn't this be something like this instead:

 while (true)
{
  while (digitalRead(rx));
  //wait for start bit
  delayMicroseconds(halfBit9600Delay);
  //if still low, break loop and proceed.
  if (digitalRead(rx) == LOW) { break; }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions