Line data Source code
1 : #ifndef FROMHOST_MESSAGE_HPP 2 : #define FROMHOST_MESSAGE_HPP 3 : 4 : #include <cstdint> 5 : #include <span> 6 : 7 : /** 8 : * @brief Represents a message to be sent to the FLX device. 9 : */ 10 : struct ToFlxMessage { 11 : 12 : /** 13 : * @brief Enum representing the status of a message in ToFLX direction 14 : */ 15 : enum class Status { 16 : MessageOk, ///< Message is OK. 17 : HeaderNotDecoded, ///< Header not decoded, not enough data. 18 : MessageNotDecoded, ///< Message not decoded, not enough data. 19 : InvalidMsgLength ///< Invalid message length. 20 : }; 21 : 22 : uint32_t elink{}; ///< The elink identifier. 23 : std::span<const uint8_t> payload{}; ///< The payload and size of the message. 24 : Status status{ Status::MessageOk }; ///< The status of the message. 25 : 26 : /** 27 : * @brief Converts the status enum to a string representation. 28 : * 29 : * @param status The status to convert. 30 : * @return const char* The string representation of the status. 31 : */ 32 0 : static const char* statusToString(Status status) { 33 0 : switch (status) { 34 : case Status::MessageOk: return "MessageOk"; 35 0 : case Status::HeaderNotDecoded: return "Header not decoded, not enough data"; 36 0 : case Status::MessageNotDecoded: return "Message not decoded, not enough data"; 37 0 : case Status::InvalidMsgLength: return "Invalid message length"; 38 0 : default: return "Unknown status in ToFlxMessage"; 39 : } 40 : } 41 : 42 : }; 43 : 44 : #endif // FROMHOST_MESSAGE_HPP