scexDataHandler
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
128
mission/devices/ScexDeviceHandler.cpp
Normal file
128
mission/devices/ScexDeviceHandler.cpp
Normal file
@ -0,0 +1,128 @@
|
||||
#include "ScexDeviceHandler.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "mission/devices/devicedefinitions/ScexDefinitions.h"
|
||||
#include "fsfw/globalfunctions/CRC.h"
|
||||
#include <linux/devices/ScexHelper.h>
|
||||
|
||||
ScexDeviceHandler::ScexDeviceHandler(object_id_t objectId, ScexUartReader& reader, CookieIF* cookie)
|
||||
: DeviceHandlerBase(objectId, reader.getObjectId(),cookie), reader(reader)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void ScexDeviceHandler::doStartUp() {
|
||||
// mode on
|
||||
setMode(MODE_ON);
|
||||
}
|
||||
|
||||
void ScexDeviceHandler::doShutDown() { setMode(_MODE_POWER_DOWN); }
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::buildNormalDeviceCommand(DeviceCommandId_t* id) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::buildTransitionDeviceCommand(DeviceCommandId_t* id) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::buildCommandFromCommand(DeviceCommandId_t deviceCommand,
|
||||
const uint8_t* commandData,
|
||||
size_t commandDataLen) {
|
||||
using namespace scex;
|
||||
|
||||
if (not std::find(VALID_CMDS.begin(), VALID_CMDS.end(), deviceCommand) != VALID_CMDS.end()) {
|
||||
return DeviceHandlerIF::COMMAND_NOT_IMPLEMENTED;
|
||||
}
|
||||
if (commandDataLen < 1) {
|
||||
return DeviceHandlerIF::INVALID_COMMAND_PARAMETER;
|
||||
}
|
||||
|
||||
switch (deviceCommand) {
|
||||
case (PING): {
|
||||
rawPacket = cmdBuf.size();
|
||||
|
||||
prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (FRAM): {
|
||||
prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (ION_CMD): {
|
||||
prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (TEMP_CMD): {
|
||||
prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (ONE_CELL): {
|
||||
prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{commandData + 1, commandData - 1});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (ALL_CELLS_CMD): {
|
||||
prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{commandData + 1, commandData - 1});
|
||||
return RETURN_OK;
|
||||
}
|
||||
case (EXP_STATUS_CMD): {
|
||||
prepareScexCmd(deviceCommand, commandData[0], {cmdBuf.data(), cmdBuf.size()}, rawPacketLen,
|
||||
{nullptr, 0});
|
||||
return RETURN_OK;
|
||||
}
|
||||
}
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
void ScexDeviceHandler::fillCommandAndReplyMap() {
|
||||
insertInCommandAndReplyMap(scex::Cmds::PING, 3);
|
||||
insertInCommandAndReplyMap(scex::Cmds::ION_CMD, 3);
|
||||
insertInCommandAndReplyMap(scex::Cmds::TEMP_CMD, 3);
|
||||
insertInCommandAndReplyMap(scex::Cmds::EXP_STATUS_CMD, 3);
|
||||
|
||||
insertInCommandMap(scex::Cmds::ALL_CELLS_CMD);
|
||||
insertInCommandMap(scex::Cmds::ONE_CELL);
|
||||
insertInCommandMap(scex::Cmds::FRAM);
|
||||
|
||||
insertInReplyMap(scex::Cmds::ERROR_REPLY, 3);
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::scanForReply(const uint8_t* start, size_t remainingSize,
|
||||
DeviceCommandId_t* foundId, size_t* foundLen) {
|
||||
//helper.deSerialize(blabla);
|
||||
//crc check
|
||||
|
||||
*foundId = helper.getCmd();
|
||||
*foundLen = remainingSize;
|
||||
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::interpretDeviceReply(DeviceCommandId_t id, const uint8_t* packet) {
|
||||
//cmd auswertung (in file reinschreiben)
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
uint32_t ScexDeviceHandler::getTransitionDelayMs(Mode_t modeFrom, Mode_t modeTo) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::getSwitches(const uint8_t** switches, uint8_t* numberOfSwitches) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t ScexDeviceHandler::initializeLocalDataPool(localpool::DataPool& localDataPoolMap,
|
||||
LocalDataPoolManager& poolManager) {
|
||||
return RETURN_OK;
|
||||
}
|
||||
|
||||
|
||||
|
||||
void ScexDeviceHandler::modeChanged() {}
|
Reference in New Issue
Block a user