mirror of
https://github.com/ArduPilot/ardupilot
synced 2025-02-21 15:23:57 -04:00
AP_BLHeli: read more efficiently from telemetry UART
This commit is contained in:
parent
6d9e563ede
commit
6cdee8c830
@ -1368,17 +1368,13 @@ uint8_t AP_BLHeli::telem_crc8(uint8_t crc, uint8_t crc_seed) const
|
||||
void AP_BLHeli::read_telemetry_packet(void)
|
||||
{
|
||||
uint8_t buf[telem_packet_size];
|
||||
uint8_t crc = 0;
|
||||
for (uint8_t i=0; i<telem_packet_size; i++) {
|
||||
int16_t v = telem_uart->read();
|
||||
if (v < 0) {
|
||||
// short read, we should have 10 bytes ready when this function is called
|
||||
return;
|
||||
}
|
||||
buf[i] = uint8_t(v);
|
||||
if (telem_uart->read(buf, telem_packet_size) < telem_packet_size) {
|
||||
// short read, we should have 10 bytes ready when this function is called
|
||||
return;
|
||||
}
|
||||
|
||||
// calculate crc
|
||||
uint8_t crc = 0;
|
||||
for (uint8_t i=0; i<telem_packet_size-1; i++) {
|
||||
crc = telem_crc8(buf[i], crc);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user