From 5871150c5c3939ab215da78261783ddc79693faa Mon Sep 17 00:00:00 2001 From: Aadi Desai <21363892+supleed2@users.noreply.github.com> Date: Sat, 10 Jun 2023 14:56:07 +0100 Subject: [PATCH] Fixes to demo program --- demo/can.cpp | 6 ++++-- demo/main.cpp | 1 + 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/demo/can.cpp b/demo/can.cpp index 37ca739..1d20b24 100644 --- a/demo/can.cpp +++ b/demo/can.cpp @@ -38,11 +38,13 @@ can_frame can_read(void) { } void can_isr(void) { + static uint32_t count = 0; can_ev_pending_frame_write(1); // Should use `can_ev_pending_read()` and check which interrupt, but there is only 1 leds_out_write(leds_out_read() ^ 0xFF0000); // Toggle Red LED + count++; can_frame frame = can_read(); - printf("\033[F\033[F\33[2K\nCAN frame received, ID: 0x%03X, data: 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n", - frame.id, frame.data[0], frame.data[1], frame.data[2], frame.data[3], frame.data[4], frame.data[5], + printf("\033[F\033[F\33[2K\nCAN frame % 5d received, ID: 0x%03X, data: 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X 0x%02X\n", + count, frame.id, frame.data[0], frame.data[1], frame.data[2], frame.data[3], frame.data[4], frame.data[5], frame.data[6], frame.data[7]); // Print CAN frame to UART can_ev_enable_frame_write(1); // Re-enable event handler, same as in `can_init()` printf("\e[92;1mStackSynth\e[0m> "); // Print prompt to UART diff --git a/demo/main.cpp b/demo/main.cpp index 749f116..2774480 100644 --- a/demo/main.cpp +++ b/demo/main.cpp @@ -23,6 +23,7 @@ char *readstr(bool print) { static unsigned int ptr = 0; if (print) { + s[ptr] = 0x00; fputs(s, stdout); } else if (readchar_nonblock()) { c[0] = getchar();