#include <stdio.h>
#include <string.h>
#include <time.h>
#include "FreeRTOS.h"
#include "task.h"
#include "cptime.h"
#include "shell.h"
Data Structures | |
struct | st_scheduled_cmd |
Macros | |
#define | CPTIME_MAX_NB_SCHED_CMDS 10 |
Typedefs | |
typedef struct st_scheduled_cmd | Scheduled_Cmd |
Functions | |
eExecStatus | e_cptime_cmd_get_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The get time config command: get the config fields value of the time module Takes no parameter. More... | |
eExecStatus | e_cptime_cmd_set_config (eModId xModId, signed short FsNavId, int ac, signed portCHAR *av[], signed portCHAR **ppcStringReply) |
The set time config command: set each config field value of the time module. Takes one parameter : field=value. More... | |
eExecStatus | e_cptime_RecordScheduledCmd (char *pcDate, int CmdId, void(*pfScheduledCmd)(int, void *), void *pvCmdParams, signed portCHAR **ppcStringReply) |
Record a scheduled command. More... | |
static void | prv_v_ShiftScheduledCmdsArray (int SrcIdx, int DstIdx) |
Shift the Scheduled Cmds array from the SrcIdx index down to the DstIdx index. More... | |
void | v_cptime_ExecuteScheduledCmd (void) |
Execute a scheduled command if expiration date is up. More... | |
void | v_cptime_GetDateInFatStringFormat (char *pcDate) |
Get the current time in the "YYYYMMDDHHMMSSMS" string format. More... | |
void | v_cptime_Init (void) |
Init the time module. More... | |
void | v_cptime_UpdateLocalTime (void) |
Update the local time. More... | |
Variables | |
static Scheduled_Cmd | axCmdsSched [CPTIME_MAX_NB_SCHED_CMDS] |
const signed portCHAR *const | CPTIME_ERRMSG_SETCFG_INVALIDDATE = (signed portCHAR *)ERROR_CRLF"Invalid date"CRLF |
const signed portCHAR *const | CPTIME_ERRMSG_SETCFG_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: set_sys_config sys=time field=value"CRLF |
const signed portCHAR *const | CPTIME_ERRMSG_SETCFG_UNKNOWNFIELD = (signed portCHAR *)ERROR_CRLF"Unknown configuration field"CRLF |
const signed portCHAR *const | CPTIME_ERRMSG_SETVAL_INVALIDTIME = (signed portCHAR *)ERROR_CRLF"Invalid schedule date"CRLF |
const signed portCHAR *const | CPTIME_ERRMSG_SETVAL_UNAVAILSCHEDSLOT = (signed portCHAR *)ERROR_CRLF"No scheduling slot left"CRLF |
static int | NbSchedCmd = 0 |
time_t | xcptime_LocalTime |
static portTickType | xcptime_TickOrigin = 0 |
#define CPTIME_MAX_NB_SCHED_CMDS 10 |
Max nb of scheduled commands.
Referenced by e_cptime_cmd_set_config(), e_cptime_RecordScheduledCmd(), and prv_v_ShiftScheduledCmdsArray().
typedef struct st_scheduled_cmd Scheduled_Cmd |
The type of a scheduled command entry.
eExecStatus e_cptime_cmd_get_config | ( | eModId | xModId, |
signed short | FsNavId, | ||
int | ac, | ||
signed portCHAR * | av[], | ||
signed portCHAR ** | ppcStringReply | ||
) |
The get time config command: get the config fields value of the time module Takes no parameter.
xModId | Input. The module that is calling this function. |
FsNavId | Ignored. |
ac | Input. The argument counter. For this command, should be 1. |
av | Input. The argument vector. |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
References NULL, pvPortMalloc(), SHELL_ERRMSG_MEMALLOC, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, sprintf(), and xcptime_LocalTime.
Referenced by e_syscmds_cmd_get_config().
eExecStatus e_cptime_cmd_set_config | ( | eModId | xModId, |
signed short | FsNavId, | ||
int | ac, | ||
signed portCHAR * | av[], | ||
signed portCHAR ** | ppcStringReply | ||
) |
The set time config command: set each config field value of the time module. Takes one parameter : field=value.
xModId | Input. The module that is calling this function. |
FsNavId | Ignored. |
ac | Input. The argument counter. For this command, should be 1. |
av | Input. The argument vector. |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
References CPTIME_ERRMSG_SETCFG_INVALIDDATE, CPTIME_ERRMSG_SETCFG_SYNTAXERROR, CPTIME_ERRMSG_SETCFG_UNKNOWNFIELD, CPTIME_MAX_NB_SCHED_CMDS, NAKED_TRACE_COM2, NbSchedCmd, NULL, prv_v_ShiftScheduledCmdsArray(), SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK, xcptime_LocalTime, and st_scheduled_cmd::xScheduledTime.
Referenced by e_syscmds_cmd_set_config().
eExecStatus e_cptime_RecordScheduledCmd | ( | char * | pcDate, |
int | CmdId, | ||
void(*)(int, void *) | pfScheduledCmd, | ||
void * | pvCmdParams, | ||
signed portCHAR ** | ppcStringReply | ||
) |
Record a scheduled command.
pcDate | Input. The date the cmd is scheduled at. Format: seconds OR mm/dd/yy hh:mm:ss |
CmdId | Scheduled command id. |
pfScheduledCmd | pointer on fct to be called at expiration date |
pvCmdParams | pointer on struct to give as param to pfScheduledCmd |
ppcStringReply | Input/Output. The response string. If Input is NULL, no response string will be output. Else a malloc for the response string is performed here; the caller must free this string. |
References st_scheduled_cmd::CmdId, CPTIME_ERRMSG_SETVAL_INVALIDTIME, CPTIME_ERRMSG_SETVAL_UNAVAILSCHEDSLOT, CPTIME_MAX_NB_SCHED_CMDS, NbSchedCmd, st_scheduled_cmd::pfScheduledCmd, st_scheduled_cmd::pxParam, SHELL_EXECSTATUS_KO, SHELL_EXECSTATUS_OK_NO_FREE, xcptime_LocalTime, and st_scheduled_cmd::xScheduledTime.
Referenced by e_actuator_ScheduleCmdSet().
|
static |
Shift the Scheduled Cmds array from the SrcIdx index down to the DstIdx index.
SrcIdx | Input. The source index. |
DstIdx | Input. The Destination index. |
References st_scheduled_cmd::CmdId, CPTIME_MAX_NB_SCHED_CMDS, st_scheduled_cmd::pfScheduledCmd, st_scheduled_cmd::pxParam, and st_scheduled_cmd::xScheduledTime.
Referenced by e_cptime_cmd_set_config(), and v_cptime_ExecuteScheduledCmd().
Execute a scheduled command if expiration date is up.
References NbSchedCmd, st_scheduled_cmd::pfScheduledCmd, prv_v_ShiftScheduledCmdsArray(), xcptime_LocalTime, and st_scheduled_cmd::xScheduledTime.
Referenced by portTASK_FUNCTION().
void v_cptime_GetDateInFatStringFormat | ( | char * | pcDate | ) |
Get the current time in the "YYYYMMDDHHMMSSMS" string format.
pcDate | Input/Output. Input allocated array. Output is the current time expressed in the "YYYYMMDDHHMMSSMS" string format. |
References sprintf(), and xcptime_LocalTime.
Referenced by b_mmi_mkdir_aLOG(), b_mmi_mkdir_bLOG(), config_file_set_value(), e_fscmds_shell_mkdir(), e_fscmds_touch(), prv_append(), prv_vsave_logs(), and prv_xopen_current_logfile().
Update the local time.
References configTICK_RATE_HZ, xcptime_LocalTime, xcptime_TickOrigin, and xTaskGetTickCount().
|
static |
const signed portCHAR* const CPTIME_ERRMSG_SETCFG_INVALIDDATE = (signed portCHAR *)ERROR_CRLF"Invalid date"CRLF |
Error msg upon set_sys_config sys=time curtime="date" where date is invalid.
Referenced by e_cptime_cmd_set_config().
const signed portCHAR* const CPTIME_ERRMSG_SETCFG_SYNTAXERROR = (signed portCHAR *)ERROR_CRLF"Usage: set_sys_config sys=time field=value"CRLF |
Error msg upon set cfg time syntax error.
Referenced by e_cptime_cmd_set_config().
const signed portCHAR* const CPTIME_ERRMSG_SETCFG_UNKNOWNFIELD = (signed portCHAR *)ERROR_CRLF"Unknown configuration field"CRLF |
Error msg upon set cfg time of an invalid config field.
Referenced by e_cptime_cmd_set_config().
const signed portCHAR* const CPTIME_ERRMSG_SETVAL_INVALIDTIME = (signed portCHAR *)ERROR_CRLF"Invalid schedule date"CRLF |
Error msg if the time for scheduling is invalid.
Referenced by e_cptime_RecordScheduledCmd().
const signed portCHAR* const CPTIME_ERRMSG_SETVAL_UNAVAILSCHEDSLOT = (signed portCHAR *)ERROR_CRLF"No scheduling slot left"CRLF |
Error msg if there is no scheduling slot left.
Referenced by e_cptime_RecordScheduledCmd().
|
static |
Nb of scheduled commands.
Referenced by e_cptime_cmd_set_config(), e_cptime_RecordScheduledCmd(), and v_cptime_ExecuteScheduledCmd().
time_t xcptime_LocalTime |
The local time raw value.
Referenced by e_cptime_cmd_get_config(), e_cptime_cmd_set_config(), e_cptime_RecordScheduledCmd(), portTASK_FUNCTION(), prv_xopen_current_logfile(), pxdatalog_log_alloc_init(), v_cptime_ExecuteScheduledCmd(), v_cptime_GetDateInFatStringFormat(), v_cptime_Init(), and v_cptime_UpdateLocalTime().
|
static |
The OS tick origin. This may not be == 0, if the local time is set through a shell command or acquired though the TIME protocol.
Referenced by v_cptime_UpdateLocalTime().