From 2c7288f57f6167eef8862b4f2dcd1b905016b726 Mon Sep 17 00:00:00 2001 From: Z3r0z0 Date: Fri, 23 Jan 2026 18:52:18 +0100 Subject: [PATCH 1/7] added interface fo cpp LiquidCan --- Cpp-Implementation/LiquidCan.h | 171 +++++++++++++++++++ Cpp-Implementation/Models/CanMessageType.h | 28 +++ Cpp-Implementation/Models/CanProcess.h | 97 +++++++++++ Cpp-Implementation/Models/CanProcessStatus.h | 14 ++ 4 files changed, 310 insertions(+) create mode 100644 Cpp-Implementation/Models/CanMessageType.h create mode 100644 Cpp-Implementation/Models/CanProcess.h create mode 100644 Cpp-Implementation/Models/CanProcessStatus.h diff --git a/Cpp-Implementation/LiquidCan.h b/Cpp-Implementation/LiquidCan.h index e69de29..df89c4f 100644 --- a/Cpp-Implementation/LiquidCan.h +++ b/Cpp-Implementation/LiquidCan.h @@ -0,0 +1,171 @@ + +#ifndef LIQUIDCAN_H +#define LIQUIDCAN_H + +/* + * @brief Class profiding an interface to the Liquid CAN prodocoll + * + * This interface declass methodes to handle + * initialization, + * external parameter access + * process management + * status reporting + */ +class LiquidCan { + public: + /* + * @brief Stats the initialisation procedure for the CAN System + * + * @pre parameter and telemetrie fields must be registerd + */ + virtual void startInitProcedure(); + + /* + * @brief Updated an external parameter by id and sets a given value + * + * @tparam T datatype of the external parameter + * @param id identifier of the external parameter + * @param data Value to set the external parameter + * + * @pre LiquidCan system must bei initialized + * @pre id must be correspond to a existing external id + * @post A CanProcess is started witch awaits the verification of the parameter update + * + * @returns processId witch tracks the response status and value + */ + template + virtual int updateExternalParameter(int id, T data); + + /* + * @brief Retreives the value ot an external parameter + * + * @tparam T datatype of the external parameter + * @param id identifier of the external parameter + * @param data reference to store retreived data + * + * @pre LiquidCan system must bei initialized + * @pre id must be correspond to a existing external id + * @post A CanProcess is started witch awaits the verification of the parameter update + * + * @returns processId witch tracks the response status + */ + template + virtual int getExternalParameter(int id, T &data); + + /* + * @brief Locks an external parameter + * + * @param id identifier of the external parameter + * + * @pre LiquidCan system must bei initialized + * @pre id must be correspond to a existing external id + * @post A CanProcess is started witch awaits the verification of the parameter update + * + * @returns processId witch tracks the response status + */ + virtual int lockExternalParameter(int id) + + /* + * @brief Unlocks an external parameter + * + * @param id identifier of the external parameter + * + * @pre LiquidCan system must bei initialized + * @pre id must be correspond to a existing external id + * @post A CanProcess is started witch awaits the verification of the parameter update + * + * @returns processId witch tracks the response status + */ + virtual int unlockExternalParameter(int id); + + /* + * @brief Sends an information status message + * + * @param message as string + * + * @pre LiquidCan system must bei initialized + */ + virtual void sendInfoStatus(std::string message); + + /* + * @brief Sends an warning status message + * + * @param message as string + * + * @pre LiquidCan system must bei initialized + */ + virtual void sendWarningStatus(std::string message); + + /* + * @brief Sends an error status message + * + * @param message as string + * + * @pre LiquidCan system must bei initialized + */ + virtual void sendErrorStatus(std::string message); + + /* + * @brief Retreives external fieldId by name + * + * @param name Name of the external field + * + * @pre LiquidCan system must bei initialized + * @post A CanProcess is started witch awaits the verification of the parameter update + * + * @returns processId witch tracks the response status + */ + virtual int lookupFieldIdByName(std::string name); + + /* + * @brief Returns the value of a finished CanProcess + * + * @tparam T datatype of the response + * @param id identifier of the CanProcess + * + * @pre id must be correspond to a existing CanProcess + * @pre CanProcess muss have the status DONE + * + * @returns Value to CanProcess or nullptr (if not ready or failed) + */ + template + virtual T* getProcessResponse(int processId); + + /* + * @brief Checks if the response of a CanProcess is read + * + * @param id identifier of the CanProcess + * + * @pre id must be correspond to a existing CanProcess + * + * @returns Returns true if the CanProcess has status Done + */ + virtual bool isProcessReady(int processId); + + /* + * @brief Checks if a CanProcess is active + * + * @param id identifier of the CanProcess + * + * @pre id must be correspond to a existing CanProcess + * + * @returns Returns true if the CanProcess has status Started + */ + virtual bool isProcessActive(int processId); + + /* + * @brief Checks if a CanProcess is falied + * + * @param id identifier of the CanProcess + * + * @pre id must be correspond to a existing CanProcess + * + * @returns Returns true if the CanProcess has status Error + */ + virtual bool isProcessFailed(int processId); + + private: + // Disable coping + LiquidCan(LiquidCan const &); + LiquidCan& operator=(LiquidCan const &); +} \ No newline at end of file diff --git a/Cpp-Implementation/Models/CanMessageType.h b/Cpp-Implementation/Models/CanMessageType.h new file mode 100644 index 0000000..e07d4f3 --- /dev/null +++ b/Cpp-Implementation/Models/CanMessageType.h @@ -0,0 +1,28 @@ +// +// Created by tobias on 19.01.26. +// + +#ifndef MESSAGETYPE_H +#define MESSAGETYPE_H +enum CanMessageType { + NODE_INFO_REQUEST = 0, + NODE_INFO_ANOUNCEMENT = 1, + INFO_STATUS = 10, + WARNING_STATUS = 11, + ERROR_STATUS = 12, + TELEMETRY_VALUE_REGISTRATION = 20, + PARAMETER_REGISTRATION = 21, + TELEMETRY_GROUP_DEFINTION = 30, + TELEMETRY_GROUP_UPDATE = 31, + HEARTBEAT_REQUEST = 40, + HEARTBEAT_RESPONSE = 41, + PARAMETER_SET_REQUEST = 50, + PARAMETER_SET_CONFIRMATION = 51, + PARAMETER_SET_LOCK_REQUEST = 52, + PARAMETER_SET_LOCK_CONFIRMATION = 53, + FIELD_GET_REQUEST = 60, + FIELD_GET_RESPONSE = 61, + FIELD_ID_LOOKUP_REQUEST = 62, + FIELD_ID_LOOKUP_RESPONSE = 63, +} +#endif //MESSAGETYPE_H \ No newline at end of file diff --git a/Cpp-Implementation/Models/CanProcess.h b/Cpp-Implementation/Models/CanProcess.h new file mode 100644 index 0000000..198cd5b --- /dev/null +++ b/Cpp-Implementation/Models/CanProcess.h @@ -0,0 +1,97 @@ +// +// Created by tobias on 17.01.26. +// + +#ifndef CANPROCESS_H +#define CANPROCESS_H + +#include +#include + +/* + * @brief Template class for CAN-Process Management + * + * This class stores the status and value of a given CAN process and + * allows querying the process type and value + * + * @tparam T Datatype of the expected value of the CAN-Process e.g. int or float + */ +template +class CanProcess { + public: + /* + * @brief Construct a CAN process with the specified MessageTypes + * + * @param processType is the CanMessageType of the message witch started the process + * @param responseType is the CanMessageType of the expected response message + * @param fieldId is the optinal field identifier used to further link the process to a message, defaults to 0 + * + * @post Process is initialized with + * status = started + * value = default + * processType, responseType and fieldId set + */ + CanProcess(CanMessageType processType, CanMessageType responseType, int fieldId = 0); + + /* + * @brief Sets the status of the CAN process + * + * @param status is the new status to set + * + * @pre The status must be "NEW" in order to be canged + * @post The internal process status is updated + */ + virtual void setStatus(CanProcessStatus status); + + /* + * @brief Returns the current status of a the CAN process + * + * @return Current CanProcessStatus fo the process + */ + virtual CanProcessStatus getStatus(); + + /* + * @brief Sets the value ot the CAN process + * + * @param value is the new value of type T + * + * @post The internal value is updated + */ + virtual void setValue(T value); + + /* + * @brief Return the value to the CAN process + * + * @pre status must be DONE + * + * @return Current value to type T + */ + virtual T getValue(); + + /* + * @brief Returns the type of the CAN process + * + * @return CanMessageType that started the process + */ + virtual CanMessageType getProcessType(); + + /* + * @brief Returns the expected type of the response message + * + * @return Expected CanMessageType ot the response + */ + virtual CanMessageType getProcessResponseType(); + + private: + CanProcessStatus status_; + T value_; + CanMessageType processType_; + CanMessageType responseType_; + int fieldId_; + + // Disable coping + CanProcess(const CanProcess &); + CanProcess &operator=(const CanProcess &); +}; + +#endif //CANPROCESS_H diff --git a/Cpp-Implementation/Models/CanProcessStatus.h b/Cpp-Implementation/Models/CanProcessStatus.h new file mode 100644 index 0000000..853b522 --- /dev/null +++ b/Cpp-Implementation/Models/CanProcessStatus.h @@ -0,0 +1,14 @@ +// +// Created by tobias on 17.01.26. +// + +#ifndef CANPROCESSSTATUS_H +#define CANPROCESSSTATUS_H + +enum CanProcessStatus{ + Started = 0, + Done = 1, + Error = 2 +} + +#endif //CANPROCESSSTATUS_H From 88710346ce13e75a834d8f35ff2857caf59598d6 Mon Sep 17 00:00:00 2001 From: Z3r0z0 Date: Sat, 24 Jan 2026 22:39:17 +0100 Subject: [PATCH 2/7] added models (wip) --- .../Infrastructure/CanMessage.h | 13 ++ .../CanMessageType.h | 0 Cpp-Implementation/Infrastructure/DataType.h | 17 ++ Cpp-Implementation/LiquidCan.h | 168 +----------------- Cpp-Implementation/Models/CanProcess.h | 97 ---------- Cpp-Implementation/Models/CanProcessStatus.h | 14 -- Cpp-Implementation/Models/FieldRegistration.h | 28 +++ Cpp-Implementation/Models/NodeInfoRequest.h | 45 +++++ .../Models/ParameterSetRequest.h | 25 +++ .../Models/TelemetryGroupDefinition.h | 26 +++ .../Models/TelemetryGroupUpdate.h | 24 +++ 11 files changed, 179 insertions(+), 278 deletions(-) create mode 100644 Cpp-Implementation/Infrastructure/CanMessage.h rename Cpp-Implementation/{Models => Infrastructure}/CanMessageType.h (100%) create mode 100644 Cpp-Implementation/Infrastructure/DataType.h delete mode 100644 Cpp-Implementation/Models/CanProcess.h delete mode 100644 Cpp-Implementation/Models/CanProcessStatus.h create mode 100644 Cpp-Implementation/Models/FieldRegistration.h create mode 100644 Cpp-Implementation/Models/NodeInfoRequest.h create mode 100644 Cpp-Implementation/Models/ParameterSetRequest.h create mode 100644 Cpp-Implementation/Models/TelemetryGroupDefinition.h create mode 100644 Cpp-Implementation/Models/TelemetryGroupUpdate.h diff --git a/Cpp-Implementation/Infrastructure/CanMessage.h b/Cpp-Implementation/Infrastructure/CanMessage.h new file mode 100644 index 0000000..d76c640 --- /dev/null +++ b/Cpp-Implementation/Infrastructure/CanMessage.h @@ -0,0 +1,13 @@ +// +// Created by tobias on 24.01.26. +// + +#ifndef CANMESSAGE_H +#define CANMESSAGE_H +class CanMessage{ +public: + virtual ~CanMessage(); +protected: + CanMessage(); +}; +#endif //CANMESSAGE_H diff --git a/Cpp-Implementation/Models/CanMessageType.h b/Cpp-Implementation/Infrastructure/CanMessageType.h similarity index 100% rename from Cpp-Implementation/Models/CanMessageType.h rename to Cpp-Implementation/Infrastructure/CanMessageType.h diff --git a/Cpp-Implementation/Infrastructure/DataType.h b/Cpp-Implementation/Infrastructure/DataType.h new file mode 100644 index 0000000..f2f0e81 --- /dev/null +++ b/Cpp-Implementation/Infrastructure/DataType.h @@ -0,0 +1,17 @@ +#ifndef DATATYPE_H +#define DATATYPE_H + +#include + +enum DataType : uint8_t{ + FLOAT32 = 0, + INT32 = 1, + INT16 = 2, + INT0 = 3, + UINT32 = 4, + UINT16 = 5, + UINT8 = 6, + BOOLEAN = 7 +}; + +#endif // DATATYPE_H diff --git a/Cpp-Implementation/LiquidCan.h b/Cpp-Implementation/LiquidCan.h index df89c4f..75cf4bf 100644 --- a/Cpp-Implementation/LiquidCan.h +++ b/Cpp-Implementation/LiquidCan.h @@ -2,170 +2,4 @@ #ifndef LIQUIDCAN_H #define LIQUIDCAN_H -/* - * @brief Class profiding an interface to the Liquid CAN prodocoll - * - * This interface declass methodes to handle - * initialization, - * external parameter access - * process management - * status reporting - */ -class LiquidCan { - public: - /* - * @brief Stats the initialisation procedure for the CAN System - * - * @pre parameter and telemetrie fields must be registerd - */ - virtual void startInitProcedure(); - - /* - * @brief Updated an external parameter by id and sets a given value - * - * @tparam T datatype of the external parameter - * @param id identifier of the external parameter - * @param data Value to set the external parameter - * - * @pre LiquidCan system must bei initialized - * @pre id must be correspond to a existing external id - * @post A CanProcess is started witch awaits the verification of the parameter update - * - * @returns processId witch tracks the response status and value - */ - template - virtual int updateExternalParameter(int id, T data); - - /* - * @brief Retreives the value ot an external parameter - * - * @tparam T datatype of the external parameter - * @param id identifier of the external parameter - * @param data reference to store retreived data - * - * @pre LiquidCan system must bei initialized - * @pre id must be correspond to a existing external id - * @post A CanProcess is started witch awaits the verification of the parameter update - * - * @returns processId witch tracks the response status - */ - template - virtual int getExternalParameter(int id, T &data); - - /* - * @brief Locks an external parameter - * - * @param id identifier of the external parameter - * - * @pre LiquidCan system must bei initialized - * @pre id must be correspond to a existing external id - * @post A CanProcess is started witch awaits the verification of the parameter update - * - * @returns processId witch tracks the response status - */ - virtual int lockExternalParameter(int id) - - /* - * @brief Unlocks an external parameter - * - * @param id identifier of the external parameter - * - * @pre LiquidCan system must bei initialized - * @pre id must be correspond to a existing external id - * @post A CanProcess is started witch awaits the verification of the parameter update - * - * @returns processId witch tracks the response status - */ - virtual int unlockExternalParameter(int id); - - /* - * @brief Sends an information status message - * - * @param message as string - * - * @pre LiquidCan system must bei initialized - */ - virtual void sendInfoStatus(std::string message); - - /* - * @brief Sends an warning status message - * - * @param message as string - * - * @pre LiquidCan system must bei initialized - */ - virtual void sendWarningStatus(std::string message); - - /* - * @brief Sends an error status message - * - * @param message as string - * - * @pre LiquidCan system must bei initialized - */ - virtual void sendErrorStatus(std::string message); - - /* - * @brief Retreives external fieldId by name - * - * @param name Name of the external field - * - * @pre LiquidCan system must bei initialized - * @post A CanProcess is started witch awaits the verification of the parameter update - * - * @returns processId witch tracks the response status - */ - virtual int lookupFieldIdByName(std::string name); - - /* - * @brief Returns the value of a finished CanProcess - * - * @tparam T datatype of the response - * @param id identifier of the CanProcess - * - * @pre id must be correspond to a existing CanProcess - * @pre CanProcess muss have the status DONE - * - * @returns Value to CanProcess or nullptr (if not ready or failed) - */ - template - virtual T* getProcessResponse(int processId); - - /* - * @brief Checks if the response of a CanProcess is read - * - * @param id identifier of the CanProcess - * - * @pre id must be correspond to a existing CanProcess - * - * @returns Returns true if the CanProcess has status Done - */ - virtual bool isProcessReady(int processId); - - /* - * @brief Checks if a CanProcess is active - * - * @param id identifier of the CanProcess - * - * @pre id must be correspond to a existing CanProcess - * - * @returns Returns true if the CanProcess has status Started - */ - virtual bool isProcessActive(int processId); - - /* - * @brief Checks if a CanProcess is falied - * - * @param id identifier of the CanProcess - * - * @pre id must be correspond to a existing CanProcess - * - * @returns Returns true if the CanProcess has status Error - */ - virtual bool isProcessFailed(int processId); - - private: - // Disable coping - LiquidCan(LiquidCan const &); - LiquidCan& operator=(LiquidCan const &); -} \ No newline at end of file +#endif //LIQUIDCAN_H \ No newline at end of file diff --git a/Cpp-Implementation/Models/CanProcess.h b/Cpp-Implementation/Models/CanProcess.h deleted file mode 100644 index 198cd5b..0000000 --- a/Cpp-Implementation/Models/CanProcess.h +++ /dev/null @@ -1,97 +0,0 @@ -// -// Created by tobias on 17.01.26. -// - -#ifndef CANPROCESS_H -#define CANPROCESS_H - -#include -#include - -/* - * @brief Template class for CAN-Process Management - * - * This class stores the status and value of a given CAN process and - * allows querying the process type and value - * - * @tparam T Datatype of the expected value of the CAN-Process e.g. int or float - */ -template -class CanProcess { - public: - /* - * @brief Construct a CAN process with the specified MessageTypes - * - * @param processType is the CanMessageType of the message witch started the process - * @param responseType is the CanMessageType of the expected response message - * @param fieldId is the optinal field identifier used to further link the process to a message, defaults to 0 - * - * @post Process is initialized with - * status = started - * value = default - * processType, responseType and fieldId set - */ - CanProcess(CanMessageType processType, CanMessageType responseType, int fieldId = 0); - - /* - * @brief Sets the status of the CAN process - * - * @param status is the new status to set - * - * @pre The status must be "NEW" in order to be canged - * @post The internal process status is updated - */ - virtual void setStatus(CanProcessStatus status); - - /* - * @brief Returns the current status of a the CAN process - * - * @return Current CanProcessStatus fo the process - */ - virtual CanProcessStatus getStatus(); - - /* - * @brief Sets the value ot the CAN process - * - * @param value is the new value of type T - * - * @post The internal value is updated - */ - virtual void setValue(T value); - - /* - * @brief Return the value to the CAN process - * - * @pre status must be DONE - * - * @return Current value to type T - */ - virtual T getValue(); - - /* - * @brief Returns the type of the CAN process - * - * @return CanMessageType that started the process - */ - virtual CanMessageType getProcessType(); - - /* - * @brief Returns the expected type of the response message - * - * @return Expected CanMessageType ot the response - */ - virtual CanMessageType getProcessResponseType(); - - private: - CanProcessStatus status_; - T value_; - CanMessageType processType_; - CanMessageType responseType_; - int fieldId_; - - // Disable coping - CanProcess(const CanProcess &); - CanProcess &operator=(const CanProcess &); -}; - -#endif //CANPROCESS_H diff --git a/Cpp-Implementation/Models/CanProcessStatus.h b/Cpp-Implementation/Models/CanProcessStatus.h deleted file mode 100644 index 853b522..0000000 --- a/Cpp-Implementation/Models/CanProcessStatus.h +++ /dev/null @@ -1,14 +0,0 @@ -// -// Created by tobias on 17.01.26. -// - -#ifndef CANPROCESSSTATUS_H -#define CANPROCESSSTATUS_H - -enum CanProcessStatus{ - Started = 0, - Done = 1, - Error = 2 -} - -#endif //CANPROCESSSTATUS_H diff --git a/Cpp-Implementation/Models/FieldRegistration.h b/Cpp-Implementation/Models/FieldRegistration.h new file mode 100644 index 0000000..2e95c5f --- /dev/null +++ b/Cpp-Implementation/Models/FieldRegistration.h @@ -0,0 +1,28 @@ +#ifndef FIELDREGISTRATION_H +#define FIELDREGISTRATION_H + +#include +#include +#include + +class FieldRegistration : public CanMessage{ +public: + FieldRegistration(); + FieldRegistration(uint8_t field_id, DataType field_type, const char* device_name); + + bool setFieldId(uint8_t field_id); + uint8_t getFieldId(); + + bool setFieldType(DataType field_type); + DataType getFieldType(); + + bool setFieldName(const char* field_name); + const char* getFieldName() const; + +private: + uint8_t field_id_; // Unique identifier for this field + DataType field_type_; // Field DataType + char field_name_[63]; // Human-readable field name +}; + +#endif // FIELDREGISTRATION_H diff --git a/Cpp-Implementation/Models/NodeInfoRequest.h b/Cpp-Implementation/Models/NodeInfoRequest.h new file mode 100644 index 0000000..f105df5 --- /dev/null +++ b/Cpp-Implementation/Models/NodeInfoRequest.h @@ -0,0 +1,45 @@ +// +// Created by tobias on 24.01.26. +// + +#ifndef NODEINFOREQUEST_H +#define NODEINFOREQUEST_H + +#include +#include + +class NodeInfoRequest : public CanMessage{ +public: + NodeInfoRequest(); + NodeInfoRequest(uint8_t tel_cnt, + uint8_t par_cnt, + uint32_t firmware_hash, + uint32_t liquid_hash, + const char* device_name); + + bool setTelemetryCount(uint8_t tel_cnt); + uint8_t getTelemetryCount() const; + + bool setParameterCount(uint8_t par_cnt); + uint8_t getParameterCount() const; + + bool setFirmwareHash(uint32_t firmware_hash); + uint32_t getFirmwareHash() const; + + bool setLiquidHash(uint32_t liquid_hash); + uint32_t getLiquidHash() const; + + bool setDeviceName(const char* device_name, uint8_t device_name_length); + const char* getDeviceName() const; + uint8_t getDeviceNameLength() const; + +private: + uint8_t tel_cnt_; // Number of telemetryValues on this node + uint8_t par_cnt_; // Number of parameters ot his node + uint32_t firmware_hash_; // Hash of the firmware version + uint32_t liquid_hash_; // Hash of the LiquidCan protocol version + uint8_t device_name_length; // Internal counter to track device_name length + char device_name_[53]; // Human-readable device name +}; + +#endif //NODEINFOREQUEST_H diff --git a/Cpp-Implementation/Models/ParameterSetRequest.h b/Cpp-Implementation/Models/ParameterSetRequest.h new file mode 100644 index 0000000..80454ae --- /dev/null +++ b/Cpp-Implementation/Models/ParameterSetRequest.h @@ -0,0 +1,25 @@ +#ifndef PARAMETERSETREQUEST_H +#define PARAMETERSETREQUEST_H + +#include +#include + +class ParameterSetReq : public CanMessage { +public: + ParameterSetReq(); + ParameterSetReq(uint8_t parameter_id, const uint8_t* value, uint8_t value_length); + + bool setParameterId(uint8_t id); + uint8_t getParameterId() const; + + bool setParameterValue(uint8_t value, uint8_t value_length); + uint8_t* getParameterValue() const; + uint8_t getParameterValueLength() const; + +private: + uint8_t parameter_id_; // Parameter identifier + uint8_t value_length_; // Internal Counter to track length of the value field + uint8_t value_[61]; // New value +}; + +#endif // PARAMETERSETREQUEST_H diff --git a/Cpp-Implementation/Models/TelemetryGroupDefinition.h b/Cpp-Implementation/Models/TelemetryGroupDefinition.h new file mode 100644 index 0000000..943689b --- /dev/null +++ b/Cpp-Implementation/Models/TelemetryGroupDefinition.h @@ -0,0 +1,26 @@ +#ifndef TELEMETRYGROUPDEFINITION_H +#define TELEMETRYGROUPDEFINITION_H + +#include +#include + +class TelemetryGroupDefinition : public CanMessage { +public: + TelemetryGroupDefinition(); + TelemetryGroupDefinition(uint8_t group_id, const uint8_t* field_ids, uint8_t field_count); + + bool setGroupId(uint8_t group_id); + uint8_t getGroupId() const; + + bool addGroupFieldId(uint8_t field_id); + bool setGroupFieldIds(const uint8_t* field_ids, uint8_t field_count); + uint8_t* getGroupFieldIds() const; + uint8_t getGroupFieldCount() const; + +private: + uint8_t group_id_; // Unique identifier for this group + uint8_t field_count_; // Internal Counter to track number of fields + uint8_t field_ids_[62]; // Array of field IDs in this group +}; + +#endif // TELEMETRYGROUPDEFINITION_H diff --git a/Cpp-Implementation/Models/TelemetryGroupUpdate.h b/Cpp-Implementation/Models/TelemetryGroupUpdate.h new file mode 100644 index 0000000..1db7ac7 --- /dev/null +++ b/Cpp-Implementation/Models/TelemetryGroupUpdate.h @@ -0,0 +1,24 @@ +#ifndef TELEMETRYGROUPUPDATE_H +#define TELEMETRYGROUPUPDATE_H + +#include +#include + +class TelemetryGroupUpdate : public CanMessage { +public: + TelemetryGroupUpdate(); + TelemetryGroupUpdate(uint8_t group_id, const uint8_t* values, uint8_t value_count); + + bool setGroupId(uint8_t group_id); + uint8_t getGroupId() const; + + bool setGroupValues(uint8_t* values, uint8_t value_count); + uint8_t* getGroupValues() const; + uint8_t getGroupValueLength() const; +private: + uint8_t group_id_; // Group identifier + uint8_t value_length_; // Internal Counter to track length of the value field + uint8_t values_[62]; // Packed values of all telemetry value in the group +}; + +#endif // TELEMETRYGROUPUPDATE_H From 9ae2bdd1d5a641fbb3ab993a557603872a014692 Mon Sep 17 00:00:00 2001 From: Z3r0z0 Date: Fri, 30 Jan 2026 17:48:35 +0100 Subject: [PATCH 3/7] added models --- .../Infrastructure/CanMessage.h | 9 ++-- .../Infrastructure/CanMessageType.h | 45 ++++++++-------- Cpp-Implementation/Infrastructure/DataType.h | 19 +++---- .../Infrastructure/ParameterSetStatus.h | 18 +++++++ Cpp-Implementation/Models/FieldGetRequest.h | 23 +++++++++ Cpp-Implementation/Models/FieldGetResult.h | 29 +++++++++++ .../Models/FieldIdLookupRequest.h | 25 +++++++++ .../Models/FieldIdLookupResult.h | 29 +++++++++++ Cpp-Implementation/Models/FieldRegistration.h | 28 +++++----- Cpp-Implementation/Models/HeartBeat.h | 25 +++++++++ Cpp-Implementation/Models/NodeInfoRequest.h | 51 ++++++++++--------- .../Models/ParameterSetConfirmation.h | 37 ++++++++++++++ Cpp-Implementation/Models/ParameterSetLock.h | 27 ++++++++++ .../Models/ParameterSetRequest.h | 18 +++---- Cpp-Implementation/Models/Status.h | 25 +++++++++ .../Models/TelemetryGroupDefinition.h | 26 +++++----- .../Models/TelemetryGroupUpdate.h | 17 ++++--- 17 files changed, 350 insertions(+), 101 deletions(-) create mode 100644 Cpp-Implementation/Infrastructure/ParameterSetStatus.h create mode 100644 Cpp-Implementation/Models/FieldGetRequest.h create mode 100644 Cpp-Implementation/Models/FieldGetResult.h create mode 100644 Cpp-Implementation/Models/FieldIdLookupRequest.h create mode 100644 Cpp-Implementation/Models/FieldIdLookupResult.h create mode 100644 Cpp-Implementation/Models/HeartBeat.h create mode 100644 Cpp-Implementation/Models/ParameterSetConfirmation.h create mode 100644 Cpp-Implementation/Models/ParameterSetLock.h create mode 100644 Cpp-Implementation/Models/Status.h diff --git a/Cpp-Implementation/Infrastructure/CanMessage.h b/Cpp-Implementation/Infrastructure/CanMessage.h index d76c640..2670fa6 100644 --- a/Cpp-Implementation/Infrastructure/CanMessage.h +++ b/Cpp-Implementation/Infrastructure/CanMessage.h @@ -4,10 +4,13 @@ #ifndef CANMESSAGE_H #define CANMESSAGE_H -class CanMessage{ + +class Can_message +{ public: - virtual ~CanMessage(); + virtual ~Can_message() = default; protected: - CanMessage(); + Can_message() = default; }; + #endif //CANMESSAGE_H diff --git a/Cpp-Implementation/Infrastructure/CanMessageType.h b/Cpp-Implementation/Infrastructure/CanMessageType.h index e07d4f3..f51eb40 100644 --- a/Cpp-Implementation/Infrastructure/CanMessageType.h +++ b/Cpp-Implementation/Infrastructure/CanMessageType.h @@ -4,25 +4,28 @@ #ifndef MESSAGETYPE_H #define MESSAGETYPE_H -enum CanMessageType { - NODE_INFO_REQUEST = 0, - NODE_INFO_ANOUNCEMENT = 1, - INFO_STATUS = 10, - WARNING_STATUS = 11, - ERROR_STATUS = 12, - TELEMETRY_VALUE_REGISTRATION = 20, - PARAMETER_REGISTRATION = 21, - TELEMETRY_GROUP_DEFINTION = 30, - TELEMETRY_GROUP_UPDATE = 31, - HEARTBEAT_REQUEST = 40, - HEARTBEAT_RESPONSE = 41, - PARAMETER_SET_REQUEST = 50, - PARAMETER_SET_CONFIRMATION = 51, - PARAMETER_SET_LOCK_REQUEST = 52, - PARAMETER_SET_LOCK_CONFIRMATION = 53, - FIELD_GET_REQUEST = 60, - FIELD_GET_RESPONSE = 61, - FIELD_ID_LOOKUP_REQUEST = 62, - FIELD_ID_LOOKUP_RESPONSE = 63, -} + +enum Can_message_type +{ + node_info_request = 0, // Request node information + node_info_announcement = 1, // Response with node capabilities and identification + info_status = 10, // Information status message + warning_status = 11, // Warning status message + error_status = 12, // Error status message + telemetry_value_registration = 20, // Register a telemetry Value field + parameter_registration = 21, // Register a parameter field + telemetry_group_definition = 30, // Define a group of fields for batch updates + telemetry_group_update = 31, // Update values for a field group + heartbeat_request = 40, // Heartbeat request + heartbeat_response = 41, // Heartbeat response + parameter_set_request = 50, // Request to set a parameter value + parameter_set_confirmation = 51, // Response with confirmed parameter value + parameter_set_lock_request = 52, // Request to lock a parameter + parameter_set_lock_confirmation = 53, // Response confirming parameter lock + field_get_request = 60, // Request field value + field_get_response = 61, // Response with field value + field_id_lookup_request = 62, // Request the fieldID of a field name + field_id_lookup_response = 63 // Response with fieldID +}; + #endif //MESSAGETYPE_H \ No newline at end of file diff --git a/Cpp-Implementation/Infrastructure/DataType.h b/Cpp-Implementation/Infrastructure/DataType.h index f2f0e81..94300b0 100644 --- a/Cpp-Implementation/Infrastructure/DataType.h +++ b/Cpp-Implementation/Infrastructure/DataType.h @@ -3,15 +3,16 @@ #include -enum DataType : uint8_t{ - FLOAT32 = 0, - INT32 = 1, - INT16 = 2, - INT0 = 3, - UINT32 = 4, - UINT16 = 5, - UINT8 = 6, - BOOLEAN = 7 +enum Data_type : uint8_t +{ + float32 = 0, + int32 = 1, + int16 = 2, + int8 = 3, + uint32 = 4, + uint16 = 5, + uint8 = 6, + boolean = 7 }; #endif // DATATYPE_H diff --git a/Cpp-Implementation/Infrastructure/ParameterSetStatus.h b/Cpp-Implementation/Infrastructure/ParameterSetStatus.h new file mode 100644 index 0000000..f620432 --- /dev/null +++ b/Cpp-Implementation/Infrastructure/ParameterSetStatus.h @@ -0,0 +1,18 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef PARAMETERSETSTATUS_H +#define PARAMETERSETSTATUS_H + +#include + +enum Parameter_set_status : uint8_t +{ + success = 0, // Parameter was successfully set + invalid_parameter_id = 1, // The Parameter ID does not exist + parameter_locked = 2, // The parameter is locked and cannot be modified + node_to_node_modification = 3 // The parameter was modified by another node +}; + +#endif //PARAMETERSETSTATUS_H diff --git a/Cpp-Implementation/Models/FieldGetRequest.h b/Cpp-Implementation/Models/FieldGetRequest.h new file mode 100644 index 0000000..b975518 --- /dev/null +++ b/Cpp-Implementation/Models/FieldGetRequest.h @@ -0,0 +1,23 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef FIELDGETREQUEST_H +#define FIELDGETREQUEST_H + +#include +#include + +class Field_get_request : public Can_message +{ +public: + Field_get_request(); + Field_get_request(uint8_t field_id); + + bool set_field_id(uint8_t field_id); + uint8_t get_field_id() const; +private: + uint8_t field_id_; // Field identifier +}; + +#endif //FIELDGETREQUEST_H diff --git a/Cpp-Implementation/Models/FieldGetResult.h b/Cpp-Implementation/Models/FieldGetResult.h new file mode 100644 index 0000000..5a826f9 --- /dev/null +++ b/Cpp-Implementation/Models/FieldGetResult.h @@ -0,0 +1,29 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef FIELDGETRESULT_H +#define FIELDGETRESULT_H + +#include +#include + +class Field_get_result : public Can_message +{ +public: + Field_get_result(); + Field_get_result(uint8_t field_id, const uint8_t* value, uint8_t length); + + bool set_field_id(uint8_t field_id); + uint8_t get_field_id() const; + + bool set_value(const uint8_t* value, uint8_t length); + const uint8_t* get_value() const; + uint8_t get_value_length() const; +private: + uint8_t field_id_; // Field identifier + uint8_t value_length_; // Field value length + uint8_t value_[62]; // Field value +}; + +#endif //FIELDGETRESULT_H diff --git a/Cpp-Implementation/Models/FieldIdLookupRequest.h b/Cpp-Implementation/Models/FieldIdLookupRequest.h new file mode 100644 index 0000000..1548f28 --- /dev/null +++ b/Cpp-Implementation/Models/FieldIdLookupRequest.h @@ -0,0 +1,25 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef FIELDIDLOOKUPREQUEST_H +#define FIELDIDLOOKUPREQUEST_H + +#include +#include + +class Field_id_lookup_request : public Can_message +{ +public: + Field_id_lookup_request(); + Field_id_lookup_request(const uint8_t* field_name, uint8_t length); + + bool set_field_name(const uint8_t* field_name, uint8_t length); + const uint8_t* get_field_name() const; + uint8_t get_field_name_length() const; +private: + uint8_t field_name_length_; // Field name length + uint8_t field_name_[61]; // Field name +}; + +#endif //FIELDIDLOOKUPREQUEST_H diff --git a/Cpp-Implementation/Models/FieldIdLookupResult.h b/Cpp-Implementation/Models/FieldIdLookupResult.h new file mode 100644 index 0000000..0c493bb --- /dev/null +++ b/Cpp-Implementation/Models/FieldIdLookupResult.h @@ -0,0 +1,29 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef FIELDIDLOOKUPRESULT_H +#define FIELDIDLOOKUPRESULT_H + +#include +#include +#include + + +class Field_id_lookup_result : public Can_message +{ +public: + Field_id_lookup_result(); + Field_id_lookup_result(uint8_t field_id, Data_type data_type); + + bool set_field_id(uint8_t field_id); + uint8_t get_field_id() const; + + bool set_data_type(Data_type data_type); + Data_type get_data_type() const; +private: + uint8_t field_id_; // Field ID + Data_type field_type_; // Field data type +}; + +#endif //FIELDIDLOOKUPRESULT_H diff --git a/Cpp-Implementation/Models/FieldRegistration.h b/Cpp-Implementation/Models/FieldRegistration.h index 2e95c5f..79220e5 100644 --- a/Cpp-Implementation/Models/FieldRegistration.h +++ b/Cpp-Implementation/Models/FieldRegistration.h @@ -5,24 +5,26 @@ #include #include -class FieldRegistration : public CanMessage{ +class Field_registration : public Can_message +{ public: - FieldRegistration(); - FieldRegistration(uint8_t field_id, DataType field_type, const char* device_name); + Field_registration(); + Field_registration(uint8_t field_id, Data_type field_type, const uint8_t* device_name, uint8_t length); - bool setFieldId(uint8_t field_id); - uint8_t getFieldId(); + bool set_field_id(uint8_t field_id); + uint8_t get_field_id() const; - bool setFieldType(DataType field_type); - DataType getFieldType(); - - bool setFieldName(const char* field_name); - const char* getFieldName() const; + bool set_field_type(Data_type field_type); + Data_type get_field_type() const; + bool set_field_name(const uint8_t* field_name, uint8_t length); + const uint8_t* get_field_name() const; + uint8_t get_field_name_length() const; private: - uint8_t field_id_; // Unique identifier for this field - DataType field_type_; // Field DataType - char field_name_[63]; // Human-readable field name + uint8_t field_id_; // Unique identifier for this field + Data_type field_type_; // Field data type + uint8_t field_name_length_; // Field name length + uint8_t field_name_[63]; // Human-readable field name }; #endif // FIELDREGISTRATION_H diff --git a/Cpp-Implementation/Models/HeartBeat.h b/Cpp-Implementation/Models/HeartBeat.h new file mode 100644 index 0000000..fb8961f --- /dev/null +++ b/Cpp-Implementation/Models/HeartBeat.h @@ -0,0 +1,25 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef HEARTBEAT_H +#define HEARTBEAT_H + +#include +#include + +class Heart_beat : public Can_message +{ +public: + Heart_beat(); + Heart_beat(uint32_t counter); + + uint32_t set_counter(uint32_t value); + uint32_t get_counter() const; + + Heart_beat& operator++(); +private: + uint32_t counter_; // Incrementing counter value +}; + +#endif //HEARTBEAT_H diff --git a/Cpp-Implementation/Models/NodeInfoRequest.h b/Cpp-Implementation/Models/NodeInfoRequest.h index f105df5..5fa0929 100644 --- a/Cpp-Implementation/Models/NodeInfoRequest.h +++ b/Cpp-Implementation/Models/NodeInfoRequest.h @@ -8,38 +8,39 @@ #include #include -class NodeInfoRequest : public CanMessage{ +class Node_info_request : public Can_message +{ public: - NodeInfoRequest(); - NodeInfoRequest(uint8_t tel_cnt, - uint8_t par_cnt, - uint32_t firmware_hash, - uint32_t liquid_hash, - const char* device_name); + Node_info_request(); + Node_info_request(uint8_t tel_cnt, + uint8_t par_cnt, + uint32_t firmware_hash, + uint32_t liquid_hash, + const uint8_t* device_name, + uint8_t length); - bool setTelemetryCount(uint8_t tel_cnt); - uint8_t getTelemetryCount() const; + bool set_telemetry_count(uint8_t tel_cnt); + uint8_t get_telemetry_count() const; - bool setParameterCount(uint8_t par_cnt); - uint8_t getParameterCount() const; + bool set_parameter_count(uint8_t par_cnt); + uint8_t get_parameter_count() const; - bool setFirmwareHash(uint32_t firmware_hash); - uint32_t getFirmwareHash() const; + bool set_firmware_hash(uint32_t firmware_hash); + uint32_t get_firmware_hash() const; - bool setLiquidHash(uint32_t liquid_hash); - uint32_t getLiquidHash() const; - - bool setDeviceName(const char* device_name, uint8_t device_name_length); - const char* getDeviceName() const; - uint8_t getDeviceNameLength() const; + bool set_liquid_hash(uint32_t liquid_hash); + uint32_t get_liquid_hash() const; + bool set_device_name(const uint8_t* device_name, uint8_t length); + const uint8_t* get_device_name() const; + uint8_t get_device_name_length() const; private: - uint8_t tel_cnt_; // Number of telemetryValues on this node - uint8_t par_cnt_; // Number of parameters ot his node - uint32_t firmware_hash_; // Hash of the firmware version - uint32_t liquid_hash_; // Hash of the LiquidCan protocol version - uint8_t device_name_length; // Internal counter to track device_name length - char device_name_[53]; // Human-readable device name + uint8_t tel_cnt_; // Number of telemetry values on this node + uint8_t par_cnt_; // Number of parameters on this node + uint32_t firmware_hash_; // Hash of the firmware version + uint32_t liquid_hash_; // Hash of the LiquidCan protocol version + uint8_t device_name_length_; // Internal counter to track device_name length + uint8_t device_name_[53]; // Human-readable device name }; #endif //NODEINFOREQUEST_H diff --git a/Cpp-Implementation/Models/ParameterSetConfirmation.h b/Cpp-Implementation/Models/ParameterSetConfirmation.h new file mode 100644 index 0000000..ce54edb --- /dev/null +++ b/Cpp-Implementation/Models/ParameterSetConfirmation.h @@ -0,0 +1,37 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef PARAMETERSETCONFIRMATION_H +#define PARAMETERSETCONFIRMATION_H + +#include +#include +#include + +class Parameter_set_confirmation : public Can_message +{ +public: + Parameter_set_confirmation(); + Parameter_set_confirmation(uint8_t parameter_id, + Parameter_set_status status, + const uint8_t* value, + uint8_t length); + + bool set_parameter_id(uint8_t parameter_id); + uint8_t get_parameter_id() const; + + bool set_status(Parameter_set_status status); + Parameter_set_status get_status() const; + + bool set_value(const uint8_t* value, uint8_t length); + const uint8_t* get_value() const; + uint8_t get_value_length() const; +private: + uint8_t parameter_id_; // Parameter identifier + Parameter_set_status status_; // Status code (Parameter_set_status enum) + uint8_t value_length_; // Confirmed value length + uint8_t value_[61]; // Confirmed value after set operation +}; + +#endif //PARAMETERSETCONFIRMATION_H diff --git a/Cpp-Implementation/Models/ParameterSetLock.h b/Cpp-Implementation/Models/ParameterSetLock.h new file mode 100644 index 0000000..8f689ab --- /dev/null +++ b/Cpp-Implementation/Models/ParameterSetLock.h @@ -0,0 +1,27 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef PARAMETERSETLOCK_H +#define PARAMETERSETLOCK_H + +#include +#include + +class Parameter_set_lock : public Can_message +{ +public: + Parameter_set_lock(); + Parameter_set_lock(uint8_t parameter_id, uint8_t lock_status); + + bool set_parameter_id(uint8_t parameter_id); + uint8_t get_parameter_id() const; + + bool set_lock_status(uint8_t lock_status); + bool get_lock_status() const; +private: + uint8_t parameter_id_; // Parameter identifier to lock + uint8_t parameter_lock_status_; // Lock status (0=locked, 1=unlocked) +}; + +#endif //PARAMETERSETLOCK_H diff --git a/Cpp-Implementation/Models/ParameterSetRequest.h b/Cpp-Implementation/Models/ParameterSetRequest.h index 80454ae..c357601 100644 --- a/Cpp-Implementation/Models/ParameterSetRequest.h +++ b/Cpp-Implementation/Models/ParameterSetRequest.h @@ -4,18 +4,18 @@ #include #include -class ParameterSetReq : public CanMessage { +class Parameter_set_request : public Can_message +{ public: - ParameterSetReq(); - ParameterSetReq(uint8_t parameter_id, const uint8_t* value, uint8_t value_length); + Parameter_set_request(); + Parameter_set_request(uint8_t parameter_id, const uint8_t* value, uint8_t length); - bool setParameterId(uint8_t id); - uint8_t getParameterId() const; - - bool setParameterValue(uint8_t value, uint8_t value_length); - uint8_t* getParameterValue() const; - uint8_t getParameterValueLength() const; + bool set_parameter_id(uint8_t id); + uint8_t get_parameter_id() const; + bool set_parameter_value(const uint8_t* value, uint8_t value_length); + const uint8_t* get_parameter_value() const; + uint8_t get_parameter_value_length() const; private: uint8_t parameter_id_; // Parameter identifier uint8_t value_length_; // Internal Counter to track length of the value field diff --git a/Cpp-Implementation/Models/Status.h b/Cpp-Implementation/Models/Status.h new file mode 100644 index 0000000..6d02e3b --- /dev/null +++ b/Cpp-Implementation/Models/Status.h @@ -0,0 +1,25 @@ +// +// Created by tobias on 30.01.26. +// + +#ifndef STATUS_H +#define STATUS_H + +#include +#include + +class Status : public Can_message +{ +public: + Status(); + Status(const uint8_t* message, uint8_t length); + + bool set_message(const uint8_t *msg, uint8_t length); + const uint8_t* get_message() const; + uint8_t get_message_length() const; +private: + uint8_t msg_length_; // Length of message string + uint8_t msg_[63]; // Message string +}; + +#endif //STATUS_H diff --git a/Cpp-Implementation/Models/TelemetryGroupDefinition.h b/Cpp-Implementation/Models/TelemetryGroupDefinition.h index 943689b..8f1aa21 100644 --- a/Cpp-Implementation/Models/TelemetryGroupDefinition.h +++ b/Cpp-Implementation/Models/TelemetryGroupDefinition.h @@ -4,23 +4,23 @@ #include #include -class TelemetryGroupDefinition : public CanMessage { +class Telemetry_group_definition : public Can_message +{ public: - TelemetryGroupDefinition(); - TelemetryGroupDefinition(uint8_t group_id, const uint8_t* field_ids, uint8_t field_count); + Telemetry_group_definition(); + Telemetry_group_definition(uint8_t group_id, const uint8_t* field_ids, uint8_t field_count); - bool setGroupId(uint8_t group_id); - uint8_t getGroupId() const; - - bool addGroupFieldId(uint8_t field_id); - bool setGroupFieldIds(const uint8_t* field_ids, uint8_t field_count); - uint8_t* getGroupFieldIds() const; - uint8_t getGroupFieldCount() const; + bool set_group_id(uint8_t group_id); + uint8_t get_group_id() const; + bool add_group_field_id(uint8_t field_id); + bool set_group_field_ids(const uint8_t* field_ids, uint8_t field_count); + const uint8_t* get_group_field_ids() const; + uint8_t get_group_field_count() const; private: - uint8_t group_id_; // Unique identifier for this group - uint8_t field_count_; // Internal Counter to track number of fields - uint8_t field_ids_[62]; // Array of field IDs in this group + uint8_t group_id_; // Unique identifier for this group + uint8_t field_count_; // Internal Counter to track number of fields + uint8_t field_ids_[62]; // Array of field IDs in this group }; #endif // TELEMETRYGROUPDEFINITION_H diff --git a/Cpp-Implementation/Models/TelemetryGroupUpdate.h b/Cpp-Implementation/Models/TelemetryGroupUpdate.h index 1db7ac7..2a99985 100644 --- a/Cpp-Implementation/Models/TelemetryGroupUpdate.h +++ b/Cpp-Implementation/Models/TelemetryGroupUpdate.h @@ -4,17 +4,18 @@ #include #include -class TelemetryGroupUpdate : public CanMessage { +class Telemetry_group_update : public Can_message +{ public: - TelemetryGroupUpdate(); - TelemetryGroupUpdate(uint8_t group_id, const uint8_t* values, uint8_t value_count); + Telemetry_group_update(); + Telemetry_group_update(uint8_t group_id, const uint8_t* values, uint8_t value_count); - bool setGroupId(uint8_t group_id); - uint8_t getGroupId() const; + bool set_group_id(uint8_t group_id); + uint8_t get_group_id() const; - bool setGroupValues(uint8_t* values, uint8_t value_count); - uint8_t* getGroupValues() const; - uint8_t getGroupValueLength() const; + bool set_group_values(const uint8_t* values, uint8_t value_count); + const uint8_t* get_group_values() const; + uint8_t get_group_value_length() const; private: uint8_t group_id_; // Group identifier uint8_t value_length_; // Internal Counter to track length of the value field From 7e2ceb6ec3d43805c1f7f79d31125333b5fbda8c Mon Sep 17 00:00:00 2001 From: Z3r0z0 Date: Sat, 7 Feb 2026 17:05:24 +0100 Subject: [PATCH 4/7] added definition yaml --- .../Infrastructure/CanMessage.h | 16 -- .../Infrastructure/CanMessageType.h | 2 +- Cpp-Implementation/Models/FieldGetRequest.h | 7 - LiquidCAN.yaml | 162 ++++++++++++++++++ 4 files changed, 163 insertions(+), 24 deletions(-) delete mode 100644 Cpp-Implementation/Infrastructure/CanMessage.h create mode 100644 LiquidCAN.yaml diff --git a/Cpp-Implementation/Infrastructure/CanMessage.h b/Cpp-Implementation/Infrastructure/CanMessage.h deleted file mode 100644 index 2670fa6..0000000 --- a/Cpp-Implementation/Infrastructure/CanMessage.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// Created by tobias on 24.01.26. -// - -#ifndef CANMESSAGE_H -#define CANMESSAGE_H - -class Can_message -{ -public: - virtual ~Can_message() = default; -protected: - Can_message() = default; -}; - -#endif //CANMESSAGE_H diff --git a/Cpp-Implementation/Infrastructure/CanMessageType.h b/Cpp-Implementation/Infrastructure/CanMessageType.h index f51eb40..7136606 100644 --- a/Cpp-Implementation/Infrastructure/CanMessageType.h +++ b/Cpp-Implementation/Infrastructure/CanMessageType.h @@ -8,7 +8,7 @@ enum Can_message_type { node_info_request = 0, // Request node information - node_info_announcement = 1, // Response with node capabilities and identification + node_info_announcement = 1, // Response with node capabilities and identification info_status = 10, // Information status message warning_status = 11, // Warning status message error_status = 12, // Error status message diff --git a/Cpp-Implementation/Models/FieldGetRequest.h b/Cpp-Implementation/Models/FieldGetRequest.h index b975518..a605da2 100644 --- a/Cpp-Implementation/Models/FieldGetRequest.h +++ b/Cpp-Implementation/Models/FieldGetRequest.h @@ -10,13 +10,6 @@ class Field_get_request : public Can_message { -public: - Field_get_request(); - Field_get_request(uint8_t field_id); - - bool set_field_id(uint8_t field_id); - uint8_t get_field_id() const; -private: uint8_t field_id_; // Field identifier }; diff --git a/LiquidCAN.yaml b/LiquidCAN.yaml new file mode 100644 index 0000000..a81d7ab --- /dev/null +++ b/LiquidCAN.yaml @@ -0,0 +1,162 @@ +enum: + - name: "parameter_set_status" + type: "uint8" + values: + - name: "success" + value: 0 + - name: "invalid_parameter_id" + value: 1 + - name: "parameter_locked" + value: 2 + - name: "node_to_node_modification" + - name: "data_type" + type: "uint8" + values: + - name: "float32" + value: 0 + - name: "int32" + value: 1 + - name: "int16" + value: 2 + - name: "int8" + value: 3 + - name: "uint32" + value: 4 + - name: "uint16" + value: 5 + - name: "uint8" + value: 6 + - name: "boolean" + value: 7 + - name: "message_type" + type: "uint8" + values: + - name: "node_info_req" + value: 0 + - name: "node_info_announcement" + value: 1 + - name: "info_status" + value: 10 + - name: "warning_status" + value: 11 + - name: "error_status" + value: 12 + - name: "telemetry_value_registration" + value: 20 + - name: "parameter_registration" + value: 21 + - name: "telemetry_group_definition" + value: 30 + - name: "telemetry_group_update" + value: 31 + - name: "heartbeat_req" + value: 40 + - name: "heartbeat_res" + value: 41 + - name: "parameter_set_req" + value: 50 + - name: "parameter_set_confirmation" + value: 51 + - name: "parameter_set_lock" + value: 52 + - name: "parameter_set_lock_confirmation" + value: 53 + - name: "field_get_req" + value: 60 + - name: "field_get_res" + value: 61 + - name: "field_id_lookup_req" + value: 62 + - name: "field_id_lookup_res" + value: 63 + +struct: + - name: "node_info_res" + fields: + - name: "tel_cnt" + type: "uint8" + - name: "par_cnt" + type: "uint8" + - name: "firmware_hash" + type: "uint32" + - name: "liquid_hash" + type: "uint32" + - name: "device_name" + type: "char" + length: 53 + - name: "status" + fields: + - name: "msg" + type: "char" + length: 63 + - name: "field_registration" + fields: + - name: "field_id" + type: "uint8" + - name: "field_type" + type: "uint8" + - name: "field_name" + type: "char" + length: 61 + - name: "telemetry_group_definition" + fields: + - name: "group_id" + type: "uint8" + - name: "field_ids" + type: "uint8" + length: 62 + - name: "telemetry_group_update" + fields: + - name: "group_id" + type: "uint8" + - name: "values" + type: "uint8" + length: 62 + - name: "heart_beat" + fields: + - name: "counter" + type: "uint32" + - name: "parameter_set_req" + fields: + - name: "parameter_id" + type: "uint8" + - name: "value" + type: "uint8" + length: 61 + - name: "parameter_set_confirmation" + fields: + - name: "parameter_id" + type: "uint8" + - name: "status" + type: "parameter_set_status" + - name: "value" + type: "uint8" + length: 61 + - name: "field_get_req" + fields: + - name: "field_id" + type: "uint8" + - name: "field_get_res" + fields: + - name: "field_id" + type: "uint8" + - name: "value" + type: "uint8" + length: 62 + - name: "field_ID_lookup_req" + fields: + - name: "field_name" + type: "uint8" + length: 61 + - name: "field_ID_lookup_res" + fields: + - name: "field_id" + type: "uint8" + - name: "field_type" + type: "data_type" + - name: "parameter_set_lock" + fields: + - name: "parameter_id" + type: "uint8" + - name: "lock_status" + type: "uint8" \ No newline at end of file From c432e3c7e440da58928add461806e751f6da7e28 Mon Sep 17 00:00:00 2001 From: Z3r0z0 Date: Sat, 7 Feb 2026 20:46:45 +0100 Subject: [PATCH 5/7] added generator --- .../Infrastructure/CanMessageType.h | 31 ---- Cpp-Implementation/Infrastructure/DataType.h | 22 +-- .../Infrastructure/ParameterSetStatus.h | 18 +- Cpp-Implementation/Models/FieldGetRequest.h | 16 -- Cpp-Implementation/Models/FieldGetResult.h | 29 ---- .../Models/FieldIdLookupRequest.h | 25 --- .../Models/FieldIdLookupResult.h | 29 ---- Cpp-Implementation/Models/FieldRegistration.h | 30 ---- Cpp-Implementation/Models/HeartBeat.h | 25 --- Cpp-Implementation/Models/NodeInfoRequest.h | 46 ----- .../Models/ParameterSetConfirmation.h | 37 ---- Cpp-Implementation/Models/ParameterSetLock.h | 27 --- .../Models/ParameterSetRequest.h | 25 --- Cpp-Implementation/Models/Status.h | 25 --- .../Models/TelemetryGroupDefinition.h | 26 --- .../Models/TelemetryGroupUpdate.h | 25 --- LiquidCAN.yaml | 5 +- LiquidCAN_generator.py | 159 ++++++++++++++++++ 18 files changed, 180 insertions(+), 420 deletions(-) delete mode 100644 Cpp-Implementation/Infrastructure/CanMessageType.h delete mode 100644 Cpp-Implementation/Models/FieldGetRequest.h delete mode 100644 Cpp-Implementation/Models/FieldGetResult.h delete mode 100644 Cpp-Implementation/Models/FieldIdLookupRequest.h delete mode 100644 Cpp-Implementation/Models/FieldIdLookupResult.h delete mode 100644 Cpp-Implementation/Models/FieldRegistration.h delete mode 100644 Cpp-Implementation/Models/HeartBeat.h delete mode 100644 Cpp-Implementation/Models/NodeInfoRequest.h delete mode 100644 Cpp-Implementation/Models/ParameterSetConfirmation.h delete mode 100644 Cpp-Implementation/Models/ParameterSetLock.h delete mode 100644 Cpp-Implementation/Models/ParameterSetRequest.h delete mode 100644 Cpp-Implementation/Models/Status.h delete mode 100644 Cpp-Implementation/Models/TelemetryGroupDefinition.h delete mode 100644 Cpp-Implementation/Models/TelemetryGroupUpdate.h create mode 100644 LiquidCAN_generator.py diff --git a/Cpp-Implementation/Infrastructure/CanMessageType.h b/Cpp-Implementation/Infrastructure/CanMessageType.h deleted file mode 100644 index 7136606..0000000 --- a/Cpp-Implementation/Infrastructure/CanMessageType.h +++ /dev/null @@ -1,31 +0,0 @@ -// -// Created by tobias on 19.01.26. -// - -#ifndef MESSAGETYPE_H -#define MESSAGETYPE_H - -enum Can_message_type -{ - node_info_request = 0, // Request node information - node_info_announcement = 1, // Response with node capabilities and identification - info_status = 10, // Information status message - warning_status = 11, // Warning status message - error_status = 12, // Error status message - telemetry_value_registration = 20, // Register a telemetry Value field - parameter_registration = 21, // Register a parameter field - telemetry_group_definition = 30, // Define a group of fields for batch updates - telemetry_group_update = 31, // Update values for a field group - heartbeat_request = 40, // Heartbeat request - heartbeat_response = 41, // Heartbeat response - parameter_set_request = 50, // Request to set a parameter value - parameter_set_confirmation = 51, // Response with confirmed parameter value - parameter_set_lock_request = 52, // Request to lock a parameter - parameter_set_lock_confirmation = 53, // Response confirming parameter lock - field_get_request = 60, // Request field value - field_get_response = 61, // Response with field value - field_id_lookup_request = 62, // Request the fieldID of a field name - field_id_lookup_response = 63 // Response with fieldID -}; - -#endif //MESSAGETYPE_H \ No newline at end of file diff --git a/Cpp-Implementation/Infrastructure/DataType.h b/Cpp-Implementation/Infrastructure/DataType.h index 94300b0..02d237d 100644 --- a/Cpp-Implementation/Infrastructure/DataType.h +++ b/Cpp-Implementation/Infrastructure/DataType.h @@ -3,16 +3,16 @@ #include -enum Data_type : uint8_t +enum DataType : uint8_t { - float32 = 0, - int32 = 1, - int16 = 2, - int8 = 3, - uint32 = 4, - uint16 = 5, - uint8 = 6, - boolean = 7 -}; + Float32 = 0, + Int32 = 1, + Int16 = 2, + Int8 = 3, + Uint32 = 4, + Uint16 = 5, + Uint8 = 6, + Boolean = 7, +} -#endif // DATATYPE_H +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Infrastructure/ParameterSetStatus.h b/Cpp-Implementation/Infrastructure/ParameterSetStatus.h index f620432..0e2eb71 100644 --- a/Cpp-Implementation/Infrastructure/ParameterSetStatus.h +++ b/Cpp-Implementation/Infrastructure/ParameterSetStatus.h @@ -1,18 +1,14 @@ -// -// Created by tobias on 30.01.26. -// - #ifndef PARAMETERSETSTATUS_H #define PARAMETERSETSTATUS_H #include -enum Parameter_set_status : uint8_t +enum ParameterSetStatus : uint8_t { - success = 0, // Parameter was successfully set - invalid_parameter_id = 1, // The Parameter ID does not exist - parameter_locked = 2, // The parameter is locked and cannot be modified - node_to_node_modification = 3 // The parameter was modified by another node -}; + Success = 0, + InvalidParameterId = 1, + ParameterLocked = 2, + NodeToNodeModification = 3, +} -#endif //PARAMETERSETSTATUS_H +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Models/FieldGetRequest.h b/Cpp-Implementation/Models/FieldGetRequest.h deleted file mode 100644 index a605da2..0000000 --- a/Cpp-Implementation/Models/FieldGetRequest.h +++ /dev/null @@ -1,16 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef FIELDGETREQUEST_H -#define FIELDGETREQUEST_H - -#include -#include - -class Field_get_request : public Can_message -{ - uint8_t field_id_; // Field identifier -}; - -#endif //FIELDGETREQUEST_H diff --git a/Cpp-Implementation/Models/FieldGetResult.h b/Cpp-Implementation/Models/FieldGetResult.h deleted file mode 100644 index 5a826f9..0000000 --- a/Cpp-Implementation/Models/FieldGetResult.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef FIELDGETRESULT_H -#define FIELDGETRESULT_H - -#include -#include - -class Field_get_result : public Can_message -{ -public: - Field_get_result(); - Field_get_result(uint8_t field_id, const uint8_t* value, uint8_t length); - - bool set_field_id(uint8_t field_id); - uint8_t get_field_id() const; - - bool set_value(const uint8_t* value, uint8_t length); - const uint8_t* get_value() const; - uint8_t get_value_length() const; -private: - uint8_t field_id_; // Field identifier - uint8_t value_length_; // Field value length - uint8_t value_[62]; // Field value -}; - -#endif //FIELDGETRESULT_H diff --git a/Cpp-Implementation/Models/FieldIdLookupRequest.h b/Cpp-Implementation/Models/FieldIdLookupRequest.h deleted file mode 100644 index 1548f28..0000000 --- a/Cpp-Implementation/Models/FieldIdLookupRequest.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef FIELDIDLOOKUPREQUEST_H -#define FIELDIDLOOKUPREQUEST_H - -#include -#include - -class Field_id_lookup_request : public Can_message -{ -public: - Field_id_lookup_request(); - Field_id_lookup_request(const uint8_t* field_name, uint8_t length); - - bool set_field_name(const uint8_t* field_name, uint8_t length); - const uint8_t* get_field_name() const; - uint8_t get_field_name_length() const; -private: - uint8_t field_name_length_; // Field name length - uint8_t field_name_[61]; // Field name -}; - -#endif //FIELDIDLOOKUPREQUEST_H diff --git a/Cpp-Implementation/Models/FieldIdLookupResult.h b/Cpp-Implementation/Models/FieldIdLookupResult.h deleted file mode 100644 index 0c493bb..0000000 --- a/Cpp-Implementation/Models/FieldIdLookupResult.h +++ /dev/null @@ -1,29 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef FIELDIDLOOKUPRESULT_H -#define FIELDIDLOOKUPRESULT_H - -#include -#include -#include - - -class Field_id_lookup_result : public Can_message -{ -public: - Field_id_lookup_result(); - Field_id_lookup_result(uint8_t field_id, Data_type data_type); - - bool set_field_id(uint8_t field_id); - uint8_t get_field_id() const; - - bool set_data_type(Data_type data_type); - Data_type get_data_type() const; -private: - uint8_t field_id_; // Field ID - Data_type field_type_; // Field data type -}; - -#endif //FIELDIDLOOKUPRESULT_H diff --git a/Cpp-Implementation/Models/FieldRegistration.h b/Cpp-Implementation/Models/FieldRegistration.h deleted file mode 100644 index 79220e5..0000000 --- a/Cpp-Implementation/Models/FieldRegistration.h +++ /dev/null @@ -1,30 +0,0 @@ -#ifndef FIELDREGISTRATION_H -#define FIELDREGISTRATION_H - -#include -#include -#include - -class Field_registration : public Can_message -{ -public: - Field_registration(); - Field_registration(uint8_t field_id, Data_type field_type, const uint8_t* device_name, uint8_t length); - - bool set_field_id(uint8_t field_id); - uint8_t get_field_id() const; - - bool set_field_type(Data_type field_type); - Data_type get_field_type() const; - - bool set_field_name(const uint8_t* field_name, uint8_t length); - const uint8_t* get_field_name() const; - uint8_t get_field_name_length() const; -private: - uint8_t field_id_; // Unique identifier for this field - Data_type field_type_; // Field data type - uint8_t field_name_length_; // Field name length - uint8_t field_name_[63]; // Human-readable field name -}; - -#endif // FIELDREGISTRATION_H diff --git a/Cpp-Implementation/Models/HeartBeat.h b/Cpp-Implementation/Models/HeartBeat.h deleted file mode 100644 index fb8961f..0000000 --- a/Cpp-Implementation/Models/HeartBeat.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef HEARTBEAT_H -#define HEARTBEAT_H - -#include -#include - -class Heart_beat : public Can_message -{ -public: - Heart_beat(); - Heart_beat(uint32_t counter); - - uint32_t set_counter(uint32_t value); - uint32_t get_counter() const; - - Heart_beat& operator++(); -private: - uint32_t counter_; // Incrementing counter value -}; - -#endif //HEARTBEAT_H diff --git a/Cpp-Implementation/Models/NodeInfoRequest.h b/Cpp-Implementation/Models/NodeInfoRequest.h deleted file mode 100644 index 5fa0929..0000000 --- a/Cpp-Implementation/Models/NodeInfoRequest.h +++ /dev/null @@ -1,46 +0,0 @@ -// -// Created by tobias on 24.01.26. -// - -#ifndef NODEINFOREQUEST_H -#define NODEINFOREQUEST_H - -#include -#include - -class Node_info_request : public Can_message -{ -public: - Node_info_request(); - Node_info_request(uint8_t tel_cnt, - uint8_t par_cnt, - uint32_t firmware_hash, - uint32_t liquid_hash, - const uint8_t* device_name, - uint8_t length); - - bool set_telemetry_count(uint8_t tel_cnt); - uint8_t get_telemetry_count() const; - - bool set_parameter_count(uint8_t par_cnt); - uint8_t get_parameter_count() const; - - bool set_firmware_hash(uint32_t firmware_hash); - uint32_t get_firmware_hash() const; - - bool set_liquid_hash(uint32_t liquid_hash); - uint32_t get_liquid_hash() const; - - bool set_device_name(const uint8_t* device_name, uint8_t length); - const uint8_t* get_device_name() const; - uint8_t get_device_name_length() const; -private: - uint8_t tel_cnt_; // Number of telemetry values on this node - uint8_t par_cnt_; // Number of parameters on this node - uint32_t firmware_hash_; // Hash of the firmware version - uint32_t liquid_hash_; // Hash of the LiquidCan protocol version - uint8_t device_name_length_; // Internal counter to track device_name length - uint8_t device_name_[53]; // Human-readable device name -}; - -#endif //NODEINFOREQUEST_H diff --git a/Cpp-Implementation/Models/ParameterSetConfirmation.h b/Cpp-Implementation/Models/ParameterSetConfirmation.h deleted file mode 100644 index ce54edb..0000000 --- a/Cpp-Implementation/Models/ParameterSetConfirmation.h +++ /dev/null @@ -1,37 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef PARAMETERSETCONFIRMATION_H -#define PARAMETERSETCONFIRMATION_H - -#include -#include -#include - -class Parameter_set_confirmation : public Can_message -{ -public: - Parameter_set_confirmation(); - Parameter_set_confirmation(uint8_t parameter_id, - Parameter_set_status status, - const uint8_t* value, - uint8_t length); - - bool set_parameter_id(uint8_t parameter_id); - uint8_t get_parameter_id() const; - - bool set_status(Parameter_set_status status); - Parameter_set_status get_status() const; - - bool set_value(const uint8_t* value, uint8_t length); - const uint8_t* get_value() const; - uint8_t get_value_length() const; -private: - uint8_t parameter_id_; // Parameter identifier - Parameter_set_status status_; // Status code (Parameter_set_status enum) - uint8_t value_length_; // Confirmed value length - uint8_t value_[61]; // Confirmed value after set operation -}; - -#endif //PARAMETERSETCONFIRMATION_H diff --git a/Cpp-Implementation/Models/ParameterSetLock.h b/Cpp-Implementation/Models/ParameterSetLock.h deleted file mode 100644 index 8f689ab..0000000 --- a/Cpp-Implementation/Models/ParameterSetLock.h +++ /dev/null @@ -1,27 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef PARAMETERSETLOCK_H -#define PARAMETERSETLOCK_H - -#include -#include - -class Parameter_set_lock : public Can_message -{ -public: - Parameter_set_lock(); - Parameter_set_lock(uint8_t parameter_id, uint8_t lock_status); - - bool set_parameter_id(uint8_t parameter_id); - uint8_t get_parameter_id() const; - - bool set_lock_status(uint8_t lock_status); - bool get_lock_status() const; -private: - uint8_t parameter_id_; // Parameter identifier to lock - uint8_t parameter_lock_status_; // Lock status (0=locked, 1=unlocked) -}; - -#endif //PARAMETERSETLOCK_H diff --git a/Cpp-Implementation/Models/ParameterSetRequest.h b/Cpp-Implementation/Models/ParameterSetRequest.h deleted file mode 100644 index c357601..0000000 --- a/Cpp-Implementation/Models/ParameterSetRequest.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef PARAMETERSETREQUEST_H -#define PARAMETERSETREQUEST_H - -#include -#include - -class Parameter_set_request : public Can_message -{ -public: - Parameter_set_request(); - Parameter_set_request(uint8_t parameter_id, const uint8_t* value, uint8_t length); - - bool set_parameter_id(uint8_t id); - uint8_t get_parameter_id() const; - - bool set_parameter_value(const uint8_t* value, uint8_t value_length); - const uint8_t* get_parameter_value() const; - uint8_t get_parameter_value_length() const; -private: - uint8_t parameter_id_; // Parameter identifier - uint8_t value_length_; // Internal Counter to track length of the value field - uint8_t value_[61]; // New value -}; - -#endif // PARAMETERSETREQUEST_H diff --git a/Cpp-Implementation/Models/Status.h b/Cpp-Implementation/Models/Status.h deleted file mode 100644 index 6d02e3b..0000000 --- a/Cpp-Implementation/Models/Status.h +++ /dev/null @@ -1,25 +0,0 @@ -// -// Created by tobias on 30.01.26. -// - -#ifndef STATUS_H -#define STATUS_H - -#include -#include - -class Status : public Can_message -{ -public: - Status(); - Status(const uint8_t* message, uint8_t length); - - bool set_message(const uint8_t *msg, uint8_t length); - const uint8_t* get_message() const; - uint8_t get_message_length() const; -private: - uint8_t msg_length_; // Length of message string - uint8_t msg_[63]; // Message string -}; - -#endif //STATUS_H diff --git a/Cpp-Implementation/Models/TelemetryGroupDefinition.h b/Cpp-Implementation/Models/TelemetryGroupDefinition.h deleted file mode 100644 index 8f1aa21..0000000 --- a/Cpp-Implementation/Models/TelemetryGroupDefinition.h +++ /dev/null @@ -1,26 +0,0 @@ -#ifndef TELEMETRYGROUPDEFINITION_H -#define TELEMETRYGROUPDEFINITION_H - -#include -#include - -class Telemetry_group_definition : public Can_message -{ -public: - Telemetry_group_definition(); - Telemetry_group_definition(uint8_t group_id, const uint8_t* field_ids, uint8_t field_count); - - bool set_group_id(uint8_t group_id); - uint8_t get_group_id() const; - - bool add_group_field_id(uint8_t field_id); - bool set_group_field_ids(const uint8_t* field_ids, uint8_t field_count); - const uint8_t* get_group_field_ids() const; - uint8_t get_group_field_count() const; -private: - uint8_t group_id_; // Unique identifier for this group - uint8_t field_count_; // Internal Counter to track number of fields - uint8_t field_ids_[62]; // Array of field IDs in this group -}; - -#endif // TELEMETRYGROUPDEFINITION_H diff --git a/Cpp-Implementation/Models/TelemetryGroupUpdate.h b/Cpp-Implementation/Models/TelemetryGroupUpdate.h deleted file mode 100644 index 2a99985..0000000 --- a/Cpp-Implementation/Models/TelemetryGroupUpdate.h +++ /dev/null @@ -1,25 +0,0 @@ -#ifndef TELEMETRYGROUPUPDATE_H -#define TELEMETRYGROUPUPDATE_H - -#include -#include - -class Telemetry_group_update : public Can_message -{ -public: - Telemetry_group_update(); - Telemetry_group_update(uint8_t group_id, const uint8_t* values, uint8_t value_count); - - bool set_group_id(uint8_t group_id); - uint8_t get_group_id() const; - - bool set_group_values(const uint8_t* values, uint8_t value_count); - const uint8_t* get_group_values() const; - uint8_t get_group_value_length() const; -private: - uint8_t group_id_; // Group identifier - uint8_t value_length_; // Internal Counter to track length of the value field - uint8_t values_[62]; // Packed values of all telemetry value in the group -}; - -#endif // TELEMETRYGROUPUPDATE_H diff --git a/LiquidCAN.yaml b/LiquidCAN.yaml index a81d7ab..f055c68 100644 --- a/LiquidCAN.yaml +++ b/LiquidCAN.yaml @@ -9,6 +9,7 @@ enum: - name: "parameter_locked" value: 2 - name: "node_to_node_modification" + value: 3 - name: "data_type" type: "uint8" values: @@ -143,12 +144,12 @@ struct: - name: "value" type: "uint8" length: 62 - - name: "field_ID_lookup_req" + - name: "field_id_lookup_req" fields: - name: "field_name" type: "uint8" length: 61 - - name: "field_ID_lookup_res" + - name: "field_id_lookup_res" fields: - name: "field_id" type: "uint8" diff --git a/LiquidCAN_generator.py b/LiquidCAN_generator.py new file mode 100644 index 0000000..ef4a365 --- /dev/null +++ b/LiquidCAN_generator.py @@ -0,0 +1,159 @@ +import yaml +import os + +cpp_path = "./Cpp-Implementation" +enum_path = "/Infrastructure" +model_path = "/Model" + + +type_converter_dict_cpp = { + "uint8": "uint8_t", + "uint16": "uint16_t", + "uint32": "uint32_t", + "int8": "int8_t", + "int16": "int16_t", + "int32": "int32_t", + "float": "float_t", + "char": "int8_t" +} + + +def convert_to_camel_case(value, upper=True): + components = value.split("_") + + if not components: + return "" + + if upper: + return "".join(x.title() for x in components) + + res = components[0].lower() + for part in components[1:]: + if part: + res += part.title() + return res + + +def change_case(value, value_type): + if value_type == "type": + return convert_to_camel_case(value) + elif value_type == "struct_member": + return convert_to_camel_case(value, False) + elif value_type == "enum_member": + return convert_to_camel_case(value) + return value + + +def add_cpp_preprocessor_directives(code_string, name): + new_code_string = f"#ifndef {name.upper()}_H\n" + new_code_string += f"#define {name.upper()}_H\n\n" + new_code_string += "#include \n\n" + new_code_string += code_string + "\n" + new_code_string += "#endif" + return new_code_string + + +def create_enum(name, fields, data_type=None): + name = change_case(name, "type") + code = f"enum {name}" + + if data_type is not None: + if not data_type in type_converter_dict_cpp: + raise Exception(f"Invalid data type: {data_type}") + code += f" : {type_converter_dict_cpp[data_type]}\n" + else: + code += "\n" + + code += "{\n" + + has_value = False + for element in fields: + code += f"\t{change_case(element["name"], "enum_member")}" + + if "value" in element: + has_value = True + code += f" = {element["value"]}" + elif has_value: + raise Exception(f"not every value in {name} has a value!") + + code += ",\n" + code += "}\n" + return add_cpp_preprocessor_directives(code, name) + + +def create_struct(name, fields, language): + name = change_case(name, "type") + code = f"struct {name}\n" + code += "{\n" + required_types = [] + for element in fields: + code += "\t" + + type_name = element["type"] + if type_name in type_converter_dict_cpp: + code += type_converter_dict_cpp[type_name] + else: + code += f"{change_case(type_name, "type")}" + required_types.append(type_name) + + code += f" {change_case(element["name"], "struct_member")}" + if "length" in element: + code += f"[{element["length"]}]" + code += ";\n" + code += "}\n" + return add_cpp_preprocessor_directives(code, name), required_types + + +def prepare_write(path): + if os.path.exists(path): + for dir_file in os.listdir(path): + os.remove(f"{path}/{dir_file}") + else: + os.makedirs(path) + + +with open("./LiquidCAN.yaml", 'r') as file: + data = yaml.safe_load(file) + +type_set = set() + +# enum +cpp_enum_code = [] +if "enum" in data.keys(): + for enum in data["enum"]: + name = enum["name"] + if "type" in enum.keys(): + cpp_enum = create_enum(name, enum["values"], enum["type"]) + else: + cpp_enum = data = create_enum(name, enum["values"]) + + type_set.add(name) + cpp_enum_code.append((name, cpp_enum)) + +# struct +cpp_struct_code = [] +if "struct" in data.keys(): + for struct in data["struct"]: + name = struct["name"] + cpp_code, requires = create_struct(name, struct["fields"], "cpp") + cpp_struct_code.append((name, cpp_code, requires)) + type_set.add(name) + +# Type validation +for name, cpp_struct, required_types in cpp_struct_code: + for required_type in required_types: + if required_type not in type_set: + raise Exception(f"{required_type} is not defined!\n\r This type is required for {name}") + +# Create cpp enums +prepare_write(f"{cpp_path}{enum_path}") +for name, code in cpp_enum_code: + with open(f"{cpp_path}{enum_path}/{convert_to_camel_case(name)}.h", "w") as file: + file.write(code) + +# Create cpp structs +prepare_write(f"{cpp_path}{model_path}") +for name, code, _ in cpp_struct_code: + with open(f"{cpp_path}{model_path}/{convert_to_camel_case(name)}.h", "w") as file: + file.write(code) + From f2d283962fe8e4c0e588f4fa0bc69e519a0efa8b Mon Sep 17 00:00:00 2001 From: Z3r0z0 Date: Sat, 7 Feb 2026 20:49:31 +0100 Subject: [PATCH 6/7] added files --- .../Infrastructure/MessageType.h | 29 +++++++++++++++++++ Cpp-Implementation/Model/FieldGetReq.h | 11 +++++++ Cpp-Implementation/Model/FieldGetRes.h | 12 ++++++++ Cpp-Implementation/Model/FieldIdLookupReq.h | 11 +++++++ Cpp-Implementation/Model/FieldIdLookupRes.h | 12 ++++++++ Cpp-Implementation/Model/FieldRegistration.h | 13 +++++++++ Cpp-Implementation/Model/HeartBeat.h | 11 +++++++ Cpp-Implementation/Model/NodeInfoRes.h | 15 ++++++++++ .../Model/ParameterSetConfirmation.h | 13 +++++++++ Cpp-Implementation/Model/ParameterSetLock.h | 12 ++++++++ Cpp-Implementation/Model/ParameterSetReq.h | 12 ++++++++ Cpp-Implementation/Model/Status.h | 11 +++++++ .../Model/TelemetryGroupDefinition.h | 12 ++++++++ .../Model/TelemetryGroupUpdate.h | 12 ++++++++ 14 files changed, 186 insertions(+) create mode 100644 Cpp-Implementation/Infrastructure/MessageType.h create mode 100644 Cpp-Implementation/Model/FieldGetReq.h create mode 100644 Cpp-Implementation/Model/FieldGetRes.h create mode 100644 Cpp-Implementation/Model/FieldIdLookupReq.h create mode 100644 Cpp-Implementation/Model/FieldIdLookupRes.h create mode 100644 Cpp-Implementation/Model/FieldRegistration.h create mode 100644 Cpp-Implementation/Model/HeartBeat.h create mode 100644 Cpp-Implementation/Model/NodeInfoRes.h create mode 100644 Cpp-Implementation/Model/ParameterSetConfirmation.h create mode 100644 Cpp-Implementation/Model/ParameterSetLock.h create mode 100644 Cpp-Implementation/Model/ParameterSetReq.h create mode 100644 Cpp-Implementation/Model/Status.h create mode 100644 Cpp-Implementation/Model/TelemetryGroupDefinition.h create mode 100644 Cpp-Implementation/Model/TelemetryGroupUpdate.h diff --git a/Cpp-Implementation/Infrastructure/MessageType.h b/Cpp-Implementation/Infrastructure/MessageType.h new file mode 100644 index 0000000..5a8c2d8 --- /dev/null +++ b/Cpp-Implementation/Infrastructure/MessageType.h @@ -0,0 +1,29 @@ +#ifndef MESSAGETYPE_H +#define MESSAGETYPE_H + +#include + +enum MessageType : uint8_t +{ + NodeInfoReq = 0, + NodeInfoAnnouncement = 1, + InfoStatus = 10, + WarningStatus = 11, + ErrorStatus = 12, + TelemetryValueRegistration = 20, + ParameterRegistration = 21, + TelemetryGroupDefinition = 30, + TelemetryGroupUpdate = 31, + HeartbeatReq = 40, + HeartbeatRes = 41, + ParameterSetReq = 50, + ParameterSetConfirmation = 51, + ParameterSetLock = 52, + ParameterSetLockConfirmation = 53, + FieldGetReq = 60, + FieldGetRes = 61, + FieldIdLookupReq = 62, + FieldIdLookupRes = 63, +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/FieldGetReq.h b/Cpp-Implementation/Model/FieldGetReq.h new file mode 100644 index 0000000..23d1552 --- /dev/null +++ b/Cpp-Implementation/Model/FieldGetReq.h @@ -0,0 +1,11 @@ +#ifndef FIELDGETREQ_H +#define FIELDGETREQ_H + +#include + +struct FieldGetReq +{ + uint8_t fieldId; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/FieldGetRes.h b/Cpp-Implementation/Model/FieldGetRes.h new file mode 100644 index 0000000..437dd90 --- /dev/null +++ b/Cpp-Implementation/Model/FieldGetRes.h @@ -0,0 +1,12 @@ +#ifndef FIELDGETRES_H +#define FIELDGETRES_H + +#include + +struct FieldGetRes +{ + uint8_t fieldId; + uint8_t value[62]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/FieldIdLookupReq.h b/Cpp-Implementation/Model/FieldIdLookupReq.h new file mode 100644 index 0000000..53a5a30 --- /dev/null +++ b/Cpp-Implementation/Model/FieldIdLookupReq.h @@ -0,0 +1,11 @@ +#ifndef FIELDIDLOOKUPREQ_H +#define FIELDIDLOOKUPREQ_H + +#include + +struct FieldIdLookupReq +{ + uint8_t fieldName[61]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/FieldIdLookupRes.h b/Cpp-Implementation/Model/FieldIdLookupRes.h new file mode 100644 index 0000000..2bb555b --- /dev/null +++ b/Cpp-Implementation/Model/FieldIdLookupRes.h @@ -0,0 +1,12 @@ +#ifndef FIELDIDLOOKUPRES_H +#define FIELDIDLOOKUPRES_H + +#include + +struct FieldIdLookupRes +{ + uint8_t fieldId; + DataType fieldType; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/FieldRegistration.h b/Cpp-Implementation/Model/FieldRegistration.h new file mode 100644 index 0000000..b3e4c0f --- /dev/null +++ b/Cpp-Implementation/Model/FieldRegistration.h @@ -0,0 +1,13 @@ +#ifndef FIELDREGISTRATION_H +#define FIELDREGISTRATION_H + +#include + +struct FieldRegistration +{ + uint8_t fieldId; + uint8_t fieldType; + int8_t fieldName[61]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/HeartBeat.h b/Cpp-Implementation/Model/HeartBeat.h new file mode 100644 index 0000000..337ba6d --- /dev/null +++ b/Cpp-Implementation/Model/HeartBeat.h @@ -0,0 +1,11 @@ +#ifndef HEARTBEAT_H +#define HEARTBEAT_H + +#include + +struct HeartBeat +{ + uint32_t counter; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/NodeInfoRes.h b/Cpp-Implementation/Model/NodeInfoRes.h new file mode 100644 index 0000000..c37c75d --- /dev/null +++ b/Cpp-Implementation/Model/NodeInfoRes.h @@ -0,0 +1,15 @@ +#ifndef NODEINFORES_H +#define NODEINFORES_H + +#include + +struct NodeInfoRes +{ + uint8_t telCnt; + uint8_t parCnt; + uint32_t firmwareHash; + uint32_t liquidHash; + int8_t deviceName[53]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/ParameterSetConfirmation.h b/Cpp-Implementation/Model/ParameterSetConfirmation.h new file mode 100644 index 0000000..e94aa52 --- /dev/null +++ b/Cpp-Implementation/Model/ParameterSetConfirmation.h @@ -0,0 +1,13 @@ +#ifndef PARAMETERSETCONFIRMATION_H +#define PARAMETERSETCONFIRMATION_H + +#include + +struct ParameterSetConfirmation +{ + uint8_t parameterId; + ParameterSetStatus status; + uint8_t value[61]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/ParameterSetLock.h b/Cpp-Implementation/Model/ParameterSetLock.h new file mode 100644 index 0000000..01738f3 --- /dev/null +++ b/Cpp-Implementation/Model/ParameterSetLock.h @@ -0,0 +1,12 @@ +#ifndef PARAMETERSETLOCK_H +#define PARAMETERSETLOCK_H + +#include + +struct ParameterSetLock +{ + uint8_t parameterId; + uint8_t lockStatus; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/ParameterSetReq.h b/Cpp-Implementation/Model/ParameterSetReq.h new file mode 100644 index 0000000..a78f19e --- /dev/null +++ b/Cpp-Implementation/Model/ParameterSetReq.h @@ -0,0 +1,12 @@ +#ifndef PARAMETERSETREQ_H +#define PARAMETERSETREQ_H + +#include + +struct ParameterSetReq +{ + uint8_t parameterId; + uint8_t value[61]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/Status.h b/Cpp-Implementation/Model/Status.h new file mode 100644 index 0000000..3f06360 --- /dev/null +++ b/Cpp-Implementation/Model/Status.h @@ -0,0 +1,11 @@ +#ifndef STATUS_H +#define STATUS_H + +#include + +struct Status +{ + int8_t msg[63]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/TelemetryGroupDefinition.h b/Cpp-Implementation/Model/TelemetryGroupDefinition.h new file mode 100644 index 0000000..229589d --- /dev/null +++ b/Cpp-Implementation/Model/TelemetryGroupDefinition.h @@ -0,0 +1,12 @@ +#ifndef TELEMETRYGROUPDEFINITION_H +#define TELEMETRYGROUPDEFINITION_H + +#include + +struct TelemetryGroupDefinition +{ + uint8_t groupId; + uint8_t fieldIds[62]; +} + +#endif \ No newline at end of file diff --git a/Cpp-Implementation/Model/TelemetryGroupUpdate.h b/Cpp-Implementation/Model/TelemetryGroupUpdate.h new file mode 100644 index 0000000..b469256 --- /dev/null +++ b/Cpp-Implementation/Model/TelemetryGroupUpdate.h @@ -0,0 +1,12 @@ +#ifndef TELEMETRYGROUPUPDATE_H +#define TELEMETRYGROUPUPDATE_H + +#include + +struct TelemetryGroupUpdate +{ + uint8_t groupId; + uint8_t values[62]; +} + +#endif \ No newline at end of file From d1ea6791c84f679791a3672a66bd5587576ee3f6 Mon Sep 17 00:00:00 2001 From: Z3r0z0 Date: Thu, 12 Feb 2026 18:03:32 +0100 Subject: [PATCH 7/7] removed base datatype conversion --- LiquidCAN.yaml | 56 +++++++++++++++++++++--------------------- LiquidCAN_generator.py | 25 +++++-------------- 2 files changed, 34 insertions(+), 47 deletions(-) diff --git a/LiquidCAN.yaml b/LiquidCAN.yaml index f055c68..8a9d3c9 100644 --- a/LiquidCAN.yaml +++ b/LiquidCAN.yaml @@ -1,6 +1,6 @@ enum: - name: "parameter_set_status" - type: "uint8" + type: "uint8_t" values: - name: "success" value: 0 @@ -11,7 +11,7 @@ enum: - name: "node_to_node_modification" value: 3 - name: "data_type" - type: "uint8" + type: "uint8_t" values: - name: "float32" value: 0 @@ -30,7 +30,7 @@ enum: - name: "boolean" value: 7 - name: "message_type" - type: "uint8" + type: "uint8_t" values: - name: "node_info_req" value: 0 @@ -75,89 +75,89 @@ struct: - name: "node_info_res" fields: - name: "tel_cnt" - type: "uint8" + type: "uint8_t" - name: "par_cnt" - type: "uint8" + type: "uint8_t" - name: "firmware_hash" - type: "uint32" + type: "uint32_t" - name: "liquid_hash" - type: "uint32" + type: "uint32_t" - name: "device_name" - type: "char" + type: "int8_t" length: 53 - name: "status" fields: - name: "msg" - type: "char" + type: "int8_t" length: 63 - name: "field_registration" fields: - name: "field_id" - type: "uint8" + type: "uint8_t" - name: "field_type" - type: "uint8" + type: "uint8_t" - name: "field_name" - type: "char" + type: "int8_t" length: 61 - name: "telemetry_group_definition" fields: - name: "group_id" - type: "uint8" + type: "uint8_t" - name: "field_ids" - type: "uint8" + type: "uint8_t" length: 62 - name: "telemetry_group_update" fields: - name: "group_id" - type: "uint8" + type: "uint8_t" - name: "values" - type: "uint8" + type: "uint8_t" length: 62 - name: "heart_beat" fields: - name: "counter" - type: "uint32" + type: "uint32_t" - name: "parameter_set_req" fields: - name: "parameter_id" - type: "uint8" + type: "uint8_t" - name: "value" - type: "uint8" + type: "uint8_t" length: 61 - name: "parameter_set_confirmation" fields: - name: "parameter_id" - type: "uint8" + type: "uint8_t" - name: "status" type: "parameter_set_status" - name: "value" - type: "uint8" + type: "uint8_t" length: 61 - name: "field_get_req" fields: - name: "field_id" - type: "uint8" + type: "uint8_t" - name: "field_get_res" fields: - name: "field_id" - type: "uint8" + type: "uint8_t" - name: "value" - type: "uint8" + type: "uint8_t" length: 62 - name: "field_id_lookup_req" fields: - name: "field_name" - type: "uint8" + type: "uint8_t" length: 61 - name: "field_id_lookup_res" fields: - name: "field_id" - type: "uint8" + type: "uint8_t" - name: "field_type" type: "data_type" - name: "parameter_set_lock" fields: - name: "parameter_id" - type: "uint8" + type: "uint8_t" - name: "lock_status" - type: "uint8" \ No newline at end of file + type: "uint8_t" \ No newline at end of file diff --git a/LiquidCAN_generator.py b/LiquidCAN_generator.py index ef4a365..ae4c6b1 100644 --- a/LiquidCAN_generator.py +++ b/LiquidCAN_generator.py @@ -6,18 +6,6 @@ model_path = "/Model" -type_converter_dict_cpp = { - "uint8": "uint8_t", - "uint16": "uint16_t", - "uint32": "uint32_t", - "int8": "int8_t", - "int16": "int16_t", - "int32": "int32_t", - "float": "float_t", - "char": "int8_t" -} - - def convert_to_camel_case(value, upper=True): components = value.split("_") @@ -58,12 +46,11 @@ def create_enum(name, fields, data_type=None): code = f"enum {name}" if data_type is not None: - if not data_type in type_converter_dict_cpp: + if not data_type.endswith("_t"): raise Exception(f"Invalid data type: {data_type}") - code += f" : {type_converter_dict_cpp[data_type]}\n" + code += f" : {data_type}\n" else: code += "\n" - code += "{\n" has_value = False @@ -81,7 +68,7 @@ def create_enum(name, fields, data_type=None): return add_cpp_preprocessor_directives(code, name) -def create_struct(name, fields, language): +def create_struct(name, fields): name = change_case(name, "type") code = f"struct {name}\n" code += "{\n" @@ -90,8 +77,8 @@ def create_struct(name, fields, language): code += "\t" type_name = element["type"] - if type_name in type_converter_dict_cpp: - code += type_converter_dict_cpp[type_name] + if type_name.endswith("_t"): + code += type_name else: code += f"{change_case(type_name, "type")}" required_types.append(type_name) @@ -135,7 +122,7 @@ def prepare_write(path): if "struct" in data.keys(): for struct in data["struct"]: name = struct["name"] - cpp_code, requires = create_struct(name, struct["fields"], "cpp") + cpp_code, requires = create_struct(name, struct["fields"]) cpp_struct_code.append((name, cpp_code, requires)) type_set.add(name)