PX4 Firmware
PX4 Autopilot Software http://px4.io
CRSFTelemetry Class Reference

High-level class that handles sending of CRSF telemetry data. More...

#include <crsf_telemetry.h>

Collaboration diagram for CRSFTelemetry:

Public Member Functions

 CRSFTelemetry (int uart_fd)
 
 ~CRSFTelemetry ()=default
 
bool update (const hrt_abstime &now)
 Send telemetry data. More...
 

Private Member Functions

bool send_battery ()
 
bool send_gps ()
 
bool send_attitude ()
 
bool send_flight_mode ()
 

Private Attributes

uORB::Subscription _vehicle_gps_position_sub {ORB_ID(vehicle_gps_position)}
 
uORB::Subscription _battery_status_sub {ORB_ID(battery_status)}
 
uORB::Subscription _vehicle_attitude_sub {ORB_ID(vehicle_attitude)}
 
uORB::Subscription _vehicle_status_sub {ORB_ID(vehicle_status)}
 
hrt_abstime _last_update {0}
 
int _next_type {0}
 
int _uart_fd
 

Static Private Attributes

static constexpr int num_data_types {4}
 number of different telemetry data types More...
 

Detailed Description

High-level class that handles sending of CRSF telemetry data.

Definition at line 57 of file crsf_telemetry.h.

Constructor & Destructor Documentation

◆ CRSFTelemetry()

CRSFTelemetry::CRSFTelemetry ( int  uart_fd)
Parameters
uart_fdfile descriptor for the UART to use. It is expected to be configured already.

Definition at line 37 of file crsf_telemetry.cpp.

◆ ~CRSFTelemetry()

CRSFTelemetry::~CRSFTelemetry ( )
default

Member Function Documentation

◆ send_attitude()

bool CRSFTelemetry::send_attitude ( )
private

Definition at line 110 of file crsf_telemetry.cpp.

References _uart_fd, _vehicle_attitude_sub, attitude, crsf_send_telemetry_attitude(), vehicle_attitude_s::q, and uORB::Subscription::update().

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_battery()

bool CRSFTelemetry::send_battery ( )
private

Definition at line 76 of file crsf_telemetry.cpp.

References _battery_status_sub, _uart_fd, crsf_send_telemetry_battery(), battery_status_s::current_filtered_a, battery_status_s::discharged_mah, battery_status_s::remaining, uORB::Subscription::update(), and battery_status_s::voltage_filtered_v.

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_flight_mode()

bool CRSFTelemetry::send_flight_mode ( )
private

Definition at line 125 of file crsf_telemetry.cpp.

References _uart_fd, _vehicle_status_sub, crsf_send_telemetry_flight_mode(), flight_mode, vehicle_status_s::nav_state, and uORB::Subscription::update().

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ send_gps()

bool CRSFTelemetry::send_gps ( )
private

Definition at line 91 of file crsf_telemetry.cpp.

References _uart_fd, _vehicle_gps_position_sub, vehicle_gps_position_s::alt, vehicle_gps_position_s::cog_rad, crsf_send_telemetry_gps(), math::degrees(), vehicle_gps_position_s::lat, vehicle_gps_position_s::lon, vehicle_gps_position_s::satellites_used, uORB::Subscription::update(), and vehicle_gps_position_s::vel_d_m_s.

Referenced by update().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ update()

bool CRSFTelemetry::update ( const hrt_abstime now)

Send telemetry data.

Call this regularly (i.e. at 100Hz), it will automatically limit the sending rate.

Returns
true if new data sent

Definition at line 42 of file crsf_telemetry.cpp.

References _last_update, _next_type, num_data_types, send_attitude(), send_battery(), send_flight_mode(), and send_gps().

Referenced by RCInput::cycle().

Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ _battery_status_sub

uORB::Subscription CRSFTelemetry::_battery_status_sub {ORB_ID(battery_status)}
private

Definition at line 82 of file crsf_telemetry.h.

Referenced by send_battery().

◆ _last_update

hrt_abstime CRSFTelemetry::_last_update {0}
private

Definition at line 86 of file crsf_telemetry.h.

Referenced by update().

◆ _next_type

int CRSFTelemetry::_next_type {0}
private

Definition at line 89 of file crsf_telemetry.h.

Referenced by update().

◆ _uart_fd

int CRSFTelemetry::_uart_fd
private

Definition at line 91 of file crsf_telemetry.h.

Referenced by send_attitude(), send_battery(), send_flight_mode(), and send_gps().

◆ _vehicle_attitude_sub

uORB::Subscription CRSFTelemetry::_vehicle_attitude_sub {ORB_ID(vehicle_attitude)}
private

Definition at line 83 of file crsf_telemetry.h.

Referenced by send_attitude().

◆ _vehicle_gps_position_sub

uORB::Subscription CRSFTelemetry::_vehicle_gps_position_sub {ORB_ID(vehicle_gps_position)}
private

Definition at line 81 of file crsf_telemetry.h.

Referenced by send_gps().

◆ _vehicle_status_sub

uORB::Subscription CRSFTelemetry::_vehicle_status_sub {ORB_ID(vehicle_status)}
private

Definition at line 84 of file crsf_telemetry.h.

Referenced by send_flight_mode().

◆ num_data_types

constexpr int CRSFTelemetry::num_data_types {4}
staticprivate

number of different telemetry data types

Definition at line 88 of file crsf_telemetry.h.

Referenced by update().


The documentation for this class was generated from the following files: