rx: fix header checksum verification

This commit is contained in:
Thomas Kolb 2024-03-30 22:07:08 +01:00
parent 79d7f74dfc
commit 171a4a369c
1 changed files with 6 additions and 3 deletions

View File

@ -217,7 +217,8 @@ result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t
modem_demodulate(rx->hdr_demod, mixed_sample, &sym_demod);
float phase_error = modem_get_demodulator_phase_error(rx->hdr_demod);
//DEBUG_LOG("Sym: %d; Phase error: %f\n", sym_demod, phase_error);
DEBUG_LOG("Sym: %d; Phase error: %f %s\n", sym_demod, phase_error,
(fabs(phase_error) > 0.3) ? "!!!" : "");
update_nco_pll(rx->carrier_fine_nco, phase_error, PLL_BW_HEADER);
@ -243,8 +244,10 @@ result_t layer1_rx_process(layer1_rx_t *rx, const float complex *samples, size_t
}
// CRC check
if(crc_check_key(LIQUID_CRC_8, header, HEADER_SIZE_BYTES-1) != LIQUID_OK) {
DEBUG_LOG("Header CRC check failed!\n");
if(crc_check_key(LIQUID_CRC_8, header, HEADER_SIZE_BYTES) != LIQUID_OK) {
uint8_t expected_crc = crc_generate_key(LIQUID_CRC_8, header, 4);
DEBUG_LOG("Header CRC check failed! Expected: 0x%02x, received: 0x%02x\n",
expected_crc, header[4]);
rx->state = RX_STATE_ACQUISITION;
rx->callback(RX_EVT_HEADER_ERROR, NULL, 0);
break;