Merge remote-tracking branch 'upstream/master'
into mueller_framework
This commit is contained in:
commit
a405357578
@ -2,10 +2,10 @@
|
||||
#define FRAMEWORK_CONTAINER_INDEXEDRINGMEMORY_H_
|
||||
|
||||
#include <framework/container/ArrayList.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <framework/serialize/SerialArrayListAdapter.h>
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <cmath>
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
@ -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 {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <framework/devicehandlers/AcceptsDeviceResponsesIF.h>
|
||||
#include <framework/devicehandlers/DeviceHandlerBase.h>
|
||||
#include <framework/devicehandlers/DeviceTmReportingWrapper.h>
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/objectmanager/ObjectManager.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <framework/subsystem/SubsystemBase.h>
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <math.h>
|
||||
|
||||
static const uint16_t crc_table[256] = {
|
||||
const uint16_t CRC::crc16ccitt_table[256] = {
|
||||
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||
@ -38,19 +38,18 @@ static const uint16_t crc_table[256] = {
|
||||
|
||||
|
||||
// CRC implementation
|
||||
uint16_t Calculate_CRC(uint8_t const input[], uint32_t length)
|
||||
uint16_t CRC::crc16ccitt(uint8_t const input[], uint32_t length, uint16_t startingCrc)
|
||||
{
|
||||
uint16_t crc = 0xFFFF;
|
||||
uint8_t *data = (uint8_t *)input;
|
||||
unsigned int tbl_idx;
|
||||
|
||||
while (length--) {
|
||||
tbl_idx = ((crc >> 8) ^ *data) & 0xff;
|
||||
crc = (crc_table[tbl_idx] ^ (crc << 8)) & 0xffff;
|
||||
tbl_idx = ((startingCrc >> 8) ^ *data) & 0xff;
|
||||
startingCrc = (crc16ccitt_table[tbl_idx] ^ (startingCrc << 8)) & 0xffff;
|
||||
|
||||
data++;
|
||||
}
|
||||
return crc & 0xffff;
|
||||
return startingCrc & 0xffff;
|
||||
|
||||
//The part below is not used!
|
||||
// bool temr[16];
|
16
globalfunctions/CRC.h
Normal file
16
globalfunctions/CRC.h
Normal file
@ -0,0 +1,16 @@
|
||||
#ifndef CRC_CCITT_H_
|
||||
#define CRC_CCITT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
class CRC {
|
||||
public:
|
||||
static uint16_t crc16ccitt(uint8_t const input[], uint32_t length,
|
||||
uint16_t startingCrc = 0xffff);
|
||||
private:
|
||||
CRC();
|
||||
|
||||
static const uint16_t crc16ccitt_table[256];
|
||||
};
|
||||
|
||||
#endif /* CRC_H_ */
|
@ -1,9 +0,0 @@
|
||||
#ifndef CRC_CCITT_H_
|
||||
#define CRC_CCITT_H_
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
uint16_t Calculate_CRC(uint8_t const input[], uint32_t length);
|
||||
|
||||
|
||||
#endif /* CRC_H_ */
|
@ -1,4 +1,4 @@
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/memory/MemoryHelper.h>
|
||||
#include <framework/memory/MemoryMessage.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
@ -98,7 +98,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
||||
break;
|
||||
}
|
||||
case MemoryMessage::CMD_MEMORY_CHECK: {
|
||||
uint16_t crc = ::Calculate_CRC(reservedSpaceInIPC, size);
|
||||
uint16_t crc = CRC::crc16ccitt(reservedSpaceInIPC, size);
|
||||
//Delete data immediately, was temporary.
|
||||
ipcStore->deleteData(ipcAddress);
|
||||
MemoryMessage::setMemoryCheckReply(&reply, crc);
|
||||
|
@ -51,27 +51,6 @@ ReturnValue_t MessageQueue::sendMessageFrom(MessageQueueId_t sendTo,
|
||||
return sendMessageFromMessageQueue(sendTo,message,sentFrom,ignoreFault, callContext);
|
||||
}
|
||||
|
||||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage *message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault, CallContext callContext) {
|
||||
message->setSender(sentFrom);
|
||||
BaseType_t result;
|
||||
if(callContext == CallContext::task) {
|
||||
result = xQueueSendToBack(reinterpret_cast<void*>(sendTo),
|
||||
reinterpret_cast<const void*>(message->getBuffer()), 0);
|
||||
}
|
||||
else {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
result = xQueueSendFromISR(reinterpret_cast<void*>(sendTo),
|
||||
reinterpret_cast<const void*>(message->getBuffer()), &xHigherPriorityTaskWoken);
|
||||
if(xHigherPriorityTaskWoken == pdTRUE) {
|
||||
TaskManagement::requestContextSwitch(callContext);
|
||||
}
|
||||
}
|
||||
return handleSendResult(result, ignoreFault);
|
||||
}
|
||||
|
||||
|
||||
|
||||
ReturnValue_t MessageQueue::handleSendResult(BaseType_t result, bool ignoreFault) {
|
||||
if (result != pdPASS) {
|
||||
@ -134,4 +113,24 @@ bool MessageQueue::isDefaultDestinationSet() const {
|
||||
}
|
||||
|
||||
|
||||
|
||||
// static core function to send messages.
|
||||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage *message, MessageQueueId_t sentFrom,
|
||||
bool ignoreFault, CallContext callContext) {
|
||||
message->setSender(sentFrom);
|
||||
BaseType_t result;
|
||||
if(callContext == CallContext::task) {
|
||||
result = xQueueSendToBack(reinterpret_cast<void*>(sendTo),
|
||||
reinterpret_cast<const void*>(message->getBuffer()), 0);
|
||||
}
|
||||
else {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
result = xQueueSendFromISR(reinterpret_cast<void*>(sendTo),
|
||||
reinterpret_cast<const void*>(message->getBuffer()),
|
||||
&xHigherPriorityTaskWoken);
|
||||
if(xHigherPriorityTaskWoken == pdTRUE) {
|
||||
TaskManagement::requestContextSwitch(callContext);
|
||||
}
|
||||
}
|
||||
return handleSendResult(result, ignoreFault);
|
||||
}
|
||||
|
@ -168,7 +168,7 @@ protected:
|
||||
*/
|
||||
static ReturnValue_t sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||
MessageQueueMessage* message, MessageQueueId_t sentFrom = NO_QUEUE,
|
||||
bool ignoreFault=false, CallContext callContex = CallContext::task);
|
||||
bool ignoreFault=false, CallContext callContext = CallContext::task);
|
||||
|
||||
static ReturnValue_t handleSendResult(BaseType_t result, bool ignoreFault);
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/storagemanager/StorageManagerIF.h>
|
||||
#include <framework/tcdistribution/TcPacketCheck.h>
|
||||
@ -8,7 +8,7 @@ TcPacketCheck::TcPacketCheck( uint16_t set_apid ) : apid(set_apid) {
|
||||
}
|
||||
|
||||
ReturnValue_t TcPacketCheck::checkPacket( TcPacketStored* current_packet ) {
|
||||
uint16_t calculated_crc = ::Calculate_CRC ( current_packet->getWholeData(), current_packet->getFullSize() );
|
||||
uint16_t calculated_crc = CRC::crc16ccitt( current_packet->getWholeData(), current_packet->getFullSize() );
|
||||
if ( calculated_crc != 0 ) {
|
||||
return INCORRECT_CHECKSUM;
|
||||
}
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/tmtcpacket/pus/TcPacketBase.h>
|
||||
#include <string.h>
|
||||
@ -40,7 +40,7 @@ uint16_t TcPacketBase::getErrorControl() {
|
||||
|
||||
void TcPacketBase::setErrorControl() {
|
||||
uint32_t full_size = getFullSize();
|
||||
uint16_t crc = ::Calculate_CRC(getWholeData(), full_size - CRC_SIZE);
|
||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||
uint32_t size = getApplicationDataSize();
|
||||
(&tcData->data)[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||
(&tcData->data)[size + 1] = (crc) & 0X00FF; // CRCL
|
||||
|
@ -1,4 +1,4 @@
|
||||
#include <framework/globalfunctions/crc_ccitt.h>
|
||||
#include <framework/globalfunctions/CRC.h>
|
||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||
#include <framework/tmtcpacket/pus/TmPacketBase.h>
|
||||
@ -39,7 +39,7 @@ uint16_t TmPacketBase::getErrorControl() {
|
||||
|
||||
void TmPacketBase::setErrorControl() {
|
||||
uint32_t full_size = getFullSize();
|
||||
uint16_t crc = ::Calculate_CRC(getWholeData(), full_size - CRC_SIZE);
|
||||
uint16_t crc = CRC::crc16ccitt(getWholeData(), full_size - CRC_SIZE);
|
||||
uint32_t size = getSourceDataSize();
|
||||
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||
getSourceData()[size + 1] = (crc) & 0X00FF; // CRCL
|
||||
|
@ -106,8 +106,9 @@ public:
|
||||
protected:
|
||||
/**
|
||||
* Check the target subservice
|
||||
* @param subservice
|
||||
* @return
|
||||
* @param subservice[in]
|
||||
* @return -@c RETURN_OK on success
|
||||
* -@c INVALID_SUBSERVICE if service is not known
|
||||
*/
|
||||
virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0;
|
||||
|
||||
|
@ -30,6 +30,7 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
|
||||
// info << "Service " << (uint16_t) this->serviceId << ": new packet!" << std::endl;
|
||||
|
||||
ReturnValue_t return_code = this->handleRequest(currentPacket.getSubService());
|
||||
|
||||
// debug << "Service " << (uint16_t)this->serviceId << ": handleRequest returned: " << (int)return_code << std::endl;
|
||||
if (return_code == RETURN_OK) {
|
||||
this->verifyReporter.sendSuccessReport(
|
||||
|
@ -101,7 +101,6 @@ protected:
|
||||
/**
|
||||
* One of two error parameters for additional error information.
|
||||
*/
|
||||
// shouldn't this be uint32_t ? The PUS Verification Message structure param2 has the size 4
|
||||
uint32_t errorParameter2;
|
||||
/**
|
||||
* This is a complete instance of the Telecommand reception queue of the class.
|
||||
|
Loading…
Reference in New Issue
Block a user