Compare commits
17 Commits
Author | SHA1 | Date | |
---|---|---|---|
db07e92b01 | |||
f094558f11 | |||
9debb7e3b5 | |||
5c2b4cf783 | |||
ff19b0d4b9 | |||
5009d12780 | |||
dd74ebecba | |||
bdec426196 | |||
86f2004569 | |||
6f4ec5eafd | |||
7652b33e11 | |||
98fb9b8e36 | |||
217bdb5123 | |||
e1b069808e | |||
1a045d7a84 | |||
28a3daabac | |||
a468d96f14 |
@ -446,6 +446,7 @@ void DeviceHandlerBase::callChildStatemachine() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) {
|
void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) {
|
||||||
|
sif::debug<<"DeviceHandlerBase::setTransition"<<std::endl;
|
||||||
triggerEvent(CHANGING_MODE, modeTo, submodeTo);
|
triggerEvent(CHANGING_MODE, modeTo, submodeTo);
|
||||||
childTransitionDelay = getTransitionDelayMs(mode, modeTo);
|
childTransitionDelay = getTransitionDelayMs(mode, modeTo);
|
||||||
transitionSourceMode = mode;
|
transitionSourceMode = mode;
|
||||||
@ -542,13 +543,15 @@ void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
|
|||||||
|
|
||||||
void DeviceHandlerBase::doSendWrite() {
|
void DeviceHandlerBase::doSendWrite() {
|
||||||
if (cookieInfo.state == COOKIE_WRITE_READY) {
|
if (cookieInfo.state == COOKIE_WRITE_READY) {
|
||||||
|
sif::debug<<" DeviceHandlerBase::doSendWrite: Calling sendMessage"<<std::endl;
|
||||||
ReturnValue_t result = communicationInterface->sendMessage(comCookie,
|
ReturnValue_t result = communicationInterface->sendMessage(comCookie,
|
||||||
rawPacket, rawPacketLen);
|
rawPacket, rawPacketLen);
|
||||||
|
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
cookieInfo.state = COOKIE_WRITE_SENT;
|
cookieInfo.state = COOKIE_WRITE_SENT;
|
||||||
|
sif::debug<<" DeviceHandlerBase::doSendWrite: Calling sendMessage succeeded"<<std::endl;
|
||||||
} else {
|
} else {
|
||||||
|
sif::debug<<" DeviceHandlerBase::doSendWrite: Calling sendMessage failed"<<std::endl;
|
||||||
//always generate a failure event, so that FDIR knows what's up
|
//always generate a failure event, so that FDIR knows what's up
|
||||||
triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result,
|
triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result,
|
||||||
cookieInfo.pendingCommand->first);
|
cookieInfo.pendingCommand->first);
|
||||||
@ -561,9 +564,11 @@ void DeviceHandlerBase::doSendWrite() {
|
|||||||
|
|
||||||
void DeviceHandlerBase::doGetWrite() {
|
void DeviceHandlerBase::doGetWrite() {
|
||||||
if (cookieInfo.state != COOKIE_WRITE_SENT) {
|
if (cookieInfo.state != COOKIE_WRITE_SENT) {
|
||||||
|
// sif::debug<<" DeviceHandlerBase::doGetWrite: COOKIE_WRITE_SENT not set"<<std::endl;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
cookieInfo.state = COOKIE_UNUSED;
|
cookieInfo.state = COOKIE_UNUSED;
|
||||||
|
sif::debug<<" DeviceHandlerBase::doGetWrite: Calling getSendSuccess"<<std::endl;
|
||||||
ReturnValue_t result = communicationInterface->getSendSuccess(comCookie);
|
ReturnValue_t result = communicationInterface->getSendSuccess(comCookie);
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
if (wiretappingMode == RAW) {
|
if (wiretappingMode == RAW) {
|
||||||
@ -587,6 +592,9 @@ void DeviceHandlerBase::doGetWrite() {
|
|||||||
void DeviceHandlerBase::doSendRead() {
|
void DeviceHandlerBase::doSendRead() {
|
||||||
ReturnValue_t result;
|
ReturnValue_t result;
|
||||||
|
|
||||||
|
// sif::debug<<" DeviceHandlerBase::doSendRead: Calling requestReceiveMessage"<<std::endl;
|
||||||
|
|
||||||
|
|
||||||
size_t requestLen = 0;
|
size_t requestLen = 0;
|
||||||
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
|
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
|
||||||
DeviceReplyIter iter = deviceReplyMap.find(
|
DeviceReplyIter iter = deviceReplyMap.find(
|
||||||
@ -597,7 +605,6 @@ void DeviceHandlerBase::doSendRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
result = communicationInterface->requestReceiveMessage(comCookie, requestLen);
|
result = communicationInterface->requestReceiveMessage(comCookie, requestLen);
|
||||||
|
|
||||||
if (result == RETURN_OK) {
|
if (result == RETURN_OK) {
|
||||||
cookieInfo.state = COOKIE_READ_SENT;
|
cookieInfo.state = COOKIE_READ_SENT;
|
||||||
} else {
|
} else {
|
||||||
@ -620,10 +627,11 @@ void DeviceHandlerBase::doGetRead() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cookieInfo.state = COOKIE_UNUSED;
|
cookieInfo.state = COOKIE_UNUSED;
|
||||||
|
// sif::debug<<" DeviceHandlerBase::doGetRead: Calling readReceivedMessage"<<std::endl;
|
||||||
|
|
||||||
|
|
||||||
ReturnValue_t result = communicationInterface->readReceivedMessage(
|
ReturnValue_t result = communicationInterface->readReceivedMessage(
|
||||||
comCookie, &receivedData, &receivedDataLen);
|
comCookie, &receivedData, &receivedDataLen);
|
||||||
|
|
||||||
if (result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result);
|
triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result);
|
||||||
//I think we can allow to ignore one missedReply.
|
//I think we can allow to ignore one missedReply.
|
||||||
@ -640,6 +648,7 @@ void DeviceHandlerBase::doGetRead() {
|
|||||||
|
|
||||||
if (mode == MODE_RAW and defaultRawReceiver != MessageQueueIF::NO_QUEUE) {
|
if (mode == MODE_RAW and defaultRawReceiver != MessageQueueIF::NO_QUEUE) {
|
||||||
replyRawReplyIfnotWiretapped(receivedData, receivedDataLen);
|
replyRawReplyIfnotWiretapped(receivedData, receivedDataLen);
|
||||||
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
parseReply(receivedData, receivedDataLen);
|
parseReply(receivedData, receivedDataLen);
|
||||||
@ -866,6 +875,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(
|
|||||||
|
|
||||||
void DeviceHandlerBase::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
void DeviceHandlerBase::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
|
||||||
setMode(getBaseMode(mode));
|
setMode(getBaseMode(mode));
|
||||||
|
sif::debug<<"DeviceHandlerBase::doTransition Mode: "<<mode<<" reached"<<std::endl;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom,
|
uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom,
|
||||||
@ -946,6 +956,7 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode,
|
|||||||
|
|
||||||
void DeviceHandlerBase::startTransition(Mode_t commandedMode,
|
void DeviceHandlerBase::startTransition(Mode_t commandedMode,
|
||||||
Submode_t commandedSubmode) {
|
Submode_t commandedSubmode) {
|
||||||
|
sif::debug<<" DeviceHandlerBase::startTransition"<<std::endl;
|
||||||
switch (commandedMode) {
|
switch (commandedMode) {
|
||||||
case MODE_ON:
|
case MODE_ON:
|
||||||
if (mode == MODE_OFF) {
|
if (mode == MODE_OFF) {
|
||||||
@ -1248,9 +1259,9 @@ void DeviceHandlerBase::buildInternalCommand(void) {
|
|||||||
if (iter == deviceCommandMap.end()) {
|
if (iter == deviceCommandMap.end()) {
|
||||||
result = COMMAND_NOT_SUPPORTED;
|
result = COMMAND_NOT_SUPPORTED;
|
||||||
} else if (iter->second.isExecuting) {
|
} else if (iter->second.isExecuting) {
|
||||||
sif::debug << std::hex << getObjectId()
|
// sif::debug << std::hex << getObjectId()
|
||||||
<< ": DHB::buildInternalCommand: Command "
|
// << ": DHB::buildInternalCommand: Command "
|
||||||
<< deviceCommandId << " isExecuting" << std::endl; //so we can track misconfigurations
|
// << deviceCommandId << " isExecuting" << std::endl; //so we can track misconfigurations
|
||||||
return; //this is an internal command, no need to report a failure here, missed reply will track if a reply is too late, otherwise, it's ok
|
return; //this is an internal command, no need to report a failure here, missed reply will track if a reply is too late, otherwise, it's ok
|
||||||
} else {
|
} else {
|
||||||
iter->second.sendReplyTo = NO_COMMANDER;
|
iter->second.sendReplyTo = NO_COMMANDER;
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include "fwSubsystemIdRanges.h"
|
#include "fwSubsystemIdRanges.h"
|
||||||
//could be move to more suitable location
|
//could be move to more suitable location
|
||||||
#include <events/subsystemIdRanges.h>
|
#include <config/tmtc/subsystemIdRanges.h>
|
||||||
|
|
||||||
typedef uint16_t EventId_t;
|
typedef uint16_t EventId_t;
|
||||||
typedef uint8_t EventSeverity_t;
|
typedef uint8_t EventSeverity_t;
|
||||||
|
@ -14,6 +14,7 @@ enum FW_MESSAGE_TYPE {
|
|||||||
MONITORING,
|
MONITORING,
|
||||||
MEMORY,
|
MEMORY,
|
||||||
PARAMETER,
|
PARAMETER,
|
||||||
|
FILE_SYSTEM_MESSAGE,
|
||||||
FW_MESSAGES_COUNT
|
FW_MESSAGES_COUNT
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
#include "../serviceinterface/ServiceInterfaceStream.h"
|
#include "../serviceinterface/ServiceInterfaceStream.h"
|
||||||
#include <iomanip>
|
#include <iomanip>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
|
#include <iomanip>
|
||||||
|
|
||||||
ObjectManager::ObjectManager( void (*setProducer)() ):
|
ObjectManager::ObjectManager( void (*setProducer)() ):
|
||||||
produceObjects(setProducer) {
|
produceObjects(setProducer) {
|
||||||
|
@ -4,7 +4,7 @@
|
|||||||
#include <limits.h>
|
#include <limits.h>
|
||||||
|
|
||||||
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
|
uint32_t FixedTimeslotTask::deadlineMissedCount = 0;
|
||||||
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = PTHREAD_STACK_MIN;
|
const size_t PeriodicTaskIF::MINIMUM_STACK_SIZE = 98304;//PTHREAD_STACK_MIN;
|
||||||
|
|
||||||
FixedTimeslotTask::FixedTimeslotTask(const char* name_, int priority_,
|
FixedTimeslotTask::FixedTimeslotTask(const char* name_, int priority_,
|
||||||
size_t stackSize_, uint32_t periodMs_):
|
size_t stackSize_, uint32_t periodMs_):
|
||||||
|
@ -178,7 +178,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
|
|||||||
} else {
|
} else {
|
||||||
//No message was received. Keep lastPartner anyway, I might send
|
//No message was received. Keep lastPartner anyway, I might send
|
||||||
//something later. But still, delete packet content.
|
//something later. But still, delete packet content.
|
||||||
memset(message->getData(), 0, message->getMaximumMessageSize());
|
memset(message->getBuffer(), 0, message->getMaximumMessageSize());
|
||||||
switch(errno){
|
switch(errno){
|
||||||
case EAGAIN:
|
case EAGAIN:
|
||||||
//O_NONBLOCK or MQ_NONBLOCK was set and there are no messages
|
//O_NONBLOCK or MQ_NONBLOCK was set and there are no messages
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#define FSFW_RETURNVALUES_HASRETURNVALUESIF_H_
|
#define FSFW_RETURNVALUES_HASRETURNVALUESIF_H_
|
||||||
|
|
||||||
#include "FwClassIds.h"
|
#include "FwClassIds.h"
|
||||||
#include <returnvalues/classIds.h>
|
#include <config/returnvalues/classIds.h>
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
#define MAKE_RETURN_CODE( number ) ((INTERFACE_ID << 8) + (number))
|
#define MAKE_RETURN_CODE( number ) ((INTERFACE_ID << 8) + (number))
|
||||||
|
149
serialize/SerialBufferAdapter2.h
Executable file
149
serialize/SerialBufferAdapter2.h
Executable file
@ -0,0 +1,149 @@
|
|||||||
|
#ifndef SERIALBUFFERADAPTER2_H_
|
||||||
|
#define SERIALBUFFERADAPTER2_H_
|
||||||
|
|
||||||
|
#include <framework/serialize/SerializeIF.h>
|
||||||
|
#include <framework/serialize/SerializeAdapter.h>
|
||||||
|
#include <framework/serviceinterface/ServiceInterfaceStream.h>
|
||||||
|
|
||||||
|
#include <cstring>
|
||||||
|
extern std::ostream error;
|
||||||
|
extern std::ostream debug;
|
||||||
|
/**
|
||||||
|
* This adapter provides an interface for SerializeIF to serialize or deserialize
|
||||||
|
* buffers with no length header but a known size.
|
||||||
|
*
|
||||||
|
* Additionally, the buffer length can be serialized too and will be put in front of the serialized buffer.
|
||||||
|
*
|
||||||
|
* Can be used with SerialLinkedListAdapter by declaring a SerializeElement with
|
||||||
|
* SerialElement<SerialBufferAdapter<bufferLengthType(will be uint8_t mostly)>> serialBufferElement.
|
||||||
|
* Right now, the SerialBufferAdapter must always be initialized with the buffer and size !
|
||||||
|
*
|
||||||
|
* \ingroup serialize
|
||||||
|
*/
|
||||||
|
template<typename BUFFER_TYPE = uint8_t, typename count_t = uint8_t>
|
||||||
|
class SerialBufferAdapter2: public SerializeIF {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor for constant uint8_t buffer. Length field can be serialized optionally.
|
||||||
|
* Type of length can be supplied as template type.
|
||||||
|
* @param buffer
|
||||||
|
* @param bufferLength
|
||||||
|
* @param serializeLength
|
||||||
|
*/
|
||||||
|
SerialBufferAdapter2(void * buffer_, count_t bufferLength_, bool serializeLength_ = false):
|
||||||
|
bufferLength(bufferLength_), serializeLength(serializeLength_) {
|
||||||
|
determineLengthInBytes(sizeof(BUFFER_TYPE));
|
||||||
|
buffer = reinterpret_cast<const uint8_t *>(buffer_);
|
||||||
|
constBuffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
SerialBufferAdapter2(const void * buffer_, count_t bufferLength_, bool serializeLength_ = false):
|
||||||
|
bufferLength(bufferLength_), serializeLength(serializeLength_) {
|
||||||
|
determineLengthInBytes(sizeof(BUFFER_TYPE));
|
||||||
|
constBuffer = reinterpret_cast<const uint8_t *>(buffer_);
|
||||||
|
buffer = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t serialize(uint8_t ** buffer, uint32_t* size,
|
||||||
|
const uint32_t max_size, bool bigEndian) const {
|
||||||
|
uint32_t serializedLength = bufferLength;
|
||||||
|
if (serializeLength) {
|
||||||
|
serializedLength += AutoSerializeAdapter::getSerializedSize(
|
||||||
|
&bufferLength);
|
||||||
|
}
|
||||||
|
if (*size + serializedLength > max_size) {
|
||||||
|
return BUFFER_TOO_SHORT;
|
||||||
|
} else {
|
||||||
|
if (serializeLength) {
|
||||||
|
AutoSerializeAdapter::serialize(&bufferLength, buffer, size,
|
||||||
|
max_size, bigEndian);
|
||||||
|
}
|
||||||
|
memcpy(*buffer, this->buffer, bufferLength);
|
||||||
|
*size += bufferLength;
|
||||||
|
(*buffer) += bufferLength;
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
uint32_t getSerializedSize() const {
|
||||||
|
if (serializeLength) {
|
||||||
|
return bufferLength + AutoSerializeAdapter::getSerializedSize(&bufferLength);
|
||||||
|
} else {
|
||||||
|
return bufferLength;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t deSerialize(const uint8_t** buffer,
|
||||||
|
int32_t* size, bool bigEndian) {
|
||||||
|
//TODO Ignores Endian flag!
|
||||||
|
if (buffer != NULL) {
|
||||||
|
if(serializeLength){
|
||||||
|
// Suggestion (would require removing rest of the block inside this if clause !):
|
||||||
|
//ReturnValue_t result = AutoSerializeAdapter::deSerialize(&bufferLength,buffer,size,bigEndian);
|
||||||
|
//if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
// return result;
|
||||||
|
//}
|
||||||
|
count_t serializedSize = AutoSerializeAdapter::getSerializedSize(
|
||||||
|
&bufferLength);
|
||||||
|
if((*size - bufferLength - serializedSize) >= 0){
|
||||||
|
*buffer += serializedSize;
|
||||||
|
*size -= serializedSize;
|
||||||
|
}else{
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//No Else If, go on with buffer
|
||||||
|
if (*size - bufferLength >= 0) {
|
||||||
|
*size -= bufferLength;
|
||||||
|
memcpy(this->buffer, *buffer, bufferLength);
|
||||||
|
(*buffer) += bufferLength;
|
||||||
|
return HasReturnvaluesIF::RETURN_OK;
|
||||||
|
} else {
|
||||||
|
return STREAM_TOO_SHORT;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
BUFFER_TYPE * getBuffer() {
|
||||||
|
return reinterpret_cast<BUFFER_TYPE *>(buffer);
|
||||||
|
}
|
||||||
|
|
||||||
|
void setBuffer(void * buffer_, count_t bufferLength_, bool serializeLength_ = false) {
|
||||||
|
buffer = buffer_;
|
||||||
|
bufferLength = bufferLength_;
|
||||||
|
serializeLength = serializeLength_;
|
||||||
|
determineLengthInBytes(sizeof(BUFFER_TYPE));
|
||||||
|
}
|
||||||
|
|
||||||
|
void setConstBuffer(const void * buffer_, count_t bufferLength_, bool serializeLength_ = false) {
|
||||||
|
constBuffer = buffer_;
|
||||||
|
bufferLength = bufferLength_;
|
||||||
|
serializeLength = serializeLength_;
|
||||||
|
determineLengthInBytes(sizeof(BUFFER_TYPE));
|
||||||
|
}
|
||||||
|
private:
|
||||||
|
uint8_t * buffer;
|
||||||
|
const uint8_t * constBuffer;
|
||||||
|
count_t bufferLength;
|
||||||
|
bool serializeLength;
|
||||||
|
|
||||||
|
void determineLengthInBytes(uint8_t typeSize) {
|
||||||
|
switch(typeSize) {
|
||||||
|
case(1): break;
|
||||||
|
case(2):
|
||||||
|
bufferLength *= 2; break;
|
||||||
|
case(4):
|
||||||
|
bufferLength *= 4; break;
|
||||||
|
case(8):
|
||||||
|
bufferLength *= 8; break;
|
||||||
|
default:
|
||||||
|
error << "Serial Buffer Adapter 2: Invalid type size, assuming regular uint8_t." << std::endl;
|
||||||
|
error << "Detected type size: " << (int) typeSize << std::endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif /* SERIALBUFFERADAPTER2_H_ */
|
@ -46,12 +46,15 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (tcStatus != RETURN_OK) {
|
if (tcStatus != RETURN_OK) {
|
||||||
return this->queueMap.end();
|
sif::debug << "PUSDistributor::handlePacket: error with " << (int) tcStatus
|
||||||
|
<< std::endl;
|
||||||
|
return this->queueMap.end();
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
return queueMapIt;
|
return queueMapIt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -31,6 +31,7 @@ ReturnValue_t TcDistributor::handlePacket() {
|
|||||||
|
|
||||||
TcMqMapIter queueMapIt = this->selectDestination();
|
TcMqMapIter queueMapIt = this->selectDestination();
|
||||||
ReturnValue_t returnValue = RETURN_FAILED;
|
ReturnValue_t returnValue = RETURN_FAILED;
|
||||||
|
// sif::debug << "TcDistributor::handlePacket" << std::endl;
|
||||||
if (queueMapIt != this->queueMap.end()) {
|
if (queueMapIt != this->queueMap.end()) {
|
||||||
returnValue = this->tcQueue->sendMessage(queueMapIt->second,
|
returnValue = this->tcQueue->sendMessage(queueMapIt->second,
|
||||||
&this->currentMessage);
|
&this->currentMessage);
|
||||||
|
Loading…
Reference in New Issue
Block a user