diff --git a/conf/settings/settings_booz2.xml b/conf/settings/settings_booz2.xml index cc91ed9e92..4fec928e81 100644 --- a/conf/settings/settings_booz2.xml +++ b/conf/settings/settings_booz2.xml @@ -4,7 +4,7 @@ - + diff --git a/conf/telemetry/telemetry.dtd b/conf/telemetry/telemetry.dtd index e53997944a..94dd31bfb0 100644 --- a/conf/telemetry/telemetry.dtd +++ b/conf/telemetry/telemetry.dtd @@ -6,6 +6,7 @@ = nb_waypoint) i = 0; \ - DownlinkSendWp(i); \ + DownlinkSendWp(_chan, i); \ } #ifdef RADIO_CONTROL_SETTINGS -#define PERIODIC_SEND_SETTINGS() if (!RcSettingsOff()) DOWNLINK_SEND_SETTINGS(&slider_1_val, &slider_2_val); +#define PERIODIC_SEND_SETTINGS(_chan) if (!RcSettingsOff()) DOWNLINK_SEND_SETTINGS(_chan, &slider_1_val, &slider_2_val); #else -#define PERIODIC_SEND_SETTINGS() {} +#define PERIODIC_SEND_SETTINGS(_chan) {} #endif #ifdef INFRARED -#define PERIODIC_SEND_IR_SENSORS() DOWNLINK_SEND_IR_SENSORS(&ir_ir1, &ir_ir2, &ir_pitch, &ir_roll, &ir_top); +#define PERIODIC_SEND_IR_SENSORS(_chan) DOWNLINK_SEND_IR_SENSORS(_chan, &ir_ir1, &ir_ir2, &ir_pitch, &ir_roll, &ir_top); #endif -#define PERIODIC_SEND_ADC() {} +#define PERIODIC_SEND_ADC(_chan) {} #ifdef IDG300 #include "gyro.h" -#define PERIODIC_SEND_GYRO_RATES() DOWNLINK_SEND_GYRO_RATES(&roll_rate_adc, &estimator_p, &estimator_q) +#define PERIODIC_SEND_GYRO_RATES(_chan) DOWNLINK_SEND_GYRO_RATES(_chan, &roll_rate_adc, &estimator_p, &estimator_q) #elif defined ADXRS150 -#define PERIODIC_SEND_GYRO_RATES() DOWNLINK_SEND_GYRO_RATES(&roll_rate_adc, &estimator_p, &temp_comp) +#define PERIODIC_SEND_GYRO_RATES(_chan) DOWNLINK_SEND_GYRO_RATES(_chan, &roll_rate_adc, &estimator_p, &temp_comp) #else -#define PERIODIC_SEND_GYRO_RATES() {} +#define PERIODIC_SEND_GYRO_RATES(_chan) {} #endif -#define PERIODIC_SEND_CALIBRATION() DOWNLINK_SEND_CALIBRATION(&v_ctl_auto_throttle_sum_err, &v_ctl_auto_throttle_submode) +#define PERIODIC_SEND_CALIBRATION(_chan) DOWNLINK_SEND_CALIBRATION(_chan, &v_ctl_auto_throttle_sum_err, &v_ctl_auto_throttle_submode) -#define PERIODIC_SEND_CIRCLE() if (nav_in_circle) { DOWNLINK_SEND_CIRCLE(&nav_circle_x, &nav_circle_y, &nav_circle_radius); } +#define PERIODIC_SEND_CIRCLE(_chan) if (nav_in_circle) { DOWNLINK_SEND_CIRCLE(_chan, &nav_circle_x, &nav_circle_y, &nav_circle_radius); } -#define PERIODIC_SEND_SEGMENT() if (nav_in_segment) { DOWNLINK_SEND_SEGMENT(&nav_segment_x_1, &nav_segment_y_1, &nav_segment_x_2, &nav_segment_y_2); } +#define PERIODIC_SEND_SEGMENT(_chan) if (nav_in_segment) { DOWNLINK_SEND_SEGMENT(_chan, &nav_segment_x_1, &nav_segment_y_1, &nav_segment_x_2, &nav_segment_y_2); } #ifdef IMU_ANALOG -#define PERIODIC_SEND_IMU() { int16_t dummy = 42; DOWNLINK_SEND_IMU(&(from_fbw.euler_dot[0]), &(from_fbw.euler_dot[1]), &(from_fbw.euler_dot[2]), &dummy, &dummy, &dummy); } +#define PERIODIC_SEND_IMU(_chan) { int16_t dummy = 42; DOWNLINK_SEND_IMU(_chan, &(from_fbw.euler_dot[0]), &(from_fbw.euler_dot[1]), &(from_fbw.euler_dot[2]), &dummy, &dummy, &dummy); } #else -#define PERIODIC_SEND_IMU() {} +#define PERIODIC_SEND_IMU(_chan) {} #endif -#define PERIODIC_SEND_ESTIMATOR() DOWNLINK_SEND_ESTIMATOR(&estimator_z, &estimator_z_dot) +#define PERIODIC_SEND_ESTIMATOR(_chan) DOWNLINK_SEND_ESTIMATOR(_chan, &estimator_z, &estimator_z_dot) -#define SEND_NAVIGATION() Downlink({ DOWNLINK_SEND_NAVIGATION(&nav_block, &nav_stage, &estimator_x, &estimator_y, &dist2_to_wp, &dist2_to_home);}) +#define SEND_NAVIGATION(_chan) Downlink({ DOWNLINK_SEND_NAVIGATION(_chan, &nav_block, &nav_stage, &estimator_x, &estimator_y, &dist2_to_wp, &dist2_to_home);}) -#define PERIODIC_SEND_NAVIGATION() SEND_NAVIGATION() +#define PERIODIC_SEND_NAVIGATION(_chan) SEND_NAVIGATION(_chan) #if defined CAM || defined MOBILE_CAM -#define SEND_CAM() Downlink({ int16_t x = cam_target_x; int16_t y = cam_target_y; int8_t phi = DegOfRad(cam_phi_c); int8_t theta = DegOfRad(cam_theta_c); DOWNLINK_SEND_CAM(&phi, &theta, &x, &y);}) +#define SEND_CAM(_chan) Downlink({ int16_t x = cam_target_x; int16_t y = cam_target_y; int8_t phi = DegOfRad(cam_phi_c); int8_t theta = DegOfRad(cam_theta_c); DOWNLINK_SEND_CAM(_chan, &phi, &theta, &x, &y);}) #else -#define SEND_CAM() {} +#define SEND_CAM(_chan) {} #endif -#define PERIODIC_SEND_DL_VALUE() PeriodicSendDlValue() /** generated from the xml settings config in conf/settings */ +#define PERIODIC_SEND_DL_VALUE(_chan) PeriodicSendDlValue(_chan) /** generated from the xml settings config in conf/settings */ -#define PERIODIC_SEND_SURVEY() { \ +#define PERIODIC_SEND_SURVEY(_chan) { \ if (nav_survey_active) \ - DOWNLINK_SEND_SURVEY(&nav_survey_east, &nav_survey_north, &nav_survey_west, &nav_survey_south); \ + DOWNLINK_SEND_SURVEY(_chan, &nav_survey_east, &nav_survey_north, &nav_survey_west, &nav_survey_south); \ } -#define PERIODIC_SEND_RANGEFINDER() DOWNLINK_SEND_RANGEFINDER(&rangemeter, &ctl_grz_z_dot, &ctl_grz_z_dot_sum_err, &ctl_grz_z_dot_setpoint, &ctl_grz_z_sum_err, &ctl_grz_z_setpoint, &flying) +#define PERIODIC_SEND_RANGEFINDER(_chan) DOWNLINK_SEND_RANGEFINDER(_chan, &rangemeter, &ctl_grz_z_dot, &ctl_grz_z_dot_sum_err, &ctl_grz_z_dot_setpoint, &ctl_grz_z_sum_err, &ctl_grz_z_setpoint, &flying) -#define PERIODIC_SEND_TUNE_ROLL() DOWNLINK_SEND_TUNE_ROLL(&estimator_p,&estimator_phi, &h_ctl_roll_setpoint); +#define PERIODIC_SEND_TUNE_ROLL(_chan) DOWNLINK_SEND_TUNE_ROLL(_chan, &estimator_p,&estimator_phi, &h_ctl_roll_setpoint); #if defined GPS || defined SITL -#define PERIODIC_SEND_GPS_SOL() DOWNLINK_SEND_GPS_SOL(&gps_Pacc, &gps_Sacc, &gps_PDOP, &gps_numSV) +#define PERIODIC_SEND_GPS_SOL(_chan) DOWNLINK_SEND_GPS_SOL(_chan, &gps_Pacc, &gps_Sacc, &gps_PDOP, &gps_numSV) #endif /* add by Haiyang Chao for debugging msg used by osam_imu*/ #if defined UGEAR -#define PERIODIC_SEND_GPS() DOWNLINK_SEND_GPS(&gps_mode, &gps_utm_east, &gps_utm_north, &gps_course, &gps_alt, &gps_gspeed,&gps_climb, &gps_week, &gps_itow, &gps_utm_zone, &gps_nb_ovrn) -#define PERIODIC_SEND_GPS_SOL() DOWNLINK_SEND_GPS_SOL(&gps_Pacc, &gps_Sacc, &gps_PDOP, &gps_numSV) -#define PERIODIC_SEND_DebugChao() DOWNLINK_SEND_DebugChao(&ugear_debug1, &ugear_debug2, &ugear_debug3, &ugear_debug4, &ugear_debug5, &ugear_debug6) +#define PERIODIC_SEND_GPS(_chan) DOWNLINK_SEND_GPS(_chan, &gps_mode, &gps_utm_east, &gps_utm_north, &gps_course, &gps_alt, &gps_gspeed,&gps_climb, &gps_week, &gps_itow, &gps_utm_zone, &gps_nb_ovrn) +#define PERIODIC_SEND_GPS_SOL(_chan) DOWNLINK_SEND_GPS_SOL(_chan, &gps_Pacc, &gps_Sacc, &gps_PDOP, &gps_numSV) +#define PERIODIC_SEND_DebugChao(_chan) DOWNLINK_SEND_DebugChao(_chan, &ugear_debug1, &ugear_debug2, &ugear_debug3, &ugear_debug4, &ugear_debug5, &ugear_debug6) #else # ifdef PERIOD_GPS_0 # include "gps.h" -# define PERIODIC_SEND_GPS() gps_send() +# define PERIODIC_SEND_GPS(_chan) gps_send() # endif #endif #ifdef USE_BARO_MS5534A #include "baro_MS5534A.h" -#define PERIODIC_SEND_BARO_MS5534A() DOWNLINK_SEND_BARO_MS5534A(&baro_MS5534A_pressure, &baro_MS5534A_temp, &baro_MS5534A_z) +#define PERIODIC_SEND_BARO_MS5534A(_chan) DOWNLINK_SEND_BARO_MS5534A(_chan, &baro_MS5534A_pressure, &baro_MS5534A_temp, &baro_MS5534A_z) #else -#define PERIODIC_SEND_BARO_MS5534A() {} +#define PERIODIC_SEND_BARO_MS5534A(_chan) {} #endif #include "fw_h_ctl_a.h" -#define PERIODIC_SEND_H_CTL_A() DOWNLINK_SEND_H_CTL_A(&h_ctl_roll_sum_err, &h_ctl_ref_roll_angle, &h_ctl_pitch_sum_err, &h_ctl_ref_pitch_angle) +#define PERIODIC_SEND_H_CTL_A(_chan) DOWNLINK_SEND_H_CTL_A(_chan, &h_ctl_roll_sum_err, &h_ctl_ref_roll_angle, &h_ctl_pitch_sum_err, &h_ctl_ref_pitch_angle) #endif /* AP_DOWNLINK_H */ diff --git a/sw/airborne/booz/booz2_datalink.c b/sw/airborne/booz/booz2_datalink.c index 1524f3adfb..1ee5135dd4 100644 --- a/sw/airborne/booz/booz2_datalink.c +++ b/sw/airborne/booz/booz2_datalink.c @@ -47,7 +47,7 @@ void dl_parse_msg(void) { case DL_PING: { - DOWNLINK_SEND_PONG(); + DOWNLINK_SEND_PONG(DefaultChannel); } break; @@ -56,7 +56,7 @@ void dl_parse_msg(void) { uint8_t i = DL_SETTING_index(dl_buffer); float var = DL_SETTING_value(dl_buffer); DlSetting(i, var); - DOWNLINK_SEND_DL_VALUE(&i, &var); + DOWNLINK_SEND_DL_VALUE(DefaultChannel, &i, &var); } break; @@ -91,7 +91,7 @@ void dl_parse_msg(void) { enu.y = POS_BFP_OF_REAL(enu.y)/100; enu.z = POS_BFP_OF_REAL(enu.z)/100; VECT3_ASSIGN(waypoints[wp_id], enu.x, enu.y, enu.z); - DOWNLINK_SEND_WP_MOVED_LTP(&wp_id, &enu.x, &enu.y, &enu.z); + DOWNLINK_SEND_WP_MOVED_LTP(DefaultChannel, &wp_id, &enu.x, &enu.y, &enu.z); } break; #endif /* USE_NAVIGATION */ diff --git a/sw/airborne/booz/booz2_telemetry.c b/sw/airborne/booz/booz2_telemetry.c index bdebef3a77..b5557dcc15 100644 --- a/sw/airborne/booz/booz2_telemetry.c +++ b/sw/airborne/booz/booz2_telemetry.c @@ -24,5 +24,5 @@ #include "booz2_telemetry.h" -uint8_t telemetry_mode_Main; +uint8_t telemetry_mode_Main_DefaultChannel; diff --git a/sw/airborne/booz/booz2_telemetry.h b/sw/airborne/booz/booz2_telemetry.h index 82c8ca159c..bd12efdde8 100644 --- a/sw/airborne/booz/booz2_telemetry.h +++ b/sw/airborne/booz/booz2_telemetry.h @@ -36,20 +36,21 @@ #include "actuators.h" -#define PERIODIC_SEND_ALIVE() DOWNLINK_SEND_ALIVE(16, MD5SUM) +#define PERIODIC_SEND_ALIVE(_chan) DOWNLINK_SEND_ALIVE(_chan, 16, MD5SUM) #include "booz2_battery.h" #include "booz_imu.h" #include "booz2_gps.h" #include "booz2_ins.h" -extern uint8_t telemetry_mode_Main; +extern uint8_t telemetry_mode_Main_DefaultChannel; #ifdef USE_GPS -#define PERIODIC_SEND_BOOZ_STATUS() { \ +#define PERIODIC_SEND_BOOZ_STATUS(_chan) { \ uint32_t booz_imu_nb_err = 0; \ uint8_t twi_blmc_nb_err = 0; \ - DOWNLINK_SEND_BOOZ_STATUS(&booz_imu_nb_err, \ + DOWNLINK_SEND_BOOZ_STATUS(_chan, \ + &booz_imu_nb_err, \ &twi_blmc_nb_err, \ &radio_control.status, \ &booz_gps_state.fix, \ @@ -63,11 +64,12 @@ extern uint8_t telemetry_mode_Main; ); \ } #else /* !USE_GPS */ -#define PERIODIC_SEND_BOOZ_STATUS() { \ +#define PERIODIC_SEND_BOOZ_STATUS(_chan) { \ uint32_t booz_imu_nb_err = 0; \ uint8_t twi_blmc_nb_err = 0; \ uint8_t fix = BOOZ2_GPS_FIX_NONE; \ - DOWNLINK_SEND_BOOZ_STATUS(&booz_imu_nb_err, \ + DOWNLINK_SEND_BOOZ_STATUS(_chan, \ + &booz_imu_nb_err, \ &twi_blmc_nb_err, \ &radio_control.status, \ &fix, \ @@ -83,90 +85,101 @@ extern uint8_t telemetry_mode_Main; #endif /* USE_GPS */ #ifdef USE_RADIO_CONTROL -#define PERIODIC_SEND_RC() DOWNLINK_SEND_RC(RADIO_CONTROL_NB_CHANNEL, radio_control.values) -#define PERIODIC_SEND_BOOZ2_RADIO_CONTROL() { \ - int16_t foo = 0; \ - DOWNLINK_SEND_BOOZ2_RADIO_CONTROL(&radio_control.values[RADIO_CONTROL_ROLL], \ - &radio_control.values[RADIO_CONTROL_PITCH], \ - &radio_control.values[RADIO_CONTROL_YAW], \ +#define PERIODIC_SEND_RC(_chan) DOWNLINK_SEND_RC(_chan, RADIO_CONTROL_NB_CHANNEL, radio_control.values) +#define PERIODIC_SEND_BOOZ2_RADIO_CONTROL(_chan) { \ + int16_t foo = 0; \ + DOWNLINK_SEND_BOOZ2_RADIO_CONTROL(_chan, \ + &radio_control.values[RADIO_CONTROL_ROLL], \ + &radio_control.values[RADIO_CONTROL_PITCH], \ + &radio_control.values[RADIO_CONTROL_YAW], \ &radio_control.values[RADIO_CONTROL_THROTTLE], \ - &radio_control.values[RADIO_CONTROL_MODE], \ - &foo, \ + &radio_control.values[RADIO_CONTROL_MODE], \ + &foo, \ &radio_control.status);} #else -#define PERIODIC_SEND_RC() {} +#define PERIODIC_SEND_RC(_chan) {} +#define PERIODIC_SEND_BOOZ2_RADIO_CONTROL(_chan) {} #endif #ifdef RADIO_CONTROL_TYPE_PPM -#define PERIODIC_SEND_PPM() DOWNLINK_SEND_PPM(&radio_control.frame_rate, \ - RADIO_CONTROL_NB_CHANNEL, \ - booz_radio_control_ppm_pulses) +#define PERIODIC_SEND_PPM(_chan) \ + DOWNLINK_SEND_PPM(_chan, \ + &radio_control.frame_rate, \ + RADIO_CONTROL_NB_CHANNEL, \ + booz_radio_control_ppm_pulses) #else -#define PERIODIC_SEND_PPM() {} +#define PERIODIC_SEND_PPM(_chan) {} #endif -#define PERIODIC_SEND_BOOZ2_GYRO() { \ - DOWNLINK_SEND_BOOZ2_GYRO(&booz_imu.gyro.p, \ +#define PERIODIC_SEND_BOOZ2_GYRO(_chan) { \ + DOWNLINK_SEND_BOOZ2_GYRO(_chan, \ + &booz_imu.gyro.p, \ &booz_imu.gyro.q, \ &booz_imu.gyro.r); \ } -#define PERIODIC_SEND_BOOZ2_ACCEL() { \ - DOWNLINK_SEND_BOOZ2_ACCEL(&booz_imu.accel.x, \ +#define PERIODIC_SEND_BOOZ2_ACCEL(_chan) { \ + DOWNLINK_SEND_BOOZ2_ACCEL(_chan, \ + &booz_imu.accel.x, \ &booz_imu.accel.y, \ &booz_imu.accel.z); \ } -#define PERIODIC_SEND_BOOZ2_MAG() { \ - DOWNLINK_SEND_BOOZ2_MAG(&booz_imu.mag.x, \ +#define PERIODIC_SEND_BOOZ2_MAG(_chan) { \ + DOWNLINK_SEND_BOOZ2_MAG(_chan, \ + &booz_imu.mag.x, \ &booz_imu.mag.y, \ &booz_imu.mag.z); \ } - - -#define PERIODIC_SEND_IMU_GYRO_RAW() { \ - DOWNLINK_SEND_IMU_GYRO_RAW(&booz_imu.gyro_unscaled.p, \ +#define PERIODIC_SEND_IMU_GYRO_RAW(_chan) { \ + DOWNLINK_SEND_IMU_GYRO_RAW(_chan, \ + &booz_imu.gyro_unscaled.p, \ &booz_imu.gyro_unscaled.q, \ &booz_imu.gyro_unscaled.r); \ } -#define PERIODIC_SEND_IMU_ACCEL_RAW() { \ - DOWNLINK_SEND_IMU_ACCEL_RAW(&booz_imu.accel_unscaled.x, \ +#define PERIODIC_SEND_IMU_ACCEL_RAW(_chan) { \ + DOWNLINK_SEND_IMU_ACCEL_RAW(_chan, \ + &booz_imu.accel_unscaled.x, \ &booz_imu.accel_unscaled.y, \ &booz_imu.accel_unscaled.z); \ } -#define PERIODIC_SEND_IMU_MAG_RAW() { \ - DOWNLINK_SEND_IMU_MAG_RAW(&booz_imu.mag_unscaled.x, \ +#define PERIODIC_SEND_IMU_MAG_RAW(_chan) { \ + DOWNLINK_SEND_IMU_MAG_RAW(_chan, \ + &booz_imu.mag_unscaled.x, \ &booz_imu.mag_unscaled.y, \ &booz_imu.mag_unscaled.z); \ } -#define PERIODIC_SEND_BOOZ2_BARO_RAW() { \ - DOWNLINK_SEND_BOOZ2_BARO_RAW(&booz2_analog_baro_offset, \ - &booz2_analog_baro_value, \ - &booz2_analog_baro_value_filtered); \ +#define PERIODIC_SEND_BOOZ2_BARO_RAW(_chan) { \ + DOWNLINK_SEND_BOOZ2_BARO_RAW(_chan, \ + &booz2_analog_baro_offset, \ + &booz2_analog_baro_value, \ + &booz2_analog_baro_value_filtered); \ } #include "booz_stabilization.h" -#define PERIODIC_SEND_BOOZ2_RATE_LOOP() { \ - DOWNLINK_SEND_BOOZ2_RATE_LOOP(&booz_stabilization_rate_measure.p, \ - &booz_stabilization_rate_measure.q, \ - &booz_stabilization_rate_measure.r, \ - &booz_stabilization_rate_sp.p, \ - &booz_stabilization_rate_sp.q, \ - &booz_stabilization_rate_sp.r, \ - &booz_stabilization_cmd[COMMAND_ROLL], \ - &booz_stabilization_cmd[COMMAND_PITCH], \ - &booz_stabilization_cmd[COMMAND_YAW], \ +#define PERIODIC_SEND_BOOZ2_RATE_LOOP(_chan) { \ + DOWNLINK_SEND_BOOZ2_RATE_LOOP(_chan, \ + &booz_stabilization_rate_measure.p, \ + &booz_stabilization_rate_measure.q, \ + &booz_stabilization_rate_measure.r, \ + &booz_stabilization_rate_sp.p, \ + &booz_stabilization_rate_sp.q, \ + &booz_stabilization_rate_sp.r, \ + &booz_stabilization_cmd[COMMAND_ROLL], \ + &booz_stabilization_cmd[COMMAND_PITCH], \ + &booz_stabilization_cmd[COMMAND_YAW], \ &booz_stabilization_cmd[COMMAND_THRUST]); \ } #ifdef STABILISATION_ATTITUDE_TYPE_INT -#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE() { \ - DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_INT(&booz_ahrs.body_rate.p, \ +#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE(_chan) { \ + DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_INT(_chan, \ + &booz_ahrs.body_rate.p, \ &booz_ahrs.body_rate.q, \ &booz_ahrs.body_rate.r, \ &booz_ahrs.ltp_to_body_euler.phi, \ @@ -190,8 +203,9 @@ extern uint8_t telemetry_mode_Main; } -#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE_REF() { \ - DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_REF_INT(&booz_stab_att_sp_euler.phi, \ +#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE_REF(_chan) { \ + DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_REF_INT(_chan, \ + &booz_stab_att_sp_euler.phi, \ &booz_stab_att_sp_euler.theta, \ &booz_stab_att_sp_euler.psi, \ &booz_stab_att_ref_euler.phi, \ @@ -207,8 +221,9 @@ extern uint8_t telemetry_mode_Main; #endif /* STABILISATION_ATTITUDE_TYPE_INT */ #ifdef STABILISATION_ATTITUDE_TYPE_FLOAT -#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE() { \ - DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_FLOAT(&booz_ahrs.body_rate.p, \ +#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE(_chan) { \ + DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_FLOAT(_chan, \ + &booz_ahrs.body_rate.p, \ &booz_ahrs.body_rate.q, \ &booz_ahrs.body_rate.r, \ &booz_ahrs.ltp_to_body_euler.phi, \ @@ -231,8 +246,9 @@ extern uint8_t telemetry_mode_Main; &booz_stabilization_cmd[COMMAND_YAW]); \ } -#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE_REF() { \ - DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_REF_FLOAT(&booz_stab_att_sp_euler.phi, \ +#define PERIODIC_SEND_BOOZ2_STAB_ATTITUDE_REF(_chan) { \ + DOWNLINK_SEND_BOOZ2_STAB_ATTITUDE_REF_FLOAT(_chan, \ + &booz_stab_att_sp_euler.phi, \ &booz_stab_att_sp_euler.theta, \ &booz_stab_att_sp_euler.psi, \ &booz_stab_att_ref_euler.phi, \ @@ -250,8 +266,9 @@ extern uint8_t telemetry_mode_Main; #include "ahrs/booz_ahrs_aligner.h" -#define PERIODIC_SEND_BOOZ2_FILTER_ALIGNER() { \ - DOWNLINK_SEND_BOOZ2_FILTER_ALIGNER(&booz_ahrs_aligner.lp_gyro.p, \ +#define PERIODIC_SEND_BOOZ2_FILTER_ALIGNER(_chan) { \ + DOWNLINK_SEND_BOOZ2_FILTER_ALIGNER(_chan, \ + &booz_ahrs_aligner.lp_gyro.p, \ &booz_ahrs_aligner.lp_gyro.q, \ &booz_ahrs_aligner.lp_gyro.r, \ &booz_imu.gyro.p, \ @@ -262,8 +279,9 @@ extern uint8_t telemetry_mode_Main; } -#define PERIODIC_SEND_BOOZ2_CMD() { \ - DOWNLINK_SEND_BOOZ2_CMD(&booz_stabilization_cmd[COMMAND_ROLL], \ +#define PERIODIC_SEND_BOOZ2_CMD(_chan) { \ + DOWNLINK_SEND_BOOZ2_CMD(_chan, \ + &booz_stabilization_cmd[COMMAND_ROLL], \ &booz_stabilization_cmd[COMMAND_PITCH], \ &booz_stabilization_cmd[COMMAND_YAW], \ &booz_stabilization_cmd[COMMAND_THRUST]); \ @@ -273,10 +291,11 @@ extern uint8_t telemetry_mode_Main; #ifdef USE_AHRS_CMPL #include "booz_ahrs.h" #include "ahrs/booz2_filter_attitude_cmpl_euler.h" -#define PERIODIC_SEND_BOOZ2_FILTER() { \ - DOWNLINK_SEND_BOOZ2_FILTER(&booz_ahrs.ltp_to_imu_euler.phi, \ +#define PERIODIC_SEND_BOOZ2_FILTER(_chan) { \ + DOWNLINK_SEND_BOOZ2_FILTER(_chan, \ + &booz_ahrs.ltp_to_imu_euler.phi, \ &booz_ahrs.ltp_to_imu_euler.theta, \ - &booz_ahrs.ltp_to_imu_euler.psi, \ + &booz_ahrs.ltp_to_imu_euler.psi, \ &booz2_face_measure.phi, \ &booz2_face_measure.theta, \ &booz2_face_measure.psi, \ @@ -291,75 +310,80 @@ extern uint8_t telemetry_mode_Main; &booz2_face_gyro_bias.r); \ } #else -#define PERIODIC_SEND_BOOZ2_FILTER() {} +#define PERIODIC_SEND_BOOZ2_FILTER(_chan) {} #endif #ifdef USE_AHRS_LKF #include "booz_ahrs.h" #include "ahrs/booz_ahrs_float_lkf.h" -#define PERIODIC_SEND_BOOZ_AHRS_LKF() { \ - DOWNLINK_SEND_BOOZ_AHRS_LKF(&bafl_eulers.phi, \ - &bafl_eulers.theta, \ - &bafl_eulers.psi, \ - &bafl_quat.qi, \ - &bafl_quat.qx, \ - &bafl_quat.qy, \ - &bafl_quat.qz, \ - &bafl_rates.p, \ - &bafl_rates.q, \ - &bafl_rates.r, \ - &bafl_accel_measure.x, \ - &bafl_accel_measure.y, \ - &bafl_accel_measure.z, \ - &bafl_mag.x, \ - &bafl_mag.y, \ - &bafl_mag.z); \ +#define PERIODIC_SEND_BOOZ_AHRS_LKF(_chan) { \ + DOWNLINK_SEND_BOOZ_AHRS_LKF(&bafl_eulers.phi, \ + _chan, \ + &bafl_eulers.theta, \ + &bafl_eulers.psi, \ + &bafl_quat.qi, \ + &bafl_quat.qx, \ + &bafl_quat.qy, \ + &bafl_quat.qz, \ + &bafl_rates.p, \ + &bafl_rates.q, \ + &bafl_rates.r, \ + &bafl_accel_measure.x, \ + &bafl_accel_measure.y, \ + &bafl_accel_measure.z, \ + &bafl_mag.x, \ + &bafl_mag.y, \ + &bafl_mag.z); \ } -#define PERIODIC_SEND_BOOZ_AHRS_LKF_DEBUG() { \ - DOWNLINK_SEND_BOOZ_AHRS_LKF_DEBUG(&bafl_X[0], \ - &bafl_X[1], \ - &bafl_X[2], \ - &bafl_bias.p, \ - &bafl_bias.q, \ - &bafl_bias.r, \ - &bafl_qnorm, \ - &bafl_phi_accel, \ - &bafl_theta_accel, \ - &bafl_P[0][0], \ - &bafl_P[1][1], \ - &bafl_P[2][2], \ - &bafl_P[3][3], \ - &bafl_P[4][4], \ - &bafl_P[5][5]); \ +#define PERIODIC_SEND_BOOZ_AHRS_LKF_DEBUG(_chan) { \ + DOWNLINK_SEND_BOOZ_AHRS_LKF_DEBUG(_chan, \ + &bafl_X[0], \ + &bafl_X[1], \ + &bafl_X[2], \ + &bafl_bias.p, \ + &bafl_bias.q, \ + &bafl_bias.r, \ + &bafl_qnorm, \ + &bafl_phi_accel, \ + &bafl_theta_accel, \ + &bafl_P[0][0], \ + &bafl_P[1][1], \ + &bafl_P[2][2], \ + &bafl_P[3][3], \ + &bafl_P[4][4], \ + &bafl_P[5][5]); \ } -#define PERIODIC_SEND_BOOZ_AHRS_LKF_ACC_DBG() { \ - DOWNLINK_SEND_BOOZ_AHRS_LKF_ACC_DBG(&bafl_q_a_err.qi, \ - &bafl_q_a_err.qx, \ - &bafl_q_a_err.qy, \ - &bafl_q_a_err.qz, \ - &bafl_b_a_err.p, \ - &bafl_b_a_err.q, \ - &bafl_b_a_err.r); \ +#define PERIODIC_SEND_BOOZ_AHRS_LKF_ACC_DBG(_chan) { \ + DOWNLINK_SEND_BOOZ_AHRS_LKF_ACC_DBG(_chan, \ + &bafl_q_a_err.qi, \ + &bafl_q_a_err.qx, \ + &bafl_q_a_err.qy, \ + &bafl_q_a_err.qz, \ + &bafl_b_a_err.p, \ + &bafl_b_a_err.q, \ + &bafl_b_a_err.r); \ } -#define PERIODIC_SEND_BOOZ_AHRS_LKF_MAG_DBG() { \ - DOWNLINK_SEND_BOOZ_AHRS_LKF_MAG_DBG(&bafl_q_m_err.qi, \ - &bafl_q_m_err.qx, \ - &bafl_q_m_err.qy, \ - &bafl_q_m_err.qz, \ - &bafl_b_m_err.p, \ - &bafl_b_m_err.q, \ - &bafl_b_m_err.r); \ +#define PERIODIC_SEND_BOOZ_AHRS_LKF_MAG_DBG(_chan) { \ + DOWNLINK_SEND_BOOZ_AHRS_LKF_MAG_DBG(_chan, \ + &bafl_q_m_err.qi, \ + &bafl_q_m_err.qx, \ + &bafl_q_m_err.qy, \ + &bafl_q_m_err.qz, \ + &bafl_b_m_err.p, \ + &bafl_b_m_err.q, \ + &bafl_b_m_err.r); \ } #else -#define PERIODIC_SEND_BOOZ_AHRS_LKF() {} -#define PERIODIC_SEND_BOOZ_AHRS_LKF_DEBUG() {} -#define PERIODIC_SEND_BOOZ_AHRS_LKF_MAG_DBG() {} -#define PERIODIC_SEND_BOOZ_AHRS_LKF_ACC_DBG() {} +#define PERIODIC_SEND_BOOZ_AHRS_LKF(_chan) {} +#define PERIODIC_SEND_BOOZ_AHRS_LKF_DEBUG(_chan) {} +#define PERIODIC_SEND_BOOZ_AHRS_LKF_MAG_DBG(_chan) {} +#define PERIODIC_SEND_BOOZ_AHRS_LKF_ACC_DBG(_chan) {} #endif -#define PERIODIC_SEND_BOOZ2_AHRS_QUAT() { \ - DOWNLINK_SEND_BOOZ2_AHRS_QUAT(&booz_ahrs.ltp_to_imu_quat.qi, \ +#define PERIODIC_SEND_BOOZ2_AHRS_QUAT(_chan) { \ + DOWNLINK_SEND_BOOZ2_AHRS_QUAT(_chan, \ + &booz_ahrs.ltp_to_imu_quat.qi, \ &booz_ahrs.ltp_to_imu_quat.qx, \ &booz_ahrs.ltp_to_imu_quat.qy, \ &booz_ahrs.ltp_to_imu_quat.qz, \ @@ -369,8 +393,9 @@ extern uint8_t telemetry_mode_Main; &booz_ahrs.ltp_to_body_quat.qz); \ } -#define PERIODIC_SEND_BOOZ2_AHRS_EULER() { \ - DOWNLINK_SEND_BOOZ2_AHRS_EULER(&booz_ahrs.ltp_to_imu_euler.phi, \ +#define PERIODIC_SEND_BOOZ2_AHRS_EULER(_chan) { \ + DOWNLINK_SEND_BOOZ2_AHRS_EULER(_chan, \ + &booz_ahrs.ltp_to_imu_euler.phi, \ &booz_ahrs.ltp_to_imu_euler.theta, \ &booz_ahrs.ltp_to_imu_euler.psi, \ &booz_ahrs.ltp_to_body_euler.phi, \ @@ -378,8 +403,9 @@ extern uint8_t telemetry_mode_Main; &booz_ahrs.ltp_to_body_euler.psi); \ } -#define PERIODIC_SEND_BOOZ2_AHRS_RMAT() { \ - DOWNLINK_SEND_BOOZ2_AHRS_RMAT(&booz_ahrs.ltp_to_imu_rmat.m[0], \ +#define PERIODIC_SEND_BOOZ2_AHRS_RMAT(_chan) { \ + DOWNLINK_SEND_BOOZ2_AHRS_RMAT(_chan, \ + &booz_ahrs.ltp_to_imu_rmat.m[0], \ &booz_ahrs.ltp_to_imu_rmat.m[1], \ &booz_ahrs.ltp_to_imu_rmat.m[2], \ &booz_ahrs.ltp_to_imu_rmat.m[3], \ @@ -402,8 +428,9 @@ extern uint8_t telemetry_mode_Main; -#define PERIODIC_SEND_BOOZ2_FILTER_Q() { \ - DOWNLINK_SEND_BOOZ2_FILTER_Q(&booz2_filter_attitude_quat.qi, \ +#define PERIODIC_SEND_BOOZ2_FILTER_Q(_chan) { \ + DOWNLINK_SEND_BOOZ2_FILTER_Q(_chan, \ + &booz2_filter_attitude_quat.qi, \ &booz2_filter_attitude_quat.qx, \ &booz2_filter_attitude_quat.qy, \ &booz2_filter_attitude_quat.qz); \ @@ -411,41 +438,45 @@ extern uint8_t telemetry_mode_Main; #ifdef USE_VFF #include "ins/booz2_vf_float.h" -#define PERIODIC_SEND_BOOZ2_VFF() { \ - DOWNLINK_SEND_BOOZ2_VFF(&b2_vff_z_meas, \ - &b2_vff_z, \ - &b2_vff_zdot, \ - &b2_vff_bias, \ - & b2_vff_P[0][0], \ - & b2_vff_P[1][1], \ - & b2_vff_P[2][2]); \ +#define PERIODIC_SEND_BOOZ2_VFF(_chan) { \ + DOWNLINK_SEND_BOOZ2_VFF(_chan, \ + &b2_vff_z_meas, \ + &b2_vff_z, \ + &b2_vff_zdot, \ + &b2_vff_bias, \ + & b2_vff_P[0][0], \ + & b2_vff_P[1][1], \ + & b2_vff_P[2][2]); \ } #else -define PERIODIC_SEND_BOOZ2_VFF() {} +#define PERIODIC_SEND_BOOZ2_VFF(_chan) {} #endif -#define PERIODIC_SEND_BOOZ2_GUIDANCE() { \ - DOWNLINK_SEND_BOOZ2_GUIDANCE(&booz2_guidance_h_cur_pos.x, \ +#define PERIODIC_SEND_BOOZ2_GUIDANCE(_chan) { \ + DOWNLINK_SEND_BOOZ2_GUIDANCE(_chan, \ + &booz2_guidance_h_cur_pos.x, \ &booz2_guidance_h_cur_pos.y, \ &booz2_guidance_h_held_pos.x, \ &booz2_guidance_h_held_pos.y); \ } -#define PERIODIC_SEND_BOOZ2_INS() { \ - DOWNLINK_SEND_BOOZ2_INS(&booz_ins_baro_alt, \ - &booz_ins_ltp_pos.z, \ - &booz_ins_ltp_speed.z, \ - &booz_ins_ltp_accel.z); \ +#define PERIODIC_SEND_BOOZ2_INS(_chan) { \ + DOWNLINK_SEND_BOOZ2_INS(_chan, \ + &booz_ins_baro_alt, \ + &booz_ins_ltp_pos.z, \ + &booz_ins_ltp_speed.z, \ + &booz_ins_ltp_accel.z); \ } -#define PERIODIC_SEND_BOOZ2_INS2() { \ +#define PERIODIC_SEND_BOOZ2_INS2(_chan) { \ struct Int32Vect3 pos_low_res; \ pos_low_res.x = (int32_t)(b2ins_pos_ltp.x>>20); \ pos_low_res.y = (int32_t)(b2ins_pos_ltp.y>>20); \ pos_low_res.z = (int32_t)(b2ins_pos_ltp.z>>20); \ - DOWNLINK_SEND_BOOZ2_INS2(&b2ins_accel_ltp.x, \ + DOWNLINK_SEND_BOOZ2_INS2(_chan, \ + &b2ins_accel_ltp.x, \ &b2ins_accel_ltp.y, \ &b2ins_accel_ltp.z, \ &b2ins_speed_ltp.x, \ @@ -458,8 +489,9 @@ define PERIODIC_SEND_BOOZ2_VFF() {} } #ifdef USE_GPS -#define PERIODIC_SEND_BOOZ2_INS3() { \ - DOWNLINK_SEND_BOOZ2_INS3(&b2ins_meas_gps_pos_ned.x, \ +#define PERIODIC_SEND_BOOZ2_INS3(_chan) { \ + DOWNLINK_SEND_BOOZ2_INS3(_chan, \ + &b2ins_meas_gps_pos_ned.x, \ &b2ins_meas_gps_pos_ned.y, \ &b2ins_meas_gps_pos_ned.z, \ &b2ins_meas_gps_speed_ned.x, \ @@ -468,11 +500,12 @@ define PERIODIC_SEND_BOOZ2_VFF() {} ); \ } #else /* !USE_GPS */ -#define PERIODIC_SEND_BOOZ2_INS3() {} +#define PERIODIC_SEND_BOOZ2_INS3(_chan) {} #endif /* USE_GPS */ -#define PERIODIC_SEND_BOOZ2_INS_REF() { \ - DOWNLINK_SEND_BOOZ2_INS_REF(&booz_ins_ltp_def.ecef.x, \ +#define PERIODIC_SEND_BOOZ2_INS_REF(_chan) { \ + DOWNLINK_SEND_BOOZ2_INS_REF(_chan, \ + &booz_ins_ltp_def.ecef.x, \ &booz_ins_ltp_def.ecef.y, \ &booz_ins_ltp_def.ecef.z, \ &booz_ins_ltp_def.lla.lat, \ @@ -483,8 +516,9 @@ define PERIODIC_SEND_BOOZ2_VFF() {} -#define PERIODIC_SEND_BOOZ2_VERT_LOOP() { \ - DOWNLINK_SEND_BOOZ2_VERT_LOOP(&booz2_guidance_v_z_sp, \ +#define PERIODIC_SEND_BOOZ2_VERT_LOOP(_chan) { \ + DOWNLINK_SEND_BOOZ2_VERT_LOOP(_chan, \ + &booz2_guidance_v_z_sp, \ &booz2_guidance_v_zd_sp, \ &booz_ins_ltp_pos.z, \ &booz_ins_ltp_speed.z, \ @@ -501,8 +535,9 @@ define PERIODIC_SEND_BOOZ2_VFF() {} &booz2_guidance_v_delta_t); \ } -#define PERIODIC_SEND_BOOZ2_HOVER_LOOP() { \ - DOWNLINK_SEND_BOOZ2_HOVER_LOOP(&booz2_guidance_h_pos_sp.x, \ +#define PERIODIC_SEND_BOOZ2_HOVER_LOOP(_chan) { \ + DOWNLINK_SEND_BOOZ2_HOVER_LOOP(_chan, \ + &booz2_guidance_h_pos_sp.x, \ &booz2_guidance_h_pos_sp.y, \ &booz_ins_ltp_pos.x, \ &booz_ins_ltp_pos.y, \ @@ -524,9 +559,10 @@ define PERIODIC_SEND_BOOZ2_VFF() {} #include "booz2_gps.h" #include "booz2_navigation.h" -#define PERIODIC_SEND_BOOZ2_FP() { \ +#define PERIODIC_SEND_BOOZ2_FP(_chan) { \ int32_t carrot_up = -booz2_guidance_v_z_sp; \ - DOWNLINK_SEND_BOOZ2_FP( &booz_ins_enu_pos.x, \ + DOWNLINK_SEND_BOOZ2_FP( _chan, \ + &booz_ins_enu_pos.x, \ &booz_ins_enu_pos.y, \ &booz_ins_enu_pos.z, \ &booz_ins_enu_speed.x, \ @@ -543,72 +579,86 @@ define PERIODIC_SEND_BOOZ2_VFF() {} } #ifdef USE_GPS -#define PERIODIC_SEND_BOOZ2_GPS() { \ - DOWNLINK_SEND_BOOZ2_GPS( &booz_gps_state.ecef_pos.x, \ - &booz_gps_state.ecef_pos.y, \ - &booz_gps_state.ecef_pos.z, \ - &booz_gps_state.ecef_vel.x, \ - &booz_gps_state.ecef_vel.y, \ - &booz_gps_state.ecef_vel.z, \ - &booz_gps_state.pacc, \ - &booz_gps_state.sacc, \ - &booz_gps_state.pdop, \ - &booz_gps_state.num_sv, \ - &booz_gps_state.fix); \ +#define PERIODIC_SEND_BOOZ2_GPS(_chan) { \ + DOWNLINK_SEND_BOOZ2_GPS( _chan, \ + &booz_gps_state.ecef_pos.x, \ + &booz_gps_state.ecef_pos.y, \ + &booz_gps_state.ecef_pos.z, \ + &booz_gps_state.ecef_vel.x, \ + &booz_gps_state.ecef_vel.y, \ + &booz_gps_state.ecef_vel.z, \ + &booz_gps_state.pacc, \ + &booz_gps_state.sacc, \ + &booz_gps_state.pdop, \ + &booz_gps_state.num_sv, \ + &booz_gps_state.fix); \ } #else -#define PERIODIC_SEND_BOOZ2_GPS() {} +#define PERIODIC_SEND_BOOZ2_GPS(_chan) {} #endif #include "booz2_navigation.h" -#define PERIODIC_SEND_BOOZ2_NAV_REF() { \ - DOWNLINK_SEND_BOOZ2_NAV_REF(&booz_ins_ltp_def.ecef.x, &booz_ins_ltp_def.ecef.y, &booz_ins_ltp_def.ecef.z); \ +#define PERIODIC_SEND_BOOZ2_NAV_REF(_chan) { \ + DOWNLINK_SEND_BOOZ2_NAV_REF(_chan, \ + &booz_ins_ltp_def.ecef.x, \ + &booz_ins_ltp_def.ecef.y, \ + &booz_ins_ltp_def.ecef.z); \ } -#define PERIODIC_SEND_BOOZ2_NAV_STATUS() { \ - DOWNLINK_SEND_BOOZ2_NAV_STATUS(&block_time,&stage_time,&nav_block,&nav_stage,&horizontal_mode); \ +#define PERIODIC_SEND_BOOZ2_NAV_STATUS(_chan) { \ + DOWNLINK_SEND_BOOZ2_NAV_STATUS(_chan, \ + &block_time, \ + &stage_time, \ + &nav_block, \ + &nav_stage, \ + &horizontal_mode); \ if (horizontal_mode == HORIZONTAL_MODE_ROUTE) { \ float sx = POS_FLOAT_OF_BFP(waypoints[nav_segment_start].x); \ float sy = POS_FLOAT_OF_BFP(waypoints[nav_segment_start].y); \ float ex = POS_FLOAT_OF_BFP(waypoints[nav_segment_end].x); \ float ey = POS_FLOAT_OF_BFP(waypoints[nav_segment_end].y); \ - DOWNLINK_SEND_SEGMENT(&sx, &sy, &ex, &ey); \ + DOWNLINK_SEND_SEGMENT(_chan, &sx, &sy, &ex, &ey); \ } \ } -#define PERIODIC_SEND_WP_MOVED() { \ - static uint8_t i; \ - i++; if (i >= nb_waypoint) i = 0; \ - DOWNLINK_SEND_WP_MOVED_LTP(&i, &(waypoints[i].x), &(waypoints[i].y), &(waypoints[i].z)); \ -} +#define PERIODIC_SEND_WP_MOVED(_chan) { \ + static uint8_t i; \ + i++; if (i >= nb_waypoint) i = 0; \ + DOWNLINK_SEND_WP_MOVED_LTP(_chan, \ + &i, \ + &(waypoints[i].x), \ + &(waypoints[i].y), \ + &(waypoints[i].z)); \ + } -#define PERIODIC_SEND_BOOZ2_TUNE_HOVER() { \ - DOWNLINK_SEND_BOOZ2_TUNE_HOVER(&radio_control.values[RADIO_CONTROL_ROLL], \ +#define PERIODIC_SEND_BOOZ2_TUNE_HOVER(_chan) { \ + DOWNLINK_SEND_BOOZ2_TUNE_HOVER(_chan, \ + &radio_control.values[RADIO_CONTROL_ROLL], \ &radio_control.values[RADIO_CONTROL_PITCH], \ - &radio_control.values[RADIO_CONTROL_YAW], \ - &booz_stabilization_cmd[COMMAND_ROLL], \ - &booz_stabilization_cmd[COMMAND_PITCH], \ - &booz_stabilization_cmd[COMMAND_YAW], \ - &booz_stabilization_cmd[COMMAND_THRUST], \ - &booz_ahrs.ltp_to_imu_euler.phi, \ - &booz_ahrs.ltp_to_imu_euler.theta, \ - &booz_ahrs.ltp_to_imu_euler.psi, \ - &booz_ahrs.ltp_to_body_euler.phi, \ - &booz_ahrs.ltp_to_body_euler.theta, \ - &booz_ahrs.ltp_to_body_euler.psi \ - ); \ + &radio_control.values[RADIO_CONTROL_YAW], \ + &booz_stabilization_cmd[COMMAND_ROLL], \ + &booz_stabilization_cmd[COMMAND_PITCH], \ + &booz_stabilization_cmd[COMMAND_YAW], \ + &booz_stabilization_cmd[COMMAND_THRUST], \ + &booz_ahrs.ltp_to_imu_euler.phi, \ + &booz_ahrs.ltp_to_imu_euler.theta, \ + &booz_ahrs.ltp_to_imu_euler.psi, \ + &booz_ahrs.ltp_to_body_euler.phi, \ + &booz_ahrs.ltp_to_body_euler.theta, \ + &booz_ahrs.ltp_to_body_euler.psi \ + ); \ } #include "settings.h" -#define PERIODIC_SEND_DL_VALUE() PeriodicSendDlValue() +#define PERIODIC_SEND_DL_VALUE(_chan) PeriodicSendDlValue(_chan) #include "periodic.h" -#define Booz2TelemetryPeriodic() { \ - PeriodicSendMain(); \ +#define Booz2TelemetryPeriodic() { \ + PeriodicSendMain_DefaultChannel(); \ } diff --git a/sw/airborne/datalink.c b/sw/airborne/datalink.c index d9a843ec6a..0ae29fbf2c 100644 --- a/sw/airborne/datalink.c +++ b/sw/airborne/datalink.c @@ -75,7 +75,7 @@ void dl_parse_msg(void) { uint8_t msg_id = IdOfMsg(dl_buffer); if (msg_id == DL_PING) { - DOWNLINK_SEND_PONG(); + DOWNLINK_SEND_PONG(DefaultChannel); } else #ifdef TRAFFIC_INFO if (msg_id == DL_ACINFO && DL_ACINFO_ac_id(dl_buffer) != AC_ID) { @@ -105,7 +105,7 @@ void dl_parse_msg(void) { coordinates */ latlong_utm_x = waypoints[wp_id].x + nav_utm_east0; latlong_utm_y = waypoints[wp_id].y + nav_utm_north0; - DOWNLINK_SEND_WP_MOVED(&wp_id, &latlong_utm_x, &latlong_utm_y, &a, &nav_utm_zone0); + DOWNLINK_SEND_WP_MOVED(DefaultChannel, &wp_id, &latlong_utm_x, &latlong_utm_y, &a, &nav_utm_zone0); } else if (msg_id == DL_BLOCK && DL_BLOCK_ac_id(dl_buffer) == AC_ID) { nav_goto_block(DL_BLOCK_block_id(dl_buffer)); } else @@ -116,7 +116,7 @@ void dl_parse_msg(void) { wind_north = DL_WIND_INFO_north(dl_buffer); estimator_airspeed = DL_WIND_INFO_airspeed(dl_buffer); #ifdef WIND_INFO_RET - DOWNLINK_SEND_WIND_INFO_RET(&wind_east, &wind_north, &estimator_airspeed); + DOWNLINK_SEND_WIND_INFO_RET(DefaultChannel, &wind_east, &wind_north, &estimator_airspeed); #endif } else #endif /** WIND_INFO */ @@ -147,11 +147,11 @@ void dl_parse_msg(void) { uint8_t i = DL_SETTING_index(dl_buffer); float val = DL_SETTING_value(dl_buffer); DlSetting(i, val); - DOWNLINK_SEND_DL_VALUE(&i, &val); + DOWNLINK_SEND_DL_VALUE(DefaultChannel, &i, &val); } else if (msg_id == DL_GET_SETTING && DL_GET_SETTING_ac_id(dl_buffer) == AC_ID) { uint8_t i = DL_SETTING_index(dl_buffer); float val = settings_get_value(i); - DOWNLINK_SEND_DL_VALUE(&i, &val); + DOWNLINK_SEND_DL_VALUE(DefaultChannel, &i, &val); } else #endif /** Else there is no dl_settings section in the flight plan */ #ifdef USE_JOYSTICK diff --git a/sw/airborne/downlink.c b/sw/airborne/downlink.c index 41407b2aaa..8a171905fc 100644 --- a/sw/airborne/downlink.c +++ b/sw/airborne/downlink.c @@ -34,14 +34,14 @@ #ifndef TELEMETRY_MODE_FBW #define TELEMETRY_MODE_FBW 0 #endif -uint8_t telemetry_mode_Fbw = TELEMETRY_MODE_FBW; +uint8_t telemetry_mode_Fbw_DefaultChannel = TELEMETRY_MODE_FBW; #endif /** FBW */ #ifdef AP #ifndef TELEMETRY_MODE_AP #define TELEMETRY_MODE_AP 0 #endif -uint8_t telemetry_mode_Ap =TELEMETRY_MODE_AP; +uint8_t telemetry_mode_Ap_DefaultChannel = TELEMETRY_MODE_AP; #endif /** AP */ uint8_t downlink_nb_ovrn; diff --git a/sw/airborne/downlink.h b/sw/airborne/downlink.h index 7df5a5c1c8..26c0deeeaf 100644 --- a/sw/airborne/downlink.h +++ b/sw/airborne/downlink.h @@ -53,14 +53,18 @@ #include "xbee.h" #endif /** !SITL */ +#ifndef DefaultChannel +#define DefaultChannel DOWNLINK_TRANSPORT +#endif + #ifdef AP /** Telemetry mode for AP process: index in the telemetry.xml file */ -extern uint8_t telemetry_mode_Ap; +extern uint8_t telemetry_mode_Ap_DefaultChannel; #endif #ifdef FBW /** Telemetry mode for FBW process: index in the telemetry.xml file */ -extern uint8_t telemetry_mode_Fbw; +extern uint8_t telemetry_mode_Fbw_DefaultChannel; #endif /** Counter of messages not sent because of unavailibity of the output buffer*/ @@ -71,41 +75,41 @@ extern uint16_t downlink_nb_msgs; #define __Transport(dev, _x) dev##_x #define _Transport(dev, _x) __Transport(dev, _x) -#define Transport(_x) _Transport(DOWNLINK_TRANSPORT, _x) +#define Transport(_chan, _fun) _Transport(_chan, _fun) /** Set of macros for generated code (messages.h) from messages.xml */ /** 2 = ac_id + msg_id */ -#define DownlinkIDsSize(_x) (_x+2) -#define DownlinkSizeOf(_x) Transport(SizeOf(DownlinkIDsSize(_x))) +#define DownlinkIDsSize(_chan, _x) (_x+2) +#define DownlinkSizeOf(_chan, _x) Transport(_chan, SizeOf(DownlinkIDsSize(_chan, _x))) -#define DownlinkCheckFreeSpace(_x) Transport(CheckFreeSpace((uint8_t)(_x))) +#define DownlinkCheckFreeSpace(_chan, _x) Transport(_chan, CheckFreeSpace((uint8_t)(_x))) -#define DownlinkPutUint8(_x) Transport(PutUint8(_x)) +#define DownlinkPutUint8(_chan, _x) Transport(_chan, PutUint8(_x)) -#define DownlinkPutInt8ByAddr(_x) Transport(PutInt8ByAddr(_x)) -#define DownlinkPutUint8ByAddr(_x) Transport(PutUint8ByAddr(_x)) -#define DownlinkPutInt16ByAddr(_x) Transport(PutInt16ByAddr(_x)) -#define DownlinkPutUint16ByAddr(_x) Transport(PutUint16ByAddr(_x)) -#define DownlinkPutInt32ByAddr(_x) Transport(PutInt32ByAddr(_x)) -#define DownlinkPutUint32ByAddr(_x) Transport(PutUint32ByAddr(_x)) -#define DownlinkPutFloatByAddr(_x) Transport(PutFloatByAddr(_x)) +#define DownlinkPutInt8ByAddr(_chan, _x) Transport(_chan, PutInt8ByAddr(_x)) +#define DownlinkPutUint8ByAddr(_chan, _x) Transport(_chan, PutUint8ByAddr(_x)) +#define DownlinkPutInt16ByAddr(_chan, _x) Transport(_chan, PutInt16ByAddr(_x)) +#define DownlinkPutUint16ByAddr(_chan, _x) Transport(_chan, PutUint16ByAddr(_x)) +#define DownlinkPutInt32ByAddr(_chan, _x) Transport(_chan, PutInt32ByAddr(_x)) +#define DownlinkPutUint32ByAddr(_chan, _x) Transport(_chan, PutUint32ByAddr(_x)) +#define DownlinkPutFloatByAddr(_chan, _x) Transport(_chan, PutFloatByAddr(_x)) -#define DownlinkPutFloatArray(_n, _x) Transport(PutFloatArray(_n, _x)) -#define DownlinkPutInt16Array(_n, _x) Transport(PutInt16Array(_n, _x)) -#define DownlinkPutUint16Array(_n, _x) Transport(PutUint16Array(_n, _x)) -#define DownlinkPutUint8Array(_n, _x) Transport(PutUint8Array(_n, _x)) +#define DownlinkPutFloatArray(_chan, _n, _x) Transport(_chan, PutFloatArray(_n, _x)) +#define DownlinkPutInt16Array(_chan, _n, _x) Transport(_chan, PutInt16Array(_n, _x)) +#define DownlinkPutUint16Array(_chan, _n, _x) Transport(_chan, PutUint16Array(_n, _x)) +#define DownlinkPutUint8Array(_chan, _n, _x) Transport(_chan, PutUint8Array(_n, _x)) -#define DownlinkOverrun() downlink_nb_ovrn++; -#define DownlinkCountBytes(_n) downlink_nb_bytes += _n; +#define DownlinkOverrun(_chan) downlink_nb_ovrn++; +#define DownlinkCountBytes(_chan, _n) downlink_nb_bytes += _n; -#define DownlinkStartMessage(_name, msg_id, payload_len) { \ +#define DownlinkStartMessage(_chan, _name, msg_id, payload_len) { \ downlink_nb_msgs++; \ - Transport(Header(DownlinkIDsSize(payload_len))); \ - Transport(PutUint8(AC_ID)); \ - Transport(PutNamedUint8(_name, msg_id)); \ + Transport(_chan, Header(DownlinkIDsSize(_chan, payload_len))); \ + Transport(_chan, PutUint8(AC_ID)); \ + Transport(_chan, PutNamedUint8(_name, msg_id)); \ } -#define DownlinkEndMessage() Transport(Trailer()) +#define DownlinkEndMessage(_chan) Transport(_chan, Trailer()) #endif /* DOWNLINK_H */ diff --git a/sw/airborne/fbw_downlink.h b/sw/airborne/fbw_downlink.h index 1cb14a444e..84d4777834 100644 --- a/sw/airborne/fbw_downlink.h +++ b/sw/airborne/fbw_downlink.h @@ -50,37 +50,37 @@ #define DOWNLINK_DEVICE DOWNLINK_FBW_DEVICE #include "downlink.h" -#define PERIODIC_SEND_COMMANDS() DOWNLINK_SEND_COMMANDS(COMMANDS_NB, commands) +#define PERIODIC_SEND_COMMANDS(_chan) DOWNLINK_SEND_COMMANDS(_chan, COMMANDS_NB, commands) #ifdef RADIO_CONTROL -#define PERIODIC_SEND_FBW_STATUS() DOWNLINK_SEND_FBW_STATUS(&rc_status, &fbw_mode, &fbw_vsupply_decivolt, &fbw_current_milliamp) -#define PERIODIC_SEND_PPM() DOWNLINK_SEND_PPM(&last_ppm_cpt, PPM_NB_PULSES, ppm_pulses) -#define PERIODIC_SEND_RC() DOWNLINK_SEND_RC(PPM_NB_PULSES, rc_values) +#define PERIODIC_SEND_FBW_STATUS(_chan) DOWNLINK_SEND_FBW_STATUS(_chan, &rc_status, &fbw_mode, &fbw_vsupply_decivolt, &fbw_current_milliamp) +#define PERIODIC_SEND_PPM(_chan) DOWNLINK_SEND_PPM(_chan, &last_ppm_cpt, PPM_NB_PULSES, ppm_pulses) +#define PERIODIC_SEND_RC(_chan) DOWNLINK_SEND_RC(_chan, PPM_NB_PULSES, rc_values) #else // RADIO_CONTROL -#define PERIODIC_SEND_FBW_STATUS() { uint8_t dummy = 0; DOWNLINK_SEND_FBW_STATUS(&dummy, &fbw_mode, &fbw_vsupply_decivolt, &fbw_current_milliamp); } -#define PERIODIC_SEND_PPM() {} -#define PERIODIC_SEND_RC() {} +#define PERIODIC_SEND_FBW_STATUS(_chan) { uint8_t dummy = 0; DOWNLINK_SEND_FBW_STATUS(_chan, &dummy, &fbw_mode, &fbw_vsupply_decivolt, &fbw_current_milliamp); } +#define PERIODIC_SEND_PPM(_chan) {} +#define PERIODIC_SEND_RC(_chan) {} #endif // RADIO_CONTROL #ifdef ACTUATORS -#define PERIODIC_SEND_ACTUATORS() DOWNLINK_SEND_ACTUATORS(SERVOS_NB, actuators) +#define PERIODIC_SEND_ACTUATORS(_chan) DOWNLINK_SEND_ACTUATORS(_chan, SERVOS_NB, actuators) #else -#define PERIODIC_SEND_ACTUATORS() {} +#define PERIODIC_SEND_ACTUATORS(_chan) {} #endif #ifdef BRICOLAGE_ADC extern uint16_t adc0_val[]; -#define PERIODIC_SEND_ADC() { \ - static const uint8_t mcu = 0; \ - DOWNLINK_SEND_ADC(&mcu, 8, adc0_val); \ +#define PERIODIC_SEND_ADC(_chan) { \ + static const uint8_t mcu = 0; \ + DOWNLINK_SEND_ADC(_chan, &mcu, 8, adc0_val); \ } #else -#define PERIODIC_SEND_ADC() {} +#define PERIODIC_SEND_ADC(_chan) {} #endif static inline void fbw_downlink_periodic_task(void) { - PeriodicSendFbw() + PeriodicSendFbw_DefaultChannel() } diff --git a/sw/airborne/gps.c b/sw/airborne/gps.c index 123bfdf633..09f170ae35 100644 --- a/sw/airborne/gps.c +++ b/sw/airborne/gps.c @@ -70,13 +70,13 @@ void gps_downlink( void ) { void gps_send( void ) { - DOWNLINK_SEND_GPS(&gps_mode, &gps_utm_east, &gps_utm_north, &gps_course, &gps_alt, &gps_gspeed,&gps_climb, &gps_week, &gps_itow, &gps_utm_zone, &gps_nb_ovrn); + DOWNLINK_SEND_GPS(DefaultChannel, &gps_mode, &gps_utm_east, &gps_utm_north, &gps_course, &gps_alt, &gps_gspeed,&gps_climb, &gps_week, &gps_itow, &gps_utm_zone, &gps_nb_ovrn); static uint8_t i; static uint8_t last_cnos[GPS_NB_CHANNELS]; if (i == gps_nb_channels) i = 0; if (i < gps_nb_channels && gps_svinfos[i].cno > 0 && gps_svinfos[i].cno != last_cnos[i]) { - DOWNLINK_SEND_SVINFO(&i, &gps_svinfos[i].svid, &gps_svinfos[i].flags, &gps_svinfos[i].qi, &gps_svinfos[i].cno, &gps_svinfos[i].elev, &gps_svinfos[i].azim); + DOWNLINK_SEND_SVINFO(DefaultChannel, &i, &gps_svinfos[i].svid, &gps_svinfos[i].flags, &gps_svinfos[i].qi, &gps_svinfos[i].cno, &gps_svinfos[i].elev, &gps_svinfos[i].azim); last_cnos[i] = gps_svinfos[i].cno; } @@ -85,7 +85,7 @@ void gps_send( void ) { for(j = 0; j < gps_nb_channels; j++) { uint8_t cno = gps_svinfos[j].cno; if (cno > 0 && j != i && abs(cno-last_cnos[j]) >= 2) { - DOWNLINK_SEND_SVINFO(&j, &gps_svinfos[j].svid, &gps_svinfos[j].flags, &gps_svinfos[j].qi, &cno, &gps_svinfos[j].elev, &gps_svinfos[j].azim); + DOWNLINK_SEND_SVINFO(DefaultChannel, &j, &gps_svinfos[j].svid, &gps_svinfos[j].flags, &gps_svinfos[j].qi, &cno, &gps_svinfos[j].elev, &gps_svinfos[j].azim); last_cnos[j] = gps_svinfos[j].cno; } } diff --git a/sw/airborne/main_ap.c b/sw/airborne/main_ap.c index 29e862234a..18edb82a94 100644 --- a/sw/airborne/main_ap.c +++ b/sw/airborne/main_ap.c @@ -241,12 +241,12 @@ static inline void reporting_task( void ) { /** initialisation phase during boot */ if (boot) { - DOWNLINK_SEND_BOOT(&version); + DOWNLINK_SEND_BOOT(DefaultChannel, &version); boot = FALSE; } /** then report periodicly */ else { - PeriodicSendAp(); + PeriodicSendAp_DefaultChannel(); } } @@ -281,7 +281,7 @@ inline void telecommand_task( void ) { } mode_changed |= mcu1_status_update(); if ( mode_changed ) - PERIODIC_SEND_PPRZ_MODE(); + PERIODIC_SEND_PPRZ_MODE(DefaultChannel); #if defined RADIO_CONTROL || defined RADIO_CONTROL_AUTO1 /** In AUTO1 mode, compute roll setpoint and pitch setpoint from @@ -333,7 +333,7 @@ static void navigation_task( void ) { if (pprz_mode == PPRZ_MODE_AUTO2 || pprz_mode == PPRZ_MODE_HOME) { last_pprz_mode = pprz_mode; pprz_mode = PPRZ_MODE_GPS_OUT_OF_ORDER; - PERIODIC_SEND_PPRZ_MODE(); + PERIODIC_SEND_PPRZ_MODE(DefaultChannel); gps_lost = TRUE; } } else /* GPS is ok */ if (gps_lost) { @@ -341,7 +341,7 @@ static void navigation_task( void ) { pprz_mode = last_pprz_mode; gps_lost = FALSE; - PERIODIC_SEND_PPRZ_MODE(); + PERIODIC_SEND_PPRZ_MODE(DefaultChannel); } } #endif /* GPS && FAILSAFE_DELAY_WITHOUT_GPS */ @@ -359,7 +359,7 @@ static void navigation_task( void ) { #endif #ifndef PERIOD_NAVIGATION_0 // If not sent periodically (in default 0 mode) - SEND_NAVIGATION(); + SEND_NAVIGATION(DefaultChannel); #endif SEND_CAM(); @@ -491,7 +491,7 @@ void periodic_task_ap( void ) { estimator_hspeed_mod > MIN_SPEED_FOR_TAKEOFF) { estimator_flight_time = 1; launch = TRUE; /* Not set in non auto launch */ - DOWNLINK_SEND_TAKEOFF(&cpu_time_sec); + DOWNLINK_SEND_TAKEOFF(DefaultChannel, &cpu_time_sec); } #ifdef DIGITAL_CAM diff --git a/sw/tools/gen_messages.ml b/sw/tools/gen_messages.ml index 85420f1e6d..87aafa5e9e 100644 --- a/sw/tools/gen_messages.ml +++ b/sw/tools/gen_messages.ml @@ -101,10 +101,10 @@ module Gen_onboard = struct let print_field = fun h (t, name, (_f: format option)) -> match t with Basic _ -> - fprintf h "\t DownlinkPut%sByAddr((%s)); \\\n" (Syntax.nameof t) name + fprintf h "\t DownlinkPut%sByAddr(_chan, (%s)); \\\n" (Syntax.nameof t) name | Array (t, varname) -> let _s = Syntax.sizeof (Basic t) in - fprintf h "\t DownlinkPut%sArray(%s, %s); \\\n" (Syntax.nameof (Basic t)) (Syntax.length_name varname) name + fprintf h "\t DownlinkPut%sArray(_chan, %s, %s); \\\n" (Syntax.nameof (Basic t)) (Syntax.length_name varname) name let print_parameter h = function (Array _, s, _) -> fprintf h "%s, %s" (Syntax.length_name s) s @@ -124,21 +124,27 @@ module Gen_onboard = struct let size_of_message = fun m -> size_fields m.fields "0" let print_downlink_macro = fun h {name=s; fields = fields} -> - fprintf h "#define DOWNLINK_SEND_%s(" s; + if List.length fields > 0 then begin + fprintf h "#define DOWNLINK_SEND_%s(_chan, " s; + end else + fprintf h "#define DOWNLINK_SEND_%s(_chan " s; print_macro_parameters h fields; fprintf h "){ \\\n"; let size = (size_fields fields "0") in - fprintf h "\tif (DownlinkCheckFreeSpace(DownlinkSizeOf(%s))) {\\\n" size; - fprintf h "\t DownlinkCountBytes(DownlinkSizeOf(%s)); \\\n" size; - fprintf h "\t DownlinkStartMessage(\"%s\", DL_%s, %s) \\\n" s s size; + fprintf h "\tif (DownlinkCheckFreeSpace(_chan, DownlinkSizeOf(_chan, %s))) {\\\n" size; + fprintf h "\t DownlinkCountBytes(_chan, DownlinkSizeOf(_chan, %s)); \\\n" size; + fprintf h "\t DownlinkStartMessage(_chan, \"%s\", DL_%s, %s) \\\n" s s size; List.iter (print_field h) fields; - fprintf h "\t DownlinkEndMessage() \\\n"; + fprintf h "\t DownlinkEndMessage(_chan ) \\\n"; fprintf h "\t} else \\\n"; - fprintf h "\t DownlinkOverrun(); \\\n"; + fprintf h "\t DownlinkOverrun(_chan ); \\\n"; fprintf h "}\n\n" let print_null_downlink_macro = fun h {name=s; fields = fields} -> - fprintf h "#define DOWNLINK_SEND_%s(" s; + if List.length fields > 0 then begin + fprintf h "#define DOWNLINK_SEND_%s(_chan, " s; + end else + fprintf h "#define DOWNLINK_SEND_%s(_chan " s; print_macro_parameters h fields; fprintf h ") {}\n" diff --git a/sw/tools/gen_periodic.ml b/sw/tools/gen_periodic.ml index c6844ddcc6..1910317257 100644 --- a/sw/tools/gen_periodic.ml +++ b/sw/tools/gen_periodic.ml @@ -50,12 +50,12 @@ let remove_dup = fun l -> loop (List.sort compare l) -let output_modes = fun avr_h process_name modes -> +let output_modes = fun avr_h process_name channel_name modes -> (** For each mode in this process *) List.iter (fun mode -> let mode_name = ExtXml.attrib mode "name" in - lprintf avr_h "if (telemetry_mode_%s == TELEMETRY_MODE_%s_%s) {\\\n" process_name process_name mode_name; + lprintf avr_h "if (telemetry_mode_%s_%s == TELEMETRY_MODE_%s_%s_%s) {\\\n" process_name channel_name process_name channel_name mode_name; right (); (** Computes the required modulos *) @@ -94,7 +94,7 @@ let output_modes = fun avr_h process_name modes -> l := (p, !phase) :: !l; i := !i + !freq/10; right (); - lprintf avr_h "PERIODIC_SEND_%s();\\\n" message_name; + lprintf avr_h "PERIODIC_SEND_%s(%s);\\\n" message_name channel_name; left (); lprintf avr_h "} \\\n" ) @@ -125,9 +125,10 @@ let _ = (** For each process *) List.iter (fun process -> - let process_name = ExtXml.attrib process "name" in + let process_name = ExtXml.attrib process "name" and + channel_name = ExtXml.attrib process "channel" in - fprintf avr_h "\n/* Macros for %s process */\n" process_name; + fprintf avr_h "\n/* Macros for %s process channel %s */\n" process_name channel_name; let modes = Xml.children process in @@ -135,20 +136,20 @@ let _ = (** For each mode of this process *) List.iter (fun mode -> let name = ExtXml.attrib mode "name" in - Xml2h.define (sprintf "TELEMETRY_MODE_%s_%s" process_name name) (string_of_int !i); + Xml2h.define (sprintf "TELEMETRY_MODE_%s_%s_%s" process_name channel_name name) (string_of_int !i); (* Output the periods of the messages *) List.iter (fun x -> let p = ExtXml.attrib x "period" and n = ExtXml.attrib x "name" in - Xml2h.define (sprintf "PERIOD_%s_%d" n !i) (sprintf "(%s)" p)) + Xml2h.define (sprintf "PERIOD_%s_%s_%d" n channel_name !i) (sprintf "(%s)" p)) (Xml.children mode); incr i) modes; - lprintf avr_h "#define PeriodicSend%s() { /* %dHz */ \\\n" process_name !freq; + lprintf avr_h "#define PeriodicSend%s_%s() { /* %dHz */ \\\n" process_name channel_name !freq; right (); - output_modes avr_h process_name modes; + output_modes avr_h process_name channel_name modes; left (); lprintf avr_h "}\n" ) diff --git a/sw/tools/gen_settings.ml b/sw/tools/gen_settings.ml index 7e6650a160..3050f295f9 100644 --- a/sw/tools/gen_settings.ml +++ b/sw/tools/gen_settings.ml @@ -96,7 +96,7 @@ let print_dl_settings = fun settings -> let nb_values = !idx in (** Macro to call to downlink current values *) - lprintf "#define PeriodicSendDlValue() { \\\n"; + lprintf "#define PeriodicSendDlValue(_chan) { \\\n"; if nb_values > 0 then begin right (); lprintf "static uint8_t i;\\\n"; @@ -113,7 +113,7 @@ let print_dl_settings = fun settings -> lprintf "default: var = 0.; break;\\\n"; left (); lprintf "}\\\n"; - lprintf "DOWNLINK_SEND_DL_VALUE(&i, &var);\\\n"; + lprintf "DOWNLINK_SEND_DL_VALUE(_chan, &i, &var);\\\n"; lprintf "i++;\\\n"; left () end;