Skip to content

Commit

Permalink
Rename can_messages to uart_tx_ringbuf
Browse files Browse the repository at this point in the history
  • Loading branch information
okhsunrog committed Feb 12, 2024
1 parent 382627a commit 51d6ae7
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions main/console.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ void console_task_tx(void* arg) {
const int fd = fileno(stdout);
size_t msg_to_print_size;
while(1) {
char* msg_to_print = xRingbufferReceive(can_messages, &msg_to_print_size, prompt_timeout);
char* msg_to_print = xRingbufferReceive(uart_tx_ringbuf, &msg_to_print_size, prompt_timeout);
update_prompt();
xSemaphoreTake(console_taken_sem, portMAX_DELAY);
xSemaphoreTake(stdout_taken_sem, portMAX_DELAY);
Expand All @@ -102,7 +102,7 @@ void console_task_tx(void* arg) {
write(fd, msg_to_print, msg_to_print_size);
flushWrite();
}
vRingbufferReturnItem(can_messages, (void *) msg_to_print);
vRingbufferReturnItem(uart_tx_ringbuf, (void *) msg_to_print);
}
linenoiseShow(&ls);
xSemaphoreGive(stdout_taken_sem);
Expand Down
6 changes: 3 additions & 3 deletions main/xvprintf.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@
#include "stdbool.h"
#include "esp_log.h"

RingbufHandle_t can_messages;
RingbufHandle_t uart_tx_ringbuf;
bool timestamp_enabled = false;

void init_tx_ringbuf() {
can_messages = xRingbufferCreate(2200, RINGBUF_TYPE_NOSPLIT);
uart_tx_ringbuf = xRingbufferCreate(2200, RINGBUF_TYPE_NOSPLIT);
}

// This function will be called by the ESP log library every time ESP_LOG needs to be performed.
// @important Do NOT use the ESP_LOG* macro's in this function ELSE recursive loop and stack overflow! So use printf() instead for debug messages.
int vxprintf(const char *fmt, va_list args) {
char msg_to_send[300];
const size_t str_len = vsnprintf(msg_to_send, 299, fmt, args);
xRingbufferSend(can_messages, msg_to_send, str_len + 1, pdMS_TO_TICKS(200));
xRingbufferSend(uart_tx_ringbuf, msg_to_send, str_len + 1, pdMS_TO_TICKS(200));
return str_len;
}

Expand Down
2 changes: 1 addition & 1 deletion main/xvprintf.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

typedef int (*print_func)(const char *fmt, ...);

extern RingbufHandle_t can_messages;
extern RingbufHandle_t uart_tx_ringbuf;
extern bool timestamp_enabled;

void init_tx_ringbuf();
Expand Down

0 comments on commit 51d6ae7

Please sign in to comment.