huh
This commit is contained in:
parent
13e89e1342
commit
b156d78274
@ -382,10 +382,8 @@ add_subdirectory(${TEST_PATH})
|
||||
add_subdirectory(${UNITTEST_PATH})
|
||||
|
||||
# This should have already been downloaded by the FSFW Still include it to be
|
||||
# safe
|
||||
# find_package(etl ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET)
|
||||
# Not installed, so use FetchContent to download and provide etl
|
||||
# if(NOT etl_FOUND)
|
||||
# safe find_package(etl ${FSFW_ETL_LIB_MAJOR_VERSION} CONFIG QUIET) Not
|
||||
# installed, so use FetchContent to download and provide etl if(NOT etl_FOUND)
|
||||
message(
|
||||
STATUS
|
||||
"No ETL installation was found with find_package. Installing and providing "
|
||||
@ -454,8 +452,9 @@ if(TGT_BSP MATCHES "arm/q7s")
|
||||
target_link_libraries(${LIB_EIVE_MISSION} PUBLIC ${LIB_GPS} ${LIB_ARCSEC})
|
||||
endif()
|
||||
|
||||
target_link_libraries(${UNITTEST_NAME} PRIVATE Catch2 ${LIB_EIVE_MISSION}
|
||||
rapidcsv ${LIB_DUMMIES} ${LIB_GOMSPACE_CLIENTS})
|
||||
target_link_libraries(
|
||||
${UNITTEST_NAME} PRIVATE Catch2 ${LIB_EIVE_MISSION} rapidcsv ${LIB_DUMMIES}
|
||||
${LIB_GOMSPACE_CLIENTS})
|
||||
|
||||
if(TGT_BSP MATCHES "arm/egse")
|
||||
target_link_libraries(${OBSW_NAME} PRIVATE ${LIB_ARCSEC})
|
||||
|
@ -231,7 +231,7 @@ void initmission::createPstTasks(TaskFactory& factory,
|
||||
result = pst::pstSpi(spiPst);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != FixedTimeslotTaskIF::SLOT_LIST_EMPTY) {
|
||||
sif::error << "InitMission::initTasks: Creating PST failed!" << std::endl;
|
||||
sif::error << "InitMission::createPstTasks: Creating PST failed!" << std::endl;
|
||||
}
|
||||
} else {
|
||||
taskVec.push_back(spiPst);
|
||||
|
@ -34,7 +34,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
||||
lock->unlockMutex();
|
||||
while (true) {
|
||||
semaphore->acquire();
|
||||
sif::info << "task was started" << std::endl;
|
||||
sif::info << "ScexUartReader::performOperation:task was started" << std::endl;
|
||||
int bytesRead = 0;
|
||||
while (true) {
|
||||
bytesRead = read(serialPort, reinterpret_cast<void *>(recBuf.data()),
|
||||
@ -42,7 +42,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
||||
if (bytesRead == 0) {
|
||||
MutexGuard mg(lock);
|
||||
if (state == States::FINISH) {
|
||||
sif::debug << "finish detected" << std::endl;
|
||||
sif::debug << "ScexUartReader::performOperation:finish detected" << std::endl;
|
||||
state = States::IDLE;
|
||||
break;
|
||||
}
|
||||
@ -67,7 +67,7 @@ ReturnValue_t ScexUartReader::performOperation(uint8_t operationCode) {
|
||||
}
|
||||
};
|
||||
// task block comes here
|
||||
sif::info << "task was stopped" << std::endl;
|
||||
sif::info << "ScexUartReader::performOperation: task was stopped" << std::endl;
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
|
@ -26,13 +26,9 @@ void ScexDeviceHandler::doStartUp() {
|
||||
|
||||
void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
return OK;
|
||||
}
|
||||
ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) { return OK; }
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
return OK;
|
||||
}
|
||||
ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) { return OK; }
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
@ -88,6 +84,13 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t devic
|
||||
finishCountdown.setTimeout(LONG_CD);
|
||||
// countdown starten
|
||||
finishCountdown.resetTimer();
|
||||
if (debugMode) {
|
||||
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
|
||||
|
||||
sif::info << "ScexDeviceHandler::buildCommandFromCommand: RemainingMillis: "
|
||||
<< remainingMillis << std::endl;
|
||||
}
|
||||
|
||||
prepareScexCmd(cmdTyped, {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{commandData + 1, commandDataLen - 1}, tempCheck);
|
||||
break;
|
||||
@ -123,12 +126,13 @@ void ScexDeviceHandler::fillCommandAndReplyMap() {
|
||||
insertInCommandAndReplyMap(scex::Cmds::TEMP_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,
|
||||
scex::Cmds::ALL_CELLS_CMD, &finishCountdown);
|
||||
insertInCommandAndReplyMap(scex::Cmds::ONE_CELL, 0, nullptr, 0, false, false,
|
||||
scex::Cmds::ONE_CELL, &finishCountdown);
|
||||
insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, false, false,
|
||||
scex::Cmds::FRAM, &finishCountdown);
|
||||
insertInCommandAndReplyMap(scex::Cmds::FRAM, 0, nullptr, 0, false, false, scex::Cmds::FRAM,
|
||||
&finishCountdown);
|
||||
|
||||
insertInReplyMap(scex::Cmds::ERROR_REPLY, 3);
|
||||
}
|
||||
@ -137,15 +141,78 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
size_t len = remainingSize;
|
||||
ReturnValue_t result = helper.deSerialize(&start, &len);
|
||||
bool commandFound = false;
|
||||
|
||||
if (result == ScexHelper::INVALID_CRC) {
|
||||
sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl;
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
*foundId = helper.getCmd();
|
||||
commandFound = true;
|
||||
*foundLen = remainingSize;
|
||||
}
|
||||
|
||||
if (commandFound) {
|
||||
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
|
||||
if (commandActive and finishCountdown.hasTimedOut()) {
|
||||
triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0);
|
||||
reader.finish();
|
||||
sif::warning << "ScexDeviceHandler::performOperationHook: Reader timeout; RemMillis: "
|
||||
<< remainingMillis << std::endl;
|
||||
fileNameSet = false;
|
||||
commandActive = false;
|
||||
}
|
||||
}
|
||||
|
||||
auto multiFileHandler = [&](std::string cmdName) {
|
||||
if ((helper.getPacketCounter() == 1) or (not fileNameSet)) {
|
||||
fileId = random_string(6);
|
||||
std::ostringstream oss("/tmp/scex-", std::ostringstream::ate);
|
||||
oss << cmdName << fileId << ".bin";
|
||||
fileName = oss.str();
|
||||
fileNameSet = true;
|
||||
ofstream out(fileName, ofstream::binary);
|
||||
if (debugMode) {
|
||||
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
|
||||
sif::info << "ScexDeviceHandler::interpretDeviceReply:MultifileHandler: RemMillis: "
|
||||
<< remainingMillis << std::endl;
|
||||
}
|
||||
if (out.bad()) {
|
||||
sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName
|
||||
<< std::endl;
|
||||
return FAILED;
|
||||
}
|
||||
} else {
|
||||
ofstream out(fileName,
|
||||
ofstream::binary | ofstream::app); // append
|
||||
if (debugMode) {
|
||||
out << helper;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
};
|
||||
ReturnValue_t status = OK;
|
||||
switch (helper.getCmd()) {
|
||||
case (FRAM): {
|
||||
if (debugMode) {
|
||||
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
|
||||
|
||||
sif::info << "ScexDeviceHandler::interpretDeviceReply: RemMillis: " << remainingMillis
|
||||
<< std::endl;
|
||||
}
|
||||
status = multiFileHandler("fram_");
|
||||
break;
|
||||
}
|
||||
case (ONE_CELL): {
|
||||
status = multiFileHandler("one_cell_");
|
||||
break;
|
||||
}
|
||||
case (ALL_CELLS_CMD): {
|
||||
status = multiFileHandler("all_cell_");
|
||||
break;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
||||
@ -170,30 +237,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
}
|
||||
return OK;
|
||||
};
|
||||
auto multiFileHandler = [&](std::string cmdName) {
|
||||
if ((helper.getPacketCounter() == 1) or (not fileNameSet)) {
|
||||
|
||||
fileId = random_string(6);
|
||||
std::ostringstream oss("/tmp/scex-", std::ostringstream::ate);
|
||||
oss << cmdName << fileId << ".bin";
|
||||
fileName = oss.str();
|
||||
fileNameSet = true;
|
||||
ofstream out(fileName, ofstream::binary);
|
||||
if (out.bad()) {
|
||||
sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName
|
||||
<< std::endl;
|
||||
return FAILED;
|
||||
}
|
||||
} else {
|
||||
ofstream out(fileName,
|
||||
ofstream::binary | ofstream::app); // append
|
||||
if (debugMode) {
|
||||
out << helper;
|
||||
}
|
||||
}
|
||||
|
||||
return OK;
|
||||
};
|
||||
switch (id) {
|
||||
case (PING): {
|
||||
status = oneFileHandler("ping_");
|
||||
@ -211,18 +255,7 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
status = oneFileHandler("exp_status_");
|
||||
break;
|
||||
}
|
||||
case (FRAM): {
|
||||
status = multiFileHandler("fram_");
|
||||
break;
|
||||
}
|
||||
case (ONE_CELL): {
|
||||
status = multiFileHandler("one_cell_");
|
||||
break;
|
||||
}
|
||||
case (ALL_CELLS_CMD): {
|
||||
status = multiFileHandler("all_cell_");
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
// Unknown DeviceCommand
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
@ -231,27 +264,21 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
reader.finish();
|
||||
commandActive = false;
|
||||
if (id != PING) {
|
||||
sif::info << "Reader is finished" << std::endl;
|
||||
sif::info << "ScexDeviceHandler::interpretDeviceReply:Reader is finished" << std::endl;
|
||||
fileNameSet = false;
|
||||
}
|
||||
}
|
||||
|
||||
if (debugMode) {
|
||||
uint32_t remainingMillis = finishCountdown.getRemainingMillis();
|
||||
sif::info << __FILE__ << __func__ << "(" << __LINE__ << ") RemMillis: " << remainingMillis
|
||||
<< std::endl;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
void ScexDeviceHandler::performOperationHook() {
|
||||
if (commandActive and finishCountdown.hasTimedOut()) {
|
||||
triggerEvent(scex::EXPERIMENT_TIMEDOUT, currCmd, 0);
|
||||
reader.finish();
|
||||
sif::warning << "ScexDeviceHandler::performOperationHook: Reader timeout" << std::endl;
|
||||
fileNameSet = false;
|
||||
commandActive = false;
|
||||
}
|
||||
}
|
||||
void ScexDeviceHandler::performOperationHook() {}
|
||||
|
||||
uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
|
||||
return OK;
|
||||
}
|
||||
uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) { return OK; }
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
|
||||
return OK;
|
||||
|
Loading…
Reference in New Issue
Block a user