Skip to content

Commit

Permalink
modified some opt states and names
Browse files Browse the repository at this point in the history
  • Loading branch information
IDV7 committed May 29, 2024
1 parent 08898b2 commit a59b548
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion software/MySrc/Common/cli.c
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ void cli_rx_callback(cli_handle_t* CLI_h) {
#define RETRY_DELAY_US 100 //us

int _write(int file, char *ptr, int len) {
if (cli_h.cli_disable_log_opt) return 0; //return 0 "success but no bytes were sent"
if (cli_h.disable_log_opt) return 0; //return 0 "success but no bytes were sent"

if (file == STDOUT_FILENO || file == STDERR_FILENO) {
if (cli_h.enable_tx_buffering_opt && cli_h.cli_connected_flag) {
Expand Down
2 changes: 1 addition & 1 deletion software/MySrc/Common/cli.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ typedef struct {
typedef struct {
// flags/options
bool halt_until_connected_opt; // set to true if you want to wait for a "connect" command before starting the main application (useful for debugging)
bool cli_disable_log_opt; // set to true if you want to disable logging from the CLI, AND SAVE CPU TIME
bool disable_log_opt; // set to true if you want to disable logging from the CLI, AND SAVE CPU TIME
bool cli_connected_flag;
bool new_data_flag;

Expand Down
10 changes: 5 additions & 5 deletions software/MySrc/Common/log.c
Original file line number Diff line number Diff line change
Expand Up @@ -68,39 +68,39 @@ void log_msg(log_level_t log_level, const char *format, va_list args) {
}

void LOGD(const char *format, ...) {
if (cli_h.cli_disable_log_opt) return; // to save cpu time when needed
if (cli_h.disable_log_opt) return; // to save cpu time when needed
va_list args;
va_start(args, format);
log_msg(LOG_LEVEL_DEBUG, format, args);
va_end(args);
}

void LOGI(const char *format, ...) {
if (cli_h.cli_disable_log_opt) return; // to save cpu time when needed
if (cli_h.disable_log_opt) return; // to save cpu time when needed
va_list args;
va_start(args, format);
log_msg(LOG_LEVEL_INFO, format, args);
va_end(args);
}

void LOGW(const char *format, ...) {
if (cli_h.cli_disable_log_opt) return; // to save cpu time when needed
if (cli_h.disable_log_opt) return; // to save cpu time when needed
va_list args;
va_start(args, format);
log_msg(LOG_LEVEL_WARN, format, args);
va_end(args);
}

void LOGE(const char *format, ...) {
if (cli_h.cli_disable_log_opt) return; // to save cpu time when needed
if (cli_h.disable_log_opt) return; // to save cpu time when needed
va_list args;
va_start(args, format);
log_msg(LOG_LEVEL_ERROR, format, args);
va_end(args);
}

void LOG(const char *format, ...) {
if (cli_h.cli_disable_log_opt) return; // to save cpu time when needed
if (cli_h.disable_log_opt) return; // to save cpu time when needed
va_list args;
va_start(args, format);

Expand Down
6 changes: 3 additions & 3 deletions software/MySrc/mymain.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static void flight_ctrl_cycle(void);
void myinit(void) {
cli_h.halt_until_connected_opt = false; //set to false if you don't want to wait for a connection
cli_h.enable_tx_buffering_opt = false; //false for init (procces has to be runned to put out buffered data)
cli_h.cli_disable_log_opt = false; // completely disables logging (returns from log functions immediately to save CPU time)
cli_h.disable_log_opt = false; // completely disables logging (returns from log functions immediately to save CPU time)



Expand Down Expand Up @@ -106,8 +106,8 @@ void myinit(void) {
LED_blink_pattern(20, 2, 50, 50);
LED_off();

cli_h.enable_tx_buffering_opt = false; //enable tx buffering NOTE: data will be buffered from now on, and ONLY be sent when cli_process is called!!
cli_h.cli_disable_log_opt = true;
cli_h.enable_tx_buffering_opt = true; //enable tx buffering NOTE: data will be buffered from now on, and ONLY be sent when cli_process is called!!
cli_h.disable_log_opt = false;
}


Expand Down

0 comments on commit a59b548

Please sign in to comment.