working parameter getting and setting of p60dock
This commit is contained in:
@ -37,6 +37,50 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
||||
break;
|
||||
}
|
||||
case(PARAM_SET):{
|
||||
SetParamMessageUnpacker setParamMessageUnpacker(commandData,
|
||||
commandDataLen);
|
||||
uint8_t tableId = setParamMessageUnpacker.getTableId();
|
||||
uint16_t address = EndianConverter::convertLittleEndian<uint16_t>(
|
||||
setParamMessageUnpacker.getAddress());
|
||||
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
||||
uint16_t seq = 0;
|
||||
uint16_t total = 0;
|
||||
/* Reply only comprises the transaction state */
|
||||
uint16_t querySize = 1;
|
||||
const uint8_t* parameterPtr = setParamMessageUnpacker.getParameter();
|
||||
uint8_t parameterSize = setParamMessageUnpacker.getParameterSize();
|
||||
uint32_t parameter;
|
||||
parameter = *parameterPtr;
|
||||
switch(parameterSize) {
|
||||
case(sizeof(uint16_t)): {
|
||||
parameter = EndianConverter::convertLittleEndian<uint16_t>(
|
||||
(uint16_t)parameter);
|
||||
break;
|
||||
}
|
||||
case(sizeof(uint32_t)): {
|
||||
parameter = EndianConverter::convertLittleEndian<uint32_t>(
|
||||
parameter);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
uint16_t payloadlength = EndianConverter::convertLittleEndian<uint16_t>(
|
||||
sizeof(address) + parameterSize);
|
||||
CspSetParamCommand setParamCmd(querySize, PARAM_SET, tableId, payloadlength,
|
||||
checksum, seq, total, address, (uint8_t*) ¶meter,
|
||||
parameterSize);
|
||||
size_t cspPacketLen = 0;
|
||||
uint8_t* buffer = cspPacket;
|
||||
setParamCmd.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||
SerializeIF::Endianness::BIG);
|
||||
if(cspPacketLen > MAX_PACKET_LEN){
|
||||
sif::error << "P60DockHandler: Received invalid set parameter "
|
||||
"command" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
rawPacket = cspPacket;
|
||||
rawPacketLen = cspPacketLen;
|
||||
break;
|
||||
}
|
||||
case(PARAM_GET):{
|
||||
@ -50,7 +94,7 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
||||
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
||||
uint16_t seq = 0;
|
||||
uint16_t total = 0;
|
||||
uint16_t querySize = getParamMessage.getQuerySize()
|
||||
uint16_t querySize = getParamMessage.getParameterSize()
|
||||
+ CspGetParamCommand::GS_HDR_LENGTH;
|
||||
/* Generate the CSP command to send to the P60 Dock */
|
||||
CspGetParamCommand getParamCmd(querySize, PARAM_GET, tableId, length,
|
||||
@ -110,19 +154,19 @@ ReturnValue_t P60DockHandler::interpretDeviceReply(DeviceCommandId_t id,
|
||||
break;
|
||||
}
|
||||
case(PARAM_GET): {
|
||||
uint16_t payloadLength = *(packet + 2);
|
||||
// -2 to subtract address size from gomspace parameter reply packet
|
||||
uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 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);
|
||||
SerializeIF::Endianness::BIG);
|
||||
uint8_t action = cspGetParamReply.getAction();
|
||||
uint8_t tableId = cspGetParamReply.getTableId();
|
||||
uint16_t address = cspGetParamReply.getAddress();
|
||||
ParamReply paramReply(action, tableId, address, payloadLength,
|
||||
tempPayloadBuffer);
|
||||
handleDeviceTM(¶mReply, id, true);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
Reference in New Issue
Block a user