Merge remote-tracking branch 'origin/develop' into mueller/update-p60-module-code
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
Some checks failed
EIVE/eive-obsw/pipeline/head There was a failure building this commit
This commit is contained in:
@ -37,7 +37,7 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) {
|
||||
if (csp_init(cspOwnAddress) != CSP_ERR_NONE ||
|
||||
csp_buffer_init(buf_count, buf_size) != CSP_ERR_NONE) {
|
||||
sif::error << "Failed to init CSP\r\n" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
int promisc = 0; // Set filter mode on
|
||||
@ -51,7 +51,7 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) {
|
||||
int result = csp_rtable_set(address, netmask, csp_if_ptr, mac);
|
||||
if (result != CSP_ERR_NONE) {
|
||||
sif::error << "Failed to add can interface to router table" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
/* Start the route task */
|
||||
@ -60,7 +60,7 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) {
|
||||
result = csp_route_start_task(task_stack_size, priority);
|
||||
if (result != CSP_ERR_NONE) {
|
||||
sif::error << "Failed to start csp route task" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
sif::info << canInterface << " initialized successfully" << std::endl;
|
||||
}
|
||||
@ -71,17 +71,17 @@ ReturnValue_t CspComIF::initializeInterface(CookieIF* cookie) {
|
||||
/* Insert device information in CSP map */
|
||||
cspDeviceMap.emplace(cspAddress, vectorBuffer(maxReplyLength));
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, size_t sendLen) {
|
||||
int result;
|
||||
if (cookie == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
CspCookie* cspCookie = dynamic_cast<CspCookie*>(cookie);
|
||||
if (cspCookie == nullptr) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
uint8_t cspPort;
|
||||
@ -89,7 +89,7 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::DEFAULT_COM_IF) {
|
||||
/* Extract csp port and bytes to query from command buffer */
|
||||
result = getPortAndQuerySize(&sendData, &sendLen, &cspPort, &querySize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != returnvalue::OK) {
|
||||
return result;
|
||||
}
|
||||
} else {
|
||||
@ -113,24 +113,24 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
requestStruct.physaddr = cspDeviceMap[cspAddress].data();
|
||||
if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::GET_PDU_HK) {
|
||||
if(!p60pdu_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
} else if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::GET_ACU_HK) {
|
||||
if(!p60acu_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
} else if(cspCookie->getRequest() == GOMSPACE::SpecialRequestTypes::GET_P60DOCK_HK) {
|
||||
if(!p60dock_get_hk(&requestStruct, cspAddress, cspCookie->getTimeout())) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
/* 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, querySize);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
if (result != returnvalue::OK) {
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
}
|
||||
replySize = querySize;
|
||||
@ -140,22 +140,22 @@ ReturnValue_t CspComIF::sendMessage(CookieIF* cookie, const uint8_t* sendData, s
|
||||
sif::error << "CspComIF: Invalid port specified" << std::endl;
|
||||
break;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::getSendSuccess(CookieIF* cookie) { return HasReturnvaluesIF::RETURN_OK; }
|
||||
ReturnValue_t CspComIF::getSendSuccess(CookieIF* cookie) { return returnvalue::OK; }
|
||||
|
||||
ReturnValue_t CspComIF::requestReceiveMessage(CookieIF* cookie, size_t requestLen) {
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer, size_t* size) {
|
||||
if (cookie == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
CspCookie* cspCookie = dynamic_cast<CspCookie*>(cookie);
|
||||
if (cspCookie == NULL) {
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
uint8_t cspAddress = cspCookie->getCspAddress();
|
||||
@ -163,7 +163,7 @@ ReturnValue_t CspComIF::readReceivedMessage(CookieIF* cookie, uint8_t** buffer,
|
||||
*buffer = cspDeviceMap[cspAddress].data();
|
||||
*size = replySize;
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const uint8_t* cmdBuffer,
|
||||
@ -175,7 +175,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const u
|
||||
if (iter == cspDeviceMap.end()) {
|
||||
sif::error << "CSP device with address " << cspAddress << " no found in"
|
||||
<< " device map" << std::endl;
|
||||
return RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
uint8_t* replyBuffer = iter->second.data();
|
||||
|
||||
@ -186,7 +186,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const u
|
||||
sif::error << "CspComIF::cspTransfer: Failed to get memory for a csp packet from the csp "
|
||||
<< "stack" << std::endl;
|
||||
csp_close(conn);
|
||||
return RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
memcpy(commandPacket->data, cmdBuffer, cmdLen);
|
||||
@ -196,12 +196,12 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const u
|
||||
csp_buffer_free(commandPacket);
|
||||
sif::error << "CspComIF::cspTransfer: Failed to send csp packet" << std::endl;
|
||||
csp_close(conn);
|
||||
return RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
/* Return when no reply is expected */
|
||||
if (expectedSize == 0) {
|
||||
return RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
csp_packet_t* reply;
|
||||
@ -209,7 +209,7 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const u
|
||||
if (reply == NULL) {
|
||||
sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl;
|
||||
csp_close(conn);
|
||||
return RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
memcpy(replyBuffer, reply->data, reply->length);
|
||||
expectedSize = expectedSize - reply->length;
|
||||
@ -220,13 +220,13 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const u
|
||||
if (reply == NULL) {
|
||||
sif::error << "CspComIF::cspTransfer: Failed to read csp packet" << std::endl;
|
||||
csp_close(conn);
|
||||
return RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
if ((reply->length + bytesRead) > iter->second.size()) {
|
||||
sif::error << "CspComIF::cspTransfer: Reply buffer to short" << std::endl;
|
||||
csp_buffer_free(reply);
|
||||
csp_close(conn);
|
||||
return RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
memcpy(replyBuffer + bytesRead, reply->data, reply->length);
|
||||
expectedSize = expectedSize - reply->length;
|
||||
@ -238,30 +238,30 @@ ReturnValue_t CspComIF::cspTransfer(uint8_t cspAddress, uint8_t cspPort, const u
|
||||
sif::error << "CspComIF::cspTransfer: Received more bytes than requested" << std::endl;
|
||||
sif::debug << "CspComIF::cspTransfer: Received bytes: " << bytesRead << std::endl;
|
||||
csp_close(conn);
|
||||
return RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
|
||||
csp_close(conn);
|
||||
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
ReturnValue_t CspComIF::getPortAndQuerySize(const uint8_t** sendData, size_t* sendLen,
|
||||
uint8_t* cspPort, uint16_t* querySize) {
|
||||
ReturnValue_t result =
|
||||
SerializeAdapter::deSerialize(cspPort, sendData, sendLen, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "CspComIF: Failed to deserialize CSP port from command "
|
||||
<< "buffer" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
SerializeAdapter::deSerialize(querySize, sendData, sendLen, SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != returnvalue::OK) {
|
||||
sif::error << "CspComIF: Failed to deserialize querySize from command "
|
||||
<< "buffer" << std::endl;
|
||||
return HasReturnvaluesIF::RETURN_FAILED;
|
||||
return returnvalue::FAILED;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
return returnvalue::OK;
|
||||
}
|
||||
|
||||
void CspComIF::initiatePingRequest(uint8_t cspAddress, uint16_t querySize) {
|
||||
|
@ -4,7 +4,7 @@
|
||||
#include <csp/csp.h>
|
||||
#include <fsfw/devicehandlers/DeviceCommunicationIF.h>
|
||||
#include <fsfw/objectmanager/SystemObject.h>
|
||||
#include <fsfw/returnvalues/HasReturnvaluesIF.h>
|
||||
#include <fsfw/returnvalues/returnvalue.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <vector>
|
||||
|
Reference in New Issue
Block a user