Skip to content

Commit

Permalink
Merge pull request #9089 from jflyper/bfdev-serial-blackbox-handle-bu…
Browse files Browse the repository at this point in the history
…ffer-overflow-properly

Serial blackbox: check TX buffer space before calling serialWrite
  • Loading branch information
mikeller committed Oct 27, 2019
1 parent db062d7 commit 1d9fff5
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/main/blackbox/blackbox_io.c
Expand Up @@ -102,7 +102,14 @@ void blackboxWrite(uint8_t value)
#endif
case BLACKBOX_DEVICE_SERIAL:
default:
serialWrite(blackboxPort, value);
{
int txBytesFree = serialTxBytesFree(blackboxPort);

if (txBytesFree == 0) {
return;
}
serialWrite(blackboxPort, value);
}
break;
}
}
Expand Down Expand Up @@ -133,7 +140,7 @@ int blackboxWriteString(const char *s)
default:
pos = (uint8_t*) s;
while (*pos) {
serialWrite(blackboxPort, *pos);
blackboxWrite(*pos);
pos++;
}

Expand Down

0 comments on commit 1d9fff5

Please sign in to comment.