working parameter getting and setting of p60dock
This commit is contained in:
parent
c88bc6508d
commit
f778292d8e
@ -339,4 +339,12 @@ x values: 1,2 or 4
|
|||||||
param table x
|
param table x
|
||||||
````
|
````
|
||||||
Table 4 lists HK parameters
|
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_conn_t * conn = csp_connect(CSP_PRIO_HIGH, cspAddress, cspPort, 0,
|
||||||
CSP_O_NONE);
|
CSP_O_NONE);
|
||||||
|
|
||||||
querySize = 14;
|
int result = csp_transaction_persistent(conn, timeout_ms,
|
||||||
int receivedBytes = csp_transaction_persistent(conn, timeout_ms,
|
|
||||||
tmpCmdBuffer, cmdBufferLen, replyBuffer, querySize);
|
tmpCmdBuffer, cmdBufferLen, replyBuffer, querySize);
|
||||||
if(receivedBytes != querySize){
|
if(querySize != 0){
|
||||||
sif::error << "CSP transfer failed to receive all requested bytes "
|
if(result != querySize){
|
||||||
<< std::endl;
|
sif::error << "CSP transfer failed to receive all requested bytes "
|
||||||
return HasReturnvaluesIF::RETURN_FAILED;
|
<< std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if(result != 1){
|
||||||
|
sif::error << "CSP transfer failed" << std::endl;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
csp_close(conn);
|
csp_close(conn);
|
||||||
|
@ -37,6 +37,50 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(PARAM_SET):{
|
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;
|
break;
|
||||||
}
|
}
|
||||||
case(PARAM_GET):{
|
case(PARAM_GET):{
|
||||||
@ -50,7 +94,7 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
|||||||
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
uint16_t checksum = GOMSPACE::IGNORE_CHECKSUM;
|
||||||
uint16_t seq = 0;
|
uint16_t seq = 0;
|
||||||
uint16_t total = 0;
|
uint16_t total = 0;
|
||||||
uint16_t querySize = getParamMessage.getQuerySize()
|
uint16_t querySize = getParamMessage.getParameterSize()
|
||||||
+ CspGetParamCommand::GS_HDR_LENGTH;
|
+ CspGetParamCommand::GS_HDR_LENGTH;
|
||||||
/* Generate the CSP command to send to the P60 Dock */
|
/* Generate the CSP command to send to the P60 Dock */
|
||||||
CspGetParamCommand getParamCmd(querySize, PARAM_GET, tableId, length,
|
CspGetParamCommand getParamCmd(querySize, PARAM_GET, tableId, length,
|
||||||
@ -110,19 +154,19 @@ ReturnValue_t P60DockHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(PARAM_GET): {
|
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];
|
uint8_t tempPayloadBuffer[payloadLength];
|
||||||
CspGetParamReply cspGetParamReply(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;
|
size_t size = CspGetParamReply::GS_HDR_LENGTH + payloadLength;
|
||||||
cspGetParamReply.deSerialize(&packet, &size,
|
cspGetParamReply.deSerialize(&packet, &size,
|
||||||
SerializeIF::Endianness::LITTLE);
|
SerializeIF::Endianness::BIG);
|
||||||
ParamReply paramReply(action, tableId, address, length, tempPayloadBuffer,
|
uint8_t action = cspGetParamReply.getAction();
|
||||||
payloadLength);
|
uint8_t tableId = cspGetParamReply.getTableId();
|
||||||
handleDeviceTM(¶mReply, id, true, true);
|
uint16_t address = cspGetParamReply.getAddress();
|
||||||
|
ParamReply paramReply(action, tableId, address, payloadLength,
|
||||||
|
tempPayloadBuffer);
|
||||||
|
handleDeviceTM(¶mReply, id, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
|
@ -64,13 +64,17 @@ private:
|
|||||||
*/
|
*/
|
||||||
class CspSetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
|
class CspSetParamCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||||
public:
|
public:
|
||||||
CspSetParamCommand(uint8_t action_, uint8_t tableId_,
|
|
||||||
uint16_t addresslength_, uint16_t checksum_, uint16_t seq_,
|
static const uint8_t GS_HDR_LENGTH = 12;
|
||||||
uint16_t total_, uint16_t addr_, const uint8_t* parameters_,
|
|
||||||
|
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_) :
|
uint8_t parameterCount_) :
|
||||||
action(action_), tableId(tableId_), addresslength(addresslength_), checksum(
|
querySize(querySize_), action(action_), tableId(tableId_), payloadlength(
|
||||||
checksum_), seq(seq_), total(total_), addr(addr_), parameters(
|
payloadlength_), checksum(checksum_), seq(seq_), total(
|
||||||
parameters_, parameterCount_) {
|
total_), addr(addr_), parameter(parameter_,
|
||||||
|
parameterCount_) {
|
||||||
setLinks();
|
setLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,23 +85,24 @@ private:
|
|||||||
cspPort.setNext(&querySize);
|
cspPort.setNext(&querySize);
|
||||||
querySize.setNext(&action);
|
querySize.setNext(&action);
|
||||||
action.setNext(&tableId);
|
action.setNext(&tableId);
|
||||||
tableId.setNext(&addresslength);
|
tableId.setNext(&payloadlength);
|
||||||
addresslength.setNext(&checksum);
|
payloadlength.setNext(&checksum);
|
||||||
checksum.setNext(&seq);
|
checksum.setNext(&seq);
|
||||||
seq.setNext(&addr);
|
seq.setNext(&total);
|
||||||
addr.setNext(¶meters);
|
total.setNext(&addr);
|
||||||
|
addr.setNext(¶meter);
|
||||||
}
|
}
|
||||||
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
|
SerializeElement<uint8_t> cspPort = GOMSPACE::PARAM_PORT;
|
||||||
/* Only parameters are set. No data will be queried with this command */
|
/* Only a parameter will be set. No data will be queried with this command */
|
||||||
SerializeElement<uint16_t> querySize = 0;
|
SerializeElement<uint16_t> querySize;
|
||||||
SerializeElement<uint8_t> action;
|
SerializeElement<uint8_t> action;
|
||||||
SerializeElement<uint8_t> tableId;
|
SerializeElement<uint8_t> tableId;
|
||||||
SerializeElement<uint16_t> addresslength;
|
SerializeElement<uint16_t> payloadlength;
|
||||||
SerializeElement<uint16_t> checksum;
|
SerializeElement<uint16_t> checksum;
|
||||||
SerializeElement<uint16_t> seq;
|
SerializeElement<uint16_t> seq;
|
||||||
SerializeElement<uint16_t> total;
|
SerializeElement<uint16_t> total;
|
||||||
SerializeElement<uint16_t> addr;
|
SerializeElement<uint16_t> addr;
|
||||||
SerializeElement<SerialBufferAdapter<uint8_t>> parameters;
|
SerializeElement<SerialBufferAdapter<uint8_t>> parameter;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -196,13 +201,17 @@ private:
|
|||||||
void setLinks() {
|
void setLinks() {
|
||||||
setStart(&action);
|
setStart(&action);
|
||||||
action.setNext(&tableId);
|
action.setNext(&tableId);
|
||||||
seq.setNext(&addr);
|
tableId.setNext(&length);
|
||||||
|
length.setNext(&checksum);
|
||||||
|
checksum.setNext(&seq);
|
||||||
|
seq.setNext(&total);
|
||||||
|
total.setNext(&addr);
|
||||||
addr.setNext(&payload);
|
addr.setNext(&payload);
|
||||||
}
|
}
|
||||||
|
|
||||||
SerializeElement<uint8_t> action;
|
SerializeElement<uint8_t> action;
|
||||||
SerializeElement<uint8_t> tableId;
|
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> checksum;
|
||||||
SerializeElement<uint16_t> seq;
|
SerializeElement<uint16_t> seq;
|
||||||
SerializeElement<uint16_t> total;
|
SerializeElement<uint16_t> total;
|
||||||
@ -226,8 +235,9 @@ public:
|
|||||||
* data will be stored.
|
* data will be stored.
|
||||||
*/
|
*/
|
||||||
ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_,
|
ParamReply(uint8_t action_, uint8_t tableId_, uint16_t addr_,
|
||||||
uint16_t length_, uint8_t* payloadBuffer_, uint8_t payloadBufferSz_) :
|
uint16_t payloadLength_, uint8_t* payloadBuffer_) :
|
||||||
payload(payloadBuffer_, payloadBufferSz_) {
|
action(action_), tableId(tableId_), addr(addr_), payloadLength(
|
||||||
|
payloadLength_), payload(payloadBuffer_, payloadLength) {
|
||||||
setLinks();
|
setLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,14 +247,14 @@ private:
|
|||||||
setStart(&action);
|
setStart(&action);
|
||||||
action.setNext(&tableId);
|
action.setNext(&tableId);
|
||||||
tableId.setNext(&addr);
|
tableId.setNext(&addr);
|
||||||
addr.setNext(&length);
|
addr.setNext(&payloadLength);
|
||||||
length.setNext(&payload);
|
payloadLength.setNext(&payload);
|
||||||
}
|
}
|
||||||
SerializeElement<uint8_t> action;
|
SerializeElement<uint8_t> action;
|
||||||
SerializeElement<uint8_t> tableId;
|
SerializeElement<uint8_t> tableId;
|
||||||
SerializeElement<uint16_t> addr;
|
SerializeElement<uint16_t> addr;
|
||||||
SerializeElement<uint16_t> length;
|
SerializeElement<uint16_t> payloadLength;
|
||||||
SerializeElement<SerialBufferAdapter<uint8_t>> payload;
|
SerializeElement<SerialBufferAdapter<uint16_t>> payload;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -261,8 +271,8 @@ public:
|
|||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
SerializeAdapter::deSerialize(&address, &commandData, &commandDataLen,
|
SerializeAdapter::deSerialize(&address, &commandData, &commandDataLen,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
parameterBuffer = commandData;
|
parameter = commandData;
|
||||||
parameterCount = commandDataLen;
|
parameterSize = commandDataLen;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getTableId() const {
|
uint8_t getTableId() const {
|
||||||
@ -273,12 +283,12 @@ public:
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
const uint8_t* getParameters() {
|
const uint8_t* getParameter() {
|
||||||
return parameterBuffer;
|
return parameter;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getParameterCount(){
|
uint8_t getParameterSize(){
|
||||||
return parameterCount;
|
return parameterSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -286,10 +296,8 @@ private:
|
|||||||
SetParamMessageUnpacker(const SetParamMessageUnpacker &message);
|
SetParamMessageUnpacker(const SetParamMessageUnpacker &message);
|
||||||
uint8_t tableId;
|
uint8_t tableId;
|
||||||
uint16_t address;
|
uint16_t address;
|
||||||
/* Parameter buffer holds the values of the parameters to set while the
|
const uint8_t * parameter;
|
||||||
* address points to the location of a parameter. */
|
uint8_t parameterSize;
|
||||||
const uint8_t * parameterBuffer;
|
|
||||||
uint8_t parameterCount;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@ -306,7 +314,7 @@ public:
|
|||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
SerializeAdapter::deSerialize(&address, &commandData, &commandDataLen,
|
SerializeAdapter::deSerialize(&address, &commandData, &commandDataLen,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
SerializeAdapter::deSerialize(&querySize, &commandData, &commandDataLen,
|
SerializeAdapter::deSerialize(¶meterSize, &commandData, &commandDataLen,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -318,8 +326,8 @@ public:
|
|||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t getQuerySize(){
|
uint8_t getParameterSize(){
|
||||||
return querySize;
|
return parameterSize;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -327,7 +335,8 @@ private:
|
|||||||
GetParamMessageUnpacker(const GetParamMessageUnpacker &message);
|
GetParamMessageUnpacker(const GetParamMessageUnpacker &message);
|
||||||
uint8_t tableId;
|
uint8_t tableId;
|
||||||
uint16_t address; //The memory address offset within the table
|
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