Compare commits

...

17 Commits
main ... ploc

Author SHA1 Message Date
db07e92b01 Bug fix buffer overflow. Only temporary, until bugfix in main is available 2021-04-15 13:43:17 +02:00
f094558f11 Update to new FSFW release. Minor changes to include path 2021-03-09 10:24:28 +01:00
9debb7e3b5 Added filesystem message type 2020-10-13 14:36:31 +02:00
5c2b4cf783 Merge branch 'master' of egit.irs.uni-stuttgart.de:fsfw/fsfw into PLOC_SOURCE 2020-10-07 15:09:24 +02:00
ff19b0d4b9 Removed debugging messages 2020-09-17 14:47:17 +02:00
5009d12780 Revert "Added SharedRingBuffer and Updated version of SimpleRingBuffer for new serialpolling task"
This reverts commit dd74ebecba.
2020-09-17 14:43:55 +02:00
dd74ebecba Added SharedRingBuffer and Updated version of SimpleRingBuffer for new serialpolling task 2020-09-16 14:54:52 +02:00
bdec426196 Update to current FSFW status 2020-09-16 07:04:33 +02:00
86f2004569 Increased minimum stack size, to avoid seg fault when initalizing MeSHCam 2020-09-15 12:32:16 +02:00
6f4ec5eafd Clarified some debug messages 2020-07-08 15:19:49 +02:00
7652b33e11 Merge branch 'master' of egit.irs.uni-stuttgart.de:fsfw/fsfw into PLOC_SOURCE 2020-06-26 14:17:50 +02:00
98fb9b8e36 Added debug message for mode reached 2020-06-24 12:52:24 +02:00
217bdb5123 Removed debugging messages in DH 2020-06-23 16:58:26 +02:00
e1b069808e Removed one debug message 2020-06-22 11:06:07 +02:00
1a045d7a84 Even more debug messages 2020-06-17 09:50:52 +02:00
28a3daabac Added some debug messages in HandlerBase and Distributor (CCSDS/PUS/TC) 2020-06-17 08:35:58 +02:00
a468d96f14 Changes for PLOC SOURCE 2020-06-09 15:41:27 +02:00
10 changed files with 177 additions and 11 deletions

View File

@ -446,6 +446,7 @@ void DeviceHandlerBase::callChildStatemachine() {
}
void DeviceHandlerBase::setTransition(Mode_t modeTo, Submode_t submodeTo) {
sif::debug<<"DeviceHandlerBase::setTransition"<<std::endl;
triggerEvent(CHANGING_MODE, modeTo, submodeTo);
childTransitionDelay = getTransitionDelayMs(mode, modeTo);
transitionSourceMode = mode;
@ -542,13 +543,15 @@ void DeviceHandlerBase::replyToReply(DeviceReplyMap::iterator iter,
void DeviceHandlerBase::doSendWrite() {
if (cookieInfo.state == COOKIE_WRITE_READY) {
sif::debug<<" DeviceHandlerBase::doSendWrite: Calling sendMessage"<<std::endl;
ReturnValue_t result = communicationInterface->sendMessage(comCookie,
rawPacket, rawPacketLen);
if (result == RETURN_OK) {
cookieInfo.state = COOKIE_WRITE_SENT;
sif::debug<<" DeviceHandlerBase::doSendWrite: Calling sendMessage succeeded"<<std::endl;
} else {
sif::debug<<" DeviceHandlerBase::doSendWrite: Calling sendMessage failed"<<std::endl;
//always generate a failure event, so that FDIR knows what's up
triggerEvent(DEVICE_SENDING_COMMAND_FAILED, result,
cookieInfo.pendingCommand->first);
@ -561,9 +564,11 @@ void DeviceHandlerBase::doSendWrite() {
void DeviceHandlerBase::doGetWrite() {
if (cookieInfo.state != COOKIE_WRITE_SENT) {
// sif::debug<<" DeviceHandlerBase::doGetWrite: COOKIE_WRITE_SENT not set"<<std::endl;
return;
}
cookieInfo.state = COOKIE_UNUSED;
sif::debug<<" DeviceHandlerBase::doGetWrite: Calling getSendSuccess"<<std::endl;
ReturnValue_t result = communicationInterface->getSendSuccess(comCookie);
if (result == RETURN_OK) {
if (wiretappingMode == RAW) {
@ -587,6 +592,9 @@ void DeviceHandlerBase::doGetWrite() {
void DeviceHandlerBase::doSendRead() {
ReturnValue_t result;
// sif::debug<<" DeviceHandlerBase::doSendRead: Calling requestReceiveMessage"<<std::endl;
size_t requestLen = 0;
if(cookieInfo.pendingCommand != deviceCommandMap.end()) {
DeviceReplyIter iter = deviceReplyMap.find(
@ -597,7 +605,6 @@ void DeviceHandlerBase::doSendRead() {
}
result = communicationInterface->requestReceiveMessage(comCookie, requestLen);
if (result == RETURN_OK) {
cookieInfo.state = COOKIE_READ_SENT;
} else {
@ -620,10 +627,11 @@ void DeviceHandlerBase::doGetRead() {
}
cookieInfo.state = COOKIE_UNUSED;
// sif::debug<<" DeviceHandlerBase::doGetRead: Calling readReceivedMessage"<<std::endl;
ReturnValue_t result = communicationInterface->readReceivedMessage(
comCookie, &receivedData, &receivedDataLen);
if (result != RETURN_OK) {
triggerEvent(DEVICE_REQUESTING_REPLY_FAILED, result);
//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) {
replyRawReplyIfnotWiretapped(receivedData, receivedDataLen);
}
else {
parseReply(receivedData, receivedDataLen);
@ -866,6 +875,7 @@ ReturnValue_t DeviceHandlerBase::enableReplyInReplyMap(
void DeviceHandlerBase::doTransition(Mode_t modeFrom, Submode_t subModeFrom) {
setMode(getBaseMode(mode));
sif::debug<<"DeviceHandlerBase::doTransition Mode: "<<mode<<" reached"<<std::endl;
}
uint32_t DeviceHandlerBase::getTransitionDelayMs(Mode_t modeFrom,
@ -946,6 +956,7 @@ ReturnValue_t DeviceHandlerBase::checkModeCommand(Mode_t commandedMode,
void DeviceHandlerBase::startTransition(Mode_t commandedMode,
Submode_t commandedSubmode) {
sif::debug<<" DeviceHandlerBase::startTransition"<<std::endl;
switch (commandedMode) {
case MODE_ON:
if (mode == MODE_OFF) {
@ -1248,9 +1259,9 @@ void DeviceHandlerBase::buildInternalCommand(void) {
if (iter == deviceCommandMap.end()) {
result = COMMAND_NOT_SUPPORTED;
} else if (iter->second.isExecuting) {
sif::debug << std::hex << getObjectId()
<< ": DHB::buildInternalCommand: Command "
<< deviceCommandId << " isExecuting" << std::endl; //so we can track misconfigurations
// sif::debug << std::hex << getObjectId()
// << ": DHB::buildInternalCommand: Command "
// << 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
} else {
iter->second.sendReplyTo = NO_COMMANDER;

View File

@ -4,7 +4,7 @@
#include <stdint.h>
#include "fwSubsystemIdRanges.h"
//could be move to more suitable location
#include <events/subsystemIdRanges.h>
#include <config/tmtc/subsystemIdRanges.h>
typedef uint16_t EventId_t;
typedef uint8_t EventSeverity_t;

View File

@ -14,6 +14,7 @@ enum FW_MESSAGE_TYPE {
MONITORING,
MEMORY,
PARAMETER,
FILE_SYSTEM_MESSAGE,
FW_MESSAGES_COUNT
};
}

View File

@ -2,6 +2,7 @@
#include "../serviceinterface/ServiceInterfaceStream.h"
#include <iomanip>
#include <cstdlib>
#include <iomanip>
ObjectManager::ObjectManager( void (*setProducer)() ):
produceObjects(setProducer) {

View File

@ -4,7 +4,7 @@
#include <limits.h>
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_,
size_t stackSize_, uint32_t periodMs_):

View File

@ -178,7 +178,7 @@ ReturnValue_t MessageQueue::receiveMessage(MessageQueueMessageIF* message) {
} else {
//No message was received. Keep lastPartner anyway, I might send
//something later. But still, delete packet content.
memset(message->getData(), 0, message->getMaximumMessageSize());
memset(message->getBuffer(), 0, message->getMaximumMessageSize());
switch(errno){
case EAGAIN:
//O_NONBLOCK or MQ_NONBLOCK was set and there are no messages

View File

@ -2,7 +2,7 @@
#define FSFW_RETURNVALUES_HASRETURNVALUESIF_H_
#include "FwClassIds.h"
#include <returnvalues/classIds.h>
#include <config/returnvalues/classIds.h>
#include <cstdint>
#define MAKE_RETURN_CODE( number ) ((INTERFACE_ID << 8) + (number))

149
serialize/SerialBufferAdapter2.h Executable file
View 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_ */

View File

@ -46,12 +46,15 @@ PUSDistributor::TcMqMapIter PUSDistributor::selectDestination() {
}
if (tcStatus != RETURN_OK) {
return this->queueMap.end();
sif::debug << "PUSDistributor::handlePacket: error with " << (int) tcStatus
<< std::endl;
return this->queueMap.end();
}
else {
return queueMapIt;
}
}

View File

@ -31,6 +31,7 @@ ReturnValue_t TcDistributor::handlePacket() {
TcMqMapIter queueMapIt = this->selectDestination();
ReturnValue_t returnValue = RETURN_FAILED;
// sif::debug << "TcDistributor::handlePacket" << std::endl;
if (queueMapIt != this->queueMap.end()) {
returnValue = this->tcQueue->sendMessage(queueMapIt->second,
&this->currentMessage);