PX4 Firmware
PX4 Autopilot Software http://px4.io
px4::logger::util Namespace Reference

Functions

bool file_exist (const char *filename)
 check if a file exists More...
 
bool get_log_time (struct tm *tt, int utc_offset_sec=0, bool boot_time=false)
 Get the time for log file name. More...
 
int check_free_space (const char *log_root_dir, int32_t max_log_dirs_to_keep, orb_advert_t &mavlink_log_pub, int &sess_dir_index)
 Check if there is enough free space left on the SD Card. More...
 
int remove_directory (const char *dir)
 Recursively remove a directory. More...
 

Function Documentation

◆ check_free_space()

int px4::logger::util::check_free_space ( const char *  log_root_dir,
int32_t  max_log_dirs_to_keep,
orb_advert_t mavlink_log_pub,
int &  sess_dir_index 
)

Check if there is enough free space left on the SD Card.

It will remove old log files if there is not enough space, and if that fails return 1, and send a user message

Parameters
log_root_dirlog root directory: it's expected to contain directories in the form of sessi or d-d-d (year, month, day)
max_log_dirs_to_keepmaximum log directories to keep (set to 0 for unlimited)
mavlink_log_pub
sess_dir_indexoutput argument: will be set to the next free directory sessi index.
Returns
0 on success, 1 if not enough space, <0 on error

Definition at line 114 of file util.cpp.

References LOG_DIR_LEN, mavlink_log_critical, px4_statfs_buf_f_bavail_t, and remove_directory().

Referenced by px4::logger::Logger::run().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ file_exist()

bool px4::logger::util::file_exist ( const char *  filename)

check if a file exists

Definition at line 68 of file util.cpp.

Referenced by px4::logger::Logger::get_log_file_name().

Here is the caller graph for this function:

◆ get_log_time()

bool px4::logger::util::get_log_time ( struct tm *  tt,
int  utc_offset_sec = 0,
bool  boot_time = false 
)

Get the time for log file name.

Parameters
ttreturned time
utc_offset_secUTC time offset [s]
boot_timeuse time when booted instead of current time
Returns
true on success, false otherwise (eg. if no gps)

Definition at line 74 of file util.cpp.

References vehicle_gps_position_s::fix_type, GPS_EPOCH_SECS, hrt_absolute_time(), ORB_ID, and vehicle_gps_position_s::time_utc_usec.

Referenced by px4::logger::Logger::get_log_file_name().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ remove_directory()

int px4::logger::util::remove_directory ( const char *  dir)

Recursively remove a directory.

Returns
0 on success, <0 otherwise

Definition at line 238 of file util.cpp.

Referenced by check_free_space().

Here is the caller graph for this function: