working parameter getting and setting of p60dock
This commit is contained in:
parent
aae6c919aa
commit
62747e83aa
@ -339,4 +339,12 @@ x values: 1,2 or 4
|
||||
param table x
|
||||
````
|
||||
Table 4 lists HK parameters
|
||||
Changing parameters
|
||||
First switch to table where parameter shall be changed (here table id is 1)
|
||||
````
|
||||
p60-dock # param mem 1
|
||||
p60-dock # param set out_en[0] 1
|
||||
p60-dock # param get out_en[0]
|
||||
GET out_en[0] = 1
|
||||
````
|
||||
|
||||
|
@ -157,13 +157,18 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
|
||||
csp_conn_t * conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0,
|
||||
CSP_O_NONE);
|
||||
|
||||
querySize = 14;
|
||||
int receivedBytes = csp_transaction_persistent(conn, timeout_ms,
|
||||
int result = csp_transaction_persistent(conn, timeout_ms,
|
||||
tmpCmdBuffer, cmdBufferLen, replyBuffer, querySize);
|
||||
if(receivedBytes != querySize){
|
||||
sif::error << "CSP transfer failed to receive all requested bytes "
|
||||
<< std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
if(querySize != 0){
|
||||
if(result != querySize){
|
||||
sif::error << "CSP transfer failed to receive all requested bytes "
|
||||
<< std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
}
|
||||
} else {
|
||||
if(result != 1){
|
||||
sif::error << "CSP transfer failed" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
csp_close(conn);
|
||||
|
@ -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:
|
||||
|
@ -64,13 +64,17 @@ private:
|
||||
*/
|
||||
class CspSetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||
public:
|
||||
CspSetParamCommand(uint8_t action_, uint8_t tableId_,
|
||||
uint16_t addresslength_, uint16_t checksum_, uint16_t seq_,
|
||||
uint16_t total_, uint16_t addr_, const uint8_t* parameters_,
|
||||
|
||||
static const uint8_t GS_HDR_LENGTH = 12;
|
||||
|
||||
CspSetParamCommand(uint16_t querySize_, uint8_t action_, uint8_t tableId_,
|
||||
uint16_t payloadlength_, uint16_t checksum_, uint16_t seq_,
|
||||
uint16_t total_, uint16_t addr_, const uint8_t* parameter_,
|
||||
uint8_t parameterCount_) :
|
||||
action(action_), tableId(tableId_), addresslength(addresslength_), checksum(
|
||||
checksum_), seq(seq_), total(total_), addr(addr_), parameters(
|
||||
parameters_, parameterCount_) {
|
||||
querySize(querySize_), action(action_), tableId(tableId_), payloadlength(
|
||||
payloadlength_), checksum(checksum_), seq(seq_), total(
|
||||
total_), addr(addr_), parameter(parameter_,
|
||||
parameterCount_) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
@ -81,23 +85,24 @@ private:
|
||||
cspPort.setNext(&querySize);
|
||||
querySize.setNext(&action);
|
||||
action.setNext(&tableId);
|
||||
tableId.setNext(&addresslength);
|
||||
addresslength.setNext(&checksum);
|
||||
tableId.setNext(&payloadlength);
|
||||
payloadlength.setNext(&checksum);
|
||||
checksum.setNext(&seq);
|
||||
seq.setNext(&addr);
|
||||
addr.setNext(¶meters);
|
||||
seq.setNext(&total);
|
||||
total.setNext(&addr);
|
||||
addr.setNext(¶meter);
|
||||
}
|
||||
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
|
||||
/* Only parameters are set. No data will be queried with this command */
|
||||
SerializeElement<uint16_t> querySize = 0;
|
||||
/* Only a parameter will be set. No data will be queried with this command */
|
||||
SerializeElement<uint16_t> querySize;
|
||||
SerializeElement<uint8_t> action;
|
||||
SerializeElement<uint8_t> tableId;
|
||||
SerializeElement<uint16_t> addresslength;
|
||||
SerializeElement<uint16_t> payloadlength;
|
||||
SerializeElement<uint16_t> checksum;
|
||||
SerializeElement<uint16_t> seq;
|
||||
SerializeElement<uint16_t> total;
|
||||
SerializeElement<uint16_t> addr;
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> parameters;
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> parameter;
|
||||
};
|
||||
|
||||
|
||||
@ -196,13 +201,17 @@ private:
|
||||
void setLinks() {
|
||||
setStart(&action);
|
||||
action.setNext(&tableId);
|
||||
seq.setNext(&addr);
|
||||
tableId.setNext(&length);
|
||||
length.setNext(&checksum);
|
||||
checksum.setNext(&seq);
|
||||
seq.setNext(&total);
|
||||
total.setNext(&addr);
|
||||
addr.setNext(&payload);
|
||||
}
|
||||
|
||||
SerializeElement<uint8_t> action;
|
||||
SerializeElement<uint8_t> tableId;
|
||||
SerializeElement<uint16_t> length; //length of payload data
|
||||
SerializeElement<uint16_t> length; //length of address field + payload data
|
||||
SerializeElement<uint16_t> checksum;
|
||||
SerializeElement<uint16_t> seq;
|
||||
SerializeElement<uint16_t> total;
|
||||
@ -226,8 +235,9 @@ public:
|
||||
* data will be stored.
|
||||
*/
|
||||
ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_,
|
||||
uint16_t length_, uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) :
|
||||
payload(payloadBuffer_, payloadBufferSz_) {
|
||||
uint16_t payloadLength_, uint8_t* payloadBuffer_) :
|
||||
action(action_), tableId(tableId_), addr(addr_), payloadLength(
|
||||
payloadLength_), payload(payloadBuffer_, payloadLength) {
|
||||
setLinks();
|
||||
}
|
||||
|
||||
@ -237,14 +247,14 @@ private:
|
||||
setStart(&action);
|
||||
action.setNext(&tableId);
|
||||
tableId.setNext(&addr);
|
||||
addr.setNext(&length);
|
||||
length.setNext(&payload);
|
||||
addr.setNext(&payloadLength);
|
||||
payloadLength.setNext(&payload);
|
||||
}
|
||||
SerializeElement<uint8_t> action;
|
||||
SerializeElement<uint8_t> tableId;
|
||||
SerializeElement<uint16_t> addr;
|
||||
SerializeElement<uint16_t> length;
|
||||
SerializeElement<SerialBufferAdapter<uint8_t>> payload;
|
||||
SerializeElement<uint16_t> payloadLength;
|
||||
SerializeElement<SerialBufferAdapter<uint16_t>> payload;
|
||||
};
|
||||
|
||||
|
||||
@ -261,8 +271,8 @@ public:
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&address, &commandData, &commandDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
parameterBuffer = commandData;
|
||||
parameterCount = commandDataLen;
|
||||
parameter = commandData;
|
||||
parameterSize = commandDataLen;
|
||||
}
|
||||
|
||||
uint8_t getTableId() const {
|
||||
@ -273,12 +283,12 @@ public:
|
||||
return address;
|
||||
}
|
||||
|
||||
const uint8_t* getParameters() {
|
||||
return parameterBuffer;
|
||||
const uint8_t* getParameter() {
|
||||
return parameter;
|
||||
}
|
||||
|
||||
uint8_t getParameterCount(){
|
||||
return parameterCount;
|
||||
uint8_t getParameterSize(){
|
||||
return parameterSize;
|
||||
}
|
||||
|
||||
|
||||
@ -286,10 +296,8 @@ private:
|
||||
SetParamMessageUnpacker(const SetParamMessageUnpacker &message);
|
||||
uint8_t tableId;
|
||||
uint16_t address;
|
||||
/* Parameter buffer holds the values of the parameters to set while the
|
||||
* address points to the location of a parameter. */
|
||||
const uint8_t * parameterBuffer;
|
||||
uint8_t parameterCount;
|
||||
const uint8_t * parameter;
|
||||
uint8_t parameterSize;
|
||||
};
|
||||
|
||||
|
||||
@ -306,7 +314,7 @@ public:
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&address, &commandData, &commandDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
SerializeAdapter::deSerialize(&querySize, &commandData, &commandDataLen,
|
||||
SerializeAdapter::deSerialize(¶meterSize, &commandData, &commandDataLen,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
|
||||
@ -318,8 +326,8 @@ public:
|
||||
return address;
|
||||
}
|
||||
|
||||
uint8_t getQuerySize(){
|
||||
return querySize;
|
||||
uint8_t getParameterSize(){
|
||||
return parameterSize;
|
||||
}
|
||||
|
||||
|
||||
@ -327,7 +335,8 @@ private:
|
||||
GetParamMessageUnpacker(const GetParamMessageUnpacker &message);
|
||||
uint8_t tableId;
|
||||
uint16_t address; //The memory address offset within the table
|
||||
uint8_t querySize; //defines number of bytes to query
|
||||
/* The size of the requested value (e.g. temperature is a uint16_t value) */
|
||||
uint8_t parameterSize;
|
||||
};
|
||||
|
||||
|
||||
|
2
tmtc
2
tmtc
@ -1 +1 @@
|
||||
Subproject commit 0c0e0595f177b8fe4100902058a10e8d5ad34663
|
||||
Subproject commit 1bfde84450f47a028ca831a4dfa8c84cbd4d1fab
|
Loading…
Reference in New Issue
Block a user