remove extra code from cmd_system

This commit is contained in:
Данила Горнушко 2023-11-24 08:30:27 +03:00
parent 7faf5238db
commit 36af7aa6fd
4 changed files with 13 additions and 25 deletions

View file

@ -9,6 +9,7 @@
#include "sdkconfig.h"
#include <stddef.h>
#include <stdio.h>
#include <string.h>
#include "freertos/ringbuf.h"
#include "xvprintf.h"
@ -72,6 +73,8 @@ void can_bus_off_check() {
void can_task(void* arg) {
twai_message_t rx_msg;
char byte_str[3];
char data_bytes_str[20];
// ESP_ERROR_CHECK(esp_task_wdt_add(NULL));
for (;;) { // A Task shall never return or exit.
// esp_task_wdt_reset();
@ -80,7 +83,12 @@ void can_task(void* arg) {
// TODO: add software filtering
// if ((((rx_msg.identifier >> 8) & 0xFF) != CONFIG_DEVICE_ID) && (((rx_msg.identifier >> 8) & 0xFF) != 0xFF)) continue;
// ESP_LOGI(LOG_TAG, "received can frame: %" PRIu32, rx_msg.identifier);
xprintf("received can frame: %" PRIu32 "\n", rx_msg.identifier);
data_bytes_str[0] = '\0';
for (int i = 0; i < rx_msg.data_length_code; i++) {
sprintf(byte_str, "%02X", rx_msg.data[i]);
strcat(data_bytes_str, byte_str);
}
xprintf("received can frame: ID: %" PRIu32 " dlc: %d data: %s\n", rx_msg.identifier, rx_msg.data_length_code, data_bytes_str);
}
}

View file

@ -1,12 +1,3 @@
/* Console example — various system commands
This example code is in the Public Domain (or CC0 licensed, at your option.)
Unless required by applicable law or agreed to in writing, this
software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
CONDITIONS OF ANY KIND, either express or implied.
*/
#include <stdio.h>
#include <string.h>
#include <ctype.h>
@ -40,7 +31,7 @@ static void register_tasks(void);
#endif
static void register_log_level(void);
void register_system_common(void)
void register_system(void)
{
register_free();
register_heap();
@ -52,12 +43,6 @@ void register_system_common(void)
register_log_level();
}
void register_system(void)
{
register_system_common();
}
/* 'version' command */
static int get_version(int argc, char **argv)
{

View file

@ -1,13 +1,6 @@
#ifndef MAIN_CMD_SYSTEM_H
#define MAIN_CMD_SYSTEM_H
// Register all system functions
void register_system(void);
// Register common system functions: "version", "restart", "free", "heap", "tasks"
void register_system_common(void);
// Register deep and light sleep functions
void register_system_sleep(void);
#endif // MAIN_CMD_SYSTEM_H

View file

@ -33,7 +33,8 @@ char prompt[50];
static void get_prompt(char* prompt_buf) {
static const char* text = "can_wizard > ";
static const char* prompt_color = LOG_COLOR_E;
memset(prompt_buf,0,strlen(prompt_buf));
// memset(prompt_buf,0,strlen(prompt_buf));
prompt_buf[0] = '\0';
if (use_colors) {
strcat(prompt_buf, prompt_color);
strcat(prompt_buf, text);
@ -114,6 +115,7 @@ void console_task_interactive(void* arg) {
}
/* linenoise allocates line buffer on the heap, so need to free it */
linenoiseFree(line);
get_prompt(prompt);
linenoiseEditStart(&ls, buf, console_config.max_cmdline_length, prompt);
}