v1.14.0 #304
@ -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);
|
||||||
@ -270,7 +269,7 @@ class TcMemWrite : public TcBase {
|
|||||||
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
|
*(commandData + MEM_ADDRESS_SIZE) << 8 | *(commandData + MEM_ADDRESS_SIZE + 1);
|
||||||
spParams.setPayloadLen(MIN_FIXED_PAYLOAD_LENGTH + memLen * 4);
|
spParams.setPayloadLen(MIN_FIXED_PAYLOAD_LENGTH + memLen * 4);
|
||||||
result = checkPayloadLen();
|
result = checkPayloadLen();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(payloadStart, commandData, commandDataLen);
|
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)
|
// 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;
|
||||||
@ -317,7 +315,7 @@ class FlashFopen : public ploc::SpTcBase {
|
|||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode));
|
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR) + sizeof(accessMode));
|
||||||
ReturnValue_t result = checkPayloadLen();
|
ReturnValue_t result = checkPayloadLen();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||||
@ -343,7 +341,7 @@ class FlashFclose : public ploc::SpTcBase {
|
|||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
||||||
ReturnValue_t result = checkPayloadLen();
|
ReturnValue_t result = checkPayloadLen();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||||
@ -369,7 +367,7 @@ class TcFlashWrite : public ploc::SpTcBase {
|
|||||||
}
|
}
|
||||||
spParams.setPayloadLen(static_cast<uint16_t>(writeLen) + 4);
|
spParams.setPayloadLen(static_cast<uint16_t>(writeLen) + 4);
|
||||||
result = checkPayloadLen();
|
result = checkPayloadLen();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
@ -403,7 +401,7 @@ class TcFlashDelete : public ploc::SpTcBase {
|
|||||||
size_t nameSize = filename.size();
|
size_t nameSize = filename.size();
|
||||||
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
spParams.setPayloadLen(nameSize + sizeof(NULL_TERMINATOR));
|
||||||
auto res = checkPayloadLen();
|
auto res = checkPayloadLen();
|
||||||
if(res != HasReturnvaluesIF::RETURN_OK) {
|
if (res != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
std::memcpy(payloadStart, filename.c_str(), nameSize);
|
||||||
@ -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;
|
||||||
}
|
}
|
||||||
@ -661,7 +660,7 @@ class TcCamcmdSend : public TcBase {
|
|||||||
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
|
uint16_t dataLen = static_cast<uint16_t>(commandDataLen + sizeof(CARRIAGE_RETURN));
|
||||||
spParams.setPayloadLen(sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN));
|
spParams.setPayloadLen(sizeof(dataLen) + commandDataLen + sizeof(CARRIAGE_RETURN));
|
||||||
auto res = checkPayloadLen();
|
auto res = checkPayloadLen();
|
||||||
if(res != HasReturnvaluesIF::RETURN_OK) {
|
if (res != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
size_t size = sizeof(dataLen);
|
size_t size = sizeof(dataLen);
|
||||||
|
@ -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,30 +417,49 @@ 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);
|
|
||||||
uint8_t year = static_cast<uint8_t>(time->year - 1900);
|
|
||||||
SerializeAdapter::serialize(&year, &dataFieldPtr, &serializedSize, sizeof(time->year),
|
|
||||||
SerializeIF::Endianness::BIG);
|
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;
|
uint8_t n = 1;
|
||||||
|
|
||||||
ReturnValue_t initPacket(uint8_t memoryId, uint32_t startAddr, uint16_t updateDataLen,
|
ReturnValue_t initPacket(uint8_t memoryId, uint32_t startAddr, uint16_t updateDataLen,
|
||||||
uint8_t* updateData) {
|
uint8_t* updateData) {
|
||||||
size_t serializedSize = 0;
|
size_t serializedSize = 0;
|
||||||
uint8_t* data = payloadStart;
|
uint8_t* data = payloadStart;
|
||||||
SerializeAdapter::serialize(&memoryId, &data, &serializedSize, sizeof(memoryId),
|
SerializeAdapter::serialize(&memoryId, &data, &serializedSize, sizeof(memoryId),
|
||||||
@ -1117,7 +1139,7 @@ class WriteMemory : public ploc::SpTcBase {
|
|||||||
}
|
}
|
||||||
// To avoid crashes in this unexpected case
|
// To avoid crashes in this unexpected case
|
||||||
ReturnValue_t result = checkPayloadLen();
|
ReturnValue_t result = checkPayloadLen();
|
||||||
if(result != HasReturnvaluesIF::RETURN_OK) {
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
std::memcpy(data, updateData, updateDataLen);
|
std::memcpy(data, updateData, updateDataLen);
|
||||||
@ -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:
|
||||||
|
@ -907,7 +907,7 @@ ReturnValue_t PlocSupervisorHandler::handleAckReport(const uint8_t* data) {
|
|||||||
|
|
||||||
AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
|
AcknowledgmentReport ack(data, SIZE_ACK_REPORT);
|
||||||
result = ack.checkSize();
|
result = ack.checkSize();
|
||||||
if(result != RETURN_OK) {
|
if (result != RETURN_OK) {
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -32,7 +32,7 @@ void AcsController::performControlOperation() {
|
|||||||
{
|
{
|
||||||
PoolReadGuard pg(&mgmData);
|
PoolReadGuard pg(&mgmData);
|
||||||
if (pg.getReadResult() == RETURN_OK) {
|
if (pg.getReadResult() == RETURN_OK) {
|
||||||
copyMgmData();
|
copyMgmData();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user