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