mirror of
https://github.com/betaflight/betaflight.git
synced 2025-07-25 01:05:27 +03:00
Check TX buffer space before calling serialWrite
- Check TX buffer space before calling serialWrite (which unconditionally manipulates buffer management variables). - Added available TX buffer space as one of debug variables. - Use blackboxWrite() instead of serialWrite in blackboxWriteString().
This commit is contained in:
parent
ca9005de66
commit
a183213ca3
1 changed files with 16 additions and 8 deletions
|
@ -127,15 +127,23 @@ void blackboxWrite(uint8_t value)
|
||||||
#endif
|
#endif
|
||||||
case BLACKBOX_DEVICE_SERIAL:
|
case BLACKBOX_DEVICE_SERIAL:
|
||||||
default:
|
default:
|
||||||
|
{
|
||||||
|
int txBytesFree = serialTxBytesFree(blackboxPort);
|
||||||
|
|
||||||
#ifdef DEBUG_BB_OUTPUT
|
#ifdef DEBUG_BB_OUTPUT
|
||||||
bbBits += 2;
|
bbBits += 2;
|
||||||
if (serialTxBytesFree(blackboxPort) == 0) {
|
DEBUG_SET(DEBUG_BLACKBOX_OUTPUT, 3, txBytesFree);
|
||||||
++bbDrops;
|
|
||||||
DEBUG_SET(DEBUG_BLACKBOX_OUTPUT, 2, bbDrops);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
#endif
|
#endif
|
||||||
serialWrite(blackboxPort, value);
|
|
||||||
|
if (txBytesFree == 0) {
|
||||||
|
#ifdef DEBUG_BB_OUTPUT
|
||||||
|
++bbDrops;
|
||||||
|
DEBUG_SET(DEBUG_BLACKBOX_OUTPUT, 2, bbDrops);
|
||||||
|
#endif
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
serialWrite(blackboxPort, value);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -181,7 +189,7 @@ int blackboxWriteString(const char *s)
|
||||||
default:
|
default:
|
||||||
pos = (uint8_t*) s;
|
pos = (uint8_t*) s;
|
||||||
while (*pos) {
|
while (*pos) {
|
||||||
serialWrite(blackboxPort, *pos);
|
blackboxWrite(*pos);
|
||||||
pos++;
|
pos++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue