Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.
Path: blob/master/Tools/AP_Periph/baro.cpp
Views: 1798
#include "AP_Periph.h"12#ifdef HAL_PERIPH_ENABLE_BARO34/*5barometer support6*/78#include <dronecan_msgs.h>910/*11update CAN baro12*/13void AP_Periph_FW::can_baro_update(void)14{15if (!periph.g.baro_enable) {16return;17}18baro.update();19if (last_baro_update_ms == baro.get_last_update()) {20return;21}2223last_baro_update_ms = baro.get_last_update();24if (!baro.healthy()) {25// don't send any data26return;27}28const float press = baro.get_pressure();29const float temp = baro.get_temperature();3031{32uavcan_equipment_air_data_StaticPressure pkt {};33pkt.static_pressure = press;34pkt.static_pressure_variance = 0; // should we make this a parameter?3536uint8_t buffer[UAVCAN_EQUIPMENT_AIR_DATA_STATICPRESSURE_MAX_SIZE];37uint16_t total_size = uavcan_equipment_air_data_StaticPressure_encode(&pkt, buffer, !periph.canfdout());3839canard_broadcast(UAVCAN_EQUIPMENT_AIR_DATA_STATICPRESSURE_SIGNATURE,40UAVCAN_EQUIPMENT_AIR_DATA_STATICPRESSURE_ID,41CANARD_TRANSFER_PRIORITY_LOW,42&buffer[0],43total_size);44}4546{47uavcan_equipment_air_data_StaticTemperature pkt {};48pkt.static_temperature = C_TO_KELVIN(temp);49pkt.static_temperature_variance = 0; // should we make this a parameter?5051uint8_t buffer[UAVCAN_EQUIPMENT_AIR_DATA_STATICTEMPERATURE_MAX_SIZE];52uint16_t total_size = uavcan_equipment_air_data_StaticTemperature_encode(&pkt, buffer, !periph.canfdout());5354canard_broadcast(UAVCAN_EQUIPMENT_AIR_DATA_STATICTEMPERATURE_SIGNATURE,55UAVCAN_EQUIPMENT_AIR_DATA_STATICTEMPERATURE_ID,56CANARD_TRANSFER_PRIORITY_LOW,57&buffer[0],58total_size);59}60}6162#endif // HAL_PERIPH_ENABLE_BARO636465