Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cpu/cc2538: Enable CRC checking of received packets #5654

Merged
merged 1 commit into from
Jul 25, 2016
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions cpu/cc2538/radio/cc2538_rf_netdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down