v1.14.0 #304
@ -32,9 +32,9 @@ ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t*
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(
|
||||
DeviceCommandId_t deviceCommand, // DeviceCommandId_t
|
||||
const uint8_t* commandData, size_t commandDataLen) {
|
||||
ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
using namespace scex;
|
||||
|
||||
auto cmdTyped = static_cast<scex::Cmds>(deviceCommand);
|
||||
@ -52,7 +52,7 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (FRAM): {
|
||||
case (EXP_STATUS_CMD): {
|
||||
prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
@ -67,6 +67,11 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (FRAM): {
|
||||
prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{commandData + 1, commandDataLen - 1});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (ONE_CELL): {
|
||||
prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{commandData + 1, commandDataLen - 1});
|
||||
@ -77,11 +82,6 @@ ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(
|
||||
{commandData + 1, commandDataLen - 1});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (EXP_STATUS_CMD): {
|
||||
prepareScexCmd(cmdTyped, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
@ -106,13 +106,9 @@ ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remai
|
||||
|
||||
const uint8_t* helperPtr = decodedPacket;
|
||||
ReturnValue_t result = helper.deSerialize(&helperPtr, &len);
|
||||
if (result == ScexHelper::INVALID_CRC) {
|
||||
sif::warning << "CRC invalid" << std::endl;
|
||||
}
|
||||
|
||||
// crc check
|
||||
if (result == ScexHelper::INVALID_CRC) {
|
||||
sif::warning << "CRC invalid" << std::endl;
|
||||
sif::warning << "ScexDeviceHandler::scanForReply: CRC invalid" << std::endl;
|
||||
return result;
|
||||
}
|
||||
*foundId = helper.getCmd();
|
||||
@ -142,29 +138,36 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
return RETURN_OK;
|
||||
};
|
||||
auto multiFileHandler = [&](std::string cmdName) {
|
||||
if (helper.getPacketCounter() == 1) {
|
||||
if ((helper.getPacketCounter() == 1) or (not fileNameSet)) {
|
||||
// countdown starten
|
||||
finishCountdown.resetTimer();
|
||||
|
||||
fileId = random_string(6);
|
||||
std::ostringstream oss("/tmp/scex-");
|
||||
oss << cmdName << fileId << ".bin";
|
||||
fileName = oss.str();
|
||||
ofstream out(fileName,
|
||||
ofstream::binary); // neues file anlegen
|
||||
fileNameSet = true;
|
||||
ofstream out(fileName, ofstream::binary);
|
||||
if (out.bad()) {
|
||||
sif::error << "ScexDeviceHandler::interpretDeviceReply: Could not open file " << fileName
|
||||
<< std::endl;
|
||||
return RETURN_FAILED;
|
||||
}
|
||||
} else {
|
||||
ofstream out(fileName,
|
||||
ofstream::binary | ofstream::app); // an bestehendes file appenden
|
||||
ofstream::binary | ofstream::app); // append
|
||||
if (debugMode) {
|
||||
out << helper;
|
||||
}
|
||||
|
||||
if (finishCountdown.hasTimedOut()) {
|
||||
triggerEvent(scex::EXPERIMENT_TIMEDOUT, id, 0);
|
||||
reader.finish();
|
||||
sif::warning << "ScexDeviceHandler::interpretDiviceReply: Reader timeout" << std::endl;
|
||||
fileNameSet = false;
|
||||
}
|
||||
}
|
||||
if (finishCountdown.hasTimedOut()) {
|
||||
triggerEvent(scex::EXPERIMENT_TIMEDOUT, id, 0);
|
||||
reader.finish();
|
||||
sif::warning << "ScexDeviceHandler: Reader timeout" << std::endl;
|
||||
// cmdDone = true;
|
||||
fileNameSet = false;
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
};
|
||||
switch (id) {
|
||||
@ -193,17 +196,14 @@ ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, cons
|
||||
// Unknown DeviceCommand
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
if (helper.getPacketCounter() == helper.getTotalPacketCounter()) {
|
||||
reader.finish();
|
||||
sif::info << "Reader is finished" << std::endl;
|
||||
// cmdDone = true;
|
||||
fileNameSet = false;
|
||||
if (helper.getCmd() == scex::Cmds::PING) {
|
||||
// cmdSent = false;
|
||||
fileNameSet = true; // to not generate everytime new file
|
||||
if (id != PING) {
|
||||
sif::info << "Reader is finished" << std::endl;
|
||||
fileNameSet = false;
|
||||
}
|
||||
}
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user