mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-05 23:43:58 -04:00
HAL_Linux: fixed a bug with UDP packetisation
this fixes a bug where we would send UDP MAVLink packets larger than 300 bytes
This commit is contained in:
parent
4f612f5d69
commit
0a36503742
@ -496,6 +496,25 @@ bool UARTDriver::_write_pending_bytes(void)
|
||||
uint16_t _tail;
|
||||
uint16_t available_bytes = BUF_AVAILABLE(_writebuf);
|
||||
n = available_bytes;
|
||||
if (_packetise && n > 0 && _writebuf[_writebuf_head] != 254) {
|
||||
/*
|
||||
we have a non-mavlink packet at the start of the
|
||||
buffer. Look ahead for a MAVLink start byte, up to 256 bytes
|
||||
ahead
|
||||
*/
|
||||
uint16_t limit = n>256?256:n;
|
||||
uint16_t i;
|
||||
for (i=0; i<limit; i++) {
|
||||
if (_writebuf[(_writebuf_head + i) % _writebuf_size] == 254) {
|
||||
n = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// if we didn't find a MAVLink marker then limit the send size to 256
|
||||
if (i == limit) {
|
||||
n = limit;
|
||||
}
|
||||
}
|
||||
if (_packetise && n > 0 && _writebuf[_writebuf_head] == 254) {
|
||||
// this looks like a MAVLink packet - try to write on
|
||||
// packet boundaries when possible
|
||||
|
Loading…
Reference in New Issue
Block a user