mirror of
https://github.com/RIOT-OS/RIOT.git
synced 2025-12-27 07:21:18 +01:00
cpu/cc2538: Enable CRC checking of received packets (#5654)
This commit is contained in:
parent
cf3ee67780
commit
66b36397b6
@ -300,14 +300,21 @@ static int _recv(netdev2_t *netdev, char *buf, int len, void *info)
|
||||
/* GNRC wants to know how much data we've got for it */
|
||||
pkt_len = rfcore_read_byte();
|
||||
|
||||
/* If the value of the first byte of the RX FIFO does not correspond
|
||||
to the amount of data received, then drop the packet. */
|
||||
if (pkt_len != RFCORE_XREG_RXFIFOCNT) {
|
||||
/* Make sure pkt_len is sane */
|
||||
if (pkt_len > CC2538_RF_MAX_DATA_LEN) {
|
||||
RFCORE_SFR_RFST = ISFLUSHRX;
|
||||
mutex_unlock(&dev->mutex);
|
||||
return -EOVERFLOW;
|
||||
}
|
||||
|
||||
/* CRC check */
|
||||
if (!(rfcore_peek_rx_fifo(pkt_len) & 0x80)) {
|
||||
/* CRC failed; discard packet */
|
||||
RFCORE_SFR_RFST = ISFLUSHRX;
|
||||
mutex_unlock(&dev->mutex);
|
||||
return -ENODATA;
|
||||
}
|
||||
|
||||
if (len > 0) {
|
||||
/* GNRC wants us to drop the packet */
|
||||
RFCORE_SFR_RFST = ISFLUSHRX;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user