16#include "configuration.h"
39 char name[CONFIG_DATALOG_MAX_NAME_LEN];
112 .help =
"Lists active datalog objects, usage: datalog list",
160 "datalog_init_subsys: cmd_register error"
167 "datalog_init_subsys: subsys initialized"
184 "datalog_deinit_subsys: subsys is not initialized"
192 "datalog_deinit_subsys: subsys deinitialized"
206 "datalog_start_subsys: subsys started"
213 "datalog_start_subsys: subsys not initialized or already started"
230 "datalog_stop_subsys: subsys stopped"
237 "datalog_stop_subsys: subsys not initialized or already already stopped"
254 "datalog_init_handle: subsys not initialized"
264 "datalog_init_handle: subsystem out of memory space"
274 "datalog_init_handle: invalid argument"
281 for(uint32_t i = 0; i < CONFIG_DATALOG_MAX_OBJECTS; i++) {
299 internal_state.datalogs[free_index].fr = f_open(&
internal_state.datalogs[free_index].fil,
"0:datalog.txt", FA_CREATE_ALWAYS | FA_WRITE);
321 "datalog_init_handle: handle %s initialized",
334 "datalog_deinit_handle: handle not initialized"
343 "datalog_deinit_handle: no such handle to deinitialize"
349 for(uint32_t i = 0; i < CONFIG_DATALOG_MAX_OBJECTS; i++) {
362 "datalog_deinit_handle: handle %s deinitialized",
369 if(i == CONFIG_DATALOG_MAX_OBJECTS - 1) {
373 "datalog_deinit_handle: no such handle to deinitialize"
403 char time_str[time_len];
405 time_str[time_len - 2] =
'\r';
406 time_str[time_len - 1] =
'\n';
417 char lat_str[lat_len];
418 str_cpy(lat_str, neo6_info->
lat, lat_len - 2);
419 lat_str[lat_len - 2] =
'\r';
420 lat_str[lat_len - 1] =
'\n';
431 char lon_str[lon_len];
432 str_cpy(lon_str, neo6_info->
lon, lon_len - 2);
433 lon_str[lon_len - 2] =
'\r';
434 lon_str[lon_len - 1] =
'\n';
445 char ort_height_str[ort_height_len];
447 ort_height_str[ort_height_len - 2] =
'\r';
448 ort_height_str[ort_height_len - 1] =
'\n';
459 char mov_speed_str[mov_speed_len];
461 mov_speed_str[mov_speed_len - 2] =
'\r';
462 mov_speed_str[mov_speed_len - 1] =
'\n';
473 char mov_dir_str[mov_dir_len];
475 mov_dir_str[mov_dir_len - 2] =
'\r';
476 mov_dir_str[mov_dir_len - 1] =
'\n';
522 "datalog_cmd_list_handler: invalid arguments"
527 for(uint32_t i = 0; i < CONFIG_DATALOG_MAX_OBJECTS; i++) {
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
Arm Cortex-M4 SysTick driver public API.
Command subsystem public API.
Common utility module public API.
CMD_INFO_ts datalog_cmds[]
Table of CLI commands registered by the data log subsystem.
CMD_CLIENT_INFO_ts datalog_cmd_client_info
Registration descriptor passed to the command subsystem.
Data log module public API.
System-wide error code definitions.
ERR_te cmd_deregister(CMD_CLIENT_INFO_ts const *cmd_client_info)
Deregisters a client from the command subsystem.
ERR_te cmd_register(CMD_CLIENT_INFO_ts *cmd_client_info)
Registers a client with the command subsystem.
int str_cpy(char *str_to, const char *str_from, uint32_t len)
Copies a null-terminated string into a destination buffer.
uint32_t get_str_len(char const *str)
Returns the length of a string, excluding the null terminator.
uint32_t systick_get_ms(void)
Returns the number of milliseconds elapsed since SysTick was initialized.
static ERR_te datalog_cmd_list_handler(uint32_t argc, char **argv)
CLI handler for the "list" command. Logs the names of all active data log handles.
ERR_te datalog_init_handle(DATALOG_CFG_ts const *datalog_cfg, DATALOG_HANDLE_ts **datalog_handle_o)
Initializes and registers a data log handle.
ERR_te datalog_stop_subsys(void)
Stops the data log subsystem.
ERR_te datalog_deinit_handle(DATALOG_HANDLE_ts const *datalog_handle)
Deinitializes a data log handle.
ERR_te datalog_run_handle(DATALOG_HANDLE_ts *datalog_handle)
Writes a GPS data entry to the log file if the logging interval has elapsed.
ERR_te datalog_start_subsys(void)
Starts the data log subsystem.
ERR_te datalog_deinit_subsys(void)
Deinitializes the data log subsystem.
ERR_te datalog_init_subsys(void)
Initializes the data log subsystem.
struct datalog_handle_s DATALOG_HANDLE_ts
Opaque handle representing a data log instance.
DATALOG_TIME_te
Logging interval in seconds between consecutive log entries.
ERR_te
Standard return type used by all public API functions.
@ ERR_UNINITIALZIED_OBJECT
@ ERR_DEINITIALIZATION_FAILURE
@ ERR_MODULE_ALREADY_INITIALIZED
@ ERR_INITIALIZATION_FAILURE
ERR_te init_log(void)
Initializes the logging subsystem.
ERR_te init_neo6(void)
Initializes the NEO-6 GPS module.
ERR_te init_systick(void)
Initializes the SysTick timer.
#define LOG_CRITICAL(subsys, lvl, fmt,...)
#define LOG_ERROR(subsys, lvl, fmt,...)
#define LOG_INFO(subsys, lvl, fmt,...)
LOG_LEVEL_te
Log severity levels, in ascending order of severity.
MODULES_te
Identifies a subsystem for use in logging and CLI output.
ERR_te neo6_get_info(NEO6_INFO_ts **neo6_info_o)
Returns a pointer to the internal GPS data structure.
Common initialization public API.
Log subsystem public API.
DATALOG_HANDLE_ts * datalog_handle
System module identifier definitions.
NEO-6M GPS module public API.
Describes a subsystem client registering with the command module.
Describes a single command exposed by a client.
Configuration structure for initializing a data log handle.
char name[CONFIG_SD_MAX_NAME_LEN]
DATALOG_TIME_te datalog_time
Holds all GPS data fields parsed from incoming NMEA sentences.
Internal structure representing a single data log instance.
char name[CONFIG_DATALOG_MAX_NAME_LEN]
DATALOG_TIME_te datalog_time
Internal state of the SysTick driver.
DATALOG_HANDLE_ts datalogs[CONFIG_DATALOG_MAX_OBJECTS]