raiden00pl commented on code in PR #3030: URL: https://github.com/apache/nuttx-apps/pull/3030#discussion_r2005866451
########## canutils/lely-canopen/0003-tools-coctl.c-use-readline-and-fix-printf-issues.patch: ########## @@ -0,0 +1,101 @@ +From 737d4b02ba71737a83be223001df6f53c5936ef8 Mon Sep 17 00:00:00 2001 +From: raiden00pl <raide...@railab.me> +Date: Wed, 19 Mar 2025 10:44:37 +0100 +Subject: [PATCH 3/5] tools/coctl.c: use readline and fix printf issues + +Signed-off-by: raiden00pl <raide...@railab.me> +--- + tools/coctl.c | 23 +++++++++++++---------- + 1 file changed, 13 insertions(+), 10 deletions(-) + +diff --git a/tools/coctl.c b/tools/coctl.c +index 12f4b3aa..d300b998 100644 +--- a/tools/coctl.c ++++ b/tools/coctl.c +@@ -40,6 +40,10 @@ + #include <stdlib.h> + #include <string.h> + ++#include <inttypes.h> ++ ++#include <system/readline.h> ++ + #if _WIN32 + #include <io.h> + #endif +@@ -315,8 +319,8 @@ main(int argc, char *argv[]) + errno = errsv; + int eof = 0; + +- char *line = NULL; +- size_t n = 0; ++#define LINE_SIZE 100 ++ char line[LINE_SIZE]; + co_unsigned32_t seq = 1; + char *cmd = NULL; + while (!done) { +@@ -358,11 +362,11 @@ main(int argc, char *argv[]) + if (cmd) + printf("... "); + else +- printf("[%u] ", seq); ++ printf("[%" PRIu32 "] ", seq); + fflush(stdout); + } + // Keep reading lines until end-of-file. +- if (getline(&line, &n, stdin) == -1) { Review Comment: I confirm that getline works at least on x86 qemu so I removed from patch. I tried to run lely on sim but unfortunately neither readline nor getline works properly there but this is most likely simulator issue. -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org