You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by xi...@apache.org on 2024/10/01 03:37:51 UTC

(nuttx-apps) branch master updated: usbserial: Add config for customize direction, message and wait time

This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx-apps.git


The following commit(s) were added to refs/heads/master by this push:
     new 23bf7fb44 usbserial: Add config for customize direction, message and wait time
23bf7fb44 is described below

commit 23bf7fb449c9f07898d1f57498b07303b55123a2
Author: Kevin Zhou <ke...@sony.com>
AuthorDate: Mon Sep 30 15:39:49 2024 +0800

    usbserial: Add config for customize direction, message and wait time
---
 examples/usbserial/Kconfig          | 52 +++++++++++++++++++++++++++++++++++++
 examples/usbserial/usbserial_main.c |  8 ++++++
 2 files changed, 60 insertions(+)

diff --git a/examples/usbserial/Kconfig b/examples/usbserial/Kconfig
index 6e1bc5510..017d58b3d 100644
--- a/examples/usbserial/Kconfig
+++ b/examples/usbserial/Kconfig
@@ -20,6 +20,58 @@ config EXAMPLES_USBSERIAL_BUFSIZE
 		The size of the array that is used as an I/O buffer for USB serial
 		data transfers.
 
+choice
+	prompt "USB serial transfer"
+	default EXAMPLES_USBSERIAL_INANDOUT
+	---help---
+		Select usb serial transfer in or out
+
+config EXAMPLES_USBSERIAL_INANDOUT
+	bool "in and out"
+
+config EXAMPLES_USBSERIAL_INONLY
+	bool "in only"
+
+config EXAMPLES_USBSERIAL_OUTONLY
+	bool "out only"
+
+endchoice # USBSERIAL in or out
+
+config EXAMPLES_USBSERIAL_CONFIG_WAIT
+	bool "Config waiting time"
+	default n
+	---help---
+		Config waiting time after transfer
+
+if EXAMPLES_USBSERIAL_CONFIG_WAIT
+
+config EXAMPLES_USBSERIAL_IN_WAITING_TIME
+	int "In waiting time (ms)"
+	default 100
+
+config EXAMPLES_USBSERIAL_OUT_WAITING_TIME
+	int "Out waiting time (ms)"
+	default 100
+
+endif # USERSERIAL config wait
+
+choice
+	prompt "USB serial message"
+	default EXAMPLES_USBSERIAL_SMALLANDBIG
+	---help---
+		Select usb serial small or big message
+
+config EXAMPLES_USBSERIAL_SMALLANDBIG
+	bool "small and big"
+
+config EXAMPLES_USBSERIAL_ONLYSMALL
+	bool "only small"
+
+config EXAMPLES_USBSERIAL_ONLYBIG
+	bool "only big"
+
+endchoice # USBSERIAL small or big message
+
 config EXAMPLES_USBSERIAL_TRACEINIT
 	bool "USB Trace Initialization"
 	default n
diff --git a/examples/usbserial/usbserial_main.c b/examples/usbserial/usbserial_main.c
index a06b2bdbf..443834a54 100644
--- a/examples/usbserial/usbserial_main.c
+++ b/examples/usbserial/usbserial_main.c
@@ -456,12 +456,20 @@ int main(int argc, FAR char *argv[])
                 }
             }
 
+#ifdef CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT
+          usleep(CONFIG_EXAMPLES_USBSERIAL_OUT_WAITING_TIME * 1000);
+#else
           sleep(1);
+#endif /* CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT */
         }
 
 #else /* CONFIG_EXAMPLES_USBSERIAL_INONLY */
       printf("usbserial_main: Waiting\n");
+#ifdef CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT
+      usleep(CONFIG_EXAMPLES_USBSERIAL_IN_WAITING_TIME * 1000);
+#else
       sleep(5);
+#endif /* CONFIG_EXAMPLES_USBSERIAL_CONFIG_WAIT */
 #endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */
 
       /* If USB tracing is enabled, then dump all collected trace data