40 #include <px4_platform_common/defines.h> 45 #include <px4_platform_common/module.h> 83 return static_cast<int32_t
>(a) & static_cast<int32_t>(b);
90 uint8_t msg_id{MSG_ID_INVALID};
95 uORB::SubscriptionInterval(meta, interval_ms * 1000,
instance)
99 class Logger :
public ModuleBase<Logger>
110 LogMode log_mode,
bool log_name_timestamp);
115 static int task_spawn(
int argc,
char *argv[]);
118 static Logger *instantiate(
int argc,
char *argv[]);
121 static int custom_command(
int argc,
char *argv[]);
124 static int print_usage(
const char *reason =
nullptr);
137 void setReplayFile(
const char *file_name);
147 bool add_topic(
const char *
name, uint32_t interval_ms = 0, uint8_t
instance = 0);
148 bool add_topic_multi(
const char *name, uint32_t interval_ms = 0);
161 static bool request_stop_static();
163 void print_statistics(
LogType type);
175 static constexpr
size_t MAX_TOPICS_NUM = 90;
176 static constexpr
int MAX_MISSION_TOPICS_NUM = 5;
177 static constexpr
unsigned MAX_NO_LOGFILE = 999;
179 PX4_STORAGEDIR
"/log",
180 PX4_STORAGEDIR
"/mission_log" 185 int sess_dir_index{1};
186 char log_file_name[31];
187 bool has_log_dir{
false};
193 float max_dropout_duration{0.0f};
194 size_t write_dropouts{0};
195 size_t high_water{0};
199 unsigned min_delta_ms{0};
200 unsigned next_write_time{0};
206 void write_all_add_logged_msg(
LogType type);
222 int create_log_dir(
LogType type, tm *tt,
char *log_dir,
int log_dir_len);
227 int get_log_file_name(
LogType type,
char *file_name,
size_t file_name_size);
229 void start_log_file(
LogType type);
231 void stop_log_file(
LogType type);
233 void start_log_mavlink();
235 void stop_log_mavlink();
245 const char *configured_backend_mode()
const;
250 void write_header(
LogType type);
257 void write_formats(
LogType type);
263 void write_perf_data(
bool preflight);
268 void write_console_output();
273 static void perf_iterate_callback(
perf_counter_t handle,
void *user);
278 static void print_load_callback(
void *user);
280 void write_version(
LogType type);
282 void write_info(
LogType type,
const char *name,
const char *value);
283 void write_info_multiple(
LogType type,
const char *name,
const char *value,
bool is_continued);
284 void write_info(
LogType type,
const char *name, int32_t value);
285 void write_info(
LogType type,
const char *name, uint32_t value);
289 void write_info_template(
LogType type,
const char *name, T value,
const char *type_str);
291 void write_parameters(
LogType type);
293 void write_changed_parameters(
LogType type);
295 inline bool copy_if_updated(
int sub_idx,
void *buffer,
bool try_to_subscribe);
302 bool write_message(
LogType type,
void *ptr,
size_t size);
309 int add_topics_from_file(
const char *fname);
323 void add_mission_topic(
const char *name, uint32_t interval_ms = 0);
328 void initialize_configured_topics();
330 void add_default_topics();
331 void add_estimator_replay_topics();
332 void add_thermal_calibration_topics();
333 void add_system_identification_topics();
334 void add_high_rate_topics();
335 void add_debug_topics();
336 void add_sensor_comparison_topics();
337 void add_vision_and_avoidance_topics();
349 void handle_vehicle_command_update();
360 void write_load_output();
367 inline void debug_print_buffer(uint32_t &total_bytes,
hrt_abstime &timer_start);
370 uint8_t *_msg_buffer{
nullptr};
371 int _msg_buffer_len{0};
375 bool _prev_state{
false};
376 bool _manually_logging_override{
false};
386 int _num_mission_subs{0};
389 uint32_t _log_interval{0};
392 uint8_t _next_topic_id{0};
393 char *_replay_file_name{
nullptr};
394 bool _should_stop_file_log{
false};
#define PARAM_INVALID
Handle returned when a parameter cannot be found.
void set_arm_override(bool override)
uint8_t Backend
bitfield to specify a backend
Manages starting, stopping & writing of logged data using the configured backend. ...
static constexpr uint8_t MSG_ID_INVALID
const bool _log_name_timestamp
LogType
Defines different log (file) types.
static void print_usage()
High-resolution timer with callouts and timekeeping.
Global flash based parameter store.
__EXPORT int logger_main(int argc, char *argv[])
static char msg[NUM_MSG][CONFIG_USART1_TXBUFSIZE]
#define ORB_ID(_name)
Generates a pointer to the uORB metadata structure for a given topic.
Print the current system load.
Array< LoggerSubscription, MAX_TOPICS_NUM > _subscriptions
all subscriptions for full & mission log (in front)
bool can_start_mavlink_log() const
check if mavlink logging can be started
__BEGIN_DECLS typedef uint64_t hrt_abstime
Absolute time, in microsecond units.
__BEGIN_DECLS typedef void * orb_advert_t
ORB topic advertiser handle.
Tools for system version detection.
static constexpr hrt_abstime TRY_SUBSCRIBE_INTERVAL
bool operator &(SDLogProfileMask a, SDLogProfileMask b)
LoggerSubscription(const orb_metadata *meta, uint32_t interval_ms=0, uint8_t instance=0)
static constexpr Backend BackendMavlink
uint32_t param_t
Parameter handle.