v1.14.0 #304

Merged
muellerr merged 366 commits from develop into main 2022-10-10 17:46:38 +02:00
6 changed files with 52 additions and 49 deletions
Showing only changes of commit a6582313f7 - Show all commits

View File

@ -82,28 +82,28 @@ void initmission::initTasks() {
PeriodicTaskIF* scexDevHandler = factory->createPeriodicTask( PeriodicTaskIF* scexDevHandler = factory->createPeriodicTask(
"SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc); "SCEX_DEV", 35, PeriodicTaskIF::MINIMUM_STACK_SIZE * 2, 0.5, missedDeadlineFunc);
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION); result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::PERFORM_OPERATION);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX); initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
} }
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE); result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_WRITE);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX); initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
} }
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE); result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_WRITE);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX); initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
} }
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ); result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::SEND_READ);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
initmission::printAddObjectError("SCEX_DEV", objects::SCEX); initmission::printAddObjectError("SCEX_DEV", objects::SCEX);
} }
result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ); result = scexDevHandler->addComponent(objects::SCEX, DeviceHandlerIF::GET_READ);
result = HasReturnvaluesIF::RETURN_OK; result = returnvalue::OK;
PeriodicTaskIF* scexReaderTask = factory->createPeriodicTask( PeriodicTaskIF* scexReaderTask = factory->createPeriodicTask(
"SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = scexReaderTask->addComponent(objects::SCEX_UART_READER); result = scexReaderTask->addComponent(objects::SCEX_UART_READER);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER);
} }
#endif #endif
@ -229,7 +229,7 @@ void initmission::createPstTasks(TaskFactory& factory,
FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask( FixedTimeslotTaskIF* spiPst = factory.createFixedTimeslotTask(
"SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc); "SPI_PST", 70, PeriodicTaskIF::MINIMUM_STACK_SIZE * 4, 1.0, missedDeadlineFunc);
result = pst::pstSpi(spiPst); result = pst::pstSpi(spiPst);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) { if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
sif::error << "InitMission::createPstTasks: Creating PST failed!" << std::endl; sif::error << "InitMission::createPstTasks: Creating PST failed!" << std::endl;
} }
@ -269,7 +269,7 @@ void initmission::createTestTasks(TaskFactory& factory,
PeriodicTaskIF* scexReaderTask = factory.createPeriodicTask( PeriodicTaskIF* scexReaderTask = factory.createPeriodicTask(
"SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc); "SCEX_UART_READER", 20, PeriodicTaskIF::MINIMUM_STACK_SIZE, 2.0, missedDeadlineFunc);
result = scexReaderTask->addComponent(objects::SCEX_UART_READER); result = scexReaderTask->addComponent(objects::SCEX_UART_READER);
if (result != HasReturnvaluesIF::RETURN_OK) { if (result != returnvalue::OK) {
initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER); initmission::printAddObjectError("SCEX_UART_READER", objects::SCEX_UART_READER);
} }
taskVec.push_back(scexReaderTask); taskVec.push_back(scexReaderTask);

View File

@ -47,8 +47,8 @@
#include "fsfw_hal/linux/spi/SpiCookie.h" #include "fsfw_hal/linux/spi/SpiCookie.h"
void Factory::setStaticFrameworkObjectIds() { void Factory::setStaticFrameworkObjectIds() {
PusServiceBase::packetSource = objects::PUS_PACKET_DISTRIBUTOR; PusServiceBase::PUS_DISTRIBUTOR = objects::PUS_PACKET_DISTRIBUTOR;
PusServiceBase::packetDestination = objects::TM_FUNNEL; PusServiceBase::PACKET_DESTINATION = objects::TM_FUNNEL;
CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR; CommandingServiceBase::defaultPacketSource = objects::PUS_PACKET_DISTRIBUTOR;
CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL; CommandingServiceBase::defaultPacketDestination = objects::TM_FUNNEL;
@ -56,9 +56,6 @@ void Factory::setStaticFrameworkObjectIds() {
TmFunnel::downlinkDestination = objects::TMTC_BRIDGE; TmFunnel::downlinkDestination = objects::TMTC_BRIDGE;
// No storage object for now. // No storage object for now.
TmFunnel::storageDestination = objects::NO_OBJECT; TmFunnel::storageDestination = objects::NO_OBJECT;
VerificationReporter::messageReceiver = objects::PUS_SERVICE_1_VERIFICATION;
TmPacketBase::timeStamperId = objects::TIME_STAMPER;
} }
void ObjectFactory::produce(void* args) { void ObjectFactory::produce(void* args) {

View File

@ -135,7 +135,6 @@ ReturnValue_t ScexUartReader::sendMessage(CookieIF *cookie, const uint8_t *sendD
sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl; sif::warning << "ScexUartReader::sendMessage: Encoding failed" << std::endl;
return FAILED; return FAILED;
} }
arrayprinter::print(cmdbuf.data(), encodedLen);
size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen); size_t bytesWritten = write(serialPort, cmdbuf.data(), encodedLen);
if (bytesWritten != encodedLen) { if (bytesWritten != encodedLen) {
sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed" sif::warning << "ScexUartReader::sendMessage: Sending ping command to solar experiment failed"

View File

@ -126,7 +126,6 @@ void ScexDeviceHandler::fillCommandAndReplyMap() {
insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3);
insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3); insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3);
// TODO: Prüfen: richtige Variablen?
insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, false, false, insertInCommandAndReplyMap(scex::Cmds::ALL_CELLS_CMD, 0, nullptr, 0, false, false,
scex::Cmds::ALL_CELLS_CMD, &finishCountdown); scex::Cmds::ALL_CELLS_CMD, &finishCountdown);
insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, false, false, insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, false, false,
@ -141,28 +140,29 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai
DeviceCommandId_t* foundId, size_t* foundLen) { DeviceCommandId_t* foundId, size_t* foundLen) {
size_t len = remainingSize; size_t len = remainingSize;
ReturnValue_t result = helper.deSerialize(&start, &len); ReturnValue_t result = helper.deSerialize(&start, &len);
bool commandFound = false;
if (result == ScexHelper::INVALID_CRC) { if (result == ScexHelper::INVALID_CRC) {
sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl; sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl;
} else {
*foundId = helper.getCmd();
commandFound = true;
*foundLen = remainingSize; *foundLen = remainingSize;
} else {
result = handleValidReply(remainingSize, foundId, foundLen);
} }
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
if (commandFound) { if (commandActive and finishCountdown.hasTimedOut()) {
uint32_t remainingMillis = finishCountdown.getRemainingMillis(); triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0);
if (commandActive and finishCountdown.hasTimedOut()) { reader.finish();
triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0); sif::warning << "ScexDeviceHandler::performOperationHook: Reader timeout; RemMillis: "
reader.finish(); << remainingMillis << std::endl;
sif::warning << "ScexDeviceHandler::performOperationHook: Reader timeout; RemMillis: " fileNameSet = false;
<< remainingMillis << std::endl; commandActive = false;
fileNameSet = false;
commandActive = false;
}
} }
return result;
}
ReturnValue_t ScexDeviceHandler::handleValidReply(size_t remSize, DeviceCommandId_t* foundId,
size_t* foundLen) {
using namespace scex;
ReturnValue_t result = OK;
auto multiFileHandler = [&](std::string cmdName) { auto multiFileHandler = [&](std::string cmdName) {
if ((helper.getPacketCounter() == 1) or (not fileNameSet)) { if ((helper.getPacketCounter() == 1) or (not fileNameSet)) {
fileId = random_string(6); fileId = random_string(6);
@ -171,27 +171,28 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai
fileName = oss.str(); fileName = oss.str();
fileNameSet = true; fileNameSet = true;
ofstream out(fileName, ofstream::binary); ofstream out(fileName, ofstream::binary);
if (debugMode) {
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
sif::info << "ScexDeviceHandler::interpretDeviceReply:MultifileHandler: RemMillis: "
<< remainingMillis << std::endl;
}
if (out.bad()) { if (out.bad()) {
sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName
<< std::endl; << std::endl;
return FAILED; return FAILED;
} }
out << helper;
} else { } else {
ofstream out(fileName, ofstream out(fileName,
ofstream::binary | ofstream::app); // append ofstream::binary | ofstream::app); // append
if (debugMode) { if (out.bad()) {
out << helper; sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName
<< std::endl;
return FAILED;
} }
out << helper;
} }
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {
return OK; *foundId = helper.getCmd();
return OK;
}
return IGNORE_FULL_PACKET;
}; };
ReturnValue_t status = OK;
switch (helper.getCmd()) { switch (helper.getCmd()) {
case (FRAM): { case (FRAM): {
if (debugMode) { if (debugMode) {
@ -200,18 +201,23 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai
sif::info << "ScexDeviceHandler::interpretDeviceReply: RemMillis: " << remainingMillis sif::info << "ScexDeviceHandler::interpretDeviceReply: RemMillis: " << remainingMillis
<< std::endl; << std::endl;
} }
status = multiFileHandler("fram_"); result = multiFileHandler("fram_");
break; break;
} }
case (ONE_CELL): { case (ONE_CELL): {
status = multiFileHandler("one_cell_"); result = multiFileHandler("one_cell_");
break; break;
} }
case (ALL_CELLS_CMD): { case (ALL_CELLS_CMD): {
status = multiFileHandler("all_cell_"); result = multiFileHandler("all_cell_");
break;
}
default: {
*foundId = helper.getCmd();
break; break;
} }
} }
*foundLen = remSize;
return result; return result;
} }
@ -225,16 +231,13 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
std::ostringstream oss("/tmp/scex-", std::ostringstream::ate); std::ostringstream oss("/tmp/scex-", std::ostringstream::ate);
oss << cmdName << fileId << ".bin"; oss << cmdName << fileId << ".bin";
fileName = oss.str(); fileName = oss.str();
std::cout << fileName << std::endl;
ofstream out(fileName, ofstream::binary); ofstream out(fileName, ofstream::binary);
if (out.bad()) { if (out.bad()) {
sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName
<< std::endl; << std::endl;
return FAILED; return FAILED;
} }
if (debugMode) { out << helper;
out << helper;
}
return OK; return OK;
}; };
@ -258,6 +261,9 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
default: default:
// Unknown DeviceCommand // Unknown DeviceCommand
if(id == FRAM or id == ONE_CELL or id == ALL_CELLS_CMD) {
break;
}
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED; return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
} }
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) { if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {

View File

@ -22,7 +22,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
std::string fileName = ""; std::string fileName = "";
bool fileNameSet = false; bool fileNameSet = false;
bool commandActive = false; bool commandActive = false;
bool debugMode = true; bool debugMode = false;
scex::Cmds currCmd = scex::Cmds::PING; scex::Cmds currCmd = scex::Cmds::PING;
SdCardMountedIF *sdcMan = nullptr; SdCardMountedIF *sdcMan = nullptr;
@ -45,6 +45,7 @@ class ScexDeviceHandler : public DeviceHandlerBase {
ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId, ReturnValue_t scanForReply(const uint8_t *start, size_t remainingSize, DeviceCommandId_t *foundId,
size_t *foundLen) override; size_t *foundLen) override;
ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override; ReturnValue_t interpretDeviceReply(DeviceCommandId_t id, const uint8_t *packet) override;
ReturnValue_t handleValidReply(size_t remSize, DeviceCommandId_t *foundId, size_t *foundLen);
uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override; uint32_t getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) override;
ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override; ReturnValue_t getSwitches(const uint8_t **switches, uint8_t *numberOfSwitches) override;

2
tmtc

@ -1 +1 @@
Subproject commit b1eafd92c202385731a990d3bdba36c48267d63a Subproject commit b4d4a51164af69a22eedd645775061dbb51702b1