18#include "configuration.h"
52 for(uint8_t i = 0; i < CONFIG_CMD_MAX_CLIENTS; i++) {
57 else if(i == CONFIG_CMD_MAX_CLIENTS - 1) {
67 for(uint8_t i = 0; i < CONFIG_CMD_MAX_CLIENTS; i++) {
72 else if(i == CONFIG_CMD_MAX_CLIENTS - 1) {
84 uint16_t num_tokens = 0;
85 char *tokens[CONFIG_CMD_MAX_TOKENS];
88 str_tokenize(console_text,
" ", CONFIG_CMD_MAX_TOKENS, tokens, &num_tokens);
94 "cmd_execute: invalid arguments"
101 if(
str_cmp(
"*", tokens[0]) ==
true) {
107 "cmd_execute: invalid arguments"
113 if(
str_cmp(
"log", tokens[1]) ==
true) {
114 if(num_tokens == 2) {
115 for(uint8_t i = 0; i < CONFIG_CMD_MAX_CLIENTS; i++) {
118 if(client_info == (
void*)0) {
124 char *log_level_name[16];
140 else if(num_tokens == 3) {
141 const char *log_level_str = tokens[2];
149 for(uint8_t i = 0; i < CONFIG_CMD_MAX_CLIENTS; i++) {
152 if(client_info == (
void*)0) {
163 "cmd_execute: invalid arguments"
174 if(
str_cmp(
"version", tokens[0]) ==
true) {
179 "cmd_execute: invalid arguments"
186 "Version=%s", CONFIG_VERSION
193 if(
str_cmp(
"help", tokens[0]) ==
true) {
194 if(num_tokens == 1) {
198 "Listing general commands:"
203 "1. version: Prints firmware version, usage: version"
208 "2. help: Shows help information for modules, usage: help <module>"
213 "3. log: Shows or sets the log level of modules, usage: log <module|*> <level>"
216 for(uint8_t i = 0; i < CONFIG_CMD_MAX_CLIENTS; i++) {
226 "Listing %s commands:",
230 for(uint8_t j = 0; j < client_info->
num_cmds; j++) {
242 else if(num_tokens == 2) {
243 for(uint8_t i = 0; i < CONFIG_CMD_MAX_CLIENTS; i++) {
250 if(
str_cmp(client_info->
name, tokens[1]) ==
true) {
254 "Listing %s commands:",
258 for(uint8_t j = 0; j < client_info->
num_cmds; j++) {
275 "cmd_execute: invalid arguments"
281 for(uint8_t i = 0; i < CONFIG_CMD_MAX_CLIENTS; i++) {
288 if(
str_cmp(tokens[0], client_info->
name) ==
true) {
289 if(
str_cmp(tokens[1],
"log") ==
true) {
290 if(num_tokens == 2) {
293 char *log_level_name[16];
309 else if(num_tokens == 3) {
310 const char *log_level_str = tokens[2];
322 else if(num_tokens > 3) {
326 "cmd_execute: invalid arguments"
332 for(uint8_t j = 0; j < client_info->
num_cmds; j++) {
338 if(j == client_info->
num_cmds - 1) {
342 "cmd_execute: invalid arguments"
353 "cmd_execute: invalid arguments"
static struct internal_state_s internal_state
Singleton instance of the SysTick driver internal state.
Command subsystem public API.
Common utility 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_execute(char *console_text)
Parses and executes a command from a console text string.
ERR_te cmd_register(CMD_CLIENT_INFO_ts *cmd_client_info)
Registers a client with the command subsystem.
bool str_cmp(const char *str1, const char *str2)
Compares two null-terminated strings for equality.
int str_tokenize(char *str, const char *separator, uint16_t max_tokens, char **tokens, uint16_t *num_tokens)
Splits a string into tokens separated by a given delimiter.
ERR_te
Standard return type used by all public API functions.
@ ERR_DEINITIALIZATION_FAILURE
ERR_te log_get_level_name(LOG_LEVEL_te log_level, char *str)
Converts a LOG_LEVEL_te value to its lowercase string name.
ERR_te log_level_to_int(char const *str, LOG_LEVEL_te *log_level_o)
Converts a log level name string to its LOG_LEVEL_te value.
#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.
Log subsystem public API.
System module identifier definitions.
Describes a subsystem client registering with the command module.
const CMD_INFO_ts *const cmds_ptr
LOG_LEVEL_te *const log_level_ptr
const CMD_HANDLER_tf handler
Internal state of the SysTick driver.
CMD_CLIENT_INFO_ts * cmd_client_info_arr[CONFIG_CMD_MAX_CLIENTS]