working cansend (don't parse args yet)

This commit is contained in:
Данила Горнушко 2023-11-24 15:46:30 +03:00
parent e059e129a9
commit d1349d9a37
2 changed files with 13 additions and 6 deletions

View file

@ -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;
}

View file

@ -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 */