From 1d6f999ab6b96275b0634bb3bf0547b7339a74be Mon Sep 17 00:00:00 2001 From: Robin Mueller Date: Mon, 17 Jan 2022 16:21:33 +0100 Subject: [PATCH] added HK deserializer --- mission/devices/BpxBatteryHandler.h | 2 + .../devicedefinitions/BpxBatteryDefinitions.h | 64 +++++++++++++++++++ 2 files changed, 66 insertions(+) diff --git a/mission/devices/BpxBatteryHandler.h b/mission/devices/BpxBatteryHandler.h index 887827fd..5edc0348 100644 --- a/mission/devices/BpxBatteryHandler.h +++ b/mission/devices/BpxBatteryHandler.h @@ -1,6 +1,8 @@ #ifndef MISSION_DEVICES_BPXBATTERYHANDLER_H_ #define MISSION_DEVICES_BPXBATTERYHANDLER_H_ +#include "devicedefinitions/BpxBatteryDefinitions.h" + #include class BpxBatteryHandler : public DeviceHandlerBase { diff --git a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h index 436cc6f6..ff96e857 100644 --- a/mission/devices/devicedefinitions/BpxBatteryDefinitions.h +++ b/mission/devices/devicedefinitions/BpxBatteryDefinitions.h @@ -1,8 +1,72 @@ #ifndef MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ #define MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ +#include +#include + namespace BpxBattery { +static constexpr uint8_t PORT_PING = 1; +static constexpr uint8_t PORT_REBOOT = 4; +static constexpr uint8_t PORT_GET_HK = 9; +static constexpr uint8_t PORT_RESET_COUNTERS = 15; +static constexpr uint8_t PORT_CONFIG_CMD = 17; +static constexpr uint8_t PORT_CONFIG_GET = 18; +static constexpr uint8_t PORT_CONFIG_SET = 19; +static constexpr uint8_t PORT_MAN_HEAT_ON = 20; +static constexpr uint8_t PORT_MAN_HEAT_OFF = 21; + +// Taken from BPX manual 3.14 +typedef struct __attribute__((packed)) { + //! Mode for battheater [0=OFF,1=Auto] + uint8_t battheater_mode; + int8_t battheater_low; + //! Turn heater on at [degC] + int8_t battheater_high; + //! Turn heater off at [degC] +} bpx_config_t; + +class BpxHkDeserializer: public SerialLinkedListAdapter { +public: + BpxHkDeserializer() { + setLinks(); + } + + //! Charge current in mA + SerializeElement chargeCurrent; + //! Discharge current in mA + SerializeElement dischargeCurrent; + //! Heater current in mA + SerializeElement heaterCurrent; + + //! Battery voltage in mV + SerializeElement battVoltage; + //! Battery temperature 1 in degC + SerializeElement battTemp1; + //! Battery temperature 2 in degC + SerializeElement battTemp2; + //! Battery temperature 3 in degC + SerializeElement battTemp3; + //! Battery temperature 4 in degC + SerializeElement battTemp4; + + SerializeElement rebootCounter; + SerializeElement bootcause; +private: + void setLinks() { + setStart(&chargeCurrent); + chargeCurrent.setNext(&dischargeCurrent); + dischargeCurrent.setNext(&heaterCurrent); + heaterCurrent.setNext(&battVoltage); + battVoltage.setNext(&battTemp1); + battTemp1.setNext(&battTemp2); + battTemp2.setNext(&battTemp3); + battTemp3.setNext(&battTemp4); + battTemp4.setNext(&rebootCounter); + rebootCounter.setNext(&bootcause); + } +}; + } #endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */