diff --git a/radio/src/io/frsky_pxx2.h b/radio/src/io/frsky_pxx2.h index 9aec8ab3d..4168678f0 100644 --- a/radio/src/io/frsky_pxx2.h +++ b/radio/src/io/frsky_pxx2.h @@ -53,15 +53,24 @@ class ModuleFifo : public Fifo { return false; } - for (uint32_t i = 0; i <= len; i++) { + // we keep the length in frame[0] + frame[0] = fifo[next]; + next = nextIndex(next); + + uint16_t crc = 0xFFFF; + + for (uint32_t i = 1; i <= len; i++) { frame[i] = fifo[next]; + crc -= frame[i]; next = nextIndex(next); } - // TODO CRC CHECK + uint8_t crcLow = fifo[next]; next = nextIndex(next); + uint8_t crcHigh = fifo[next]; ridx = nextIndex(next); - return true; + + return ((crc >> 8) == crcLow) && ((crc & 0xFF) == crcHigh); } uint32_t errors;