mirror of
https://github.com/thelsing/knx.git
synced 2025-10-22 11:14:38 +02:00
Optimization: do not calc CRC for block1 again in rf_data_link_layer
This commit is contained in:
parent
007742483a
commit
12ffd1e86b
@ -98,9 +98,16 @@ void RfDataLinkLayer::frameBytesReceived(uint8_t* rfPacketBuf, uint16_t length)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if defined(DeviceFamily_CC13X0)
|
||||||
|
// Small optimization:
|
||||||
|
// We do not calculate the CRC16-DNP again for the first block.
|
||||||
|
// It was already done in the CC13x0 RX driver during reception.
|
||||||
|
// Also the two fixed bytes 0x44 and 0xFF are also there.
|
||||||
|
// So if we get here we can assume a valid block 1
|
||||||
|
#else
|
||||||
// CRC16-DNP of first block is always located here
|
// CRC16-DNP of first block is always located here
|
||||||
uint16_t block1Crc = rfPacketBuf[10] << 8 | rfPacketBuf[11];
|
uint16_t block1Crc = rfPacketBuf[10] << 8 | rfPacketBuf[11];
|
||||||
|
|
||||||
// If the checksum was ok and the other
|
// If the checksum was ok and the other
|
||||||
// two constant header bytes match the KNX-RF spec. (C-field: 0x44 and ESC-field: 0xFF)...
|
// two constant header bytes match the KNX-RF spec. (C-field: 0x44 and ESC-field: 0xFF)...
|
||||||
// then we seem to have a valid first block of an KNX RF frame.
|
// then we seem to have a valid first block of an KNX RF frame.
|
||||||
@ -108,6 +115,7 @@ void RfDataLinkLayer::frameBytesReceived(uint8_t* rfPacketBuf, uint16_t length)
|
|||||||
if ((rfPacketBuf[1] == 0x44) &&
|
if ((rfPacketBuf[1] == 0x44) &&
|
||||||
(rfPacketBuf[2] == 0xFF) &&
|
(rfPacketBuf[2] == 0xFF) &&
|
||||||
(crc16Dnp(rfPacketBuf, 10) == block1Crc))
|
(crc16Dnp(rfPacketBuf, 10) == block1Crc))
|
||||||
|
#endif
|
||||||
{
|
{
|
||||||
// bytes left from the remaining block(s)
|
// bytes left from the remaining block(s)
|
||||||
uint16_t bytesLeft = length - 12;
|
uint16_t bytesLeft = length - 12;
|
||||||
|
Loading…
Reference in New Issue
Block a user