From d1349d9a3701d6213a9515861c77b232fb7966ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=B0=D0=BD=D0=B8=D0=BB=D0=B0=20=D0=93=D0=BE=D1=80?= =?UTF-8?q?=D0=BD=D1=83=D1=88=D0=BA=D0=BE?= Date: Fri, 24 Nov 2023 15:46:30 +0300 Subject: [PATCH] working cansend (don't parse args yet) --- main/cmd_can.c | 15 +++++++++++---- main/console.c | 4 ++-- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/main/cmd_can.c b/main/cmd_can.c index d20c032..048f642 100644 --- a/main/cmd_can.c +++ b/main/cmd_can.c @@ -21,20 +21,27 @@ static struct { } cansend_args; static int send_can_frame(int argc, char **argv) { + const char *delim = "#"; + int tmp_can_id = 0; + int tmp_id = 0; + char printf_str[30]; + char can_msg_str_buf[40]; int nerrors = arg_parse(argc, argv, (void **) &cansend_args); if (nerrors != 0) { arg_print_errors(stderr, cansend_args.end, argv[0]); return 1; } - const char* can_msg_str = cansend_args.message->sval[0]; + const char* can_msg_ptr = cansend_args.message->sval[0]; + + strlcpy(can_msg_str_buf, can_msg_ptr, sizeof(can_msg_str_buf)); + printf("%s\n", can_msg_str_buf); - char data_bytes_str[30]; twai_message_t msg = {.extd = 1}; msg.data_length_code = 0; msg.identifier = 0xFF << 8; twai_transmit(&msg, pdMS_TO_TICKS(1000)); - can_msg_to_str(&msg, data_bytes_str); - printf("sent %s\n", data_bytes_str); + can_msg_to_str(&msg, printf_str); + printf("sent %s\n", printf_str); return 0; } diff --git a/main/console.c b/main/console.c index 2f19371..88c5222 100644 --- a/main/console.c +++ b/main/console.c @@ -30,7 +30,7 @@ static const char* TAG = "console task"; esp_console_config_t console_config; struct linenoiseState ls; -char prompt[50]; +char prompt[40]; static void get_prompt(char* prompt_buf) { static const char* text = "can_wizard > "; @@ -74,7 +74,7 @@ void console_task_interactive(void* arg) { char *buf = calloc(1, console_config.max_cmdline_length); char *line; /* Figure out if the terminal supports escape sequences */ - printf("Testing your console..."); + printf("Testing your console...\n"); int probe_status = linenoiseProbe(); // int probe_status = 1; if (probe_status) { /* zero indicates success */