Merge remote-tracking branch 'upstream/master' into mueller_stopwatch
This commit is contained in:
commit
1181ebcbda
@ -21,7 +21,7 @@ public:
|
|||||||
readIndex(0), writeIndex(0), currentSize(0) {
|
readIndex(0), writeIndex(0), currentSize(0) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool emtpy() {
|
bool empty() {
|
||||||
return (currentSize == 0);
|
return (currentSize == 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,7 +45,7 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t retrieve(T *value) {
|
ReturnValue_t retrieve(T *value) {
|
||||||
if (emtpy()) {
|
if (empty()) {
|
||||||
return EMPTY;
|
return EMPTY;
|
||||||
} else {
|
} else {
|
||||||
*value = data[readIndex];
|
*value = data[readIndex];
|
||||||
|
@ -2,10 +2,10 @@
|
|||||||
#define FRAMEWORK_CONTAINER_INDEXEDRINGMEMORY_H_
|
#define FRAMEWORK_CONTAINER_INDEXEDRINGMEMORY_H_
|
||||||
|
|
||||||
#include <framework/container/ArrayList.h>
|
#include <framework/container/ArrayList.h>
|
||||||
|
#include <framework/globalfunctions/CRC.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
#include <framework/returnvalues/HasReturnvaluesIF.h>
|
||||||
#include <framework/serialize/SerialArrayListAdapter.h>
|
#include <framework/serialize/SerialArrayListAdapter.h>
|
||||||
#include <framework/globalfunctions/crc_ccitt.h>
|
|
||||||
#include <cmath>
|
#include <cmath>
|
||||||
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
#include <framework/datalinklayer/DataLinkLayer.h>
|
#include <framework/datalinklayer/DataLinkLayer.h>
|
||||||
#include <framework/globalfunctions/crc_ccitt.h>
|
#include <framework/globalfunctions/CRC.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
|
||||||
DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw,
|
DataLinkLayer::DataLinkLayer(uint8_t* set_frame_buffer, ClcwIF* setClcw,
|
||||||
@ -60,7 +60,7 @@ ReturnValue_t DataLinkLayer::frameValidationCheck() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t DataLinkLayer::frameCheckCRC() {
|
ReturnValue_t DataLinkLayer::frameCheckCRC() {
|
||||||
uint16_t checkValue = ::Calculate_CRC(this->currentFrame.getFullFrame(),
|
uint16_t checkValue = CRC::crc16ccitt(this->currentFrame.getFullFrame(),
|
||||||
this->currentFrame.getFullSize());
|
this->currentFrame.getFullSize());
|
||||||
if (checkValue == 0) {
|
if (checkValue == 0) {
|
||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <framework/datalinklayer/TcTransferFrameLocal.h>
|
#include <framework/datalinklayer/TcTransferFrameLocal.h>
|
||||||
#include <framework/globalfunctions/crc_ccitt.h>
|
#include <framework/globalfunctions/CRC.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <string.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;
|
uint16_t totalSize = sizeof(TcTransferFramePrimaryHeader) + dataSize + FRAME_CRC_SIZE -1;
|
||||||
frame->header.vcidAndLength_h |= (totalSize & 0x0300) >> 8;
|
frame->header.vcidAndLength_h |= (totalSize & 0x0300) >> 8;
|
||||||
frame->header.length_l = (totalSize & 0x00FF);
|
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()-2] = (crc & 0xFF00) >> 8;
|
||||||
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
|
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
|
||||||
} else if (dataSize <= 1016) {
|
} 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;
|
uint16_t dataCrcSize = sizeof(TcTransferFramePrimaryHeader) + 1 + dataSize + FRAME_CRC_SIZE -1;
|
||||||
frame->header.vcidAndLength_h |= (dataCrcSize & 0x0300) >> 8;
|
frame->header.vcidAndLength_h |= (dataCrcSize & 0x0300) >> 8;
|
||||||
frame->header.length_l = (dataCrcSize & 0x00FF);
|
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()-2] = (crc & 0xFF00) >> 8;
|
||||||
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
|
this->getFullFrame()[getFullSize()-1] = (crc & 0x00FF);
|
||||||
} else {
|
} else {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <framework/devicehandlers/AcceptsDeviceResponsesIF.h>
|
#include <framework/devicehandlers/AcceptsDeviceResponsesIF.h>
|
||||||
#include <framework/devicehandlers/DeviceHandlerBase.h>
|
#include <framework/devicehandlers/DeviceHandlerBase.h>
|
||||||
#include <framework/devicehandlers/DeviceTmReportingWrapper.h>
|
#include <framework/devicehandlers/DeviceTmReportingWrapper.h>
|
||||||
#include <framework/globalfunctions/crc_ccitt.h>
|
#include <framework/globalfunctions/CRC.h>
|
||||||
#include <framework/objectmanager/ObjectManager.h>
|
#include <framework/objectmanager/ObjectManager.h>
|
||||||
#include <framework/storagemanager/StorageManagerIF.h>
|
#include <framework/storagemanager/StorageManagerIF.h>
|
||||||
#include <framework/subsystem/SubsystemBase.h>
|
#include <framework/subsystem/SubsystemBase.h>
|
||||||
|
@ -89,7 +89,10 @@ uint32_t FixedSlotSequence::getLengthMs() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t FixedSlotSequence::checkSequence() const {
|
ReturnValue_t FixedSlotSequence::checkSequence() const {
|
||||||
//Iterate through slotList and check successful creation. Checks if timing is ok (must be ascending) and if all handlers were found.
|
if(slotList.empty()) {
|
||||||
|
error << "Fixed Slot Sequence: Slot list is empty!" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
auto slotIt = slotList.begin();
|
auto slotIt = slotList.begin();
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
uint32_t time = 0;
|
uint32_t time = 0;
|
||||||
|
@ -6,12 +6,18 @@
|
|||||||
#include <list>
|
#include <list>
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* \brief This class is the representation of a Polling Sequence Table in software.
|
* @brief This class is the representation of a Polling Sequence Table in software.
|
||||||
*
|
*
|
||||||
* \details The FixedSlotSequence object maintains the dynamic execution of device handler objects.
|
* @details
|
||||||
* The main idea is to create a list of device handlers, to announce all handlers to the
|
* The FixedSlotSequence object maintains the dynamic execution of
|
||||||
* polling sequence and to maintain a list of polling slot objects. This slot list represents the
|
* device handler objects.
|
||||||
* Polling Sequence Table in software. Each polling slot contains information to indicate when and
|
*
|
||||||
|
* The main idea is to create a list of device handlers, to announce all
|
||||||
|
* handlers to thepolling sequence and to maintain a list of
|
||||||
|
* polling slot objects. This slot list represents the Polling Sequence Table
|
||||||
|
* in software.
|
||||||
|
*
|
||||||
|
* Each polling slot contains information to indicate when and
|
||||||
* which device handler shall be executed within a given polling period.
|
* which device handler shall be executed within a given polling period.
|
||||||
* The sequence is then executed by iterating through this slot list.
|
* The sequence is then executed by iterating through this slot list.
|
||||||
* Handlers are invoking by calling a certain function stored in the handler list.
|
* Handlers are invoking by calling a certain function stored in the handler list.
|
||||||
@ -97,6 +103,11 @@ public:
|
|||||||
*/
|
*/
|
||||||
std::list<FixedSequenceSlot*>::iterator current;
|
std::list<FixedSequenceSlot*>::iterator current;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate through slotList and check successful creation.
|
||||||
|
* Checks if timing is ok (must be ascending) and if all handlers were found.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
ReturnValue_t checkSequence() const;
|
ReturnValue_t checkSequence() const;
|
||||||
protected:
|
protected:
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#include <framework/globalfunctions/crc_ccitt.h>
|
#include <framework/globalfunctions/CRC.h>
|
||||||
#include <math.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,
|
0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50a5, 0x60c6, 0x70e7,
|
||||||
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
0x8108, 0x9129, 0xa14a, 0xb16b, 0xc18c, 0xd1ad, 0xe1ce, 0xf1ef,
|
||||||
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
0x1231, 0x0210, 0x3273, 0x2252, 0x52b5, 0x4294, 0x72f7, 0x62d6,
|
||||||
@ -38,19 +38,18 @@ static const uint16_t crc_table[256] = {
|
|||||||
|
|
||||||
|
|
||||||
// CRC implementation
|
// 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;
|
uint8_t *data = (uint8_t *)input;
|
||||||
unsigned int tbl_idx;
|
unsigned int tbl_idx;
|
||||||
|
|
||||||
while (length--) {
|
while (length--) {
|
||||||
tbl_idx = ((crc >> 8) ^ *data) & 0xff;
|
tbl_idx = ((startingCrc >> 8) ^ *data) & 0xff;
|
||||||
crc = (crc_table[tbl_idx] ^ (crc << 8)) & 0xffff;
|
startingCrc = (crc16ccitt_table[tbl_idx] ^ (startingCrc << 8)) & 0xffff;
|
||||||
|
|
||||||
data++;
|
data++;
|
||||||
}
|
}
|
||||||
return crc & 0xffff;
|
return startingCrc & 0xffff;
|
||||||
|
|
||||||
//The part below is not used!
|
//The part below is not used!
|
||||||
// bool temr[16];
|
// 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/MemoryHelper.h>
|
||||||
#include <framework/memory/MemoryMessage.h>
|
#include <framework/memory/MemoryMessage.h>
|
||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
@ -98,7 +98,7 @@ void MemoryHelper::completeDump(ReturnValue_t errorCode,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case MemoryMessage::CMD_MEMORY_CHECK: {
|
case MemoryMessage::CMD_MEMORY_CHECK: {
|
||||||
uint16_t crc = ::Calculate_CRC(reservedSpaceInIPC, size);
|
uint16_t crc = CRC::crc16ccitt(reservedSpaceInIPC, size);
|
||||||
//Delete data immediately, was temporary.
|
//Delete data immediately, was temporary.
|
||||||
ipcStore->deleteData(ipcAddress);
|
ipcStore->deleteData(ipcAddress);
|
||||||
MemoryMessage::setMemoryCheckReply(&reply, crc);
|
MemoryMessage::setMemoryCheckReply(&reply, crc);
|
||||||
|
@ -19,8 +19,7 @@ FixedTimeslotTask::~FixedTimeslotTask() {
|
|||||||
void FixedTimeslotTask::taskEntryPoint(void* argument) {
|
void FixedTimeslotTask::taskEntryPoint(void* argument) {
|
||||||
|
|
||||||
//The argument is re-interpreted as FixedTimeslotTask. The Task object is global, so it is found from any place.
|
//The argument is re-interpreted as FixedTimeslotTask. The Task object is global, so it is found from any place.
|
||||||
FixedTimeslotTask *originalTask(
|
FixedTimeslotTask *originalTask(reinterpret_cast<FixedTimeslotTask*>(argument));
|
||||||
reinterpret_cast<FixedTimeslotTask*>(argument));
|
|
||||||
// Task should not start until explicitly requested
|
// Task should not start until explicitly requested
|
||||||
// in FreeRTOS, tasks start as soon as they are created if the scheduler is running
|
// in FreeRTOS, tasks start as soon as they are created if the scheduler is running
|
||||||
// but not if the scheduler is not running.
|
// but not if the scheduler is not running.
|
||||||
@ -58,8 +57,19 @@ ReturnValue_t FixedTimeslotTask::startTask() {
|
|||||||
|
|
||||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||||
uint32_t slotTimeMs, int8_t executionStep) {
|
uint32_t slotTimeMs, int8_t executionStep) {
|
||||||
|
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) {
|
||||||
|
if(slotTimeMs == 0) {
|
||||||
|
// FreeRTOS throws a sanity error for zero values, so we set
|
||||||
|
// the time to one millisecond.
|
||||||
|
slotTimeMs = 1;
|
||||||
|
}
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
error << "Component " << std::hex << componentId <<
|
||||||
|
" not found, not adding it to pst" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t FixedTimeslotTask::getPeriodMs() const {
|
uint32_t FixedTimeslotTask::getPeriodMs() const {
|
||||||
|
@ -38,7 +38,9 @@ ReturnValue_t MessageQueue::reply(MessageQueueMessage* message) {
|
|||||||
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessage* message,
|
ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessage* message,
|
||||||
MessageQueueId_t* receivedFrom) {
|
MessageQueueId_t* receivedFrom) {
|
||||||
ReturnValue_t status = this->receiveMessage(message);
|
ReturnValue_t status = this->receiveMessage(message);
|
||||||
|
if(status == HasReturnvaluesIF::RETURN_OK) {
|
||||||
*receivedFrom = this->lastPartner;
|
*receivedFrom = this->lastPartner;
|
||||||
|
}
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -89,6 +91,7 @@ MessageQueueId_t MessageQueue::getDefaultDestination() const {
|
|||||||
bool MessageQueue::isDefaultDestinationSet() const {
|
bool MessageQueue::isDefaultDestinationSet() const {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
ReturnValue_t MessageQueue::sendMessageFromMessageQueue(MessageQueueId_t sendTo,
|
||||||
MessageQueueMessage *message, MessageQueueId_t sentFrom,
|
MessageQueueMessage *message, MessageQueueId_t sentFrom,
|
||||||
bool ignoreFault) {
|
bool ignoreFault) {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <framework/ipc/QueueFactory.h>
|
#include <framework/ipc/QueueFactory.h>
|
||||||
|
|
||||||
#include "../FreeRTOS/MessageQueue.h"
|
#include <framework/osal/FreeRTOS/MessageQueue.h>
|
||||||
|
|
||||||
|
|
||||||
QueueFactory* QueueFactory::factoryInstance = NULL;
|
QueueFactory* QueueFactory::factoryInstance = NULL;
|
||||||
|
@ -15,6 +15,7 @@ TaskFactory* TaskFactory::instance() {
|
|||||||
}
|
}
|
||||||
/***
|
/***
|
||||||
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
||||||
|
* High taskPriority_ number means high priority.
|
||||||
*/
|
*/
|
||||||
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,
|
PeriodicTaskIF* TaskFactory::createPeriodicTask(TaskName name_,
|
||||||
TaskPriority taskPriority_, TaskStackSize stackSize_,
|
TaskPriority taskPriority_, TaskStackSize stackSize_,
|
||||||
|
@ -40,8 +40,14 @@ uint32_t FixedTimeslotTask::getPeriodMs() const {
|
|||||||
|
|
||||||
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
ReturnValue_t FixedTimeslotTask::addSlot(object_id_t componentId,
|
||||||
uint32_t slotTimeMs, int8_t executionStep) {
|
uint32_t slotTimeMs, int8_t executionStep) {
|
||||||
|
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) {
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
error << "Component " << std::hex << componentId <<
|
||||||
|
" not found, not adding it to pst" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t FixedTimeslotTask::checkSequence() const {
|
ReturnValue_t FixedTimeslotTask::checkSequence() const {
|
||||||
|
@ -66,10 +66,16 @@ ReturnValue_t PollingTask::startTask() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t PollingTask::addSlot(object_id_t componentId, uint32_t slotTimeMs,
|
ReturnValue_t PollingTask::addSlot(object_id_t componentId,
|
||||||
int8_t executionStep) {
|
uint32_t slotTimeMs, int8_t executionStep) {
|
||||||
|
if (objectManager->get<ExecutableObjectIF>(componentId) != nullptr) {
|
||||||
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
pst.addSlot(componentId, slotTimeMs, executionStep, this);
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
|
||||||
|
error << "Component " << std::hex << componentId <<
|
||||||
|
" not found, not adding it to pst" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t PollingTask::getPeriodMs() const {
|
uint32_t PollingTask::getPeriodMs() const {
|
||||||
|
@ -91,7 +91,7 @@ template<typename T>
|
|||||||
ReturnValue_t ParameterWrapper::serializeData(uint8_t** buffer, uint32_t* size,
|
ReturnValue_t ParameterWrapper::serializeData(uint8_t** buffer, uint32_t* size,
|
||||||
const uint32_t max_size, bool bigEndian) const {
|
const uint32_t max_size, bool bigEndian) const {
|
||||||
const T *element = (const T*) readonlyData;
|
const T *element = (const T*) readonlyData;
|
||||||
ReturnValue_t result;
|
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||||
uint16_t dataSize = columns * rows;
|
uint16_t dataSize = columns * rows;
|
||||||
while (dataSize != 0) {
|
while (dataSize != 0) {
|
||||||
result = SerializeAdapter<T>::serialize(element, buffer, size, max_size,
|
result = SerializeAdapter<T>::serialize(element, buffer, size, max_size,
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
#include <framework/globalfunctions/crc_ccitt.h>
|
#include <framework/globalfunctions/CRC.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <framework/storagemanager/StorageManagerIF.h>
|
#include <framework/storagemanager/StorageManagerIF.h>
|
||||||
#include <framework/tcdistribution/TcPacketCheck.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 ) {
|
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 ) {
|
if ( calculated_crc != 0 ) {
|
||||||
return INCORRECT_CHECKSUM;
|
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/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <framework/tmtcpacket/pus/TcPacketBase.h>
|
#include <framework/tmtcpacket/pus/TcPacketBase.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@ -40,7 +40,7 @@ uint16_t TcPacketBase::getErrorControl() {
|
|||||||
|
|
||||||
void TcPacketBase::setErrorControl() {
|
void TcPacketBase::setErrorControl() {
|
||||||
uint32_t full_size = getFullSize();
|
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();
|
uint32_t size = getApplicationDataSize();
|
||||||
(&tcData->data)[size] = (crc & 0XFF00) >> 8; // CRCH
|
(&tcData->data)[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||||
(&tcData->data)[size + 1] = (crc) & 0X00FF; // CRCL
|
(&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/objectmanager/ObjectManagerIF.h>
|
||||||
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
#include <framework/tmtcpacket/pus/TmPacketBase.h>
|
#include <framework/tmtcpacket/pus/TmPacketBase.h>
|
||||||
@ -39,7 +39,7 @@ uint16_t TmPacketBase::getErrorControl() {
|
|||||||
|
|
||||||
void TmPacketBase::setErrorControl() {
|
void TmPacketBase::setErrorControl() {
|
||||||
uint32_t full_size = getFullSize();
|
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();
|
uint32_t size = getSourceDataSize();
|
||||||
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
|
getSourceData()[size] = (crc & 0XFF00) >> 8; // CRCH
|
||||||
getSourceData()[size + 1] = (crc) & 0X00FF; // CRCL
|
getSourceData()[size + 1] = (crc) & 0X00FF; // CRCL
|
||||||
|
@ -64,7 +64,7 @@ public:
|
|||||||
virtual ~CommandingServiceBase();
|
virtual ~CommandingServiceBase();
|
||||||
|
|
||||||
/***
|
/***
|
||||||
* This is the periodic called function
|
* This is the periodically called function.
|
||||||
* Handle request queue for external commands.
|
* Handle request queue for external commands.
|
||||||
* Handle command Queue for internal commands.
|
* Handle command Queue for internal commands.
|
||||||
* @param opCode is unused here at the moment
|
* @param opCode is unused here at the moment
|
||||||
@ -104,6 +104,69 @@ public:
|
|||||||
};
|
};
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
/**
|
||||||
|
* Check the target subservice
|
||||||
|
* @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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Once a TC Request is valid, the existence of the destination and its target interface is checked and retrieved.
|
||||||
|
* The target message queue ID can then be acquired by using the target interface.
|
||||||
|
* @param subservice
|
||||||
|
* @param tcData Application Data of TC Packet
|
||||||
|
* @param tcDataLen
|
||||||
|
* @param id MessageQueue ID is stored here
|
||||||
|
* @param objectId Object ID is extracted and stored here
|
||||||
|
* @return - @c RETURN_OK on success
|
||||||
|
* - @c RETURN_FAILED
|
||||||
|
* - @c CSB or implementation specific return codes
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
|
||||||
|
const uint8_t *tcData, uint32_t tcDataLen, MessageQueueId_t *id,
|
||||||
|
object_id_t *objectId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* After the Message Queue and Object ID are determined,
|
||||||
|
* the command is prepared by using an implementation specific CommandMessage type
|
||||||
|
* which is sent to the target object.
|
||||||
|
* It contains all necessary information for the device to execute telecommands.
|
||||||
|
* @param message[out] message to be sent to the object
|
||||||
|
* @param subservice[in] Subservice of the current communication
|
||||||
|
* @param tcData Additional data of the command
|
||||||
|
* @param tcDataLen Length of the additional data
|
||||||
|
* @param state[out] Setable state of the communication
|
||||||
|
* @param objectId Target object ID
|
||||||
|
* @return - @c RETURN_OK on success
|
||||||
|
* - @c EXECUTION_COMPLETE if exectuin is finished
|
||||||
|
* - any other return code will be part of (1,4) start failure
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t prepareCommand(CommandMessage *message,
|
||||||
|
uint8_t subservice, const uint8_t *tcData, uint32_t tcDataLen,
|
||||||
|
uint32_t *state, object_id_t objectId) = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* This function is responsible for the communication between the Command Service Base
|
||||||
|
* and the respective PUS Commanding Service once the execution has started.
|
||||||
|
* The PUS Commanding Service receives replies from the target device and forwards them by calling this function.
|
||||||
|
* There are different translations of these replies to specify how the Command Service proceeds.
|
||||||
|
* @param reply Command Message which contains information about the command
|
||||||
|
* @param previousCommand Command_t of last command
|
||||||
|
* @param state state of the communication
|
||||||
|
* @param optionalNextCommand[out] An optional next command which can be set in this function
|
||||||
|
* @param objectId Source object ID
|
||||||
|
* @param isStep Flag value to mark steps of command execution
|
||||||
|
* @return - @c RETURN_OK, @c EXECUTION_COMPLETE or @c NO_STEP_MESSAGE to generate TC verification success
|
||||||
|
* - @c INVALID_REPLY can handle unrequested replies
|
||||||
|
* - Anything else triggers a TC verification failure
|
||||||
|
*/
|
||||||
|
virtual ReturnValue_t handleReply(const CommandMessage *reply,
|
||||||
|
Command_t previousCommand, uint32_t *state,
|
||||||
|
CommandMessage *optionalNextCommand, object_id_t objectId,
|
||||||
|
bool *isStep) = 0;
|
||||||
|
|
||||||
struct CommandInfo {
|
struct CommandInfo {
|
||||||
struct tcInfo {
|
struct tcInfo {
|
||||||
uint8_t ackFlags;
|
uint8_t ackFlags;
|
||||||
@ -180,20 +243,6 @@ protected:
|
|||||||
*/
|
*/
|
||||||
void sendTmPacket(uint8_t subservice, SerializeIF* content,
|
void sendTmPacket(uint8_t subservice, SerializeIF* content,
|
||||||
SerializeIF* header = NULL);
|
SerializeIF* header = NULL);
|
||||||
virtual ReturnValue_t isValidSubservice(uint8_t subservice) = 0;
|
|
||||||
|
|
||||||
virtual ReturnValue_t prepareCommand(CommandMessage *message,
|
|
||||||
uint8_t subservice, const uint8_t *tcData, uint32_t tcDataLen,
|
|
||||||
uint32_t *state, object_id_t objectId) = 0;
|
|
||||||
|
|
||||||
virtual ReturnValue_t handleReply(const CommandMessage *reply,
|
|
||||||
Command_t previousCommand, uint32_t *state,
|
|
||||||
CommandMessage *optionalNextCommand, object_id_t objectId,
|
|
||||||
bool *isStep) = 0;
|
|
||||||
|
|
||||||
virtual ReturnValue_t getMessageQueueAndObject(uint8_t subservice,
|
|
||||||
const uint8_t *tcData, uint32_t tcDataLen, MessageQueueId_t *id,
|
|
||||||
object_id_t *objectId) = 0;
|
|
||||||
|
|
||||||
virtual void handleUnrequestedReply(CommandMessage *reply);
|
virtual void handleUnrequestedReply(CommandMessage *reply);
|
||||||
|
|
||||||
@ -209,7 +258,8 @@ private:
|
|||||||
* It handles replies generated by the devices and relayed by the specific service implementation.
|
* It handles replies generated by the devices and relayed by the specific service implementation.
|
||||||
* This means that it determines further course of action depending on the return values specified
|
* This means that it determines further course of action depending on the return values specified
|
||||||
* in the service implementation.
|
* in the service implementation.
|
||||||
* This includes the generation of TC verification messages:
|
* This includes the generation of TC verification messages. Note that
|
||||||
|
* the static framework object ID @c VerificationReporter::messageReceiver needs to be set.
|
||||||
* - TM[1,5] Step Successs
|
* - TM[1,5] Step Successs
|
||||||
* - TM[1,6] Step Failure
|
* - TM[1,6] Step Failure
|
||||||
* - TM[1,7] Completion Success
|
* - TM[1,7] Completion Success
|
||||||
|
@ -23,11 +23,11 @@ ReturnValue_t PusServiceBase::performOperation(uint8_t opCode) {
|
|||||||
TmTcMessage message;
|
TmTcMessage message;
|
||||||
for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) {
|
for (uint8_t count = 0; count < PUS_SERVICE_MAX_RECEPTION; count++) {
|
||||||
ReturnValue_t status = this->requestQueue->receiveMessage(&message);
|
ReturnValue_t status = this->requestQueue->receiveMessage(&message);
|
||||||
// debug << "PusServiceBase::performOperation: Receiving from MQ ID: " << std::hex << this->requestQueue.getId() << std::dec << " returned: " << status << std::endl;
|
// debug << "PusServiceBase::performOperation: Receiving from MQ ID: " << std::hex << this->requestQueue.getId()
|
||||||
|
// << std::dec << " returned: " << status << std::endl;
|
||||||
if (status == RETURN_OK) {
|
if (status == RETURN_OK) {
|
||||||
this->currentPacket.setStoreAddress(message.getStorageId());
|
this->currentPacket.setStoreAddress(message.getStorageId());
|
||||||
// info << "Service " << (uint16_t) this->serviceId << ": new packet!"
|
// info << "Service " << (uint16_t) this->serviceId << ": new packet!" << std::endl;
|
||||||
// << std::endl;
|
|
||||||
|
|
||||||
ReturnValue_t return_code = this->handleRequest();
|
ReturnValue_t return_code = this->handleRequest();
|
||||||
// debug << "Service " << (uint16_t)this->serviceId << ": handleRequest returned: " << (int)return_code << std::endl;
|
// debug << "Service " << (uint16_t)this->serviceId << ": handleRequest returned: " << (int)return_code << std::endl;
|
||||||
|
@ -46,13 +46,20 @@ public:
|
|||||||
*/
|
*/
|
||||||
virtual ~PusServiceBase();
|
virtual ~PusServiceBase();
|
||||||
/**
|
/**
|
||||||
* The handleRequest method shall handle any kind of Telecommand Request immediately.
|
* @brief The handleRequest method shall handle any kind of Telecommand Request immediately.
|
||||||
|
* @details
|
||||||
* Implemetations can take the Telecommand in currentPacket and perform any kind of operation.
|
* Implemetations can take the Telecommand in currentPacket and perform any kind of operation.
|
||||||
* They may send additional "Start Success (1,3)" messages with the verifyReporter, but Completion
|
* They may send additional "Start Success (1,3)" messages with the verifyReporter, but Completion
|
||||||
* Success or Failure Reports are generated automatically after execution of this method.
|
* Success or Failure Reports are generated automatically after execution of this method.
|
||||||
* If a Telecommand can not be executed within one call cycle, this Base class is not the right parent.
|
*
|
||||||
* The child class may add additional error information in #errorParameters which are attached to the generated
|
* If a Telecommand can not be executed within one call cycle,
|
||||||
* verification message.
|
* this Base class is not the right parent.
|
||||||
|
*
|
||||||
|
* The child class may add additional error information by setting #errorParameters which are
|
||||||
|
* attached to the generated verification message.
|
||||||
|
*
|
||||||
|
* Subservice checking should be implemented in this method.
|
||||||
|
*
|
||||||
* @return The returned status_code is directly taken as main error code in the Verification Report.
|
* @return The returned status_code is directly taken as main error code in the Verification Report.
|
||||||
* On success, RETURN_OK shall be returned.
|
* On success, RETURN_OK shall be returned.
|
||||||
*/
|
*/
|
||||||
@ -68,8 +75,8 @@ public:
|
|||||||
* It checks for new requests, and, if found, calls handleRequest, sends completion verification messages and deletes
|
* It checks for new requests, and, if found, calls handleRequest, sends completion verification messages and deletes
|
||||||
* the TC requests afterwards.
|
* the TC requests afterwards.
|
||||||
* performService is always executed afterwards.
|
* performService is always executed afterwards.
|
||||||
* @return - \c RETURN_OK if the periodic performService was successful.
|
* @return \c RETURN_OK if the periodic performService was successful.
|
||||||
* - \c RETURN_FAILED else.
|
* \c RETURN_FAILED else.
|
||||||
*/
|
*/
|
||||||
ReturnValue_t performOperation(uint8_t opCode);
|
ReturnValue_t performOperation(uint8_t opCode);
|
||||||
virtual uint16_t getIdentifier();
|
virtual uint16_t getIdentifier();
|
||||||
@ -91,7 +98,7 @@ protected:
|
|||||||
/**
|
/**
|
||||||
* One of two error parameters for additional error information.
|
* One of two error parameters for additional error information.
|
||||||
*/
|
*/
|
||||||
uint8_t errorParameter2;
|
uint32_t errorParameter2;
|
||||||
/**
|
/**
|
||||||
* This is a complete instance of the Telecommand reception queue of the class.
|
* This is a complete instance of the Telecommand reception queue of the class.
|
||||||
* It is initialized on construction of the class.
|
* It is initialized on construction of the class.
|
||||||
|
Loading…
Reference in New Issue
Block a user