RC_Channel: avoid invalid misaligned access in example

This commit is contained in:
Andrew Tridgell 2020-05-03 21:33:51 +10:00
parent 5350ea5c58
commit 04e29d58e3
1 changed files with 3 additions and 1 deletions

View File

@ -110,7 +110,9 @@ void RC_UART::loop()
uint16_t rcin[8]; uint16_t rcin[8];
uint16_t crc; uint16_t crc;
} rcin; } rcin;
if (hal.rcin->new_input() && hal.rcin->read(rcin.rcin, 8) == 8) { uint16_t rcval[8];
if (hal.rcin->new_input() && hal.rcin->read(rcval, 8) == 8) {
memcpy(rcin.rcin, rcval, sizeof(rcval));
rcin.crc = crc_calculate((uint8_t*)&rcin.rcin[0], 16); rcin.crc = crc_calculate((uint8_t*)&rcin.rcin[0], 16);
hal.UART->write((uint8_t*)&rcin, sizeof(rcin)); hal.UART->write((uint8_t*)&rcin, sizeof(rcin));
} }