[telemetry] disabling telemetry made easier

- reorganize telemetry makefiles for FW
- protect some calls and provide default implementation of
  register_periodic
- improve generator with attribute unused keyword
This commit is contained in:
Gautier Hattenberger
2014-12-09 23:29:01 +01:00
committed by Felix Ruess
parent 3c8ee22880
commit 83df8f15b5
12 changed files with 88 additions and 40 deletions
@@ -77,7 +77,9 @@ static void send_mode(struct transport_tx *trans, struct link_device *dev) {
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) {
@@ -241,7 +241,9 @@ void init_ap( void ) {
/** - start interrupt task */
mcu_int_enable();
#if DOWNLINK
downlink_init();
#endif
#if defined AEROCOMM_DATA_PIN
IO0DIR |= _BV(AEROCOMM_DATA_PIN);
@@ -449,7 +451,9 @@ void reporting_task( void ) {
/** then report periodicly */
else {
//PeriodicSendAp(DefaultChannel, DefaultDevice);
#if PERIODIC_TELEMETRY
periodic_telemetry_send_Ap(&(DefaultChannel).trans_tx, &(DefaultDevice).device);
#endif
}
}
+9 -1
View File
@@ -176,7 +176,9 @@ STATIC_INLINE void main_init( void ) {
mcu_int_enable();
#if DOWNLINK
downlink_init();
#endif
// register the timers for the periodic functions
main_periodic_tid = sys_time_register_timer((1./PERIODIC_FREQUENCY), NULL);
@@ -220,14 +222,20 @@ STATIC_INLINE void main_periodic( void ) {
SetActuatorsFromCommands(commands, autopilot_mode);
if (autopilot_in_flight) {
RunOnceEvery(PERIODIC_FREQUENCY, { autopilot_flight_time++; datalink_time++; });
RunOnceEvery(PERIODIC_FREQUENCY, { autopilot_flight_time++;
#if defined DATALINK || defined SITL
datalink_time++;
#endif
});
}
RunOnceEvery(10, LED_PERIODIC());
}
STATIC_INLINE void telemetry_periodic(void) {
#if PERIODIC_TELEMETRY
periodic_telemetry_send_Main(&(DefaultChannel).trans_tx, &(DefaultDevice).device);
#endif
}
/** mode to enter when RC is lost while using a mode with RC input (not AP_MODE_NAV) */
@@ -36,6 +36,8 @@
* @return TRUE if message registered with success, FALSE otherwise
*/
bool_t register_periodic_telemetry(struct pprz_telemetry * _pt, const char * _msg, telemetry_cb _cb) {
// return FALSE if NULL is passed as pprz_telemetry
if (_pt == NULL) return FALSE;
// look for message name
uint8_t i;
for (i = 0; i < _pt->nb; i++) {
@@ -34,6 +34,12 @@
#include "mcu_periph/link_device.h"
#include "subsystems/datalink/transport.h"
/** Set default periodic telemetry to NULL
*/
#ifndef DefaultPeriodic
#define DefaultPeriodic NULL
#endif
/** Telemetry callback definition
*/
typedef void (*telemetry_cb)(struct transport_tx *trans, struct link_device *dev);
@@ -55,12 +61,17 @@ struct pprz_telemetry {
};
/** Register a telemetry callback function.
* empty implementation is provided if PERIODIC_TELEMETRY is not set or set to FALSE
* @param _pt periodic telemetry structure to register
* @param _msg message name (string) as defined in telemetry xml file
* @param _cb callback function, called according to telemetry mode and specified period
* @return TRUE if message registered with success, FALSE otherwise
*/
#if PERIODIC_TELEMETRY
extern bool_t register_periodic_telemetry(struct pprz_telemetry * _pt, const char * _msg, telemetry_cb _cb);
#else
static inline bool_t register_periodic_telemetry(struct pprz_telemetry * _pt __attribute__((unused)), const char * _msg __attribute__((unused)), telemetry_cb _cb __attribute__((unused))) { return FALSE; }
#endif
#if USE_PERIODIC_TELEMETRY_REPORT
/** Send an error report when trying to send message that as not been register
+13 -10
View File
@@ -166,17 +166,20 @@ module Gen_onboard = struct
print_macro_param h f;
List.iter (fun f -> fprintf h ", "; print_macro_param h f) fields
let print_fun_param h = function
(Array (t, _), s, _) -> fprintf h "uint8_t %s, %s *_%s" (Syntax.length_name s) (c_type (Syntax.nameof (Basic t))) s
| (FixedArray (t, _, _), s, _) -> fprintf h "%s *_%s" (c_type (Syntax.nameof (Basic t))) s
| (t, s, _) -> fprintf h "%s *_%s" (c_type (Syntax.nameof t)) s
let print_unused_param = fun unused ->
if unused then " __attribute__((unused))" else ""
let print_function_parameters h = function
let print_fun_param ?(unused=false) h = function
(Array (t, _), s, _) -> fprintf h "uint8_t %s%s, %s *_%s%s" (Syntax.length_name s) (print_unused_param unused) (c_type (Syntax.nameof (Basic t))) s (print_unused_param unused)
| (FixedArray (t, _, _), s, _) -> fprintf h "%s *_%s%s" (c_type (Syntax.nameof (Basic t))) s (print_unused_param unused)
| (t, s, _) -> fprintf h "%s *_%s%s" (c_type (Syntax.nameof t)) s (print_unused_param unused)
let print_function_parameters ?(unused=false) h = function
[] -> ()
| f::fields ->
fprintf h ", ";
print_fun_param h f;
List.iter (fun f -> fprintf h ", "; print_fun_param h f) fields
print_fun_param ~unused h f;
List.iter (fun f -> fprintf h ", "; print_fun_param ~unused h f) fields
let rec size_fields = fun fields size ->
match fields with
@@ -222,8 +225,8 @@ module Gen_onboard = struct
fprintf h "#define DOWNLINK_SEND_%s(_trans, _dev" s;
print_macro_parameters h fields;
fprintf h ") {}\n";
fprintf h "void pprz_msg_send_%s(struct transport_tx *trans, struct link_device *dev, uint8_t ac_id" s;
print_function_parameters h fields;
fprintf h "static inline void pprz_msg_send_%s(struct transport_tx *trans __attribute__((unused)), struct link_device *dev __attribute__((unused)), uint8_t ac_id __attribute__((unused))" s;
print_function_parameters ~unused:true h fields;
fprintf h ") {}\n"
(** Prints the messages ids *)
@@ -370,7 +373,7 @@ let () =
(** Macros for airborne downlink (sending) *)
if class_name = "telemetry" then begin (** FIXME *)
Printf.fprintf h "#ifdef DOWNLINK\n"
Printf.fprintf h "#if DOWNLINK\n"
end;
Gen_onboard.print_downlink_macros h class_name messages;
if class_name = "telemetry" then begin