v1.9.0 #175
@ -1,10 +1,10 @@
|
|||||||
#ifndef MISSION_DEVICES_BPXBATTERYHANDLER_H_
|
#ifndef MISSION_DEVICES_BPXBATTERYHANDLER_H_
|
||||||
#define MISSION_DEVICES_BPXBATTERYHANDLER_H_
|
#define MISSION_DEVICES_BPXBATTERYHANDLER_H_
|
||||||
|
|
||||||
#include "devicedefinitions/BpxBatteryDefinitions.h"
|
|
||||||
|
|
||||||
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
#include <fsfw/devicehandlers/DeviceHandlerBase.h>
|
||||||
|
|
||||||
|
#include "devicedefinitions/BpxBatteryDefinitions.h"
|
||||||
|
|
||||||
class BpxBatteryHandler : public DeviceHandlerBase {
|
class BpxBatteryHandler : public DeviceHandlerBase {
|
||||||
public:
|
public:
|
||||||
BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
|
BpxBatteryHandler(object_id_t objectId, object_id_t comIF, CookieIF* comCookie);
|
||||||
|
@ -1,11 +1,28 @@
|
|||||||
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_
|
#ifndef MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_
|
||||||
#define MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_
|
#define MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_
|
||||||
|
|
||||||
|
#include <fsfw/datapoollocal/StaticLocalDataSet.h>
|
||||||
#include <fsfw/serialize/SerialLinkedListAdapter.h>
|
#include <fsfw/serialize/SerialLinkedListAdapter.h>
|
||||||
|
|
||||||
#include <cstdint>
|
#include <cstdint>
|
||||||
|
|
||||||
namespace BpxBattery {
|
namespace BpxBattery {
|
||||||
|
|
||||||
|
enum BpxPoolIds {
|
||||||
|
CHARGE_CURRENT = 0,
|
||||||
|
DISCHARGE_CURRENT = 1,
|
||||||
|
HEATER_CURRENT = 2,
|
||||||
|
BATT_VOLTAGE = 3,
|
||||||
|
BATT_TEMP_1 = 4,
|
||||||
|
BATT_TEMP_2 = 5,
|
||||||
|
BATT_TEMP_3 = 6,
|
||||||
|
BATT_TEMP_4 = 7,
|
||||||
|
REBOOT_COUNTER = 8,
|
||||||
|
BOOTCAUSE = 9
|
||||||
|
};
|
||||||
|
|
||||||
|
static constexpr uint32_t HK_SET_ID = 0;
|
||||||
|
|
||||||
static constexpr uint8_t PORT_PING = 1;
|
static constexpr uint8_t PORT_PING = 1;
|
||||||
static constexpr uint8_t PORT_REBOOT = 4;
|
static constexpr uint8_t PORT_REBOOT = 4;
|
||||||
static constexpr uint8_t PORT_GET_HK = 9;
|
static constexpr uint8_t PORT_GET_HK = 9;
|
||||||
@ -16,6 +33,9 @@ static constexpr uint8_t PORT_CONFIG_SET = 19;
|
|||||||
static constexpr uint8_t PORT_MAN_HEAT_ON = 20;
|
static constexpr uint8_t PORT_MAN_HEAT_ON = 20;
|
||||||
static constexpr uint8_t PORT_MAN_HEAT_OFF = 21;
|
static constexpr uint8_t PORT_MAN_HEAT_OFF = 21;
|
||||||
|
|
||||||
|
static constexpr uint8_t HK_ENTRIES = 10;
|
||||||
|
|
||||||
|
|
||||||
// Taken from BPX manual 3.14
|
// Taken from BPX manual 3.14
|
||||||
typedef struct __attribute__((packed)) {
|
typedef struct __attribute__((packed)) {
|
||||||
//! Mode for battheater [0=OFF,1=Auto]
|
//! Mode for battheater [0=OFF,1=Auto]
|
||||||
@ -26,11 +46,11 @@ typedef struct __attribute__((packed)) {
|
|||||||
//! Turn heater off at [degC]
|
//! Turn heater off at [degC]
|
||||||
} bpx_config_t;
|
} bpx_config_t;
|
||||||
|
|
||||||
class BpxHkDeserializer: public SerialLinkedListAdapter<SerializeIF> {
|
|
||||||
public:
|
//! Not used for more but might still be useful
|
||||||
BpxHkDeserializer() {
|
class BpxHkDeserializer : public SerialLinkedListAdapter<SerializeIF> {
|
||||||
setLinks();
|
public:
|
||||||
}
|
BpxHkDeserializer() { setLinks(); }
|
||||||
|
|
||||||
//! Charge current in mA
|
//! Charge current in mA
|
||||||
SerializeElement<uint16_t> chargeCurrent;
|
SerializeElement<uint16_t> chargeCurrent;
|
||||||
@ -42,17 +62,18 @@ public:
|
|||||||
//! Battery voltage in mV
|
//! Battery voltage in mV
|
||||||
SerializeElement<uint16_t> battVoltage;
|
SerializeElement<uint16_t> battVoltage;
|
||||||
//! Battery temperature 1 in degC
|
//! Battery temperature 1 in degC
|
||||||
SerializeElement<uint16_t> battTemp1;
|
SerializeElement<int16_t> battTemp1;
|
||||||
//! Battery temperature 2 in degC
|
//! Battery temperature 2 in degC
|
||||||
SerializeElement<uint16_t> battTemp2;
|
SerializeElement<int16_t> battTemp2;
|
||||||
//! Battery temperature 3 in degC
|
//! Battery temperature 3 in degC
|
||||||
SerializeElement<uint16_t> battTemp3;
|
SerializeElement<int16_t> battTemp3;
|
||||||
//! Battery temperature 4 in degC
|
//! Battery temperature 4 in degC
|
||||||
SerializeElement<uint16_t> battTemp4;
|
SerializeElement<int16_t> battTemp4;
|
||||||
|
|
||||||
SerializeElement<uint32_t> rebootCounter;
|
SerializeElement<uint32_t> rebootCounter;
|
||||||
SerializeElement<uint8_t> bootcause;
|
SerializeElement<uint8_t> bootcause;
|
||||||
private:
|
|
||||||
|
private:
|
||||||
void setLinks() {
|
void setLinks() {
|
||||||
setStart(&chargeCurrent);
|
setStart(&chargeCurrent);
|
||||||
chargeCurrent.setNext(&dischargeCurrent);
|
chargeCurrent.setNext(&dischargeCurrent);
|
||||||
@ -67,6 +88,107 @@ private:
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
|
||||||
|
/**
|
||||||
|
* @brief BPX HK data holder
|
||||||
|
*/
|
||||||
|
class BpxBatteryHk : public StaticLocalDataSet<HK_ENTRIES> {
|
||||||
|
public:
|
||||||
|
/**
|
||||||
|
* Constructor for data users
|
||||||
|
* @param gyroId
|
||||||
|
*/
|
||||||
|
BpxBatteryHk(object_id_t bpxId) : StaticLocalDataSet(sid_t(bpxId, BpxBattery::HK_SET_ID)) {
|
||||||
|
setAllVariablesReadOnly();
|
||||||
|
}
|
||||||
|
|
||||||
|
ReturnValue_t parseRawHk(const uint8_t* data, size_t size) {
|
||||||
|
size_t remSize = size;
|
||||||
|
ReturnValue_t result =
|
||||||
|
chargeCurrent.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = dischargeCurrent.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = heaterCurrent.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = battVoltage.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = battTemp1.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = battTemp2.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = battTemp3.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = battTemp4.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = rebootCounter.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
result = bootcause.deSerialize(&data, &remSize, SerializeIF::Endianness::NETWORK);
|
||||||
|
if (result != HasReturnvaluesIF::RETURN_OK) {
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
BpxBatteryHk();
|
||||||
|
|
||||||
|
private:
|
||||||
|
//! Charge current in mA
|
||||||
|
lp_var_t<uint16_t> chargeCurrent =
|
||||||
|
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::CHARGE_CURRENT, this);
|
||||||
|
//! Discharge current in mA
|
||||||
|
lp_var_t<uint16_t> dischargeCurrent =
|
||||||
|
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::DISCHARGE_CURRENT, this);
|
||||||
|
//! Heater current in mA
|
||||||
|
lp_var_t<uint16_t> heaterCurrent =
|
||||||
|
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::HEATER_CURRENT, this);
|
||||||
|
|
||||||
|
//! Battery voltage in mV
|
||||||
|
lp_var_t<uint16_t> battVoltage =
|
||||||
|
lp_var_t<uint16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_VOLTAGE, this);
|
||||||
|
//! Battery temperature 1 in degC
|
||||||
|
SerializeElement<int16_t> battTemp1 =
|
||||||
|
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_1, this);
|
||||||
|
//! Battery temperature 2 in degC
|
||||||
|
SerializeElement<int16_t> battTemp2 =
|
||||||
|
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_2, this);
|
||||||
|
//! Battery temperature 3 in degC
|
||||||
|
SerializeElement<int16_t> battTemp3 =
|
||||||
|
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_3, this);
|
||||||
|
//! Battery temperature 4 in degC
|
||||||
|
SerializeElement<int16_t> battTemp4 =
|
||||||
|
lp_var_t<int16_t>(sid.objectId, BpxBattery::BpxPoolIds::BATT_TEMP_4, this);
|
||||||
|
SerializeElement<uint32_t> rebootCounter =
|
||||||
|
lp_var_t<uint32_t>(sid.objectId, BpxBattery::BpxPoolIds::REBOOT_COUNTER, this);
|
||||||
|
SerializeElement<uint8_t> bootcause =
|
||||||
|
lp_var_t<uint8_t>(sid.objectId, BpxBattery::BpxPoolIds::BOOTCAUSE, this);
|
||||||
|
|
||||||
|
friend class BpxBatteryHandler;
|
||||||
|
/**
|
||||||
|
* Constructor for data creator
|
||||||
|
* @param hkOwner
|
||||||
|
*/
|
||||||
|
BpxBatteryHk(HasLocalDataPoolIF* hkOwner) : StaticLocalDataSet(hkOwner, BpxBattery::HK_SET_ID) {}
|
||||||
|
};
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */
|
#endif /* MISSION_DEVICES_DEVICEDEFINITIONS_BPXBATTERYDEFINITIONS_H_ */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user