important bugfix for CRC calculation
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
All checks were successful
EIVE/eive-obsw/pipeline/pr-develop This commit looks good
This commit is contained in:
parent
732602a4cc
commit
ec47d7eeef
@ -259,7 +259,6 @@ class TcMemWrite : public TcBase {
|
||||
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
|
||||
|
||||
protected:
|
||||
|
||||
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
|
||||
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
|
||||
result = lengthCheck(commandDataLen);
|
||||
@ -270,7 +269,7 @@ class TcMemWrite : public TcBase {
|
||||
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
|
||||
spParams.setPayloadLen(MIN_FIXED_PAYLOAD_LENGTH + memLen * 4);
|
||||
result = checkPayloadLen();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
||||
@ -284,16 +283,15 @@ class TcMemWrite : public TcBase {
|
||||
// Min length consists of 4 byte address, 2 byte mem length field, 4 byte data (1 word)
|
||||
static const size_t MIN_COMMAND_DATA_LENGTH = MIN_FIXED_PAYLOAD_LENGTH + 4;
|
||||
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
|
||||
sif::warning << "TcMemWrite: Length " << commandDataLen << " smaller than minimum " <<
|
||||
MIN_COMMAND_DATA_LENGTH << std::endl;
|
||||
sif::warning << "TcMemWrite: Length " << commandDataLen << " smaller than minimum "
|
||||
<< MIN_COMMAND_DATA_LENGTH << std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
if(commandDataLen + CRC_SIZE > spParams.maxSize) {
|
||||
sif::warning << "TcMemWrite: Length " << commandDataLen << " larger than allowed " <<
|
||||
spParams.maxSize - CRC_SIZE << std::endl;
|
||||
if (commandDataLen + CRC_SIZE > spParams.maxSize) {
|
||||
sif::warning << "TcMemWrite: Length " << commandDataLen << " larger than allowed "
|
||||
<< spParams.maxSize - CRC_SIZE << std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
return HasReturnvaluesIF::RETURN_OK;
|
||||
@ -317,7 +315,7 @@ class FlashFopen : public ploc::SpTcBase {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode));
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
@ -343,7 +341,7 @@ class FlashFclose : public ploc::SpTcBase {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
@ -369,7 +367,7 @@ class TcFlashWrite : public ploc::SpTcBase {
|
||||
}
|
||||
spParams.setPayloadLen(static_cast<uint16_t>(writeLen) + 4);
|
||||
result = checkPayloadLen();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
size_t serializedSize = 0;
|
||||
@ -403,7 +401,7 @@ class TcFlashDelete : public ploc::SpTcBase {
|
||||
size_t nameSize = filename.size();
|
||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
||||
auto res = checkPayloadLen();
|
||||
if(res != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (res != HasReturnvaluesIF::RETURN_OK) {
|
||||
return res;
|
||||
}
|
||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||
@ -460,7 +458,8 @@ class TcReplayStart : public TcBase {
|
||||
static const uint8_t ONCE = 1;
|
||||
|
||||
ReturnValue_t lengthCheck(size_t commandDataLen) {
|
||||
if (commandDataLen != COMMAND_DATA_LENGTH or checkPayloadLen() != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (commandDataLen != COMMAND_DATA_LENGTH or
|
||||
checkPayloadLen() != HasReturnvaluesIF::RETURN_OK) {
|
||||
sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
|
||||
return INVALID_LENGTH;
|
||||
}
|
||||
@ -661,7 +660,7 @@ class TcCamcmdSend : public TcBase {
|
||||
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
|
||||
spParams.setPayloadLen(sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN));
|
||||
auto res = checkPayloadLen();
|
||||
if(res != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (res != HasReturnvaluesIF::RETURN_OK) {
|
||||
return res;
|
||||
}
|
||||
size_t size = sizeof(dataLen);
|
||||
|
@ -405,7 +405,10 @@ class SetTimeRef : public ploc::SpTcBase {
|
||||
if (res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
initPacket(time);
|
||||
res = initPacket(time);
|
||||
if (res != result::OK) {
|
||||
return res;
|
||||
}
|
||||
return calcCrc();
|
||||
}
|
||||
|
||||
@ -414,30 +417,49 @@ class SetTimeRef : public ploc::SpTcBase {
|
||||
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
|
||||
static const uint16_t SYNC = 0x8000;
|
||||
|
||||
void initPacket(Clock::TimeOfDay_t* time) {
|
||||
size_t serializedSize = 0;
|
||||
ReturnValue_t initPacket(Clock::TimeOfDay_t* time) {
|
||||
size_t serializedSize = 6;
|
||||
uint8_t* dataFieldPtr = payloadStart;
|
||||
uint16_t milliseconds = static_cast<uint16_t>(time->usecond / 1000) | SYNC;
|
||||
SerializeAdapter::serialize(&milliseconds, &dataFieldPtr, &serializedSize,
|
||||
sizeof(milliseconds), SerializeIF::Endianness::BIG);
|
||||
ReturnValue_t result =
|
||||
SerializeAdapter::serialize(&milliseconds, &dataFieldPtr, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t second = static_cast<uint8_t>(time->second);
|
||||
SerializeAdapter::serialize(&second, &dataFieldPtr, &serializedSize,
|
||||
sizeof(time->second), SerializeIF::Endianness::BIG);
|
||||
result = SerializeAdapter::serialize(&second, &dataFieldPtr, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t minute = static_cast<uint8_t>(time->minute);
|
||||
SerializeAdapter::serialize(&minute, &dataFieldPtr, &serializedSize,
|
||||
sizeof(time->minute), SerializeIF::Endianness::BIG);
|
||||
result = SerializeAdapter::serialize(&minute, &dataFieldPtr, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t hour = static_cast<uint8_t>(time->hour);
|
||||
SerializeAdapter::serialize(&hour, &dataFieldPtr, &serializedSize, sizeof(time->hour),
|
||||
result = SerializeAdapter::serialize(&hour, &dataFieldPtr, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t day = static_cast<uint8_t>(time->day);
|
||||
SerializeAdapter::serialize(&day, &dataFieldPtr, &serializedSize, sizeof(time->day),
|
||||
result = SerializeAdapter::serialize(&day, &dataFieldPtr, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t month = static_cast<uint8_t>(time->month);
|
||||
SerializeAdapter::serialize(&month, &dataFieldPtr, &serializedSize,
|
||||
sizeof(time->month), SerializeIF::Endianness::BIG);
|
||||
uint8_t year = static_cast<uint8_t>(time->year - 1900);
|
||||
SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, sizeof(time->year),
|
||||
result = SerializeAdapter::serialize(&month, &dataFieldPtr, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
uint8_t year = static_cast<uint8_t>(time->year - 1900);
|
||||
return SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, spParams.maxSize,
|
||||
SerializeIF::Endianness::BIG);
|
||||
}
|
||||
};
|
||||
|
||||
@ -1096,7 +1118,7 @@ class WriteMemory : public ploc::SpTcBase {
|
||||
uint8_t n = 1;
|
||||
|
||||
ReturnValue_t initPacket(uint8_t memoryId, uint32_t startAddr, uint16_t updateDataLen,
|
||||
uint8_t* updateData) {
|
||||
uint8_t* updateData) {
|
||||
size_t serializedSize = 0;
|
||||
uint8_t* data = payloadStart;
|
||||
SerializeAdapter::serialize(&memoryId, &data, &serializedSize, sizeof(memoryId),
|
||||
@ -1117,7 +1139,7 @@ class WriteMemory : public ploc::SpTcBase {
|
||||
}
|
||||
// To avoid crashes in this unexpected case
|
||||
ReturnValue_t result = checkPayloadLen();
|
||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
||||
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
std::memcpy(data, updateData, updateDataLen);
|
||||
@ -1311,38 +1333,38 @@ class AcknowledgmentReport : public VerificationReport {
|
||||
|
||||
void printStatusInformation() {
|
||||
StatusCode statusCode = static_cast<StatusCode>(getStatusCode());
|
||||
const char* prefix = "Supervisor acknowledgment report status: ";
|
||||
switch (statusCode) {
|
||||
case StatusCode::OK: {
|
||||
sif::warning << "Supervisor acknowledgment report status: Ok" << std::endl;
|
||||
sif::warning << prefix << "Ok" << std::endl;
|
||||
break;
|
||||
}
|
||||
case StatusCode::BAD_PARAM: {
|
||||
sif::warning << "Supervisor acknowledgment report status: Bad param" << std::endl;
|
||||
sif::warning << prefix << "Bad param" << std::endl;
|
||||
break;
|
||||
}
|
||||
case StatusCode::TIMEOUT: {
|
||||
sif::warning << "Supervisor acknowledgment report status: Timeout" << std::endl;
|
||||
sif::warning << prefix << "Timeout" << std::endl;
|
||||
break;
|
||||
}
|
||||
case StatusCode::RX_ERROR: {
|
||||
sif::warning << "Supervisor acknowledgment report status: RX error" << std::endl;
|
||||
sif::warning << prefix << "RX error" << std::endl;
|
||||
break;
|
||||
}
|
||||
case StatusCode::TX_ERROR: {
|
||||
sif::warning << "Supervisor acknowledgment report status: TX error" << std::endl;
|
||||
sif::warning << prefix << "TX error" << std::endl;
|
||||
break;
|
||||
}
|
||||
case StatusCode::HEADER_EMPTY: {
|
||||
sif::warning << "Supervisor acknowledgment report status: Header empty" << std::endl;
|
||||
sif::warning << prefix << "Header empty" << std::endl;
|
||||
break;
|
||||
}
|
||||
case StatusCode::DEFAULT_NAK: {
|
||||
sif::warning << "Supervisor acknowledgment report status: Default code for nak"
|
||||
<< std::endl;
|
||||
sif::warning << prefix << "Default code for NAK" << std::endl;
|
||||
break;
|
||||
}
|
||||
case StatusCode::ROUTE_PACKET: {
|
||||
sif::warning << "Supervisor acknowledgment report status: Route packet error" << std::endl;
|
||||
sif::warning << prefix << "Route packet error" << std::endl;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -907,7 +907,7 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
||||
|
||||
AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
|
||||
result = ack.checkSize();
|
||||
if(result != RETURN_OK) {
|
||||
if (result != RETURN_OK) {
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ void AcsController::performControlOperation() {
|
||||
{
|
||||
PoolReadGuard pg(&mgmData);
|
||||
if (pg.getReadResult() == RETURN_OK) {
|
||||
copyMgmData();
|
||||
copyMgmData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -73,12 +73,12 @@ class SpTcBase {
|
||||
|
||||
ReturnValue_t calcCrc() {
|
||||
/* Calculate crc */
|
||||
uint16_t crc = CRC::crc16ccitt(spParams.buf, ccsds::HEADER_LEN + spParams.dataFieldLen - 2);
|
||||
uint16_t crc = CRC::crc16ccitt(spParams.buf, getFullPacketLen() - 2);
|
||||
|
||||
/* Add crc to packet data field of space packet */
|
||||
size_t serializedSize = 0;
|
||||
return SerializeAdapter::serialize<uint16_t>(&crc, &payloadStart, &serializedSize, sizeof(crc),
|
||||
SerializeIF::Endianness::BIG);
|
||||
return SerializeAdapter::serialize(&crc, spParams.buf + getFullPacketLen() - 2, &serializedSize,
|
||||
spParams.maxSize, SerializeIF::Endianness::BIG);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
Loading…
Reference in New Issue
Block a user