p60 dock handler completed

This commit is contained in:
2020-12-17 13:26:00 +01:00
parent 32bd57d6d1
commit 5fac6424ca
5 changed files with 91 additions and 76 deletions

View File

@ -86,7 +86,8 @@ ReturnValue_t CspComIF::sendMessage(CookieIF *cookie,
SerializeAdapter::deSerialize(&querySize, &sendData, &sendLen,
SerializeIF::Endianness::BIG);
uint8_t cspAddress = cspCookie->getCspAddress();
if(cspPort == csp_reserved_ports_e::CSP_PING){
switch(cspPort) {
case(Ports::CSP_PING): {
uint32_t timeout = 1000; // ms
unsigned int pingSize = 100; // 100 bytes
uint32_t replyTime = csp_ping(cspAddress, timeout, pingSize,
@ -96,11 +97,15 @@ ReturnValue_t CspComIF::sendMessage(CookieIF *cookie,
/* Store reply time in reply buffer * */
uint8_t* replyBuffer = cspDeviceMap[cspAddress].data();
memcpy(replyBuffer, &replyTime, sizeof(replyTime));
replySize = sizeof(replyTime);
break;
}
else if(cspPort == csp_reserved_ports_e::CSP_REBOOT){
csp_reboot(cspCookie->getCspAddress());
case(Ports::CSP_REBOOT): {
csp_reboot(cspAddress);
break;
}
else{
case(Ports::P60_PORT_GNDWDT_RESET):
case(Ports::P60_PORT_RPARAM): {
/* No CSP fixed port was selected. Send data to the specified port and
* wait for querySize number of bytes */
result = cspTransfer(cspAddress, cspPort, sendData, sendLen,
@ -108,7 +113,12 @@ ReturnValue_t CspComIF::sendMessage(CookieIF *cookie,
if(result != HasReturnvaluesIF::RETURN_OK){
return HasReturnvaluesIF::RETURN_FAILED;
}
rememberQuerySize = querySize;
replySize = querySize;
break;
}
default:
sif::error << "CspComIF: Invalid port specified" << std::endl;
break;
}
return HasReturnvaluesIF::RETURN_OK;
}
@ -135,7 +145,7 @@ ReturnValue_t CspComIF::readReceivedMessage(CookieIF *cookie,
uint8_t cspAddress = cspCookie->getCspAddress();
*buffer = cspDeviceMap[cspAddress].data();
*size = rememberQuerySize;
*size = replySize;
return HasReturnvaluesIF::RETURN_OK;
}

View File

@ -46,6 +46,14 @@ private:
ReturnValue_t cspTransfer(uint8_t cspAddress, uint8_t cspPort,
const uint8_t* cmdBuffer, int cmdBufferLen, uint16_t querySize);
enum Ports {
CSP_PING = 1,
CSP_REBOOT = 4,
P60_PORT_RPARAM = 7,
P60_PORT_GNDWDT_RESET = 9
};
typedef uint8_t node_t;
using vectorBuffer = std::vector<uint8_t>;
using VectorBufferMap = std::unordered_map<node_t, vectorBuffer>;
@ -54,7 +62,7 @@ private:
/* In this map assigns reply buffers to a CSP device */
VectorBufferMap cspDeviceMap;
uint16_t rememberQuerySize = 0;
uint16_t replySize = 0;
/* This is the CSP address of the OBC. */
node_t cspClientAddress = 1;