Paparazzi UAS v7.0_unstable
Paparazzi is a free software Unmanned Aircraft System.
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
can_fuelcell.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2024 Freek van Tienen <freek.v.tienen@gmail.com>
3 *
4 * This file is part of paparazzi
5 *
6 * paparazzi is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2, or (at your option)
9 * any later version.
10 *
11 * paparazzi is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with paparazzi; see the file COPYING. If not, see
18 * <http://www.gnu.org/licenses/>.
19 */
20
29#include "uavcan/uavcan.h"
30
31
32/* uavcan EQUIPMENT_ESC_STATUS message definition */
33#define UAVCAN_EQUIPMENT_FUELCELL_STATUS_MAX_SIZE 11
34#define UAVCAN_EQUIPMENT_FUELCELL_STATUS_SIGNATURE (0x475459FF3AA36FE5ULL)
35#define UAVCAN_EQUIPMENT_FUELCELL_STATUS_ID 1141
36
37
38/* Fuel-Cell */
52static struct uavcan_equipment_fuelcell can_fuelcell_data = { 0, 67, 0.78, 45.9, 1457.0, 1234.0, -223.0, 2, 12, 7};
53
54#if !(USE_NPS)
55
56/* CAN feedback */
58
60{
61
62 uint32_t bit_ofs = 0;
64 bit_ofs += 7;
65 uint16_t temp = 0;
66 canardDecodeScalar(transfer, bit_ofs, 8, false, &temp);
67 can_fuelcell_data.press_reg = ((float) temp) / 100.0f;
68 bit_ofs += 8;
69 temp = 0;
70 canardDecodeScalar(transfer, bit_ofs, 10, false, &temp);
71 can_fuelcell_data.volt_bat = ((float) temp) / 10.0f;
72 bit_ofs += 10;
73 temp = 0;
74 canardDecodeScalar(transfer, bit_ofs, 14, false, &temp);
76 bit_ofs += 14;
77 temp = 0;
78 canardDecodeScalar(transfer, bit_ofs, 13, false, &temp);
80 bit_ofs += 13;
81 int16_t temp2 = 0;
82 canardDecodeScalar(transfer, bit_ofs, 16, true, &temp2);
84 bit_ofs += 16;
86 bit_ofs += 4;
88 bit_ofs += 8;
90 bit_ofs += 8;
91
93
94}
95#endif
96
97
98extern void can_fuelcell_periodic(void)
99{
100#if USE_NPS
101 // Simulate data
103#endif
104 if (can_fuelcell_data.timeout > 0) {
106 }
107}
108
109
110
111#if PERIODIC_TELEMETRY
113
123#endif /* PERIODIC_TELEMETRY */
124
125
126
128{
129#if !(USE_NPS)
130
131 // Bind uavcan BATTERYINFO message from EQUIPMENT.POWER
134#endif
135
136
137 // Configure telemetry
138#if PERIODIC_TELEMETRY
140#endif
141
142
143}
void can_fuelcell_periodic(void)
void can_fuelcell_init(void)
#define UAVCAN_EQUIPMENT_FUELCELL_STATUS_ID
static uavcan_event fuelcell_uavcan_ev
static struct uavcan_equipment_fuelcell can_fuelcell_data
static void can_fuelcell_send_telemetry(struct transport_tx *trans, struct link_device *dev)
static void fuelcell_uavcan_cb(struct uavcan_iface_t *iface, CanardRxTransfer *transfer)
#define UAVCAN_EQUIPMENT_FUELCELL_STATUS_SIGNATURE
Main uavcan event structure for registering/calling callbacks.
Definition uavcan.h:60
uint16_t foo
Definition main_demo5.c:58
uavcan interface structure
Definition uavcan.h:34
static const struct usb_device_descriptor dev
Definition usb_ser_hw.c:74
int8_t register_periodic_telemetry(struct periodic_telemetry *_pt, uint8_t _id, telemetry_cb _cb)
Register a telemetry callback function.
Definition telemetry.c:51
Periodic telemetry system header (includes downlink utility and generated code).
#define DefaultPeriodic
Set default periodic telemetry.
Definition telemetry.h:66
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.
Definition uavcan.c:417
unsigned short uint16_t
Typedef defining 16 bit unsigned short type.
unsigned int uint32_t
Typedef defining 32 bit unsigned int type.
short int16_t
Typedef defining 16 bit short type.
unsigned char uint8_t
Typedef defining 8 bit unsigned char type.
int transfer(const Mat *from, const image_t *to)