use result instead of retval

This commit is contained in:
2022-07-27 21:43:32 +02:00
parent 88ebb67c8d
commit 5355e63711
22 changed files with 298 additions and 303 deletions

View File

@ -16,27 +16,27 @@ static constexpr uint8_t VERSION_BITS = 0b00100000;
static constexpr uint8_t CFDP_CLASS_ID = CLASS_ID::CFDP;
static constexpr ReturnValue_t INVALID_TLV_TYPE =
retval::makeCode(CFDP_CLASS_ID, 1);
result::makeCode(CFDP_CLASS_ID, 1);
static constexpr ReturnValue_t INVALID_DIRECTIVE_FIELDS =
retval::makeCode(CFDP_CLASS_ID, 2);
result::makeCode(CFDP_CLASS_ID, 2);
static constexpr ReturnValue_t INVALID_PDU_DATAFIELD_LEN =
retval::makeCode(CFDP_CLASS_ID, 3);
result::makeCode(CFDP_CLASS_ID, 3);
static constexpr ReturnValue_t INVALID_ACK_DIRECTIVE_FIELDS =
retval::makeCode(CFDP_CLASS_ID, 4);
result::makeCode(CFDP_CLASS_ID, 4);
//! Can not parse options. This can also occur because there are options
//! available but the user did not pass a valid options array
static constexpr ReturnValue_t METADATA_CANT_PARSE_OPTIONS =
retval::makeCode(CFDP_CLASS_ID, 5);
result::makeCode(CFDP_CLASS_ID, 5);
static constexpr ReturnValue_t NAK_CANT_PARSE_OPTIONS =
retval::makeCode(CFDP_CLASS_ID, 6);
result::makeCode(CFDP_CLASS_ID, 6);
static constexpr ReturnValue_t FINISHED_CANT_PARSE_FS_RESPONSES =
retval::makeCode(CFDP_CLASS_ID, 6);
result::makeCode(CFDP_CLASS_ID, 6);
static constexpr ReturnValue_t FILESTORE_REQUIRES_SECOND_FILE =
retval::makeCode(CFDP_CLASS_ID, 8);
result::makeCode(CFDP_CLASS_ID, 8);
//! Can not parse filestore response because user did not pass a valid instance
//! or remaining size is invalid
static constexpr ReturnValue_t FILESTORE_RESPONSE_CANT_PARSE_FS_MESSAGE =
retval::makeCode(CFDP_CLASS_ID, 9);
result::makeCode(CFDP_CLASS_ID, 9);
//! Checksum types according to the SANA Checksum Types registry
//! https://sanaregistry.org/r/checksum_identifiers/

View File

@ -108,7 +108,7 @@ class TcpTmTcServer : public SystemObject, public TcpIpBase, public ExecutableOb
StorageManagerIF* tmStore = nullptr;
private:
static constexpr ReturnValue_t CONN_BROKEN = retval::makeCode(1, 0);
static constexpr ReturnValue_t CONN_BROKEN = result::makeCode(1, 0);
//! TMTC bridge is cached.
object_id_t tmtcBridgeId = objects::NO_OBJECT;
TcpTmTcBridge* tmtcBridge = nullptr;

View File

@ -10,19 +10,19 @@
#define MAKE_RETURN_CODE(number) ((INTERFACE_ID << 8) + (number))
typedef uint16_t ReturnValue_t;
namespace retval {
namespace result {
static constexpr ReturnValue_t OK = 0;
static constexpr ReturnValue_t FAILED = 1;
static constexpr ReturnValue_t makeCode(uint8_t classId, uint8_t number) {
return (static_cast<ReturnValue_t>(classId) << 8) + number;
}
} // namespace retval
} // namespace result
class HasReturnvaluesIF {
public:
static const ReturnValue_t RETURN_OK = retval::OK;
static const ReturnValue_t RETURN_FAILED = retval::FAILED;
static const ReturnValue_t RETURN_OK = result::OK;
static const ReturnValue_t RETURN_FAILED = result::FAILED;
virtual ~HasReturnvaluesIF() = default;
@ -33,9 +33,9 @@ class HasReturnvaluesIF {
* @param number
* @return
*/
[[deprecated("Use retval::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode(
[[deprecated("Use result::makeCode instead")]] static constexpr ReturnValue_t makeReturnCode(
uint8_t classId, uint8_t number) {
return retval::makeCode(classId, number);
return result::makeCode(classId, number);
}
};

View File

@ -15,7 +15,7 @@ class FixedTimeslotTaskIF : public PeriodicTaskIF {
~FixedTimeslotTaskIF() override = default;
static constexpr ReturnValue_t SLOT_LIST_EMPTY =
retval::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0);
result::makeCode(CLASS_ID::FIXED_SLOT_TASK_IF, 0);
/**
* Add an object with a slot time and the execution step to the task.

View File

@ -20,22 +20,22 @@ void testmq::testMq() {
testSenderMq->setDefaultDestination(testReceiverMqId);
auto result = testSenderMq->sendMessage(testReceiverMqId, &testMessage);
if (result != retval::OK) {
if (result != result::OK) {
unitt::put_error(id);
}
MessageQueueMessage recvMessage;
result = testReceiverMq->receiveMessage(&recvMessage);
if (result != retval::OK or recvMessage.getData()[0] != 42) {
if (result != result::OK or recvMessage.getData()[0] != 42) {
unitt::put_error(id);
}
result = testSenderMq->sendMessage(testReceiverMqId, &testMessage);
if (result != retval::OK) {
if (result != result::OK) {
unitt::put_error(id);
}
MessageQueueId_t senderId = 0;
result = testReceiverMq->receiveMessage(&recvMessage, &senderId);
if (result != retval::OK or recvMessage.getData()[0] != 42) {
if (result != result::OK or recvMessage.getData()[0] != 42) {
unitt::put_error(id);
}
if (senderId != testSenderMqId) {

View File

@ -13,18 +13,18 @@ std::array<uint8_t, 512> testserialize::test_array = {0};
ReturnValue_t testserialize::test_serialization() {
// Here, we test all serialization tools. First test basic cases.
ReturnValue_t result = test_endianness_tools();
if (result != retval::OK) {
if (result != result::OK) {
return result;
}
result = test_autoserialization();
if (result != retval::OK) {
if (result != result::OK) {
return result;
}
result = test_serial_buffer_adapter();
if (result != retval::OK) {
if (result != result::OK) {
return result;
}
return retval::OK;
return result::OK;
}
ReturnValue_t testserialize::test_endianness_tools() {
@ -48,7 +48,7 @@ ReturnValue_t testserialize::test_endianness_tools() {
if (test_array[0] != 0 and test_array[1] != 1) {
return unitt::put_error(id);
}
return retval::OK;
return result::OK;
}
ReturnValue_t testserialize::test_autoserialization() {
@ -152,7 +152,7 @@ ReturnValue_t testserialize::test_autoserialization() {
}
// Check overflow
return retval::OK;
return result::OK;
}
// TODO: Also test for constant buffers.
@ -205,5 +205,5 @@ ReturnValue_t testserialize::test_serial_buffer_adapter() {
if (testUint16 != 16) {
return unitt::put_error(id);
}
return retval::OK;
return result::OK;
}