Moved crc calculation into its own class, renamed function to show which

crc is calculated.
This commit is contained in:
2020-04-06 13:22:42 +02:00
parent 90cba58ded
commit f28886e970
11 changed files with 35 additions and 28 deletions

View File

@ -1,5 +1,5 @@
#include <framework/datalinklayer/DataLinkLayer.h>
#include <framework/globalfunctions/crc_ccitt.h>
#include <framework/globalfunctions/CRC.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw,
@ -60,7 +60,7 @@ ReturnValue_t DataLinkLayer::frameValidationCheck() {
}
ReturnValue_t DataLinkLayer::frameCheckCRC() {
uint16_t checkValue = ::Calculate_CRC(this->currentFrame.getFullFrame(),
uint16_t checkValue = CRC::crc16ccitt(this->currentFrame.getFullFrame(),
this->currentFrame.getFullSize());
if (checkValue == 0) {
return RETURN_OK;

View File

@ -6,7 +6,7 @@
*/
#include <framework/datalinklayer/TcTransferFrameLocal.h>
#include <framework/globalfunctions/crc_ccitt.h>
#include <framework/globalfunctions/CRC.h>
#include <framework/serviceinterface/ServiceInterfaceStream.h>
#include <string.h>
@ -25,7 +25,7 @@ TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uin
uint16_t totalSize = sizeof(TcTransferFramePrimaryHeader) + dataSize + FRAME_CRC_SIZE -1;
frame->header.vcidAndLength_h |= (totalSize & 0x0300) >> 8;
frame->header.length_l = (totalSize & 0x00FF);
uint16_t crc = ::Calculate_CRC(getFullFrame(), getFullSize() -2);
uint16_t crc = CRC::crc16ccitt(getFullFrame(), getFullSize() -2);
this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8;
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
} else if (dataSize <= 1016) {
@ -33,7 +33,7 @@ TcTransferFrameLocal::TcTransferFrameLocal(bool bypass, bool controlCommand, uin
uint16_t dataCrcSize = sizeof(TcTransferFramePrimaryHeader) + 1 + dataSize + FRAME_CRC_SIZE -1;
frame->header.vcidAndLength_h |= (dataCrcSize & 0x0300) >> 8;
frame->header.length_l = (dataCrcSize & 0x00FF);
uint16_t crc = ::Calculate_CRC(getFullFrame(), getFullSize() -2);
uint16_t crc = CRC::crc16ccitt(getFullFrame(), getFullSize() -2);
this->getFullFrame()[getFullSize()-2] = (crc & 0xFF00) >> 8;
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
} else {