27 #include "uavcan/uavcan.h"
32 #define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_ID 1092
33 #define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_SIGNATURE (0x249C26548A711966ULL)
34 #define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_MAX_SIZE 55
37 #define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_ID 1091
38 #define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_SIGNATURE (0x8313D33D0DDDA115ULL)
39 #define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_MAX_SIZE 7
42 #ifndef POWER_UAVCAN_BATTERIES_MAX
43 #define POWER_UAVCAN_BATTERIES_MAX 3
47 #ifndef POWER_UAVCAN_CIRCUITS_MAX
48 #define POWER_UAVCAN_CIRCUITS_MAX 15
52 #ifndef POWER_UAVCAN_BATTERY_CIRCUITS
53 #define POWER_UAVCAN_BATTERY_CIRCUITS {}
102 #if PERIODIC_TELEMETRY
131 float temperature = canardConvertFloat16ToNativeFloat(tmp_float);
133 float voltage = canardConvertFloat16ToNativeFloat(tmp_float);
135 float current = canardConvertFloat16ToNativeFloat(tmp_float);
137 float average_power_10sec = canardConvertFloat16ToNativeFloat(tmp_float);
139 float remaining_capacity_wh = canardConvertFloat16ToNativeFloat(tmp_float);
141 float full_charge_capacity_wh = canardConvertFloat16ToNativeFloat(tmp_float);
143 float hours_to_full_charge = canardConvertFloat16ToNativeFloat(tmp_float);
145 canardDecodeScalar(
transfer, (
uint32_t)112, 11,
false, (
void *)&status_flags);
146 uint8_t state_of_health_pct = 0;
147 canardDecodeScalar(
transfer, (
uint32_t)123, 7,
false, (
void *)&state_of_health_pct);
148 uint8_t state_of_charge_pct = 0;
149 canardDecodeScalar(
transfer, (
uint32_t)130, 7,
false, (
void *)&state_of_charge_pct);
150 uint8_t state_of_charge_pct_stdev = 0;
151 canardDecodeScalar(
transfer, (
uint32_t)137, 7,
false, (
void *)&state_of_charge_pct_stdev);
155 canardDecodeScalar(
transfer, (
uint32_t)152, 32,
false, (
void *)&model_instance_id);
194 float current_sum = 0;
214 float voltage = canardConvertFloat16ToNativeFloat(tmp_float);
216 float current = canardConvertFloat16ToNativeFloat(tmp_float);
247 float current_sum = 0;
254 if (voltage > 0 &&
circuits[circuit_idx].is_battery) {
278 #if PERIODIC_TELEMETRY
Main uavcan event structure for registering/calling callbacks.
struct Electrical electrical
Interface for electrical status: supply voltage, current, battery status, etc.
float current
current in A
float vsupply
supply voltage in V
static struct uavcan_circuit_battery_t battery_circuits[]
float average_power_10sec
static void power_uavcan_battery_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
#define POWER_UAVCAN_BATTERY_CIRCUITS
static void power_uavcan_circuit_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
uint32_t model_instance_id
#define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_SIGNATURE
float remaining_capacity_wh
static void power_uavcan_send_power_device(struct transport_tx *trans, struct link_device *dev)
uint8_t state_of_charge_pct
#define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_SIGNATURE
float full_charge_capacity_wh
static uavcan_event circuit_uavcan_ev
#define POWER_UAVCAN_CIRCUITS_MAX
uint8_t state_of_charge_pct_stdev
static struct uavcan_equipment_power_BatteryInfo batteries[POWER_UAVCAN_BATTERIES_MAX]
void power_uavcan_init(void)
#define UAVCAN_EQUIPMENT_POWER_CIRCUITSTATUS_ID
static uavcan_event power_uavcan_ev
#define POWER_UAVCAN_BATTERIES_MAX
uint8_t state_of_health_pct
static struct uavcan_equipment_power_CircuitStatus circuits[POWER_UAVCAN_CIRCUITS_MAX]
float hours_to_full_charge
#define UAVCAN_EQUIPMENT_POWER_BATTERYINFO_ID
Power sensors on the uavcan bus.
double rand_uniform(void)
uavcan interface structure
static const struct usb_device_descriptor dev
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
void uavcan_bind(uint16_t data_type_id, uint64_t data_type_signature, uavcan_event *ev, uavcan_callback cb)
Bind to a receiving message from uavcan.
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
int transfer(const Mat *from, const image_t *to)