|
#define | SUBSYSTEM_IO_NONE 0 |
|
#define | SUBSYSTEM_IO_UART 1 |
|
#define | SUBSYSTEM_IO_PRINTF 2 |
|
#define | SUBSYSTEM_IO_CUSTOM 255 |
|
#define | SUBSYSTEM_IO SUBSYSTEM_IO_NONE |
|
#define | LogError(sys_id, str,...) |
|
#define | LogWarning(sys_id, str,...) |
|
#define | LogMsg(sys_id, str,...) |
|
#define | LogDebug(sys_id, str,...) |
|
#define | Subsystem_printf(str,...) |
|
#define | Subsystem_vprintf(str, arg) |
|
#define | Subsystem_PrintChar(c) |
|
#define | Subsystem_RegisterReceiver(r) |
|
#define | SYSTEM_VERSION 0x04000000u |
| subsystem module version number More...
|
|
#define | RECEIVE_MAX_LENGTH 64 |
| default length of receive line for commands More...
|
|
#define | RECEIVE_START_CHAR '$' |
| start character for command lines More...
|
|
#define | RECEIVE_STOP_CHAR '\r' |
| stop character for command lines More...
|
|
#define | RECEIVE_MAX_ARGC 8 |
| max number of arguments after the command name More...
|
|
#define | GetLogTimestamp() TimeNow() |
|
|
void | LogStr (char *str,...) |
|
void | Subsystem_Write (uint8_t subsystem_id, enum log_level level, char *str,...) |
|
uint8_t | Subsystem_Init (char *name, version_t version, void(*callback)(int argc, char *argv[])) |
|
void | Subsystem_RegisterCallback (uint8_t subsystem_id, void(*callback)(int argc, char *argv[])) |
|
char * | Subsystem_GetName (uint8_t subsystem_id) |
|
void | Log_EchoOn (void) |
|
void | Log_EchoOff (void) |
|
uint8_t | Log_GetEcho (void) |
|
void | Log_Version (uint8_t subys_id) |
|
void | Log_Header (uint8_t subsystem_id, enum log_level level) |
|
void | Log_MuteAll (void) |
|
void | Log_UnmuteAll (void) |
|
void | Log_MuteSys (uint8_t sys_id) |
|
void | Log_UnmuteSys (uint8_t sys_id) |
|
void | Log_SetLevel (uint8_t sys_id, enum log_level level) |
|
uint16_t | ArgToU16 (char *arg) |
|
uint8_t | ArgToU8 (char *arg) |
|
uint32_t | ArgToU32 (char *arg) |
|
void | Subsystem_SystemDisable (void) |
|
void | Subsystem_SystemEnable (void) |
|
This module is intended to assist in logging and or management of modules via a command line. The user should define one of the following IO methods in project_settings.h:
If bi-directional communication is available (e.g. UART) then the user can interface with the SubSystem module in real time using the module's command interface.A command can be sent to the module in the following format:
$name arg1 arg2 arg3 arg4
Where the $ indicates the start of the command, name is the name of the subsystem the command is sent to and it is followed by argument stringsThe Subsytem Module registers itself as "SYS" and the commands available are:
- "$sys list" list the handles and names of all present subsystems
- "$sys mute" global mute of log messages
- "$sys unmute" global unmute of log messages
- "$sys unmute all" global unmute of log messages plus enable logging of every subsystem
- "$sys echo" echo back received characters
- "$sys echo off" disable echoing
- "$sys name mute" turn off logging for the subsystem called "name"
- "$sys name unmute" turn on logging for the subsystem called "name"
If your module wishes to receive commands from the command line simply register with the subsystem module and the arguments following a command that starts with the name of your module will be passed to your callback.
static uint8_t sys_id;
void MyCallback(int argc, char *argv[]) {
}
...
LogMsG(sys_id, "printf style formatted %s", "message");
Below are three example of how a subsystem could initialize itself.
#define TASK_VERSION (version_t)0x01010014u
static uint8_t sys_id;
static uint8_t sys_id;
#define TASK_VERSION_MAJOR 1
#define TASK_VERSION_MINOR 1
#define TASK_VERSION_BUILD 20
task_version.major = TASK_VERSION_MAJOR;
task_version.minor = TASK_VERSION_MINOR;
task_version.build = TASK_VERSION_BUILD;
static uint8_t sys_id;
LogMsg(sys_id,
"Crap hit the fan");
void LogStr |
( |
char * |
str, |
|
|
|
... |
|
) |
| |
Logs the null terminated string at the pointer (str)
Same as LogMsg() without the header in the beginning and without the CRLF at the end.
This function is implemented using Push_vprintf. See Push_printf() for supported flags/features.
Will log the string to the buffer defined by LOG_BUF (typically tx0)
- Parameters
-
str | pointer to string to log |
... | variable number of replacement parameters for the str string |
Example usage:
LogStr(
"oops I crapped my pants %d times", num_craps);
void Subsystem_Write |
( |
uint8_t |
subsystem_id, |
|
|
enum log_level |
level, |
|
|
char * |
str, |
|
|
|
... |
|
) |
| |
Logs the message at the pointer (str) with a timestamp and subsystem name
Before logging the message the function will check the current log setting of the subsystem and to determine if the message should be logged
This function is implemented using Push_vprintf. See Push_printf() for supported flags/features.
Will log the string to the buffer defined by SUSSYS_UART
- Parameters
-
subsystem_id | subsystem id |
str | pointer to message to log |
... | variable number of replacement parameters for the str string |
Example usage:
LogMsg(
sys.
id,
"System Index %d, System Name %s.",
sys.
id, GetSubsystemName(SYSTEM));