[telemetry] change register callback to pass arguments

This commit is contained in:
Gautier Hattenberger
2014-11-04 23:12:47 +01:00
parent f1a64a9362
commit c4b73552cd
44 changed files with 119 additions and 117 deletions
+10 -10
View File
@@ -56,13 +56,13 @@ bool_t gps_lost;
bool_t power_switch;
static void send_alive(void) {
static void send_alive(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);
}
#if defined RADIO_CALIB && defined RADIO_CONTROL_SETTINGS
#include "rc_settings.h"
static void send_rc_settings(void) {
static void send_rc_settings(struct transport_tx *trans, struct device *dev) {
if (!RcSettingsOff())
DOWNLINK_SEND_SETTINGS(DefaultChannel, DefaultDevice, &slider_1_val, &slider_2_val);
}
@@ -75,18 +75,18 @@ void autopilot_send_mode(void) {
&pprz_mode, &v_ctl_mode, &lateral_mode, &horizontal_mode, &rc_settings_mode, &mcu1_status);
}
static void send_attitude(void) {
static void send_attitude(struct transport_tx *trans, struct device *dev) {
struct FloatEulers* att = stateGetNedToBodyEulers_f();
DOWNLINK_SEND_ATTITUDE(DefaultChannel, DefaultDevice,
&(att->phi), &(att->psi), &(att->theta));
};
static void send_estimator(void) {
static void send_estimator(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ESTIMATOR(DefaultChannel, DefaultDevice,
&(stateGetPositionUtm_f()->alt), &(stateGetSpeedEnu_f()->z));
}
static void send_bat(void) {
static void send_bat(struct transport_tx *trans, struct device *dev) {
int16_t amps = (int16_t) (current/10);
int16_t e = energy;
DOWNLINK_SEND_BAT(DefaultChannel, DefaultDevice,
@@ -95,7 +95,7 @@ static void send_bat(void) {
&block_time, &stage_time, &e);
}
static void send_energy(void) {
static void send_energy(struct transport_tx *trans, struct device *dev) {
uint16_t e = energy;
float vsup = ((float)vsupply) / 10.0f;
float curs = ((float)current) / 1000.0f;
@@ -103,14 +103,14 @@ static void send_energy(void) {
DOWNLINK_SEND_ENERGY(DefaultChannel, DefaultDevice, &vsup, &curs, &e, &power);
}
static void send_dl_value(void) {
static void send_dl_value(struct transport_tx *trans, struct device *dev) {
PeriodicSendDlValue(DefaultChannel, DefaultDevice);
}
// FIXME not the best place
#include "firmwares/fixedwing/stabilization/stabilization_attitude.h"
#include CTRL_TYPE_H
static void send_desired(void) {
static void send_desired(struct transport_tx *trans, struct device *dev) {
#ifndef USE_AIRSPEED
float v_ctl_auto_airspeed_setpoint = NOMINAL_AIRSPEED;
#endif
@@ -120,7 +120,7 @@ static void send_desired(void) {
&v_ctl_auto_airspeed_setpoint);
}
static void send_airspeed(void) {
static void send_airspeed(struct transport_tx *trans, struct device *dev) {
#ifdef MEASURE_AIRSPEED
float* airspeed = stateGetAirspeed_f();
DOWNLINK_SEND_AIRSPEED(DefaultChannel, DefaultDevice, airspeed, airspeed, airspeed, airspeed);
@@ -131,7 +131,7 @@ static void send_airspeed(void) {
#endif
}
static void send_downlink(void) {
static void send_downlink(struct transport_tx *trans, struct device *dev) {
static uint16_t last;
uint16_t rate = (downlink_nb_bytes - last) / PERIOD_DOWNLINK_Ap_0;
last = downlink_nb_bytes;
+2 -2
View File
@@ -143,7 +143,7 @@ static inline void on_mag_event( void );
volatile uint8_t ahrs_timeout_counter = 0;
//FIXME not the correct place
static void send_filter_status(void) {
static void send_filter_status(struct transport_tx *trans, struct device *dev) {
uint8_t mde = 3;
if (ahrs.status == AHRS_UNINIT) mde = 2;
if (ahrs_timeout_counter > 10) mde = 5;
@@ -460,7 +460,7 @@ void reporting_task( void ) {
/** then report periodicly */
else {
//PeriodicSendAp(DefaultChannel, DefaultDevice);
periodic_telemetry_send_Ap();
periodic_telemetry_send_Ap((void*)(DefaultChannel), (void*)(DefaultDevice));
}
}
+6 -6
View File
@@ -76,22 +76,22 @@ tid_t electrical_tid; ///< id for electrical_periodic() timer
/********** PERIODIC MESSAGES ************************************************/
#if PERIODIC_TELEMETRY
static void send_commands(void) {
static void send_commands(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_COMMANDS(DefaultChannel, DefaultDevice, COMMANDS_NB, commands);
}
#ifdef RADIO_CONTROL
static void send_fbw_status(void) {
static void send_fbw_status(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_FBW_STATUS(DefaultChannel, DefaultDevice,
&(radio_control.status), &(radio_control.frame_rate), &fbw_mode, &electrical.vsupply, &electrical.current);
}
static void send_rc(void) {
static void send_rc(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_RC(DefaultChannel, DefaultDevice, RADIO_CONTROL_NB_CHANNEL, radio_control.values);
}
#else
static void send_fbw_status(void) {
static void send_fbw_status(struct transport_tx *trans, struct device *dev) {
uint8_t dummy = 0;
DOWNLINK_SEND_FBW_STATUS(DefaultChannel, DefaultDevice,
&dummy, &dummy, &fbw_mode, &electrical.vsupply, &electrical.current);
@@ -99,7 +99,7 @@ static void send_fbw_status(void) {
#endif
#ifdef ACTUATORS
static void send_actuators(void) {
static void send_actuators(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice , ACTUATORS_NB, actuators);
}
#endif
@@ -335,7 +335,7 @@ void periodic_task_fbw( void ) {
#endif
#if PERIODIC_TELEMETRY
periodic_telemetry_send_Fbw();
periodic_telemetry_send_Fbw((void*)(DefaultChannel), (void*)(DefaultDevice));
#endif
}
+6 -6
View File
@@ -451,16 +451,16 @@ void nav_periodic_task(void) {
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_nav_ref(void) {
static void send_nav_ref(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_NAVIGATION_REF(DefaultChannel, DefaultDevice,
&nav_utm_east0, &nav_utm_north0, &nav_utm_zone0, &ground_alt);
}
static void send_nav(void) {
static void send_nav(struct transport_tx *trans, struct device *dev) {
SEND_NAVIGATION(DefaultChannel, DefaultDevice);
}
static void send_wp_moved(void) {
static void send_wp_moved(struct transport_tx *trans, struct device *dev) {
static uint8_t i;
i++; if (i >= nb_waypoint) i = 0;
DownlinkSendWp(DefaultChannel, DefaultDevice, i);
@@ -473,21 +473,21 @@ bool_t DownlinkSendWpNr(uint8_t _wp)
}
static void send_circle(void) {
static void send_circle(struct transport_tx *trans, struct device *dev) {
if (nav_in_circle) {
DOWNLINK_SEND_CIRCLE(DefaultChannel, DefaultDevice,
&nav_circle_x, &nav_circle_y, &nav_circle_radius);
}
}
static void send_segment(void) {
static void send_segment(struct transport_tx *trans, struct device *dev) {
if (nav_in_segment) {
DOWNLINK_SEND_SEGMENT(DefaultChannel, DefaultDevice,
&nav_segment_x_1, &nav_segment_y_1, &nav_segment_x_2, &nav_segment_y_2);
}
}
static void send_survey(void) {
static void send_survey(struct transport_tx *trans, struct device *dev) {
if (nav_survey_active) {
DOWNLINK_SEND_SURVEY(DefaultChannel, DefaultDevice,
&nav_survey_east, &nav_survey_north, &nav_survey_west, &nav_survey_south);
@@ -192,16 +192,16 @@ inline static void h_ctl_pitch_loop( void );
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_calibration(void) {
static void send_calibration(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_CALIBRATION(DefaultChannel, DefaultDevice, &v_ctl_auto_throttle_sum_err, &v_ctl_auto_throttle_submode);
}
static void send_tune_roll(void) {
static void send_tune_roll(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_TUNE_ROLL(DefaultChannel, DefaultDevice,
&(stateGetBodyRates_f()->p), &(stateGetNedToBodyEulers_f()->phi), &h_ctl_roll_setpoint);
}
static void send_ctl_a(void) {
static void send_ctl_a(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_H_CTL_A(DefaultChannel, DefaultDevice,
&h_ctl_roll_sum_err,
&h_ctl_roll_setpoint,
@@ -115,7 +115,7 @@ static float nav_ratio;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_calibration(void) {
static void send_calibration(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_CALIBRATION(DefaultChannel, DefaultDevice, &v_ctl_auto_throttle_sum_err, &v_ctl_auto_throttle_submode);
}
#endif
+9 -9
View File
@@ -138,7 +138,7 @@ PRINT_CONFIG_MSG("Enabled UNLOCKED_HOME_MODE since MODE_AUTO2 is AP_MODE_HOME")
#endif
#endif
static void send_alive(void) {
static void send_alive(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ALIVE(DefaultChannel, DefaultDevice, 16, MD5SUM);
}
@@ -146,7 +146,7 @@ static void send_alive(void) {
#include "subsystems/actuators/motor_mixing.h"
#endif
static void send_status(void) {
static void send_status(struct transport_tx *trans, struct device *dev) {
uint32_t imu_nb_err = 0;
#if USE_MOTOR_MIXING
uint8_t _motor_nb_err = motor_mixing.nb_saturation + motor_mixing.nb_failure * 10;
@@ -168,7 +168,7 @@ static void send_status(void) {
&electrical.vsupply, &time_sec);
}
static void send_energy(void) {
static void send_energy(struct transport_tx *trans, struct device *dev) {
uint16_t e = electrical.energy;
float vsup = ((float)electrical.vsupply) / 10.0f;
float curs = ((float)electrical.current) / 1000.0f;
@@ -176,7 +176,7 @@ static void send_energy(void) {
DOWNLINK_SEND_ENERGY(DefaultChannel, DefaultDevice, &vsup, &curs, &e, &power);
}
static void send_fp(void) {
static void send_fp(struct transport_tx *trans, struct device *dev) {
int32_t carrot_up = -guidance_v_z_sp;
DOWNLINK_SEND_ROTORCRAFT_FP(DefaultChannel, DefaultDevice,
&(stateGetPositionEnu_i()->x),
@@ -197,11 +197,11 @@ static void send_fp(void) {
}
#ifdef RADIO_CONTROL
static void send_rc(void) {
static void send_rc(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_RC(DefaultChannel, DefaultDevice, RADIO_CONTROL_NB_CHANNEL, radio_control.values);
}
static void send_rotorcraft_rc(void) {
static void send_rotorcraft_rc(struct transport_tx *trans, struct device *dev) {
#ifdef RADIO_KILL_SWITCH
int16_t _kill_switch = radio_control.values[RADIO_KILL_SWITCH];
#else
@@ -219,16 +219,16 @@ static void send_rotorcraft_rc(void) {
#endif
#ifdef ACTUATORS
static void send_actuators(void) {
static void send_actuators(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ACTUATORS(DefaultChannel, DefaultDevice , ACTUATORS_NB, actuators);
}
#endif
static void send_dl_value(void) {
static void send_dl_value(struct transport_tx *trans, struct device *dev) {
PeriodicSendDlValue(DefaultChannel, DefaultDevice);
}
static void send_rotorcraft_cmd(void) {
static void send_rotorcraft_cmd(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ROTORCRAFT_CMD(DefaultChannel, DefaultDevice,
&stabilization_cmd[COMMAND_ROLL],
&stabilization_cmd[COMMAND_PITCH],
@@ -109,7 +109,7 @@ static void read_rc_setpoint_speed_i(struct Int32Vect2 *speed_sp, bool_t in_flig
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_gh(void) {
static void send_gh(struct transport_tx *trans, struct device *dev) {
struct NedCoor_i* pos = stateGetPositionNed_i();
DOWNLINK_SEND_GUIDANCE_H_INT(DefaultChannel, DefaultDevice,
&guidance_h_pos_sp.x, &guidance_h_pos_sp.y,
@@ -117,7 +117,7 @@ static void send_gh(void) {
&(pos->x), &(pos->y));
}
static void send_hover_loop(void) {
static void send_hover_loop(struct transport_tx *trans, struct device *dev) {
struct NedCoor_i* pos = stateGetPositionNed_i();
struct NedCoor_i* speed = stateGetSpeedNed_i();
struct NedCoor_i* accel = stateGetAccelNed_i();
@@ -138,7 +138,7 @@ static void send_hover_loop(void) {
&guidance_h_heading_sp);
}
static void send_href(void) {
static void send_href(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_GUIDANCE_H_REF_INT(DefaultChannel, DefaultDevice,
&guidance_h_pos_sp.x, &guidance_h_pos_ref.x,
&guidance_h_speed_sp.x, &guidance_h_speed_ref.x,
@@ -148,7 +148,7 @@ static void send_href(void) {
&guidance_h_accel_ref.y);
}
static void send_tune_hover(void) {
static void send_tune_hover(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ROTORCRAFT_TUNE_HOVER(DefaultChannel, DefaultDevice,
&radio_control.values[RADIO_ROLL],
&radio_control.values[RADIO_PITCH],
@@ -142,7 +142,7 @@ static void run_hover_loop(bool_t in_flight);
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_vert_loop(void) {
static void send_vert_loop(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_VERT_LOOP(DefaultChannel, DefaultDevice,
&guidance_v_z_sp, &guidance_v_zd_sp,
&(stateGetPositionNed_i()->z),
@@ -159,7 +159,7 @@ static void send_vert_loop(void) {
&guidance_v_delta_t);
}
static void send_tune_vert(void) {
static void send_tune_vert(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_TUNE_VERT(DefaultChannel, DefaultDevice,
&guidance_v_z_sp,
&(stateGetPositionNed_i()->z),
+1 -1
View File
@@ -228,7 +228,7 @@ STATIC_INLINE void main_periodic( void ) {
}
STATIC_INLINE void telemetry_periodic(void) {
periodic_telemetry_send_Main();
periodic_telemetry_send_Main((void*)(DefaultChannel), (void*)(DefaultDevice));
}
/** mode to enter when RC is lost while using a mode with RC input (not AP_MODE_NAV) */
@@ -106,7 +106,7 @@ static inline void nav_set_altitude( void );
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_nav_status(void) {
static void send_nav_status(struct transport_tx *trans, struct device *dev) {
float dist_home = sqrtf(dist2_to_home);
float dist_wp = sqrtf(dist2_to_wp);
DOWNLINK_SEND_ROTORCRAFT_NAV_STATUS(DefaultChannel, DefaultDevice,
@@ -129,7 +129,7 @@ static void send_nav_status(void) {
}
}
static void send_wp_moved(void) {
static void send_wp_moved(struct transport_tx *trans, struct device *dev) {
static uint8_t i;
i++; if (i >= nb_waypoint) i = 0;
DOWNLINK_SEND_WP_MOVED_ENU(DefaultChannel, DefaultDevice,
@@ -44,7 +44,7 @@ float stabilization_att_ff_cmd[COMMANDS_NB];
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_att(void) {
static void send_att(struct transport_tx *trans, struct device *dev) {
struct FloatRates* body_rate = stateGetBodyRates_f();
struct FloatEulers* att = stateGetNedToBodyEulers_f();
float foo = 0.0;
@@ -69,7 +69,7 @@ static void send_att(void) {
&foo, &foo, &foo);
}
static void send_att_ref(void) {
static void send_att_ref(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_STAB_ATTITUDE_REF_FLOAT(DefaultChannel, DefaultDevice,
&stab_att_sp_euler.phi,
&stab_att_sp_euler.theta,
@@ -65,7 +65,7 @@ static inline void reset_psi_ref_from_body(void) {
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_att(void) {
static void send_att(struct transport_tx *trans, struct device *dev) {
struct Int32Rates* body_rate = stateGetBodyRates_i();
struct Int32Eulers* att = stateGetNedToBodyEulers_i();
DOWNLINK_SEND_STAB_ATTITUDE_INT(DefaultChannel, DefaultDevice,
@@ -88,7 +88,7 @@ static void send_att(void) {
&stabilization_cmd[COMMAND_YAW]);
}
static void send_att_ref(void) {
static void send_att_ref(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_STAB_ATTITUDE_REF_INT(DefaultChannel, DefaultDevice,
&stab_att_sp_euler.phi,
&stab_att_sp_euler.theta,
@@ -95,7 +95,7 @@ static const float psi_ddgain_surface[] = STABILIZATION_ATTITUDE_PSI_DDGAIN_SURF
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_att(void) {
static void send_att(struct transport_tx *trans, struct device *dev) {
struct FloatRates* body_rate = stateGetBodyRates_f();
struct FloatEulers* att = stateGetNedToBodyEulers_f();
DOWNLINK_SEND_STAB_ATTITUDE_FLOAT(DefaultChannel, DefaultDevice,
@@ -119,7 +119,7 @@ static void send_att(void) {
&body_rate_d.p, &body_rate_d.q, &body_rate_d.r);
}
static void send_att_ref(void) {
static void send_att_ref(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_STAB_ATTITUDE_REF_FLOAT(DefaultChannel, DefaultDevice,
&stab_att_sp_euler.phi,
&stab_att_sp_euler.theta,
@@ -69,7 +69,7 @@ int32_t stabilization_att_ff_cmd[COMMANDS_NB];
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_att(void) { //FIXME really use this message here ?
static void send_att(struct transport_tx *trans, struct device *dev) { //FIXME really use this message here ?
struct Int32Rates* body_rate = stateGetBodyRates_i();
struct Int32Eulers* att = stateGetNedToBodyEulers_i();
DOWNLINK_SEND_STAB_ATTITUDE_INT(DefaultChannel, DefaultDevice,
@@ -92,7 +92,7 @@ static void send_att(void) { //FIXME really use this message here ?
&stabilization_cmd[COMMAND_YAW]);
}
static void send_att_ref(void) {
static void send_att_ref(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_STAB_ATTITUDE_REF_INT(DefaultChannel, DefaultDevice,
&stab_att_sp_euler.phi,
&stab_att_sp_euler.theta,
@@ -108,7 +108,7 @@ static void send_att_ref(void) {
&stab_att_ref_accel.r);
}
static void send_ahrs_ref_quat(void) {
static void send_ahrs_ref_quat(struct transport_tx *trans, struct device *dev) {
struct Int32Quat* quat = stateGetNedToBodyQuat_i();
DOWNLINK_SEND_AHRS_REF_QUAT(DefaultChannel, DefaultDevice,
&stab_att_ref_quat.qi,
@@ -118,7 +118,7 @@ struct Int32Rates stabilization_rate_ff_cmd;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_rate(void) {
static void send_rate(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_RATE_LOOP(DefaultChannel, DefaultDevice,
&stabilization_rate_sp.p,
&stabilization_rate_sp.q,
+2 -2
View File
@@ -184,12 +184,12 @@ struct link_mcu_msg link_mcu_from_fbw_msg;
#define RC_REALLY_LOST 2
static void send_commands(void)
static void send_commands(struct transport_tx *trans, struct device *dev)
{
DOWNLINK_SEND_COMMANDS(DefaultChannel, DefaultDevice, COMMANDS_NB, ap_state->commands);
}
static void send_fbw_status(void)
static void send_fbw_status(struct transport_tx *trans, struct device *dev)
{
uint8_t rc_status = 0;
uint8_t fbw_status = 0;
+1 -1
View File
@@ -106,7 +106,7 @@ uint8_t link_mcu_fbw_nb_err;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_debug_link(void) {
static void send_debug_link(struct transport_tx *trans, struct device *dev) {
uint8_t mcu1_ppm_cpt_foo = 0; //FIXME
DOWNLINK_SEND_DEBUG_MCU_LINK(DefaultChannel, DefaultDevice,
&link_mcu_nb_err, &link_mcu_fbw_nb_err, &mcu1_ppm_cpt_foo);
+2 -2
View File
@@ -254,12 +254,12 @@ inline void parse_mavpilot_msg( void );
#define RC_REALLY_LOST 2
static void send_commands(void) {
static void send_commands(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_COMMANDS(DefaultChannel, DefaultDevice, COMMANDS_NB, ap_state->commands);
}
static void send_fbw_status(void) {
static void send_fbw_status(struct transport_tx *trans, struct device *dev) {
uint8_t rc_status = 0;
uint8_t fbw_status = 0;
if (bit_is_set(fbw_state->status, STATUS_MODE_AUTO))
+3 -3
View File
@@ -138,13 +138,13 @@ static void temperature_cb(uint8_t __attribute__((unused)) sender_id, const floa
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_baro_raw(void)
static void send_baro_raw(struct transport_tx *trans, struct device *dev)
{
DOWNLINK_SEND_BARO_RAW(DefaultChannel, DefaultDevice,
&air_data.pressure, &air_data.differential);
}
static void send_air_data(void)
static void send_air_data(struct transport_tx *trans, struct device *dev)
{
DOWNLINK_SEND_AIR_DATA(DefaultChannel, DefaultDevice,
&air_data.pressure, &air_data.differential,
@@ -153,7 +153,7 @@ static void send_air_data(void)
&air_data.tas_factor);
}
static void send_amsl(void)
static void send_amsl(struct transport_tx *trans, struct device *dev)
{
const float MeterPerFeet = 0.3048;
float amsl_baro_ft = air_data.amsl_baro / MeterPerFeet;
+2 -2
View File
@@ -100,12 +100,12 @@ void cam_target(void);
void cam_waypoint_target(void);
void cam_ac_target(void);
static void send_cam(void) {
static void send_cam(struct transport_tx *trans, struct device *dev) {
SEND_CAM(DefaultChannel, DefaultDevice);
}
#ifdef SHOW_CAM_COORDINATES
static void send_cam_point(void) {
static void send_cam_point(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_CAM_POINT(DefaultChannel, DefaultDevice,
&cam_point_distance_from_home, &cam_point_lat, &cam_point_lon);
}
@@ -88,7 +88,7 @@ int16_t rotorcraft_cam_pan;
#define ROTORCRAFT_CAM_PAN_MIN 0
#define ROTORCRAFT_CAM_PAN_MAX INT32_ANGLE_2_PI
static void send_cam(void) {
static void send_cam(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_ROTORCRAFT_CAM(DefaultChannel, DefaultDevice,
&rotorcraft_cam_tilt,&rotorcraft_cam_pan);
}
@@ -96,7 +96,7 @@ void digital_cam_uart_event(void)
}
#if PERIODIC_TELEMETRY
static void send_thumbnails(void)
static void send_thumbnails(struct transport_tx *trans, struct device *dev)
{
static int cnt = 0;
if (digital_cam_uart_thumbnails > 0) {
+1 -1
View File
@@ -45,7 +45,7 @@ static uint32_t samples_idx;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_aligner(void) {
static void send_aligner(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_FILTER_ALIGNER(DefaultChannel, DefaultDevice,
&ahrs_aligner.lp_gyro.p,
&ahrs_aligner.lp_gyro.q,
+1 -1
View File
@@ -49,7 +49,7 @@ unsigned char buffer[4096]; //Packet buffer
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_ahrs_ad2(void) {
static void send_ahrs_ad2(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_AHRS_ARDRONE2(DefaultChannel, DefaultDevice,
&ahrs_impl.state,
&ahrs_impl.control_state,
@@ -93,7 +93,7 @@ struct AhrsFloatCmpl ahrs_impl;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_att(void) {
static void send_att(struct transport_tx *trans, struct device *dev) {
struct FloatEulers ltp_to_imu_euler;
float_eulers_of_quat(&ltp_to_imu_euler, &ahrs_impl.ltp_to_imu_quat);
struct Int32Eulers euler_i;
@@ -108,14 +108,14 @@ static void send_att(void) {
&(eulers_body->psi));
}
static void send_geo_mag(void) {
static void send_geo_mag(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_GEO_MAG(DefaultChannel, DefaultDevice,
&ahrs_impl.mag_h.x, &ahrs_impl.mag_h.y, &ahrs_impl.mag_h.z);
}
// TODO convert from float to int if we really need this one
/*
static void send_rmat(void) {
static void send_rmat(struct transport_tx *trans, struct device *dev) {
struct Int32RMat* att_rmat = stateGetNedToBodyRMat_i();
DOWNLINK_SEND_AHRS_RMAT(DefaultChannel, DefaultDevice,
&ahrs_impl.ltp_to_imu_rmat.m[0],
@@ -63,7 +63,7 @@ struct AhrsMlkf ahrs_impl;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_geo_mag(void) {
static void send_geo_mag(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_GEO_MAG(DefaultChannel, DefaultDevice,
&ahrs_impl.mag_h.x, &ahrs_impl.mag_h.y, &ahrs_impl.mag_h.z);
}
+2 -2
View File
@@ -42,12 +42,12 @@ float heading;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_infrared(void) {
static void send_infrared(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IR_SENSORS(DefaultChannel, DefaultDevice,
&infrared.value.ir1, &infrared.value.ir2, &infrared.pitch, &infrared.roll, &infrared.top);
}
static void send_status(void) {
static void send_status(struct transport_tx *trans, struct device *dev) {
uint16_t contrast = abs(infrared.roll) + abs(infrared.pitch) + abs(infrared.top);
uint8_t mde = 3;
if (contrast < 50) mde = 7;
@@ -64,7 +64,7 @@ static inline void set_body_state_from_euler(void);
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_filter(void) {
static void send_filter(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_FILTER(DefaultChannel, DefaultDevice,
&ahrs_impl.ltp_to_imu_euler.phi,
&ahrs_impl.ltp_to_imu_euler.theta,
@@ -83,7 +83,7 @@ static void send_filter(void) {
&ahrs_impl.gyro_bias.r);
}
static void send_euler(void) {
static void send_euler(struct transport_tx *trans, struct device *dev) {
struct Int32Eulers* eulers = stateGetNedToBodyEulers_i();
DOWNLINK_SEND_AHRS_EULER_INT(DefaultChannel, DefaultDevice,
&ahrs_impl.ltp_to_imu_euler.phi,
@@ -94,7 +94,7 @@ static void send_euler(void) {
&(eulers->psi));
}
static void send_bias(void) {
static void send_bias(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_AHRS_GYRO_BIAS_INT(DefaultChannel, DefaultDevice,
&ahrs_impl.gyro_bias.p, &ahrs_impl.gyro_bias.q, &ahrs_impl.gyro_bias.r);
}
@@ -114,7 +114,7 @@ static inline void ahrs_update_mag_2d(float dt);
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_quat(void) {
static void send_quat(struct transport_tx *trans, struct device *dev) {
struct Int32Quat* quat = stateGetNedToBodyQuat_i();
DOWNLINK_SEND_AHRS_QUAT_INT(DefaultChannel, DefaultDevice,
&ahrs_impl.weight,
@@ -128,7 +128,7 @@ static void send_quat(void) {
&(quat->qz));
}
static void send_euler(void) {
static void send_euler(struct transport_tx *trans, struct device *dev) {
struct Int32Eulers ltp_to_imu_euler;
int32_eulers_of_quat(&ltp_to_imu_euler, &ahrs_impl.ltp_to_imu_quat);
struct Int32Eulers* eulers = stateGetNedToBodyEulers_i();
@@ -141,12 +141,12 @@ static void send_euler(void) {
&(eulers->psi));
}
static void send_bias(void) {
static void send_bias(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_AHRS_GYRO_BIAS_INT(DefaultChannel, DefaultDevice,
&ahrs_impl.gyro_bias.p, &ahrs_impl.gyro_bias.q, &ahrs_impl.gyro_bias.r);
}
static void send_geo_mag(void) {
static void send_geo_mag(struct transport_tx *trans, struct device *dev) {
struct FloatVect3 h_float;
h_float.x = MAG_FLOAT_OF_BFP(ahrs_impl.mag_h.x);
h_float.y = MAG_FLOAT_OF_BFP(ahrs_impl.mag_h.y);
+1 -1
View File
@@ -178,7 +178,7 @@ static const uint8_t pn_bind[] = { 0x98, 0x88, 0x1B, 0xE4, 0x30, 0x79, 0x03, 0x8
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_superbit(void) {
static void send_superbit(struct transport_tx *trans, struct device *dev) {
uint8_t status = superbitrf.status;
uint8_t cyrf6936_status = superbitrf.cyrf6936.status;
DOWNLINK_SEND_SUPERBITRF(DefaultChannel, DefaultDevice,
@@ -31,10 +31,12 @@
#include <inttypes.h>
#include "std.h"
#include "mcu_periph/device.h"
#include "subsystems/datalink/transport.h"
/** Telemetry callback definition
*/
typedef void (*telemetry_cb)(void);
typedef void (*telemetry_cb)(struct transport_tx *trans, struct device *dev);
/** Telemetry header
*/
+4 -4
View File
@@ -45,7 +45,7 @@ struct GpsTimeSync gps_time_sync;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_gps(void) {
static void send_gps(struct transport_tx *trans, struct device *dev) {
static uint8_t i;
int16_t climb = -gps.ned_vel.z;
int16_t course = (DegOfRad(gps.course)/((int32_t)1e6));
@@ -64,7 +64,7 @@ static void send_gps(void) {
i++;
}
static void send_gps_int(void) {
static void send_gps_int(struct transport_tx *trans, struct device *dev) {
static uint8_t i;
static uint8_t last_cnos[GPS_NB_CHANNELS];
DOWNLINK_SEND_GPS_INT(DefaultChannel, DefaultDevice,
@@ -88,7 +88,7 @@ static void send_gps_int(void) {
i++;
}
static void send_gps_lla(void) {
static void send_gps_lla(struct transport_tx *trans, struct device *dev) {
uint8_t err = 0;
int16_t climb = -gps.ned_vel.z;
int16_t course = (DegOfRad(gps.course)/((int32_t)1e6));
@@ -99,7 +99,7 @@ static void send_gps_lla(void) {
&gps.fix, &err);
}
static void send_gps_sol(void) {
static void send_gps_sol(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_GPS_SOL(DefaultChannel, DefaultDevice, &gps.pacc, &gps.sacc, &gps.pdop, &gps.num_sv);
}
#endif
+11 -11
View File
@@ -44,63 +44,63 @@
#if USE_IMU_FLOAT
static void send_accel(void) {
static void send_accel(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_ACCEL(DefaultChannel, DefaultDevice,
&imuf.accel.x, &imuf.accel.y, &imuf.accel.z);
}
static void send_gyro(void) {
static void send_gyro(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_GYRO(DefaultChannel, DefaultDevice,
&imuf.gyro.p, &imuf.gyro.q, &imuf.gyro.r);
}
#else // !USE_IMU_FLOAT
static void send_accel_raw(void) {
static void send_accel_raw(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_ACCEL_RAW(DefaultChannel, DefaultDevice,
&imu.accel_unscaled.x, &imu.accel_unscaled.y, &imu.accel_unscaled.z);
}
static void send_accel_scaled(void) {
static void send_accel_scaled(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_ACCEL_SCALED(DefaultChannel, DefaultDevice,
&imu.accel.x, &imu.accel.y, &imu.accel.z);
}
static void send_accel(void) {
static void send_accel(struct transport_tx *trans, struct device *dev) {
struct FloatVect3 accel_float;
ACCELS_FLOAT_OF_BFP(accel_float, imu.accel);
DOWNLINK_SEND_IMU_ACCEL(DefaultChannel, DefaultDevice,
&accel_float.x, &accel_float.y, &accel_float.z);
}
static void send_gyro_raw(void) {
static void send_gyro_raw(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_GYRO_RAW(DefaultChannel, DefaultDevice,
&imu.gyro_unscaled.p, &imu.gyro_unscaled.q, &imu.gyro_unscaled.r);
}
static void send_gyro_scaled(void) {
static void send_gyro_scaled(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_GYRO_SCALED(DefaultChannel, DefaultDevice,
&imu.gyro.p, &imu.gyro.q, &imu.gyro.r);
}
static void send_gyro(void) {
static void send_gyro(struct transport_tx *trans, struct device *dev) {
struct FloatRates gyro_float;
RATES_FLOAT_OF_BFP(gyro_float, imu.gyro);
DOWNLINK_SEND_IMU_GYRO(DefaultChannel, DefaultDevice,
&gyro_float.p, &gyro_float.q, &gyro_float.r);
}
static void send_mag_raw(void) {
static void send_mag_raw(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_MAG_RAW(DefaultChannel, DefaultDevice,
&imu.mag_unscaled.x, &imu.mag_unscaled.y, &imu.mag_unscaled.z);
}
static void send_mag_scaled(void) {
static void send_mag_scaled(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_IMU_MAG_SCALED(DefaultChannel, DefaultDevice,
&imu.mag.x, &imu.mag.y, &imu.mag.z);
}
static void send_mag(void) {
static void send_mag(struct transport_tx *trans, struct device *dev) {
struct FloatVect3 mag_float;
MAGS_FLOAT_OF_BFP(mag_float, imu.mag);
DOWNLINK_SEND_IMU_MAG(DefaultChannel, DefaultDevice,
+3 -3
View File
@@ -229,7 +229,7 @@ static void b2_hff_update_ydot(struct HfilterFloat* hff_work, float vel, float R
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_hff(void) {
static void send_hff(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_HFF(DefaultChannel, DefaultDevice,
&b2_hff_state.x,
&b2_hff_state.y,
@@ -239,7 +239,7 @@ static void send_hff(void) {
&b2_hff_state.ydotdot);
}
static void send_hff_debug(void) {
static void send_hff_debug(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_HFF_DBG(DefaultChannel, DefaultDevice,
&b2_hff_x_meas,
&b2_hff_y_meas,
@@ -252,7 +252,7 @@ static void send_hff_debug(void) {
}
#ifdef GPS_LAG
static void send_hff_gps(void) {
static void send_hff_gps(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_HFF_GPS(DefaultChannel, DefaultDevice,
&(b2_hff_rb_last->lag_counter),
&lag_counter_err,
@@ -62,7 +62,7 @@
#if !INS_UPDATE_FW_ESTIMATOR && PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_ins_ref(void) {
static void send_ins_ref(struct transport_tx *trans, struct device *dev) {
float foo = 0.;
if (state.ned_initialized_i) {
DOWNLINK_SEND_INS_REF(DefaultChannel, DefaultDevice,
@@ -58,20 +58,20 @@ struct InsGpsPassthrough ins_impl;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_ins(void) {
static void send_ins(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_INS(DefaultChannel, DefaultDevice,
&ins_impl.ltp_pos.x, &ins_impl.ltp_pos.y, &ins_impl.ltp_pos.z,
&ins_impl.ltp_speed.x, &ins_impl.ltp_speed.y, &ins_impl.ltp_speed.z,
&ins_impl.ltp_accel.x, &ins_impl.ltp_accel.y, &ins_impl.ltp_accel.z);
}
static void send_ins_z(void) {
static void send_ins_z(struct transport_tx *trans, struct device *dev) {
static const float fake_baro_z = 0.0;
DOWNLINK_SEND_INS_Z(DefaultChannel, DefaultDevice,
&fake_baro_z, &ins_impl.ltp_pos.z, &ins_impl.ltp_speed.z, &ins_impl.ltp_accel.z);
}
static void send_ins_ref(void) {
static void send_ins_ref(struct transport_tx *trans, struct device *dev) {
static const float fake_qfe = 0.0;
if (ins_impl.ltp_initialized) {
DOWNLINK_SEND_INS_REF(DefaultChannel, DefaultDevice,
+3 -3
View File
@@ -121,19 +121,19 @@ struct InsInt ins_impl;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_ins(void) {
static void send_ins(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_INS(DefaultChannel, DefaultDevice,
&ins_impl.ltp_pos.x, &ins_impl.ltp_pos.y, &ins_impl.ltp_pos.z,
&ins_impl.ltp_speed.x, &ins_impl.ltp_speed.y, &ins_impl.ltp_speed.z,
&ins_impl.ltp_accel.x, &ins_impl.ltp_accel.y, &ins_impl.ltp_accel.z);
}
static void send_ins_z(void) {
static void send_ins_z(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_INS_Z(DefaultChannel, DefaultDevice,
&ins_impl.baro_z, &ins_impl.ltp_pos.z, &ins_impl.ltp_speed.z, &ins_impl.ltp_accel.z);
}
static void send_ins_ref(void) {
static void send_ins_ref(struct transport_tx *trans, struct device *dev) {
if (ins_impl.ltp_initialized) {
DOWNLINK_SEND_INS_REF(DefaultChannel, DefaultDevice,
&ins_impl.ltp_def.ecef.x, &ins_impl.ltp_def.ecef.y, &ins_impl.ltp_def.ecef.z,
@@ -69,7 +69,7 @@ struct VffExtended vff;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_vffe(void) {
static void send_vffe(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_VFF_EXTENDED(DefaultChannel, DefaultDevice,
&vff.z_meas, &vff.z_meas_baro,
&vff.z, &vff.zdot, &vff.zdotdot,
+1 -1
View File
@@ -62,7 +62,7 @@ struct Vff vff;
#if PERIODIC_TELEMETRY
#include "subsystems/datalink/telemetry.h"
static void send_vff(void) {
static void send_vff(struct transport_tx *trans, struct device *dev) {
DOWNLINK_SEND_VFF(DefaultChannel, DefaultDevice,
&vff.z_meas, &vff.z, &vff.zdot, &vff.bias,
&vff.P[0][0], &vff.P[1][1], &vff.P[2][2]);
+1 -1
View File
@@ -58,7 +58,7 @@ static bool_t ppm_data_valid;
#include "subsystems/datalink/telemetry.h"
static void send_ppm(void)
static void send_ppm(struct transport_tx *trans, struct device *dev)
{
uint16_t ppm_pulses_usec[RADIO_CONTROL_NB_CHANNEL];
for (int i = 0; i < RADIO_CONTROL_NB_CHANNEL; i++) {
+1 -1
View File
@@ -42,7 +42,7 @@ struct Sbus sbus;
#include "subsystems/datalink/telemetry.h"
static void send_sbus(void)
static void send_sbus(struct transport_tx *trans, struct device *dev)
{
// Using PPM message
DOWNLINK_SEND_PPM(DefaultChannel, DefaultDevice,
@@ -45,7 +45,7 @@ struct Sbus sbus1, sbus2;
#include "subsystems/datalink/telemetry.h"
static void send_sbus(void)
static void send_sbus(struct transport_tx *trans, struct device *dev)
{
// Using PPM message
DOWNLINK_SEND_PPM(DefaultChannel, DefaultDevice,
+2 -2
View File
@@ -84,7 +84,7 @@ let output_modes = fun out_h process_name modes freq modules ->
right ();
lprintf out_h "if (telemetry_%s.msgs[TELEMETRY_%s_MSG_%s_ID].cb != NULL)\n" process_name (String.uppercase process_name) message_name;
right ();
lprintf out_h "telemetry_%s.msgs[TELEMETRY_%s_MSG_%s_ID].cb();\n" process_name (String.uppercase process_name) message_name;
lprintf out_h "telemetry_%s.msgs[TELEMETRY_%s_MSG_%s_ID].cb(trans, dev);\n" process_name (String.uppercase process_name) message_name;
left ();
fprintf out_h "#if USE_PERIODIC_TELEMETRY_REPORT\n";
lprintf out_h "else periodic_telemetry_err_report(TELEMETRY_PROCESS_%s, telemetry_mode_%s, TELEMETRY_%s_MSG_%s_ID);\n" process_name process_name (String.uppercase process_name) message_name;
@@ -212,7 +212,7 @@ let _ =
fprintf out_h "extern struct pprz_telemetry telemetry_%s;\n" process_name;
fprintf out_h "#endif /* PERIODIC_C_%s */\n" (String.uppercase process_name);
lprintf out_h "static inline void periodic_telemetry_send_%s(void) { /* %dHz */\n" process_name freq; (*TODO pass transport+device *)
lprintf out_h "static inline void periodic_telemetry_send_%s(struct transport_tx *trans, struct device *dev) { /* %dHz */\n" process_name freq; (*TODO pass transport+device with correct types *)
right ();
output_modes out_h process_name modes freq modules_name;
left ();