eive-obsw/mission/devices/P60DockHandler.cpp

114 lines
2.6 KiB
C++
Raw Normal View History

2020-11-19 18:24:03 +01:00
#include <csp/csp.h>
#include <csp/interfaces/csp_if_can.h>
2020-12-04 14:14:08 +01:00
#include <mission/devices/P60DockHandler.h>
#include "bsp_linux/comIF/cookies/P60DockCookie.h"
#include "bsp_linux/comIF/P60DockComIF.h"
P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF,
CookieIF * comCookie):DeviceHandlerBase(objectId, comIF, comCookie) {
mode = MODE_NORMAL;
if(comCookie == NULL){
sif::error << "P60DockHandler invalid com cookie" << std::endl;
}
p60DockCookie = dynamic_cast<P60DockCookie*> (comCookie);
if(p60DockCookie == NULL){
sif::error << "P60DockHandler failed to get P60DockCookie" << std::endl;
}
2020-12-04 14:14:08 +01:00
}
P60DockHandler::~P60DockHandler() {
}
void P60DockHandler::doStartUp(){
}
void P60DockHandler::doShutDown(){
}
ReturnValue_t P60DockHandler::buildNormalDeviceCommand(DeviceCommandId_t * id){
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t P60DockHandler::buildTransitionDeviceCommand(
DeviceCommandId_t * id){
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t P60DockHandler::buildCommandFromCommand(
DeviceCommandId_t deviceCommand, const uint8_t * commandData,
size_t commandDataLen) {
switch(deviceCommand) {
2020-12-10 10:01:45 +01:00
case(PING): {
p60DockCookie->setPingMessage();
break;
}
2020-12-04 14:14:08 +01:00
case(READ_MODULE_CFG):{
p60DockCookie->setReadModuleCfgMessage();
break;
}
case(READ_HK):{
p60DockCookie->setReadHkMessage();
2020-12-04 14:14:08 +01:00
break;
}
default:
break;
}
return HasReturnvaluesIF::RETURN_OK;
}
void P60DockHandler::fillCommandAndReplyMap(){
2020-12-10 10:01:45 +01:00
this->insertInCommandAndReplyMap(PING, 3);
2020-12-04 14:14:08 +01:00
this->insertInCommandAndReplyMap(READ_MODULE_CFG, 3);
this->insertInCommandAndReplyMap(READ_HK, 3);
2020-12-04 14:14:08 +01:00
}
ReturnValue_t P60DockHandler::scanForReply(const uint8_t *start,
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
2020-12-10 10:01:45 +01:00
MessageType_t messageType = p60DockCookie->getMessageType();
switch(messageType) {
case(PING):
*foundId = PING;
*foundLen = 4;
break;
case(READ_MODULE_CFG): {
2020-12-04 14:14:08 +01:00
*foundId = READ_MODULE_CFG;
*foundLen = moduleCfgTableSize;
break;
}
2020-12-10 10:01:45 +01:00
case(READ_HK): {
*foundId = READ_HK;
*foundLen = hkTableSize;
break;
}
2020-12-04 14:14:08 +01:00
default:
return IGNORE_REPLY_DATA;
}
2020-12-10 10:01:45 +01:00
p60DockCookie->resetMessageType();
2020-12-04 14:14:08 +01:00
return HasReturnvaluesIF::RETURN_OK;
}
ReturnValue_t P60DockHandler::interpretDeviceReply(DeviceCommandId_t id,
const uint8_t *packet) {
switch(id) {
case(READ_MODULE_CFG): {
handleDeviceTM((SerializeIF*)packet, id, true, true);
break;
}
case(READ_HK): {
handleDeviceTM((SerializeIF*)packet, id, true, true);
break;
}
2020-12-04 14:14:08 +01:00
default:
break;
}
return HasReturnvaluesIF::RETURN_OK;
}
2020-12-04 20:08:58 +01:00
void P60DockHandler::setNormalDatapoolEntriesInvalid(){
2020-12-04 14:14:08 +01:00
}