Skip to content

Commit

Permalink
fixed cmd_log
Browse files Browse the repository at this point in the history
  • Loading branch information
Known4225 committed Sep 25, 2024
1 parent 2018742 commit 9b78d05
Showing 1 changed file with 9 additions and 13 deletions.
22 changes: 9 additions & 13 deletions sdk/shared/sys/cmd/cmd_log.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ int cmd_log(int argc, char **argv)
// Handle 'reg' sub-command
if (strcmp("reg", argv[1]) == 0) {
// Check correct number of arguments
if (argc != 7)
if (argc != 6)
return CMD_INVALID_ARGUMENTS;

// Parse arg1: log_var_idx
Expand All @@ -57,32 +57,28 @@ int cmd_log(int argc, char **argv)
// Parse arg2: name
char *name = argv[3];

// Parse arg3: memory_addr
void *memory_addr = (void *) atoi(argv[4]);

// Parse arg4: samples_per_sec
int samples_per_sec = atoi(argv[5]);

if (samples_per_sec > LOG_UPDATE_FREQ || samples_per_sec <= 0) {
// Parse arg3: interval_ticks
int interval_ticks = atoi(argv[4]);
if (interval_ticks <= 0) {
// ERROR
return CMD_INVALID_ARGUMENTS;
}

// Parse arg5: type
// Parse arg4: type
var_type_e type;
if (strcmp("int", argv[6]) == 0) {
if (strcmp("int", argv[5]) == 0) {
type = LOG_INT;
} else if (strcmp("float", argv[6]) == 0) {
} else if (strcmp("float", argv[5]) == 0) {
type = LOG_FLOAT;
} else if (strcmp("double", argv[6]) == 0) {
} else if (strcmp("double", argv[5]) == 0) {
type = LOG_DOUBLE;
} else {
// ERROR
return CMD_INVALID_ARGUMENTS;
}

// Register the variable with the logging engine
int err = log_var_register(log_var_idx, name, memory_addr, samples_per_sec, type);
int err = log_var_register(log_var_idx, name, interval_ticks, type);
if (err != SUCCESS) {
return CMD_FAILURE;
}
Expand Down

0 comments on commit 9b78d05

Please sign in to comment.