Merge branch 'mueller/master' into source/master
This commit is contained in:
commit
76cc3e96e8
@ -35,7 +35,7 @@
|
|||||||
class HasActionsIF {
|
class HasActionsIF {
|
||||||
public:
|
public:
|
||||||
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_ACTIONS_IF;
|
static const uint8_t INTERFACE_ID = CLASS_ID::HAS_ACTIONS_IF;
|
||||||
static const ReturnValue_t IS_BUSY = MAKE_RETURN_CODE(1);//!<
|
static const ReturnValue_t IS_BUSY = MAKE_RETURN_CODE(1);
|
||||||
static const ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2);
|
static const ReturnValue_t INVALID_PARAMETERS = MAKE_RETURN_CODE(2);
|
||||||
static const ReturnValue_t EXECUTION_FINISHED = MAKE_RETURN_CODE(3);
|
static const ReturnValue_t EXECUTION_FINISHED = MAKE_RETURN_CODE(3);
|
||||||
static const ReturnValue_t INVALID_ACTION_ID = MAKE_RETURN_CODE(4);
|
static const ReturnValue_t INVALID_ACTION_ID = MAKE_RETURN_CODE(4);
|
||||||
|
@ -16,13 +16,8 @@ public:
|
|||||||
class Iterator {
|
class Iterator {
|
||||||
public:
|
public:
|
||||||
LinkedElement<T> *value = nullptr;
|
LinkedElement<T> *value = nullptr;
|
||||||
//! Creates an uninitialized iterator which points to nullptr.
|
|
||||||
Iterator() {}
|
Iterator() {}
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize iterator at specified linked element.
|
|
||||||
* @param element
|
|
||||||
*/
|
|
||||||
Iterator(LinkedElement<T> *element) :
|
Iterator(LinkedElement<T> *element) :
|
||||||
value(element) {
|
value(element) {
|
||||||
}
|
}
|
||||||
@ -77,11 +72,6 @@ private:
|
|||||||
LinkedElement *next;
|
LinkedElement *next;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @brief SinglyLinkedList data structure which keeps a pointer to its
|
|
||||||
* first element to perform all operations.
|
|
||||||
* @tparam T
|
|
||||||
*/
|
|
||||||
template<typename T>
|
template<typename T>
|
||||||
class SinglyLinkedList {
|
class SinglyLinkedList {
|
||||||
public:
|
public:
|
||||||
@ -99,12 +89,21 @@ public:
|
|||||||
return ElementIterator::Iterator(start);
|
return ElementIterator::Iterator(start);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Returns iterator to nulltr */
|
||||||
ElementIterator end() const {
|
ElementIterator end() const {
|
||||||
LinkedElement<T> *element = start;
|
return ElementIterator::Iterator();
|
||||||
while (element != nullptr) {
|
}
|
||||||
element = element->getNext();
|
|
||||||
}
|
/**
|
||||||
return ElementIterator::Iterator(element);
|
* Returns last element in singly linked list.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
ElementIterator back() const {
|
||||||
|
LinkedElement<T> *element = start;
|
||||||
|
while (element != nullptr) {
|
||||||
|
element = element->getNext();
|
||||||
|
}
|
||||||
|
return ElementIterator::Iterator(element);
|
||||||
}
|
}
|
||||||
|
|
||||||
size_t getSize() const {
|
size_t getSize() const {
|
||||||
@ -116,15 +115,37 @@ public:
|
|||||||
}
|
}
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
void setStart(LinkedElement<T>* setStart) {
|
void setStart(LinkedElement<T>* firstElement) {
|
||||||
start = setStart;
|
start = firstElement;
|
||||||
}
|
}
|
||||||
|
|
||||||
void setEnd(LinkedElement<T>* setEnd) {
|
void setNext(LinkedElement<T>* currentElement,
|
||||||
setEnd->setEnd();
|
LinkedElement<T>* nextElement) {
|
||||||
|
currentElement->setNext(nextElement);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setLast(LinkedElement<T>* lastElement) {
|
||||||
|
lastElement->setEnd();
|
||||||
}
|
}
|
||||||
|
|
||||||
// SHOULDDO: Insertion operation ?
|
void insertElement(LinkedElement<T>* element, size_t position) {
|
||||||
|
LinkedElement<T> *currentElement = start;
|
||||||
|
for(size_t count = 0; count < position; count++) {
|
||||||
|
if(currentElement == nullptr) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
currentElement = currentElement->getNext();
|
||||||
|
}
|
||||||
|
LinkedElement<T>* elementAfterCurrent = currentElement->next;
|
||||||
|
currentElement->setNext(element);
|
||||||
|
if(elementAfterCurrent != nullptr) {
|
||||||
|
element->setNext(elementAfterCurrent);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void insertBack(LinkedElement<T>* lastElement) {
|
||||||
|
back().value->setNext(lastElement);
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
LinkedElement<T> *start = nullptr;
|
LinkedElement<T> *start = nullptr;
|
||||||
|
@ -4,15 +4,14 @@
|
|||||||
|
|
||||||
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId,
|
ChildHandlerBase::ChildHandlerBase(object_id_t setObjectId,
|
||||||
object_id_t deviceCommunication, CookieIF * cookie,
|
object_id_t deviceCommunication, CookieIF * cookie,
|
||||||
uint8_t setDeviceSwitch, object_id_t hkDestination,
|
object_id_t hkDestination, uint32_t thermalStatePoolId,
|
||||||
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
|
uint32_t thermalRequestPoolId,
|
||||||
object_id_t parent,
|
object_id_t parent,
|
||||||
FailureIsolationBase* customFdir, size_t cmdQueueSize) :
|
FailureIsolationBase* customFdir, size_t cmdQueueSize) :
|
||||||
DeviceHandlerBase(setObjectId, deviceCommunication, cookie,
|
DeviceHandlerBase(setObjectId, deviceCommunication, cookie,
|
||||||
(customFdir == nullptr? &childHandlerFdir : customFdir),
|
(customFdir == nullptr? &childHandlerFdir : customFdir),
|
||||||
cmdQueueSize),
|
cmdQueueSize),
|
||||||
parentId(parent), childHandlerFdir(setObjectId) {
|
parentId(parent), childHandlerFdir(setObjectId) {
|
||||||
this->setDeviceSwitch(setDeviceSwitch);
|
|
||||||
this->setHkDestination(hkDestination);
|
this->setHkDestination(hkDestination);
|
||||||
this->setThermalStateRequestPoolIds(thermalStatePoolId,
|
this->setThermalStateRequestPoolIds(thermalStatePoolId,
|
||||||
thermalRequestPoolId);
|
thermalRequestPoolId);
|
||||||
@ -40,7 +39,7 @@ ReturnValue_t ChildHandlerBase::initialize() {
|
|||||||
parent->registerChild(getObjectId());
|
parent->registerChild(getObjectId());
|
||||||
}
|
}
|
||||||
|
|
||||||
healthHelper.setParentQeueue(parentQueue);
|
healthHelper.setParentQueue(parentQueue);
|
||||||
|
|
||||||
modeHelper.setParentQueue(parentQueue);
|
modeHelper.setParentQueue(parentQueue);
|
||||||
|
|
||||||
|
@ -7,9 +7,9 @@
|
|||||||
class ChildHandlerBase: public DeviceHandlerBase {
|
class ChildHandlerBase: public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
|
ChildHandlerBase(object_id_t setObjectId, object_id_t deviceCommunication,
|
||||||
CookieIF * cookie, uint8_t setDeviceSwitch,
|
CookieIF * cookie, object_id_t hkDestination,
|
||||||
object_id_t hkDestination, uint32_t thermalStatePoolId,
|
uint32_t thermalStatePoolId, uint32_t thermalRequestPoolId,
|
||||||
uint32_t thermalRequestPoolId, object_id_t parent = objects::NO_OBJECT,
|
object_id_t parent = objects::NO_OBJECT,
|
||||||
FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20);
|
FailureIsolationBase* customFdir = nullptr, size_t cmdQueueSize = 20);
|
||||||
virtual ~ChildHandlerBase();
|
virtual ~ChildHandlerBase();
|
||||||
|
|
||||||
|
@ -63,10 +63,6 @@ void DeviceHandlerBase::setThermalStateRequestPoolIds(
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void DeviceHandlerBase::setDeviceSwitch(uint8_t deviceSwitch) {
|
|
||||||
this->deviceSwitch = deviceSwitch;
|
|
||||||
}
|
|
||||||
|
|
||||||
DeviceHandlerBase::~DeviceHandlerBase() {
|
DeviceHandlerBase::~DeviceHandlerBase() {
|
||||||
delete comCookie;
|
delete comCookie;
|
||||||
if (defaultFDIRUsed) {
|
if (defaultFDIRUsed) {
|
||||||
@ -132,7 +128,9 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
|
|
||||||
result = communicationInterface->initializeInterface(comCookie);
|
result = communicationInterface->initializeInterface(comCookie);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
sif::error << "DeviceHandlerBase::initialize: Initializing "
|
||||||
|
"communication interface failed!" << std::endl;
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
IPCStore = objectManager->get<StorageManagerIF>(objects::IPC_STORE);
|
||||||
@ -168,12 +166,8 @@ ReturnValue_t DeviceHandlerBase::initialize() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = healthHelper.initialize();
|
result = healthHelper.initialize();
|
||||||
if (result == RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
healthHelperActive = true;
|
return result;
|
||||||
}
|
|
||||||
else {
|
|
||||||
sif::warning << "DeviceHandlerBase::initialize: Health Helper "
|
|
||||||
"initialization failure." << std::endl;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = modeHelper.initialize();
|
result = modeHelper.initialize();
|
||||||
@ -250,11 +244,9 @@ void DeviceHandlerBase::readCommandQueue() {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(healthHelperActive) {
|
result = healthHelper.handleHealthCommand(&command);
|
||||||
result = healthHelper.handleHealthCommand(&command);
|
if (result == RETURN_OK) {
|
||||||
if (result == RETURN_OK) {
|
return;
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
result = modeHelper.handleModeCommand(&command);
|
result = modeHelper.handleModeCommand(&command);
|
||||||
@ -688,16 +680,24 @@ void DeviceHandlerBase::parseReply(const uint8_t* receivedData,
|
|||||||
switch (result) {
|
switch (result) {
|
||||||
case RETURN_OK:
|
case RETURN_OK:
|
||||||
handleReply(receivedData, foundId, foundLen);
|
handleReply(receivedData, foundId, foundLen);
|
||||||
|
if(foundLen == 0) {
|
||||||
|
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
|
||||||
|
" Packet parsing will be stuck." << std::endl;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case APERIODIC_REPLY: {
|
case APERIODIC_REPLY: {
|
||||||
result = interpretDeviceReply(foundId, receivedData);
|
result = interpretDeviceReply(foundId, receivedData);
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
replyRawReplyIfnotWiretapped(receivedData, foundLen);
|
replyRawReplyIfnotWiretapped(receivedData, foundLen);
|
||||||
triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result,
|
triggerEvent(DEVICE_INTERPRETING_REPLY_FAILED, result,
|
||||||
foundId);
|
foundId);
|
||||||
}
|
}
|
||||||
|
if(foundLen == 0) {
|
||||||
|
sif::warning << "DeviceHandlerBase::parseReply: foundLen is 0!"
|
||||||
|
" Packet parsing will be stuck." << std::endl;
|
||||||
|
}
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
case IGNORE_REPLY_DATA:
|
case IGNORE_REPLY_DATA:
|
||||||
break;
|
break;
|
||||||
case IGNORE_FULL_PACKET:
|
case IGNORE_FULL_PACKET:
|
||||||
@ -1032,9 +1032,7 @@ void DeviceHandlerBase::getMode(Mode_t* mode, Submode_t* submode) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::setToExternalControl() {
|
void DeviceHandlerBase::setToExternalControl() {
|
||||||
if(healthHelperActive) {
|
healthHelper.setHealth(EXTERNAL_CONTROL);
|
||||||
healthHelper.setHealth(EXTERNAL_CONTROL);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::announceMode(bool recursive) {
|
void DeviceHandlerBase::announceMode(bool recursive) {
|
||||||
@ -1054,25 +1052,12 @@ void DeviceHandlerBase::missedReply(DeviceCommandId_t id) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HasHealthIF::HealthState DeviceHandlerBase::getHealth() {
|
HasHealthIF::HealthState DeviceHandlerBase::getHealth() {
|
||||||
if(healthHelperActive) {
|
return healthHelper.getHealth();
|
||||||
return healthHelper.getHealth();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
sif::warning << "DeviceHandlerBase::getHealth: Health helper not active"
|
|
||||||
<< std::endl;
|
|
||||||
return HasHealthIF::HEALTHY;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::setHealth(HealthState health) {
|
ReturnValue_t DeviceHandlerBase::setHealth(HealthState health) {
|
||||||
if(healthHelperActive) {
|
healthHelper.setHealth(health);
|
||||||
healthHelper.setHealth(health);
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
|
||||||
else {
|
|
||||||
sif::warning << "DeviceHandlerBase::getHealth: Health helper not active"
|
|
||||||
<< std::endl;
|
|
||||||
}
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::checkSwitchState() {
|
void DeviceHandlerBase::checkSwitchState() {
|
||||||
@ -1159,7 +1144,7 @@ ReturnValue_t DeviceHandlerBase::handleDeviceHandlerMessage(
|
|||||||
|
|
||||||
void DeviceHandlerBase::setParentQueue(MessageQueueId_t parentQueueId) {
|
void DeviceHandlerBase::setParentQueue(MessageQueueId_t parentQueueId) {
|
||||||
modeHelper.setParentQueue(parentQueueId);
|
modeHelper.setParentQueue(parentQueueId);
|
||||||
healthHelper.setParentQeueue(parentQueueId);
|
healthHelper.setParentQueue(parentQueueId);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool DeviceHandlerBase::isAwaitingReply() {
|
bool DeviceHandlerBase::isAwaitingReply() {
|
||||||
@ -1264,18 +1249,23 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
|||||||
if (mode == MODE_NORMAL) {
|
if (mode == MODE_NORMAL) {
|
||||||
result = buildNormalDeviceCommand(&deviceCommandId);
|
result = buildNormalDeviceCommand(&deviceCommandId);
|
||||||
if (result == BUSY) {
|
if (result == BUSY) {
|
||||||
|
//so we can track misconfigurations
|
||||||
sif::debug << std::hex << getObjectId()
|
sif::debug << std::hex << getObjectId()
|
||||||
<< ": DHB::buildInternalCommand busy" << std::endl; //so we can track misconfigurations
|
<< ": DHB::buildInternalCommand: Busy" << std::endl;
|
||||||
result = NOTHING_TO_SEND; //no need to report this
|
result = NOTHING_TO_SEND; //no need to report this
|
||||||
}
|
}
|
||||||
} else if (mode == MODE_RAW) {
|
}
|
||||||
|
else if (mode == MODE_RAW) {
|
||||||
result = buildChildRawCommand();
|
result = buildChildRawCommand();
|
||||||
deviceCommandId = RAW_COMMAND_ID;
|
deviceCommandId = RAW_COMMAND_ID;
|
||||||
} else if (mode & TRANSITION_MODE_CHILD_ACTION_MASK) {
|
}
|
||||||
|
else if (mode & TRANSITION_MODE_CHILD_ACTION_MASK) {
|
||||||
result = buildTransitionDeviceCommand(&deviceCommandId);
|
result = buildTransitionDeviceCommand(&deviceCommandId);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result == NOTHING_TO_SEND) {
|
if (result == NOTHING_TO_SEND) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -1386,18 +1376,6 @@ LocalDataPoolManager* DeviceHandlerBase::getHkManagerHandle() {
|
|||||||
return &hkManager;
|
return &hkManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::addDataSet(sid_t sid) {
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::removeDataSet(sid_t sid) {
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::changeCollectionInterval(sid_t sid,
|
|
||||||
dur_seconds_t newInterval) {
|
|
||||||
return HasReturnvaluesIF::RETURN_OK;
|
|
||||||
}
|
|
||||||
|
|
||||||
ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
|
ReturnValue_t DeviceHandlerBase::initializeAfterTaskCreation() {
|
||||||
// In this function, the task handle should be valid if the task
|
// In this function, the task handle should be valid if the task
|
||||||
|
@ -108,7 +108,6 @@ public:
|
|||||||
CookieIF * comCookie, FailureIsolationBase* fdirInstance = nullptr,
|
CookieIF * comCookie, FailureIsolationBase* fdirInstance = nullptr,
|
||||||
size_t cmdQueueSize = 20);
|
size_t cmdQueueSize = 20);
|
||||||
|
|
||||||
void setDeviceSwitch(uint8_t deviceSwitch);
|
|
||||||
void setHkDestination(object_id_t hkDestination);
|
void setHkDestination(object_id_t hkDestination);
|
||||||
void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId,
|
void setThermalStateRequestPoolIds(uint32_t thermalStatePoolId,
|
||||||
uint32_t thermalRequestPoolId);
|
uint32_t thermalRequestPoolId);
|
||||||
@ -380,6 +379,8 @@ protected:
|
|||||||
* @param deviceCommand Identifier of the command to add.
|
* @param deviceCommand Identifier of the command to add.
|
||||||
* @param maxDelayCycles The maximum number of delay cycles the command
|
* @param maxDelayCycles The maximum number of delay cycles the command
|
||||||
* waits until it times out.
|
* waits until it times out.
|
||||||
|
* @param replyLen Will be supplied to the requestReceiveMessage call of
|
||||||
|
* the communication interface.
|
||||||
* @param periodic Indicates if the command is periodic (i.e. it is sent
|
* @param periodic Indicates if the command is periodic (i.e. it is sent
|
||||||
* by the device repeatedly without request) or not. Default is aperiodic (0)
|
* by the device repeatedly without request) or not. Default is aperiodic (0)
|
||||||
* @return - @c RETURN_OK when the command was successfully inserted,
|
* @return - @c RETURN_OK when the command was successfully inserted,
|
||||||
@ -487,11 +488,6 @@ protected:
|
|||||||
/** Get the HK manager object handle */
|
/** Get the HK manager object handle */
|
||||||
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
virtual LocalDataPoolManager* getHkManagerHandle() override;
|
||||||
|
|
||||||
virtual ReturnValue_t addDataSet(sid_t sid) override;
|
|
||||||
virtual ReturnValue_t removeDataSet(sid_t sid) override;
|
|
||||||
virtual ReturnValue_t changeCollectionInterval(sid_t sid,
|
|
||||||
dur_seconds_t newInterval) override;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Hook function for child handlers which is called once per
|
* @brief Hook function for child handlers which is called once per
|
||||||
* performOperation(). Default implementation is empty.
|
* performOperation(). Default implementation is empty.
|
||||||
@ -610,7 +606,6 @@ protected:
|
|||||||
|
|
||||||
/** Health helper for HasHealthIF */
|
/** Health helper for HasHealthIF */
|
||||||
HealthHelper healthHelper;
|
HealthHelper healthHelper;
|
||||||
bool healthHelperActive = false;
|
|
||||||
/** Mode helper for HasModesIF */
|
/** Mode helper for HasModesIF */
|
||||||
ModeHelper modeHelper;
|
ModeHelper modeHelper;
|
||||||
/** Parameter helper for ReceivesParameterMessagesIF */
|
/** Parameter helper for ReceivesParameterMessagesIF */
|
||||||
@ -1079,13 +1074,6 @@ private:
|
|||||||
*/
|
*/
|
||||||
Submode_t transitionSourceSubMode;
|
Submode_t transitionSourceSubMode;
|
||||||
|
|
||||||
/**
|
|
||||||
* the switch of the device
|
|
||||||
*
|
|
||||||
* for devices using two switches override getSwitches()
|
|
||||||
*/
|
|
||||||
uint8_t deviceSwitch;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* read the command queue
|
* read the command queue
|
||||||
*/
|
*/
|
||||||
|
@ -98,7 +98,7 @@ public:
|
|||||||
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
|
static const uint8_t INTERFACE_ID = CLASS_ID::DEVICE_HANDLER_IF;
|
||||||
|
|
||||||
// Standard codes used when building commands.
|
// Standard codes used when building commands.
|
||||||
static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA0); //!< If the command size is 0. Checked in DHB
|
static const ReturnValue_t NO_COMMAND_DATA = MAKE_RETURN_CODE(0xA0); //!< If no command data was given when expected.
|
||||||
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); //!< Command ID not in commandMap. Checked in DHB
|
static const ReturnValue_t COMMAND_NOT_SUPPORTED = MAKE_RETURN_CODE(0xA1); //!< Command ID not in commandMap. Checked in DHB
|
||||||
static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA2); //!< Command was already executed. Checked in DHB
|
static const ReturnValue_t COMMAND_ALREADY_SENT = MAKE_RETURN_CODE(0xA2); //!< Command was already executed. Checked in DHB
|
||||||
static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA3);
|
static const ReturnValue_t COMMAND_WAS_NOT_SENT = MAKE_RETURN_CODE(0xA3);
|
||||||
|
@ -38,7 +38,7 @@ MessageQueueId_t HealthDevice::getCommandQueue() const {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void HealthDevice::setParentQueue(MessageQueueId_t parentQueue) {
|
void HealthDevice::setParentQueue(MessageQueueId_t parentQueue) {
|
||||||
healthHelper.setParentQeueue(parentQueue);
|
healthHelper.setParentQueue(parentQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HealthDevice::hasHealthChanged() {
|
bool HealthDevice::hasHealthChanged() {
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
#ifndef EVENTOBJECT_EVENT_H_
|
#ifndef FRAMEWORK_EVENTS_EVENT_H_
|
||||||
#define EVENTOBJECT_EVENT_H_
|
#define FRAMEWORK_EVENTS_EVENT_H_
|
||||||
|
|
||||||
#include <stdint.h>
|
#include <cstdint>
|
||||||
#include <framework/events/fwSubsystemIdRanges.h>
|
#include <framework/events/fwSubsystemIdRanges.h>
|
||||||
//could be move to more suitable location
|
//could be move to more suitable location
|
||||||
#include <config/tmtc/subsystemIdRanges.h>
|
#include <subsystemIdRanges.h>
|
||||||
|
|
||||||
typedef uint16_t EventId_t;
|
typedef uint16_t EventId_t;
|
||||||
typedef uint8_t EventSeverity_t;
|
typedef uint8_t EventSeverity_t;
|
||||||
@ -21,6 +21,7 @@ EventSeverity_t getSeverity(Event event);
|
|||||||
Event makeEvent(EventId_t eventId, EventSeverity_t eventSeverity);
|
Event makeEvent(EventId_t eventId, EventSeverity_t eventSeverity);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
namespace SEVERITY {
|
namespace SEVERITY {
|
||||||
static const EventSeverity_t INFO = 1;
|
static const EventSeverity_t INFO = 1;
|
||||||
static const EventSeverity_t LOW = 2;
|
static const EventSeverity_t LOW = 2;
|
||||||
@ -41,4 +42,4 @@ namespace SEVERITY {
|
|||||||
// static const EventSeverity_t HIGH = 4;
|
// static const EventSeverity_t HIGH = 4;
|
||||||
//};
|
//};
|
||||||
|
|
||||||
#endif /* EVENTOBJECT_EVENT_H_ */
|
#endif /* FRAMEWORK_EVENTS_EVENT_H_ */
|
||||||
|
@ -104,9 +104,9 @@ MessageQueueId_t FailureIsolationBase::getEventReceptionQueue() {
|
|||||||
ReturnValue_t FailureIsolationBase::sendConfirmationRequest(EventMessage* event,
|
ReturnValue_t FailureIsolationBase::sendConfirmationRequest(EventMessage* event,
|
||||||
MessageQueueId_t destination) {
|
MessageQueueId_t destination) {
|
||||||
event->setMessageId(EventMessage::CONFIRMATION_REQUEST);
|
event->setMessageId(EventMessage::CONFIRMATION_REQUEST);
|
||||||
if (destination != 0) {
|
if (destination != MessageQueueIF::NO_QUEUE) {
|
||||||
return eventQueue->sendMessage(destination, event);
|
return eventQueue->sendMessage(destination, event);
|
||||||
} else if (faultTreeParent != 0) {
|
} else if (faultTreeParent != objects::NO_OBJECT) {
|
||||||
return eventQueue->sendToDefault(event);
|
return eventQueue->sendToDefault(event);
|
||||||
}
|
}
|
||||||
return RETURN_FAILED;
|
return RETURN_FAILED;
|
||||||
|
@ -45,7 +45,7 @@ protected:
|
|||||||
virtual ReturnValue_t confirmFault(EventMessage* event);
|
virtual ReturnValue_t confirmFault(EventMessage* event);
|
||||||
virtual void decrementFaultCounters() = 0;
|
virtual void decrementFaultCounters() = 0;
|
||||||
ReturnValue_t sendConfirmationRequest(EventMessage* event,
|
ReturnValue_t sendConfirmationRequest(EventMessage* event,
|
||||||
MessageQueueId_t destination = 0);
|
MessageQueueId_t destination = MessageQueueIF::NO_QUEUE);
|
||||||
void throwFdirEvent(Event event, uint32_t parameter1 = 0,
|
void throwFdirEvent(Event event, uint32_t parameter1 = 0,
|
||||||
uint32_t parameter2 = 0);
|
uint32_t parameter2 = 0);
|
||||||
private:
|
private:
|
||||||
|
@ -28,21 +28,30 @@ HasHealthIF::HealthState HealthHelper::getHealth() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HealthHelper::initialize(MessageQueueId_t parentQueue) {
|
ReturnValue_t HealthHelper::initialize(MessageQueueId_t parentQueue) {
|
||||||
setParentQeueue(parentQueue);
|
setParentQueue(parentQueue);
|
||||||
return initialize();
|
return initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
void HealthHelper::setParentQeueue(MessageQueueId_t parentQueue) {
|
void HealthHelper::setParentQueue(MessageQueueId_t parentQueue) {
|
||||||
this->parentQueue = parentQueue;
|
this->parentQueue = parentQueue;
|
||||||
}
|
}
|
||||||
|
|
||||||
ReturnValue_t HealthHelper::initialize() {
|
ReturnValue_t HealthHelper::initialize() {
|
||||||
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
healthTable = objectManager->get<HealthTableIF>(objects::HEALTH_TABLE);
|
||||||
eventSender = objectManager->get<EventReportingProxyIF>(objectId);
|
eventSender = objectManager->get<EventReportingProxyIF>(objectId);
|
||||||
// TODO: Better returnvalues
|
|
||||||
if ((healthTable == NULL) || eventSender == NULL) {
|
if (healthTable == nullptr) {
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
sif::error << "HealthHelper::initialize: Health table object needs"
|
||||||
|
"to be created in factory." << std::endl;
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(eventSender == nullptr) {
|
||||||
|
sif::error << "HealthHelper::initialize: Owner has to implement "
|
||||||
|
"ReportingProxyIF." << std::endl;
|
||||||
|
return ObjectManagerIF::CHILD_INIT_FAILED;
|
||||||
|
}
|
||||||
|
|
||||||
ReturnValue_t result = healthTable->registerObject(objectId,
|
ReturnValue_t result = healthTable->registerObject(objectId,
|
||||||
HasHealthIF::HEALTHY);
|
HasHealthIF::HEALTHY);
|
||||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
@ -79,7 +79,7 @@ public:
|
|||||||
/**
|
/**
|
||||||
* @param parentQueue the Queue id of the parent object. Set to 0 if no parent present
|
* @param parentQueue the Queue id of the parent object. Set to 0 if no parent present
|
||||||
*/
|
*/
|
||||||
void setParentQeueue(MessageQueueId_t parentQueue);
|
void setParentQueue(MessageQueueId_t parentQueue);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -125,19 +125,18 @@ void FixedTimeslotTask::checkMissedDeadline(const TickType_t xLastWakeTime,
|
|||||||
* it. */
|
* it. */
|
||||||
TickType_t currentTickCount = xTaskGetTickCount();
|
TickType_t currentTickCount = xTaskGetTickCount();
|
||||||
TickType_t timeToWake = xLastWakeTime + interval;
|
TickType_t timeToWake = xLastWakeTime + interval;
|
||||||
// Tick count has overflown
|
// Time to wake has not overflown.
|
||||||
if(currentTickCount < xLastWakeTime) {
|
if(timeToWake > xLastWakeTime) {
|
||||||
// Time to wake has overflown as well. If the tick count
|
/* If the current time has overflown exclusively or the current
|
||||||
// is larger than the time to wake, a deadline was missed.
|
* tick count is simply larger than the time to wake, a deadline was
|
||||||
if(timeToWake < xLastWakeTime and
|
* missed */
|
||||||
currentTickCount > timeToWake) {
|
if((currentTickCount < xLastWakeTime) or (currentTickCount > timeToWake)) {
|
||||||
handleMissedDeadline();
|
handleMissedDeadline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No tick count overflow. If the timeToWake has not overflown
|
/* Time to wake has overflown. A deadline was missed if the current time
|
||||||
// and the current tick count is larger than the time to wake,
|
* is larger than the time to wake */
|
||||||
// a deadline was missed.
|
else if((timeToWake < xLastWakeTime) and (currentTickCount > timeToWake)) {
|
||||||
else if(timeToWake > xLastWakeTime and currentTickCount > timeToWake) {
|
|
||||||
handleMissedDeadline();
|
handleMissedDeadline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -157,6 +156,6 @@ ReturnValue_t FixedTimeslotTask::sleepFor(uint32_t ms) {
|
|||||||
return HasReturnvaluesIF::RETURN_OK;
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskHandle_t FixedTimeslotTask::getTaskHandle() const {
|
TaskHandle_t FixedTimeslotTask::getTaskHandle() {
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#ifndef FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
#define FRAMEWORK_OSAL_FREERTOS_FIXEDTIMESLOTTASK_H_
|
||||||
|
|
||||||
|
#include <framework/osal/FreeRTOS/FreeRTOSTaskIF.h>
|
||||||
#include <framework/tasks/FixedSlotSequence.h>
|
#include <framework/tasks/FixedSlotSequence.h>
|
||||||
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
#include <framework/tasks/FixedTimeslotTaskIF.h>
|
||||||
#include <framework/tasks/Typedef.h>
|
#include <framework/tasks/Typedef.h>
|
||||||
@ -8,7 +9,7 @@
|
|||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
|
|
||||||
class FixedTimeslotTask: public FixedTimeslotTaskIF {
|
class FixedTimeslotTask: public FixedTimeslotTaskIF, public FreeRTOSTaskIF {
|
||||||
public:
|
public:
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -57,7 +58,7 @@ public:
|
|||||||
|
|
||||||
ReturnValue_t sleepFor(uint32_t ms) override;
|
ReturnValue_t sleepFor(uint32_t ms) override;
|
||||||
|
|
||||||
TaskHandle_t getTaskHandle() const;
|
TaskHandle_t getTaskHandle() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
|
13
osal/FreeRTOS/FreeRTOSTaskIF.h
Normal file
13
osal/FreeRTOS/FreeRTOSTaskIF.h
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
#ifndef FRAMEWORK_OSAL_FREERTOS_FREERTOSTASKIF_H_
|
||||||
|
#define FRAMEWORK_OSAL_FREERTOS_FREERTOSTASKIF_H_
|
||||||
|
|
||||||
|
#include <freertos/FreeRTOS.h>
|
||||||
|
#include <freertos/task.h>
|
||||||
|
|
||||||
|
class FreeRTOSTaskIF {
|
||||||
|
public:
|
||||||
|
virtual~ FreeRTOSTaskIF() {}
|
||||||
|
virtual TaskHandle_t getTaskHandle() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* FRAMEWORK_OSAL_FREERTOS_FREERTOSTASKIF_H_ */
|
@ -8,7 +8,7 @@ const uint32_t MutexIF::BLOCKING = portMAX_DELAY;
|
|||||||
Mutex::Mutex() {
|
Mutex::Mutex() {
|
||||||
handle = xSemaphoreCreateMutex();
|
handle = xSemaphoreCreateMutex();
|
||||||
if(handle == nullptr) {
|
if(handle == nullptr) {
|
||||||
sif::error << "Mutex: Creation failure" << std::endl;
|
sif::error << "Mutex::Mutex(FreeRTOS): Creation failure" << std::endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@ public:
|
|||||||
~Mutex();
|
~Mutex();
|
||||||
ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::BLOCKING) override;
|
ReturnValue_t lockMutex(uint32_t timeoutMs = MutexIF::BLOCKING) override;
|
||||||
ReturnValue_t unlockMutex() override;
|
ReturnValue_t unlockMutex() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
SemaphoreHandle_t handle;
|
SemaphoreHandle_t handle;
|
||||||
};
|
};
|
||||||
|
@ -109,24 +109,23 @@ void PeriodicTask::checkMissedDeadline(const TickType_t xLastWakeTime,
|
|||||||
* it. */
|
* it. */
|
||||||
TickType_t currentTickCount = xTaskGetTickCount();
|
TickType_t currentTickCount = xTaskGetTickCount();
|
||||||
TickType_t timeToWake = xLastWakeTime + interval;
|
TickType_t timeToWake = xLastWakeTime + interval;
|
||||||
// Tick count has overflown
|
// Time to wake has not overflown.
|
||||||
if(currentTickCount < xLastWakeTime) {
|
if(timeToWake > xLastWakeTime) {
|
||||||
// Time to wake has overflown as well. If the tick count
|
/* If the current time has overflown exclusively or the current
|
||||||
// is larger than the time to wake, a deadline was missed.
|
* tick count is simply larger than the time to wake, a deadline was
|
||||||
if(timeToWake < xLastWakeTime and
|
* missed */
|
||||||
currentTickCount > timeToWake) {
|
if((currentTickCount < xLastWakeTime) or (currentTickCount > timeToWake)) {
|
||||||
handleMissedDeadline();
|
handleMissedDeadline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// No tick count overflow. If the timeToWake has not overflown
|
/* Time to wake has overflown. A deadline was missed if the current time
|
||||||
// and the current tick count is larger than the time to wake,
|
* is larger than the time to wake */
|
||||||
// a deadline was missed.
|
else if((timeToWake < xLastWakeTime) and (currentTickCount > timeToWake)) {
|
||||||
else if(timeToWake > xLastWakeTime and currentTickCount > timeToWake) {
|
|
||||||
handleMissedDeadline();
|
handleMissedDeadline();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TaskHandle_t PeriodicTask::getTaskHandle() const {
|
TaskHandle_t PeriodicTask::getTaskHandle() {
|
||||||
return handle;
|
return handle;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
#ifndef FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
#ifndef FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
||||||
#define FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
#define FRAMEWORK_OSAL_FREERTOS_PERIODICTASK_H_
|
||||||
|
|
||||||
|
#include <framework/osal/FreeRTOS/FreeRTOSTaskIF.h>
|
||||||
#include <framework/objectmanager/ObjectManagerIF.h>
|
#include <framework/objectmanager/ObjectManagerIF.h>
|
||||||
#include <framework/tasks/PeriodicTaskIF.h>
|
#include <framework/tasks/PeriodicTaskIF.h>
|
||||||
#include <framework/tasks/Typedef.h>
|
#include <framework/tasks/Typedef.h>
|
||||||
|
|
||||||
|
|
||||||
#include <freertos/FreeRTOS.h>
|
#include <freertos/FreeRTOS.h>
|
||||||
#include <freertos/task.h>
|
#include <freertos/task.h>
|
||||||
|
|
||||||
@ -17,7 +19,7 @@ class ExecutableObjectIF;
|
|||||||
* periodic activities of multiple objects.
|
* periodic activities of multiple objects.
|
||||||
* @ingroup task_handling
|
* @ingroup task_handling
|
||||||
*/
|
*/
|
||||||
class PeriodicTask: public PeriodicTaskIF {
|
class PeriodicTask: public PeriodicTaskIF, public FreeRTOSTaskIF {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
* Keep in Mind that you need to call before this vTaskStartScheduler()!
|
||||||
@ -70,7 +72,7 @@ public:
|
|||||||
|
|
||||||
ReturnValue_t sleepFor(uint32_t ms) override;
|
ReturnValue_t sleepFor(uint32_t ms) override;
|
||||||
|
|
||||||
TaskHandle_t getTaskHandle() const;
|
TaskHandle_t getTaskHandle() override;
|
||||||
protected:
|
protected:
|
||||||
bool started;
|
bool started;
|
||||||
TaskHandle_t handle;
|
TaskHandle_t handle;
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
#include <framework/osal/FreeRTOS/TaskManagement.h>
|
||||||
|
|
||||||
void TaskManagement::requestContextSwitchFromTask() {
|
void TaskManagement::vRequestContextSwitchFromTask() {
|
||||||
vTaskDelay(0);
|
vTaskDelay(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8,9 +8,9 @@ void TaskManagement::requestContextSwitch(
|
|||||||
CallContext callContext = CallContext::TASK) {
|
CallContext callContext = CallContext::TASK) {
|
||||||
if(callContext == CallContext::ISR) {
|
if(callContext == CallContext::ISR) {
|
||||||
// This function depends on the partmacro.h definition for the specific device
|
// This function depends on the partmacro.h definition for the specific device
|
||||||
requestContextSwitchFromISR();
|
vRequestContextSwitchFromISR();
|
||||||
} else {
|
} else {
|
||||||
requestContextSwitchFromTask();
|
vRequestContextSwitchFromTask();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -18,7 +18,7 @@ TaskHandle_t TaskManagement::getCurrentTaskHandle() {
|
|||||||
return xTaskGetCurrentTaskHandle();
|
return xTaskGetCurrentTaskHandle();
|
||||||
}
|
}
|
||||||
|
|
||||||
configSTACK_DEPTH_TYPE TaskManagement::getTaskStackHighWatermark(
|
size_t TaskManagement::getTaskStackHighWatermark(
|
||||||
TaskHandle_t task) {
|
TaskHandle_t task) {
|
||||||
return uxTaskGetStackHighWaterMark(task);
|
return uxTaskGetStackHighWaterMark(task) * sizeof(StackType_t);
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ extern "C" {
|
|||||||
* Architecture dependant portmacro.h function call.
|
* Architecture dependant portmacro.h function call.
|
||||||
* Should be implemented in bsp.
|
* Should be implemented in bsp.
|
||||||
*/
|
*/
|
||||||
extern "C" void requestContextSwitchFromISR();
|
extern void vRequestContextSwitchFromISR();
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
* Used by functions to tell if they are being called from
|
* Used by functions to tell if they are being called from
|
||||||
@ -41,7 +41,7 @@ public:
|
|||||||
* If task preemption in FreeRTOS is disabled, a context switch
|
* If task preemption in FreeRTOS is disabled, a context switch
|
||||||
* can be requested manually by calling this function.
|
* can be requested manually by calling this function.
|
||||||
*/
|
*/
|
||||||
static void requestContextSwitchFromTask(void);
|
static void vRequestContextSwitchFromTask(void);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return The current task handle
|
* @return The current task handle
|
||||||
@ -57,7 +57,7 @@ public:
|
|||||||
* @return Smallest value of stack remaining since the task was started in
|
* @return Smallest value of stack remaining since the task was started in
|
||||||
* words.
|
* words.
|
||||||
*/
|
*/
|
||||||
static configSTACK_DEPTH_TYPE getTaskStackHighWatermark(
|
static size_t getTaskStackHighWatermark(
|
||||||
TaskHandle_t task = nullptr);
|
TaskHandle_t task = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -15,7 +15,15 @@ public:
|
|||||||
static const ReturnValue_t RETURN_FAILED = 1;
|
static const ReturnValue_t RETURN_FAILED = 1;
|
||||||
virtual ~HasReturnvaluesIF() {}
|
virtual ~HasReturnvaluesIF() {}
|
||||||
|
|
||||||
static ReturnValue_t makeReturnCode(uint8_t interfaceId, uint8_t number) {
|
/**
|
||||||
|
* It is discouraged to use the input parameters 0,0 and 0,1 as this
|
||||||
|
* will generate the RETURN_OK and RETURN_FAILED returnvalues.
|
||||||
|
* @param interfaceId
|
||||||
|
* @param number
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
static constexpr ReturnValue_t makeReturnCode(uint8_t interfaceId,
|
||||||
|
uint8_t number) {
|
||||||
return (interfaceId << 8) + number;
|
return (interfaceId << 8) + number;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -78,9 +78,9 @@ int ServiceInterfaceBuffer::sync(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
size_t preambleSize = 0;
|
size_t preambleSize = 0;
|
||||||
auto preamble = getPreamble(&preambleSize);
|
std::string* preamble = getPreamble(&preambleSize);
|
||||||
// Write logMessage and time
|
// Write logMessage and time
|
||||||
this->putChars(preamble.data(), preamble.data() + preambleSize);
|
this->putChars(preamble->data(), preamble->data() + preambleSize);
|
||||||
// Handle output
|
// Handle output
|
||||||
this->putChars(pbase(), pptr());
|
this->putChars(pbase(), pptr());
|
||||||
// This tells that buffer is empty again
|
// This tells that buffer is empty again
|
||||||
@ -92,7 +92,7 @@ bool ServiceInterfaceBuffer::isBuffered() const {
|
|||||||
return buffered;
|
return buffered;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
std::string* ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
||||||
Clock::TimeOfDay_t loggerTime;
|
Clock::TimeOfDay_t loggerTime;
|
||||||
Clock::getDateAndTime(&loggerTime);
|
Clock::getDateAndTime(&loggerTime);
|
||||||
size_t currentSize = 0;
|
size_t currentSize = 0;
|
||||||
@ -110,18 +110,18 @@ std::string ServiceInterfaceBuffer::getPreamble(size_t * preambleSize) {
|
|||||||
loggerTime.usecond /1000);
|
loggerTime.usecond /1000);
|
||||||
if(charCount < 0) {
|
if(charCount < 0) {
|
||||||
printf("ServiceInterfaceBuffer: Failure parsing preamble\r\n");
|
printf("ServiceInterfaceBuffer: Failure parsing preamble\r\n");
|
||||||
return "";
|
return &preamble;
|
||||||
}
|
}
|
||||||
if(charCount > MAX_PREAMBLE_SIZE) {
|
if(charCount > MAX_PREAMBLE_SIZE) {
|
||||||
printf("ServiceInterfaceBuffer: Char count too large for maximum "
|
printf("ServiceInterfaceBuffer: Char count too large for maximum "
|
||||||
"preamble size");
|
"preamble size");
|
||||||
return "";
|
return &preamble;
|
||||||
}
|
}
|
||||||
currentSize += charCount;
|
currentSize += charCount;
|
||||||
if(preambleSize != nullptr) {
|
if(preambleSize != nullptr) {
|
||||||
*preambleSize = currentSize;
|
*preambleSize = currentSize;
|
||||||
}
|
}
|
||||||
return preamble;
|
return &preamble;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ private:
|
|||||||
//! In this function, the characters are parsed.
|
//! In this function, the characters are parsed.
|
||||||
void putChars(char const* begin, char const* end);
|
void putChars(char const* begin, char const* end);
|
||||||
|
|
||||||
std::string getPreamble(size_t * preambleSize = nullptr);
|
std::string* getPreamble(size_t * preambleSize = nullptr);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -9,7 +9,7 @@ void ServiceInterfaceStream::setActive( bool myActive) {
|
|||||||
this->streambuf.isActive = myActive;
|
this->streambuf.isActive = myActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ServiceInterfaceStream::getPreamble() {
|
std::string* ServiceInterfaceStream::getPreamble() {
|
||||||
return streambuf.getPreamble();
|
return streambuf.getPreamble();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@ public:
|
|||||||
* the unbuffered mode.
|
* the unbuffered mode.
|
||||||
* @return Preamle consisting of log message and timestamp.
|
* @return Preamle consisting of log message and timestamp.
|
||||||
*/
|
*/
|
||||||
std::string getPreamble();
|
std::string* getPreamble();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This prints an error with a preamble. Useful if using the unbuffered
|
* This prints an error with a preamble. Useful if using the unbuffered
|
||||||
|
@ -205,9 +205,10 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
|
|||||||
uint8_t hour;
|
uint8_t hour;
|
||||||
uint8_t minute;
|
uint8_t minute;
|
||||||
float second;
|
float second;
|
||||||
//try Code A (yyyy-mm-dd)
|
//try Code A (yyyy-mm-dd)
|
||||||
int count = sscanf((char *) from, "%4hi-%2hhi-%2hiT%2hhi:%2hhi:%fZ", &year,
|
int count = sscanf((char *) from, "%4" SCNu16 "-%2" SCNu8 "-%2" SCNu16
|
||||||
&month, &day, &hour, &minute, &second);
|
"T%2" SCNu8 ":%2" SCNu8 ":%fZ", &year, &month, &day,
|
||||||
|
&hour, &minute, &second);
|
||||||
if (count == 6) {
|
if (count == 6) {
|
||||||
to->year = year;
|
to->year = year;
|
||||||
to->month = month;
|
to->month = month;
|
||||||
@ -219,9 +220,9 @@ ReturnValue_t CCSDSTime::convertFromASCII(Clock::TimeOfDay_t* to, const uint8_t*
|
|||||||
return RETURN_OK;
|
return RETURN_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
//try Code B (yyyy-ddd)
|
//try Code B (yyyy-ddd)
|
||||||
count = sscanf((char *) from, "%4hi-%3hiT%2hhi:%2hhi:%fZ", &year, &day,
|
count = sscanf((char *) from, "%4" SCNu16 "-%3" SCNu16 "T%2" SCNu8
|
||||||
&hour, &minute, &second);
|
":%2" SCNu8 ":%fZ", &year, &day, &hour, &minute, &second);
|
||||||
if (count == 5) {
|
if (count == 5) {
|
||||||
uint8_t tempDay;
|
uint8_t tempDay;
|
||||||
ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, &month,
|
ReturnValue_t result = CCSDSTime::convertDaysOfYear(day, year, &month,
|
||||||
|
Loading…
Reference in New Issue
Block a user