xiaoxiang781216 commented on code in PR #3030:
URL: https://github.com/apache/nuttx-apps/pull/3030#discussion_r2006706757


##########
canutils/lely-canopen/Makefile:
##########
@@ -170,25 +170,34 @@ MAINSRC    = $(LELYCANOPEN_SRCDIR)/tools/coctl.c
 endif
 
 # Download and unpack tarball if no git repo found
-ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)/.git),)
+ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)),)
 $(LELYCANOPEN_TARBALL):
        @echo "Downloading: $(LELYCANOPEN_TARBALL)"
        $(Q) curl -L -O 
$(CONFIG_CANUTILS_LELYCANOPEN_URL)/$(LELYCANOPEN_TARBALL)
 
 $(LELYCANOPEN_SRCNAME): $(LELYCANOPEN_TARBALL)
        @echo "Unpacking: $(LELYCANOPEN_TARBALL) -> $(LELYCANOPEN_UNPACKNAME)"
        $(Q) $(UNPACK) $(LELYCANOPEN_TARBALL)
+
+patch_src: $(LELYCANOPEN_SRCNAME)
        # Get the name of the directory created by the tar command
        $(eval LELYCANOPEN_UNPACKNAME := $(shell ls -d lely-core-master*))
        $(Q) mv $(LELYCANOPEN_UNPACKNAME) $(LELYCANOPEN_SRCNAME)
-       $(Q) cat 0001-NuttX-port.patch | patch -s -N -d $(LELYCANOPEN_SRCNAME) 
-p1
+       $(Q) cat 
0001-tools-eliminate-multiple-definitions-of-poll-compile.patch | patch -s -N 
-d $(LELYCANOPEN_SRCNAME) -p1
+       $(Q) cat 0002-tools-coctl.c-use-readline-and-fix-printf-issues.patch | 
patch -s -N -d $(LELYCANOPEN_SRCNAME) -p1
+       $(Q) cat 0003-src-co-nmt.c-fix-compilation.patch | patch -s -N -d 
$(LELYCANOPEN_SRCNAME) -p1
+       $(Q) cat 0004-tools-coctl.c-add-missing-mutex-init.patch | patch -s -N 
-d $(LELYCANOPEN_SRCNAME) -p1
+       $(Q) cat 0005-add-NuttX-support.patch | patch -s -N -d 
$(LELYCANOPEN_SRCNAME) -p1
        $(Q) echo "Patching $(LELYCANOPEN_SRCNAME)"
-endif
 
+context:: patch_src
+else
 context:: $(LELYCANOPEN_SRCNAME)
+endif
+
 
 distclean::
-ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)/.git),)

Review Comment:
   why change? we need skip remove the directory which contian git history



##########
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:
   so, we should prefer to use getline, not readline_stream?



##########
canutils/lely-canopen/Makefile:
##########
@@ -170,25 +170,34 @@ MAINSRC    = $(LELYCANOPEN_SRCDIR)/tools/coctl.c
 endif
 
 # Download and unpack tarball if no git repo found
-ifeq ($(wildcard $(LELYCANOPEN_SRCNAME)/.git),)

Review Comment:
   ditto



-- 
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

Reply via email to