void rxData(uint8_t in) {
uint8_t nextByte;
cc1000_header_t *rxHeader = getHeader(rxBufPtr);
-
- // rxLength is the offset into a message_t at which the packet
- // data ends: it is NOT equal to the number of bytes received,
- // as there may be padding in the message_t before the packet.
- uint8_t rxLength = rxHeader->length + offsetof(message_t, data);
+ uint8_t rxLength = rxHeader->length;
// Reject invalid length packets
- if (rxLength > TOSH_DATA_LENGTH + offsetof(message_t, data))
+ if (rxLength > TOSH_DATA_LENGTH)
{
// The packet's screwed up, so just dump it
enterListenState();
nextByte = rxShiftBuf >> f.rxBitOffset;
((uint8_t *)rxBufPtr)[count++] = nextByte;
+ // Adjust rxLength to correspond to the corresponding offset in message_t
+ rxLength += offsetof(message_t, data);
if (count <= rxLength)
runningCrc = crcByte(runningCrc, nextByte);