mirror of
https://github.com/paparazzi/paparazzi.git
synced 2026-05-09 22:49:53 +08:00
[fixedwing] ifdef some downlink/telemetry functions to make telemetry subsystem optional
This commit is contained in:
@@ -29,9 +29,7 @@
|
||||
#include "firmwares/fixedwing/autopilot.h"
|
||||
|
||||
#include "state.h"
|
||||
#include "subsystems/datalink/telemetry.h"
|
||||
#include "firmwares/fixedwing/nav.h"
|
||||
#include "generated/settings.h"
|
||||
|
||||
#ifdef POWER_SWITCH_GPIO
|
||||
#include "mcu_periph/gpio.h"
|
||||
@@ -58,6 +56,10 @@ bool_t gps_lost;
|
||||
|
||||
bool_t power_switch;
|
||||
|
||||
#if PERIODIC_TELEMETRY
|
||||
#include "subsystems/datalink/telemetry.h"
|
||||
#include "generated/settings.h"
|
||||
|
||||
void send_autopilot_version(struct transport_tx *trans, struct link_device *dev)
|
||||
{
|
||||
static uint32_t ap_version = PPRZ_VERSION_INT;
|
||||
@@ -88,14 +90,6 @@ static void send_mode(struct transport_tx *trans, struct link_device *dev)
|
||||
&pprz_mode, &v_ctl_mode, &lateral_mode, &horizontal_mode, &rc_settings_mode, &mcu1_status);
|
||||
}
|
||||
|
||||
void autopilot_send_mode(void)
|
||||
{
|
||||
// use default telemetry here
|
||||
#if DOWNLINK
|
||||
send_mode(&(DefaultChannel).trans_tx, &(DefaultDevice).device);
|
||||
#endif
|
||||
}
|
||||
|
||||
static void send_attitude(struct transport_tx *trans, struct link_device *dev)
|
||||
{
|
||||
struct FloatEulers *att = stateGetNedToBodyEulers_f();
|
||||
@@ -159,6 +153,15 @@ static void send_airspeed(struct transport_tx *trans __attribute__((unused)),
|
||||
pprz_msg_send_AIRSPEED(trans, dev, AC_ID, stateGetAirspeed_f(), &zero, &zero, &zero);
|
||||
#endif
|
||||
}
|
||||
#endif /* PERIODIC_TELEMETRY */
|
||||
|
||||
void autopilot_send_mode(void)
|
||||
{
|
||||
// use default telemetry here
|
||||
#if DOWNLINK
|
||||
send_mode(&(DefaultChannel).trans_tx, &(DefaultDevice).device);
|
||||
#endif
|
||||
}
|
||||
|
||||
void autopilot_init(void)
|
||||
{
|
||||
@@ -177,6 +180,7 @@ void autopilot_init(void)
|
||||
gpio_clear(POWER_SWITCH_GPIO);
|
||||
#endif
|
||||
|
||||
#if PERIODIC_TELEMETRY
|
||||
/* register some periodic message */
|
||||
register_periodic_telemetry(DefaultPeriodic, "AUTOPILOT_VERSION", send_autopilot_version);
|
||||
register_periodic_telemetry(DefaultPeriodic, "ALIVE", send_alive);
|
||||
@@ -191,5 +195,6 @@ void autopilot_init(void)
|
||||
#if defined RADIO_CALIB && defined RADIO_CONTROL_SETTINGS
|
||||
register_periodic_telemetry(DefaultPeriodic, "RC_SETTINGS", send_rc_settings);
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -72,9 +72,13 @@ PRINT_CONFIG_MSG_VALUE("USE_BARO_BOARD is TRUE, reading onboard baro: ", BARO_BO
|
||||
#endif
|
||||
|
||||
// datalink & telemetry
|
||||
#if DATALINK
|
||||
#include "subsystems/datalink/datalink.h"
|
||||
#include "subsystems/datalink/downlink.h"
|
||||
#endif
|
||||
#if PERIODIC_TELEMETRY
|
||||
#include "subsystems/datalink/telemetry.h"
|
||||
#endif
|
||||
#include "subsystems/settings.h"
|
||||
|
||||
// modules & settings
|
||||
@@ -112,6 +116,9 @@ PRINT_CONFIG_VAR(CONTROL_FREQUENCY)
|
||||
/* TELEMETRY_FREQUENCY is defined in generated/periodic_telemetry.h
|
||||
* defaults to 60Hz or set by TELEMETRY_FREQUENCY configure option in airframe file
|
||||
*/
|
||||
#ifndef TELEMETRY_FREQUENCY
|
||||
#define TELEMETRY_FREQUENCY 60
|
||||
#endif
|
||||
PRINT_CONFIG_VAR(TELEMETRY_FREQUENCY)
|
||||
|
||||
/* MODULES_FREQUENCY is defined in generated/modules.h
|
||||
@@ -510,7 +517,7 @@ void navigation_task(void)
|
||||
CallTCAS();
|
||||
#endif
|
||||
|
||||
#ifndef PERIOD_NAVIGATION_Ap_0 // If not sent periodically (in default 0 mode)
|
||||
#if DOWNLINK && !defined PERIOD_NAVIGATION_Ap_0 // If not sent periodically (in default 0 mode)
|
||||
SEND_NAVIGATION(&(DefaultChannel).trans_tx, &(DefaultDevice).device);
|
||||
#endif
|
||||
|
||||
@@ -652,8 +659,10 @@ void monitor_task(void)
|
||||
*stateGetHorizontalSpeedNorm_f() > MIN_SPEED_FOR_TAKEOFF) {
|
||||
autopilot_flight_time = 1;
|
||||
launch = TRUE; /* Not set in non auto launch */
|
||||
#if DOWNLINK
|
||||
uint16_t time_sec = sys_time.nb_sec;
|
||||
DOWNLINK_SEND_TAKEOFF(DefaultChannel, DefaultDevice, &time_sec);
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -201,6 +201,7 @@ bool_t nav_approaching_xy(float x, float y, float from_x, float from_y, float ap
|
||||
#define GetPosAlt() (stateGetPositionUtm_f()->alt)
|
||||
#define GetAltRef() (ground_alt)
|
||||
|
||||
#if DOWNLINK
|
||||
#define SEND_NAVIGATION(_trans, _dev) { \
|
||||
uint8_t _circle_count = NavCircleCount(); \
|
||||
struct EnuCoor_f* pos = stateGetPositionEnu_f(); \
|
||||
@@ -216,5 +217,6 @@ extern bool_t DownlinkSendWpNr(uint8_t _wp);
|
||||
float y = nav_utm_north0 + waypoints[i].y; \
|
||||
pprz_msg_send_WP_MOVED(_trans, _dev, AC_ID, &i, &x, &y, &(waypoints[i].a),&nav_utm_zone0); \
|
||||
}
|
||||
#endif /* DOWNLINK */
|
||||
|
||||
#endif /* NAV_H */
|
||||
|
||||
Reference in New Issue
Block a user