wip CspComIF
This commit is contained in:
@ -1,8 +1,5 @@
|
||||
#include <csp/csp.h>
|
||||
#include <csp/interfaces/csp_if_can.h>
|
||||
#include <mission/devices/P60DockHandler.h>
|
||||
#include "bsp_linux/comIF/cookies/P60DockCookie.h"
|
||||
#include "bsp_linux/comIF/P60DockComIF.h"
|
||||
#include <mission/devices/devicedefinitions/GomSpacePackets.h>
|
||||
|
||||
P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF,
|
||||
CookieIF * comCookie):DeviceHandlerBase(objectId, comIF, comCookie) {
|
||||
@ -10,10 +7,6 @@ P60DockHandler::P60DockHandler(object_id_t objectId, object_id_t comIF,
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
P60DockHandler::~P60DockHandler() {
|
||||
@ -41,15 +34,39 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
||||
size_t commandDataLen) {
|
||||
switch(deviceCommand) {
|
||||
case(PING): {
|
||||
p60DockCookie->setPingMessage();
|
||||
break;
|
||||
}
|
||||
case(READ_MODULE_CFG):{
|
||||
p60DockCookie->setReadModuleCfgMessage();
|
||||
case(PARAM_SET):{
|
||||
break;
|
||||
}
|
||||
case(READ_HK):{
|
||||
p60DockCookie->setReadHkMessage();
|
||||
case(PARAM_GET):{
|
||||
/* Unpack the received action message */
|
||||
GetParamMessageUnpacker getParamMessage(commandData, commandDataLen);
|
||||
uint8_t tableId = getParamMessage.getTableId();
|
||||
uint16_t address = getParamMessage.getAddress();
|
||||
uint16_t length = EndianConverter::convertLittleEndian<uint16_t>(
|
||||
sizeof(address));
|
||||
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
||||
uint16_t seq = 0;
|
||||
uint16_t total = 0;
|
||||
uint16_t querySize = getParamMessage.getQuerySize();
|
||||
|
||||
/* Generate the CSP command to send to the P60 Dock */
|
||||
CspGetParamCommand getParamCmd(querySize, PARAM_GET, tableId, length,
|
||||
checksum, seq, total, address);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
getParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(cspPacketLen > MAX_PACKET_LEN){
|
||||
sif::error << "P60DockHandler: Received invalid get parameter "
|
||||
"command" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
rememberRequestedSize = querySize;
|
||||
rememberCommandId = PARAM_GET;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
@ -60,44 +77,51 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
||||
|
||||
void P60DockHandler::fillCommandAndReplyMap(){
|
||||
this->insertInCommandAndReplyMap(PING, 3);
|
||||
this->insertInCommandAndReplyMap(READ_MODULE_CFG, 3);
|
||||
this->insertInCommandAndReplyMap(READ_HK, 3);
|
||||
this->insertInCommandAndReplyMap(PARAM_SET, 3);
|
||||
this->insertInCommandAndReplyMap(PARAM_GET, 3);
|
||||
}
|
||||
|
||||
ReturnValue_t P60DockHandler::scanForReply(const uint8_t *start,
|
||||
size_t remainingSize, DeviceCommandId_t *foundId, size_t *foundLen) {
|
||||
MessageType_t messageType = p60DockCookie->getMessageType();
|
||||
switch(messageType) {
|
||||
switch(rememberCommandId) {
|
||||
case(PING):
|
||||
*foundId = PING;
|
||||
*foundLen = 4;
|
||||
*foundLen = rememberRequestedSize;
|
||||
rememberCommandId = NONE;
|
||||
break;
|
||||
case(READ_MODULE_CFG): {
|
||||
*foundId = READ_MODULE_CFG;
|
||||
*foundLen = moduleCfgTableSize;
|
||||
break;
|
||||
}
|
||||
case(READ_HK): {
|
||||
*foundId = READ_HK;
|
||||
*foundLen = hkTableSize;
|
||||
case(PARAM_GET): {
|
||||
*foundId = PARAM_GET;
|
||||
*foundLen = rememberRequestedSize + CspGetParamReply::GS_HDR_LENGTH;
|
||||
rememberCommandId = NONE;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
return IGNORE_REPLY_DATA;
|
||||
}
|
||||
p60DockCookie->resetMessageType();
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
}
|
||||
|
||||
ReturnValue_t P60DockHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
const uint8_t *packet) {
|
||||
switch(id) {
|
||||
case(READ_MODULE_CFG): {
|
||||
case(PING): {
|
||||
handleDeviceTM((SerializeIF*)packet, id, true, true);
|
||||
break;
|
||||
}
|
||||
case(READ_HK): {
|
||||
handleDeviceTM((SerializeIF*)packet, id, true, true);
|
||||
case(PARAM_GET): {
|
||||
uint16_t payloadLength = *(packet + 2);
|
||||
uint8_t tempPayloadBuffer[payloadLength];
|
||||
CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength);
|
||||
uint8_t action = cspGetParamReply.getAction();
|
||||
uint8_t tableId = cspGetParamReply.getTableId();
|
||||
uint16_t length = cspGetParamReply.getLength();
|
||||
uint16_t address = cspGetParamReply.getAddress();
|
||||
size_t size = CspGetParamReply::GS_HDR_LENGTH + payloadLength;
|
||||
cspGetParamReply.deSerialize(&packet, &size,
|
||||
SerializeIF::Endianness::LITTLE);
|
||||
ParamReply paramReply(action, tableId, address, length, tempPayloadBuffer,
|
||||
payloadLength);
|
||||
handleDeviceTM(¶mReply, id, true, true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
Reference in New Issue
Block a user