ping test
This commit is contained in:
parent
380543756d
commit
32bd57d6d1
@ -86,7 +86,6 @@ ReturnValue_t CspComIF::sendMessage(CookieIF *cookie,
|
|||||||
SerializeAdapter::deSerialize(&querySize, &sendData, &sendLen,
|
SerializeAdapter::deSerialize(&querySize, &sendData, &sendLen,
|
||||||
SerializeIF::Endianness::BIG);
|
SerializeIF::Endianness::BIG);
|
||||||
uint8_t cspAddress = cspCookie->getCspAddress();
|
uint8_t cspAddress = cspCookie->getCspAddress();
|
||||||
|
|
||||||
if(cspPort == csp_reserved_ports_e::CSP_PING){
|
if(cspPort == csp_reserved_ports_e::CSP_PING){
|
||||||
uint32_t timeout = 1000; // ms
|
uint32_t timeout = 1000; // ms
|
||||||
unsigned int pingSize = 100; // 100 bytes
|
unsigned int pingSize = 100; // 100 bytes
|
||||||
@ -168,6 +167,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort,
|
|||||||
} else {
|
} else {
|
||||||
if(result != 1){
|
if(result != 1){
|
||||||
sif::error << "CSP transfer failed" << std::endl;
|
sif::error << "CSP transfer failed" << std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,6 +34,22 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
|||||||
size_t commandDataLen) {
|
size_t commandDataLen) {
|
||||||
switch(deviceCommand) {
|
switch(deviceCommand) {
|
||||||
case(PING): {
|
case(PING): {
|
||||||
|
PingMessageUnpacker pingMessageUnpacker(commandData, commandDataLen);
|
||||||
|
const uint8_t* pingData = pingMessageUnpacker.getPingData();
|
||||||
|
uint8_t pingDataSz = pingMessageUnpacker.getPingDataSz();
|
||||||
|
CspPingCommand cspPingCommand(pingDataSz, pingData);
|
||||||
|
size_t cspPacketLen = 0;
|
||||||
|
uint8_t* buffer = cspPacket;
|
||||||
|
cspPingCommand.serialize(&buffer, &cspPacketLen, sizeof(cspPacket),
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
|
if(cspPacketLen > MAX_PACKET_LEN){
|
||||||
|
sif::error << "P60DockHandler: Received invalid ping message"
|
||||||
|
<< std::endl;
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
rawPacket = cspPacket;
|
||||||
|
rawPacketLen = cspPacketLen;
|
||||||
|
rememberCommandId = PING;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(PARAM_SET):{
|
case(PARAM_SET):{
|
||||||
@ -63,16 +79,16 @@ ReturnValue_t P60DockHandler::buildCommandFromCommand(
|
|||||||
}
|
}
|
||||||
rawPacket = cspPacket;
|
rawPacket = cspPacket;
|
||||||
rawPacketLen = cspPacketLen;
|
rawPacketLen = cspPacketLen;
|
||||||
|
rememberRequestedSize = querySize;
|
||||||
|
rememberCommandId = PARAM_SET;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(PARAM_GET):{
|
case(PARAM_GET):{
|
||||||
/* Unpack the received action message */
|
/* Unpack the received action message */
|
||||||
GetParamMessageUnpacker getParamMessage(commandData, commandDataLen);
|
GetParamMessageUnpacker getParamMessage(commandData, commandDataLen);
|
||||||
uint8_t tableId = getParamMessage.getTableId();
|
uint8_t tableId = getParamMessage.getTableId();
|
||||||
uint16_t address = EndianConverter::convertLittleEndian<uint16_t>(
|
uint16_t address = getParamMessage.getAddress();
|
||||||
getParamMessage.getAddress());
|
uint16_t length = sizeof(address);
|
||||||
uint16_t length = EndianConverter::convertLittleEndian<uint16_t>(
|
|
||||||
sizeof(address));
|
|
||||||
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;
|
||||||
@ -113,7 +129,7 @@ ReturnValue_t P60DockHandler::scanForReply(const uint8_t *start,
|
|||||||
switch(rememberCommandId) {
|
switch(rememberCommandId) {
|
||||||
case(PING):
|
case(PING):
|
||||||
*foundId = PING;
|
*foundId = PING;
|
||||||
*foundLen = rememberRequestedSize;
|
*foundLen = PING_REPLY_SIZE;
|
||||||
rememberCommandId = NONE;
|
rememberCommandId = NONE;
|
||||||
break;
|
break;
|
||||||
case(PARAM_GET): {
|
case(PARAM_GET): {
|
||||||
@ -122,6 +138,12 @@ ReturnValue_t P60DockHandler::scanForReply(const uint8_t *start,
|
|||||||
rememberCommandId = NONE;
|
rememberCommandId = NONE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case(PARAM_SET): {
|
||||||
|
*foundId = PARAM_SET;
|
||||||
|
*foundLen = rememberRequestedSize;
|
||||||
|
rememberCommandId = NONE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
return IGNORE_REPLY_DATA;
|
return IGNORE_REPLY_DATA;
|
||||||
}
|
}
|
||||||
@ -132,13 +154,15 @@ ReturnValue_t P60DockHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
const uint8_t *packet) {
|
const uint8_t *packet) {
|
||||||
switch(id) {
|
switch(id) {
|
||||||
case(PING): {
|
case(PING): {
|
||||||
handleDeviceTM((SerializeIF*)packet, id, true, true);
|
PingReply pingReply(*packet, *(packet + 1));
|
||||||
|
handleDeviceTM(&pingReply, id, true, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case(PARAM_GET): {
|
case(PARAM_GET): {
|
||||||
// -2 to subtract address size from gomspace parameter reply packet
|
// -2 to subtract address size from gomspace parameter reply packet
|
||||||
uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2;
|
uint16_t payloadLength = (*(packet + 2) << 8 | *(packet + 3)) - 2;
|
||||||
uint8_t tempPayloadBuffer[payloadLength];
|
uint8_t tempPayloadBuffer[payloadLength];
|
||||||
|
/* Extract information from received data */
|
||||||
CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength);
|
CspGetParamReply cspGetParamReply(tempPayloadBuffer, payloadLength);
|
||||||
size_t size = CspGetParamReply::GS_HDR_LENGTH + payloadLength;
|
size_t size = CspGetParamReply::GS_HDR_LENGTH + payloadLength;
|
||||||
cspGetParamReply.deSerialize(&packet, &size,
|
cspGetParamReply.deSerialize(&packet, &size,
|
||||||
@ -146,11 +170,20 @@ ReturnValue_t P60DockHandler::interpretDeviceReply(DeviceCommandId_t id,
|
|||||||
uint8_t action = cspGetParamReply.getAction();
|
uint8_t action = cspGetParamReply.getAction();
|
||||||
uint8_t tableId = cspGetParamReply.getTableId();
|
uint8_t tableId = cspGetParamReply.getTableId();
|
||||||
uint16_t address = cspGetParamReply.getAddress();
|
uint16_t address = cspGetParamReply.getAddress();
|
||||||
|
/* Pack relevant information into a tm reply packet */
|
||||||
ParamReply paramReply(action, tableId, address, payloadLength,
|
ParamReply paramReply(action, tableId, address, payloadLength,
|
||||||
tempPayloadBuffer);
|
tempPayloadBuffer);
|
||||||
handleDeviceTM(¶mReply, id, true);
|
handleDeviceTM(¶mReply, id, true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case(PARAM_SET): {
|
||||||
|
/* When setting a parameter, the p60dock sends back the state of the
|
||||||
|
* operation */
|
||||||
|
if(*packet != PARAM_SET_OK){
|
||||||
|
return HasReturnvaluesIF::RETURN_FAILED;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -34,6 +34,8 @@ protected:
|
|||||||
private:
|
private:
|
||||||
|
|
||||||
static const uint8_t MAX_PACKET_LEN = 36;
|
static const uint8_t MAX_PACKET_LEN = 36;
|
||||||
|
static const uint8_t PARAM_SET_OK = 1;
|
||||||
|
static const uint8_t PING_REPLY_SIZE = 2;
|
||||||
/* Device commands are derived from the rparam.h of the gomspace lib */
|
/* Device commands are derived from the rparam.h of the gomspace lib */
|
||||||
static const DeviceCommandId_t PING = 0x1; //!< [EXPORT] : [COMMAND]
|
static const DeviceCommandId_t PING = 0x1; //!< [EXPORT] : [COMMAND]
|
||||||
static const DeviceCommandId_t NONE = 0x2; // Set when no command is pending
|
static const DeviceCommandId_t NONE = 0x2; // Set when no command is pending
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
#include "fsfw/serialize/SerialLinkedListAdapter.h"
|
||||||
|
|
||||||
namespace GOMSPACE{
|
namespace GOMSPACE{
|
||||||
static const uint16_t IGNORE_CHECKSUM = 0xb00b;
|
static const uint16_t IGNORE_CHECKSUM = 0xbb0;
|
||||||
/* CSP port to ping gomspace devices. */
|
/* CSP port to ping gomspace devices. */
|
||||||
static const uint8_t PING_PORT = 1;
|
static const uint8_t PING_PORT = 1;
|
||||||
static const uint8_t REBOOT_PORT = 4;
|
static const uint8_t REBOOT_PORT = 4;
|
||||||
@ -16,14 +16,15 @@ namespace GOMSPACE{
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief A serial linked list adapter implementation to generate ping
|
* @brief A serial linked list adapter implementation to generate ping
|
||||||
* messages for gomspace devices.
|
* commands for devices supporting the CSP protocol. This command can
|
||||||
|
* be sent to the CspComIF which will send out the ping request.
|
||||||
*
|
*
|
||||||
* @details A ping request simply sends back the received data provided by the
|
* @details A ping request simply sends back the received data provided by the
|
||||||
* data buffer. cspPort and querySize are only informations required
|
* data buffer. cspPort and querySize are only informations required
|
||||||
* by the CspComI and other than the data array not physically
|
* by the CspComI and other than the data array not physically
|
||||||
* transmitted to the target device.
|
* transmitted to the target device.
|
||||||
*/
|
*/
|
||||||
class CspPing : public SerialLinkedListAdapter<SerializeIF> {
|
class CspPingCommand : public SerialLinkedListAdapter<SerializeIF> {
|
||||||
public:
|
public:
|
||||||
/**
|
/**
|
||||||
* @brief Constructor
|
* @brief Constructor
|
||||||
@ -32,16 +33,14 @@ public:
|
|||||||
* Amounts to the number of bytes send.
|
* Amounts to the number of bytes send.
|
||||||
* @param parameters_ Pointer to data which should be sent to the device.
|
* @param parameters_ Pointer to data which should be sent to the device.
|
||||||
* All data will be sent back by the ping target.
|
* All data will be sent back by the ping target.
|
||||||
* @param paramterCount_ Number of bytes to send with the ping request.
|
|
||||||
*/
|
*/
|
||||||
CspPing(uint16_t querySize_, const uint8_t* parameters_,
|
CspPingCommand(uint16_t querySize_, const uint8_t* parameters_) :
|
||||||
uint8_t parameterCount_) :
|
querySize(querySize_), data(parameters_, querySize_) {
|
||||||
querySize(querySize_), data(parameters_, parameterCount_) {
|
|
||||||
setLinks();
|
setLinks();
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
CspPing(const CspPing &command);
|
CspPingCommand(const CspPingCommand &command);
|
||||||
void setLinks() {
|
void setLinks() {
|
||||||
setStart(&cspPort);
|
setStart(&cspPort);
|
||||||
cspPort.setNext(&querySize);
|
cspPort.setNext(&querySize);
|
||||||
@ -258,6 +257,28 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This class generates telemetry packets containing data from
|
||||||
|
* CSP get-parameter-replies.
|
||||||
|
*/
|
||||||
|
class PingReply : public SerialLinkedListAdapter<SerializeIF> {
|
||||||
|
public:
|
||||||
|
PingReply(uint8_t action_, uint8_t replyTime_) :
|
||||||
|
action(action_), replyTime(replyTime_) {
|
||||||
|
setLinks();
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
PingReply(const PingReply &reply);
|
||||||
|
void setLinks() {
|
||||||
|
setStart(&action);
|
||||||
|
action.setNext(&replyTime);
|
||||||
|
}
|
||||||
|
SerializeElement<uint8_t> action;
|
||||||
|
SerializeElement<uint32_t> replyTime;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief This class helps to unpack information from an action messages
|
* @brief This class helps to unpack information from an action messages
|
||||||
* to set a parameter in gomspace devices. The action message can be
|
* to set a parameter in gomspace devices. The action message can be
|
||||||
@ -340,4 +361,40 @@ private:
|
|||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief This class helps to extract the information of a message received
|
||||||
|
* from an other software component (e.g. the service 8) to generate
|
||||||
|
* a ping request for gomspace devices.
|
||||||
|
*/
|
||||||
|
class PingMessageUnpacker: public SerialLinkedListAdapter<SerializeIF> {
|
||||||
|
public:
|
||||||
|
|
||||||
|
PingMessageUnpacker(const uint8_t* commandData, size_t commandDataLen) {
|
||||||
|
SerializeAdapter::deSerialize(&action, &commandData, &commandDataLen,
|
||||||
|
SerializeIF::Endianness::BIG);
|
||||||
|
pingData = commandData;
|
||||||
|
pingDataSz = commandDataLen;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getAction() const {
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
|
||||||
|
const uint8_t* getPingData() {
|
||||||
|
return pingData;
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t getPingDataSz(){
|
||||||
|
return pingDataSz;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private:
|
||||||
|
PingMessageUnpacker(const PingMessageUnpacker &message);
|
||||||
|
uint8_t action;
|
||||||
|
const uint8_t * pingData;
|
||||||
|
uint8_t pingDataSz;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_GOMSPACEPACKETS_H_ */
|
||||||
|
Loading…
Reference in New Issue
Block a user