forked from Archive/PX4-Autopilot
Check packet CRCs and count errors; don't reject packets yet.
This commit is contained in:
parent
5a8f874166
commit
50cae347b4
|
@ -181,6 +181,7 @@ private:
|
||||||
perf_counter_t _perf_timeouts;
|
perf_counter_t _perf_timeouts;
|
||||||
perf_counter_t _perf_errors;
|
perf_counter_t _perf_errors;
|
||||||
perf_counter_t _perf_txns;
|
perf_counter_t _perf_txns;
|
||||||
|
perf_counter_t _perf_crcerrs;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -201,7 +202,8 @@ PX4IO_serial::PX4IO_serial() :
|
||||||
_perf_dmasetup(perf_alloc(PC_ELAPSED, "dmasetup")),
|
_perf_dmasetup(perf_alloc(PC_ELAPSED, "dmasetup")),
|
||||||
_perf_timeouts(perf_alloc(PC_COUNT, "timeouts")),
|
_perf_timeouts(perf_alloc(PC_COUNT, "timeouts")),
|
||||||
_perf_errors(perf_alloc(PC_COUNT, "errors ")),
|
_perf_errors(perf_alloc(PC_COUNT, "errors ")),
|
||||||
_perf_txns(perf_alloc(PC_ELAPSED, "txns "))
|
_perf_txns(perf_alloc(PC_ELAPSED, "txns ")),
|
||||||
|
_perf_crcerrs(perf_alloc(PC_COUNT, "crcerrs "))
|
||||||
{
|
{
|
||||||
/* allocate DMA */
|
/* allocate DMA */
|
||||||
_tx_dma = stm32_dmachannel(PX4IO_SERIAL_TX_DMAMAP);
|
_tx_dma = stm32_dmachannel(PX4IO_SERIAL_TX_DMAMAP);
|
||||||
|
@ -319,6 +321,7 @@ PX4IO_serial::test(unsigned mode)
|
||||||
perf_print_counter(_perf_txns);
|
perf_print_counter(_perf_txns);
|
||||||
perf_print_counter(_perf_timeouts);
|
perf_print_counter(_perf_timeouts);
|
||||||
perf_print_counter(_perf_errors);
|
perf_print_counter(_perf_errors);
|
||||||
|
perf_print_counter(_perf_crcerrs);
|
||||||
count = 0;
|
count = 0;
|
||||||
}
|
}
|
||||||
usleep(10000);
|
usleep(10000);
|
||||||
|
@ -460,11 +463,19 @@ PX4IO_serial::_wait_complete(bool expect_reply, unsigned tx_length)
|
||||||
if (_tx_dma_status & DMA_STATUS_TEIF) {
|
if (_tx_dma_status & DMA_STATUS_TEIF) {
|
||||||
lowsyslog("DMA transmit error\n");
|
lowsyslog("DMA transmit error\n");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
if (_rx_dma_status & DMA_STATUS_TEIF) {
|
if (_rx_dma_status & DMA_STATUS_TEIF) {
|
||||||
lowsyslog("DMA receive error\n");
|
lowsyslog("DMA receive error\n");
|
||||||
ret = -1;
|
ret = -1;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* check packet CRC */
|
||||||
|
uint8_t crc = _dma_buffer.crc;
|
||||||
|
_dma_buffer.crc = 0;
|
||||||
|
if (crc != crc_packet(_dma_buffer))
|
||||||
|
perf_count(_perf_crcerrs);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -64,6 +64,7 @@ static perf_counter_t pc_ore;
|
||||||
static perf_counter_t pc_fe;
|
static perf_counter_t pc_fe;
|
||||||
static perf_counter_t pc_ne;
|
static perf_counter_t pc_ne;
|
||||||
static perf_counter_t pc_regerr;
|
static perf_counter_t pc_regerr;
|
||||||
|
static perf_counter_t pc_crcerr;
|
||||||
|
|
||||||
static void rx_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg);
|
static void rx_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg);
|
||||||
static void tx_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg);
|
static void tx_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg);
|
||||||
|
@ -124,6 +125,7 @@ interface_init(void)
|
||||||
pc_fe = perf_alloc(PC_COUNT, "framing");
|
pc_fe = perf_alloc(PC_COUNT, "framing");
|
||||||
pc_ne = perf_alloc(PC_COUNT, "noise");
|
pc_ne = perf_alloc(PC_COUNT, "noise");
|
||||||
pc_regerr = perf_alloc(PC_COUNT, "regerr");
|
pc_regerr = perf_alloc(PC_COUNT, "regerr");
|
||||||
|
pc_crcerr = perf_alloc(PC_COUNT, "crcerr");
|
||||||
|
|
||||||
/* allocate DMA */
|
/* allocate DMA */
|
||||||
tx_dma = stm32_dmachannel(PX4FMU_SERIAL_TX_DMA);
|
tx_dma = stm32_dmachannel(PX4FMU_SERIAL_TX_DMA);
|
||||||
|
@ -205,6 +207,11 @@ rx_dma_callback(DMA_HANDLE handle, uint8_t status, void *arg)
|
||||||
|
|
||||||
perf_count(pc_rx);
|
perf_count(pc_rx);
|
||||||
|
|
||||||
|
uint8_t crc = dma_packet.crc;
|
||||||
|
dma_packet.crc = 0;
|
||||||
|
if (crc != crc_packet())
|
||||||
|
perf_count(pc_crcerr);
|
||||||
|
|
||||||
/* default to not sending a reply */
|
/* default to not sending a reply */
|
||||||
if (PKT_CODE(dma_packet) == PKT_CODE_WRITE) {
|
if (PKT_CODE(dma_packet) == PKT_CODE_WRITE) {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue