v1.14.0 #304

Merged
muellerr merged 366 commits from develop into main 2022-10-10 17:46:38 +02:00
5 changed files with 66 additions and 45 deletions
Showing only changes of commit ec47d7eeef - Show all commits

View File

@ -259,7 +259,6 @@ class TcMemWrite : public TcBase {
: TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {} : TcBase(params, apid::TC_MEM_WRITE, sequenceCount) {}
protected: protected:
ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override { ReturnValue_t initPacket(const uint8_t* commandData, size_t commandDataLen) override {
ReturnValue_t result = HasReturnvaluesIF::RETURN_OK; ReturnValue_t result = HasReturnvaluesIF::RETURN_OK;
result = lengthCheck(commandDataLen); result = lengthCheck(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) // 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; static const size_t MIN_COMMAND_DATA_LENGTH = MIN_FIXED_PAYLOAD_LENGTH + 4;
ReturnValue_t lengthCheck(size_t commandDataLen) { ReturnValue_t lengthCheck(size_t commandDataLen) {
if (commandDataLen < MIN_COMMAND_DATA_LENGTH) { if (commandDataLen < MIN_COMMAND_DATA_LENGTH) {
sif::warning << "TcMemWrite: Length " << commandDataLen << " smaller than minimum " << sif::warning << "TcMemWrite: Length " << commandDataLen << " smaller than minimum "
MIN_COMMAND_DATA_LENGTH << std::endl; << MIN_COMMAND_DATA_LENGTH << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }
if (commandDataLen + CRC_SIZE > spParams.maxSize) { if (commandDataLen + CRC_SIZE > spParams.maxSize) {
sif::warning << "TcMemWrite: Length " << commandDataLen << " larger than allowed " << sif::warning << "TcMemWrite: Length " << commandDataLen << " larger than allowed "
spParams.maxSize - CRC_SIZE << std::endl; << spParams.maxSize - CRC_SIZE << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }
return HasReturnvaluesIF::RETURN_OK; return HasReturnvaluesIF::RETURN_OK;
@ -460,7 +458,8 @@ class TcReplayStart : public TcBase {
static const uint8_t ONCE = 1; static const uint8_t ONCE = 1;
ReturnValue_t lengthCheck(size_t commandDataLen) { 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; sif::warning << "TcReplayStart: Command has invalid length " << commandDataLen << std::endl;
return INVALID_LENGTH; return INVALID_LENGTH;
} }

View File

@ -405,7 +405,10 @@ class SetTimeRef : public ploc::SpTcBase {
if (res != result::OK) { if (res != result::OK) {
return res; return res;
} }
initPacket(time); res = initPacket(time);
if (res != result::OK) {
return res;
}
return calcCrc(); return calcCrc();
} }
@ -414,29 +417,48 @@ class SetTimeRef : public ploc::SpTcBase {
static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2; static const uint16_t CRC_OFFSET = DATA_FIELD_LENGTH - 2;
static const uint16_t SYNC = 0x8000; static const uint16_t SYNC = 0x8000;
void initPacket(Clock::TimeOfDay_t* time) { ReturnValue_t initPacket(Clock::TimeOfDay_t* time) {
size_t serializedSize = 0; size_t serializedSize = 6;
uint8_t* dataFieldPtr = payloadStart; uint8_t* dataFieldPtr = payloadStart;
uint16_t milliseconds = static_cast<uint16_t>(time->usecond / 1000) | SYNC; uint16_t milliseconds = static_cast<uint16_t>(time->usecond / 1000) | SYNC;
SerializeAdapter::serialize(&milliseconds, &dataFieldPtr, &serializedSize, ReturnValue_t result =
sizeof(milliseconds), SerializeIF::Endianness::BIG); 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); uint8_t second = static_cast<uint8_t>(time->second);
SerializeAdapter::serialize(&second, &dataFieldPtr, &serializedSize, result = SerializeAdapter::serialize(&second, &dataFieldPtr, &serializedSize, spParams.maxSize,
sizeof(time->second), SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
uint8_t minute = static_cast<uint8_t>(time->minute); uint8_t minute = static_cast<uint8_t>(time->minute);
SerializeAdapter::serialize(&minute, &dataFieldPtr, &serializedSize, result = SerializeAdapter::serialize(&minute, &dataFieldPtr, &serializedSize, spParams.maxSize,
sizeof(time->minute), SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
uint8_t hour = static_cast<uint8_t>(time->hour); 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); SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
uint8_t day = static_cast<uint8_t>(time->day); 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); SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
uint8_t month = static_cast<uint8_t>(time->month); uint8_t month = static_cast<uint8_t>(time->month);
SerializeAdapter::serialize(&month, &dataFieldPtr, &serializedSize, result = SerializeAdapter::serialize(&month, &dataFieldPtr, &serializedSize, spParams.maxSize,
sizeof(time->month), SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
if (result != HasReturnvaluesIF::RETURN_OK) {
return result;
}
uint8_t year = static_cast<uint8_t>(time->year - 1900); uint8_t year = static_cast<uint8_t>(time->year - 1900);
SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, sizeof(time->year), return SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, spParams.maxSize,
SerializeIF::Endianness::BIG); SerializeIF::Endianness::BIG);
} }
}; };
@ -1311,38 +1333,38 @@ class AcknowledgmentReport : public VerificationReport {
void printStatusInformation() { void printStatusInformation() {
StatusCode statusCode = static_cast<StatusCode>(getStatusCode()); StatusCode statusCode = static_cast<StatusCode>(getStatusCode());
const char* prefix = "Supervisor acknowledgment report status: ";
switch (statusCode) { switch (statusCode) {
case StatusCode::OK: { case StatusCode::OK: {
sif::warning << "Supervisor acknowledgment report status: Ok" << std::endl; sif::warning << prefix << "Ok" << std::endl;
break; break;
} }
case StatusCode::BAD_PARAM: { case StatusCode::BAD_PARAM: {
sif::warning << "Supervisor acknowledgment report status: Bad param" << std::endl; sif::warning << prefix << "Bad param" << std::endl;
break; break;
} }
case StatusCode::TIMEOUT: { case StatusCode::TIMEOUT: {
sif::warning << "Supervisor acknowledgment report status: Timeout" << std::endl; sif::warning << prefix << "Timeout" << std::endl;
break; break;
} }
case StatusCode::RX_ERROR: { case StatusCode::RX_ERROR: {
sif::warning << "Supervisor acknowledgment report status: RX error" << std::endl; sif::warning << prefix << "RX error" << std::endl;
break; break;
} }
case StatusCode::TX_ERROR: { case StatusCode::TX_ERROR: {
sif::warning << "Supervisor acknowledgment report status: TX error" << std::endl; sif::warning << prefix << "TX error" << std::endl;
break; break;
} }
case StatusCode::HEADER_EMPTY: { case StatusCode::HEADER_EMPTY: {
sif::warning << "Supervisor acknowledgment report status: Header empty" << std::endl; sif::warning << prefix << "Header empty" << std::endl;
break; break;
} }
case StatusCode::DEFAULT_NAK: { case StatusCode::DEFAULT_NAK: {
sif::warning << "Supervisor acknowledgment report status: Default code for nak" sif::warning << prefix << "Default code for NAK" << std::endl;
<< std::endl;
break; break;
} }
case StatusCode::ROUTE_PACKET: { case StatusCode::ROUTE_PACKET: {
sif::warning << "Supervisor acknowledgment report status: Route packet error" << std::endl; sif::warning << prefix << "Route packet error" << std::endl;
break; break;
} }
default: default:

View File

@ -73,12 +73,12 @@ class SpTcBase {
ReturnValue_t calcCrc() { ReturnValue_t calcCrc() {
/* Calculate crc */ /* 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 */ /* Add crc to packet data field of space packet */
size_t serializedSize = 0; size_t serializedSize = 0;
return SerializeAdapter::serialize<uint16_t>(&crc, &payloadStart, &serializedSize, sizeof(crc), return SerializeAdapter::serialize(&crc, spParams.buf + getFullPacketLen() - 2, &serializedSize,
SerializeIF::Endianness::BIG); spParams.maxSize, SerializeIF::Endianness::BIG);
} }
protected: protected: