summaryrefslogtreecommitdiffstats
path: root/apps
diff options
context:
space:
mode:
authorpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-05-25 22:10:40 +0000
committerpatacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679>2012-05-25 22:10:40 +0000
commit2f9e7c17ae5a9e7ada93021a9d1ed2ee9835d969 (patch)
treefa1aaf27248cfc57d4bc9c9f1f066b98e93d0191 /apps
parent5f1c79814968af20b104c8c1b58a7792611c31b5 (diff)
Fix packet size calculation in CDC/ACM and PL2303 USB serial drivers
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4771 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'apps')
-rwxr-xr-xapps/ChangeLog.txt4
-rw-r--r--apps/nshlib/README.txt27
-rw-r--r--apps/nshlib/nsh.h36
-rw-r--r--apps/nshlib/nsh_usbdev.c16
4 files changed, 79 insertions, 4 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index 75d5c2b097..825b1e50f3 100755
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -230,3 +230,7 @@
initialization interfaces.
6.19 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
+
+ * apps/nshlib/nsh_usbdev.c: Add the capability to use an arbitrary USB
+ device as the console (not necessarily /dev/console). This is a useful
+ option because then you can still use the serial console to debug with.
diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt
index ee47767a91..42e831ddc7 100644
--- a/apps/nshlib/README.txt
+++ b/apps/nshlib/README.txt
@@ -916,6 +916,33 @@ NSH-Specific Configuration Settings
CDC/ACM serial device as a console device at
dev/console.
+ CONFIG_NSH_USBCONSOLE
+ If defined, then the an arbitrary USB device may be used
+ to as the NSH console. In this case, CONFIG_NSH_USBCONDEV
+ must be defined to indicate which USB device to use as
+ the console.
+
+ CONFIG_NSH_USBCONDEV
+ If CONFIG_NSH_USBCONSOLE is set to 'y', then CONFIG_NSH_USBCONDEV
+ must also be set to select the USB device used to support
+ the NSH console. This should be set to the quoted name of a
+ readable/write-able USB driver such as:
+ CONFIG_NSH_USBCONDEV="/dev/ttyACM0".
+
+ If there are more than one USB devices, then a USB device
+ minor number may also need to be provided:
+
+ CONFIG_NSH_UBSDEV_MINOR
+ The minor device number of the USB device. Default: 0
+
+ If USB tracing is enabled, then NSH will initialize USB
+ tracing as requested by the following:
+
+ CONFIG_NSH_UBSDEV_TRACEINIT
+ Bit set with each bit enabling a trace option (see
+ include/nuttx/usb/usbdev_trace.h). Default: Only USB errors
+ are traced.
+
* CONFIG_NSH_CONDEV
If CONFIG_NSH_CONSOLE is set to 'y', then CONFIG_NSH_CONDEV
may also be set to select the serial device used to support
diff --git a/apps/nshlib/nsh.h b/apps/nshlib/nsh.h
index bdd12658e7..babdedd915 100644
--- a/apps/nshlib/nsh.h
+++ b/apps/nshlib/nsh.h
@@ -49,6 +49,8 @@
#include <stdbool.h>
#include <errno.h>
+#include <nuttx/usb/usbdev_trace.h>
+
/****************************************************************************
* Definitions
****************************************************************************/
@@ -79,10 +81,44 @@
#undef HAVE_USB_CONSOLE
#if defined(CONFIG_USBDEV)
+
+/* Check for a PL2303 serial console. Use console device "/dev/console". */
+
# if defined(CONFIG_PL2303) && defined(CONFIG_PL2303_CONSOLE)
# define HAVE_USB_CONSOLE 1
+
+/* Check for a CDC/ACM serial console. Use console device "/dev/console". */
+
# elif defined(CONFIG_CDCACM) && defined(CONFIG_CDCACM_CONSOLE)
# define HAVE_USB_CONSOLE 1
+
+/* Check for other USB console. USB console device must be provided in CONFIG_NSH_CONDEV */
+
+# elif defined(CONFIG_NSH_USBCONSOLE)
+# define HAVE_USB_CONSOLE 1
+# endif
+#endif
+
+/* Defaults for the USB console */
+
+#ifdef HAVE_USB_CONSOLE
+
+/* The default USB console device minor number is 0*/
+
+# ifndef CONFIG_NSH_UBSDEV_MINOR
+# define CONFIG_NSH_UBSDEV_MINOR 0
+# endif
+
+/* USB trace settings */
+
+# ifndef CONFIG_NSH_UBSDEV_TRACEINIT
+# define CONFIG_NSH_UBSDEV_TRACEINIT (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
+# endif
+
+/* The default console device is always /dev/console */
+
+# ifndef CONFIG_NSH_USBCONDEV
+# define CONFIG_NSH_USBCONDEV "/dev/console"
# endif
#endif
diff --git a/apps/nshlib/nsh_usbdev.c b/apps/nshlib/nsh_usbdev.c
index a784c6b777..2b31a1a141 100644
--- a/apps/nshlib/nsh_usbdev.c
+++ b/apps/nshlib/nsh_usbdev.c
@@ -95,6 +95,10 @@ int nsh_usbconsole(void)
int fd;
int ret;
+ /* Initialize any USB tracing options that were requested */
+
+ usbtrace_enable(CONFIG_NSH_UBSDEV_TRACEINIT);
+
/* Don't start the NSH console until the console device is ready. Chances
* are, we get here with no functional console. The USB console will not
* be available until the device is connected to the host and until the
@@ -103,12 +107,14 @@ int nsh_usbconsole(void)
/* Initialize the USB serial driver */
+#if defined(CONFIG_PL2303) || defined(CONFIG_CDCACM)
#ifdef CONFIG_CDCACM
- ret = cdcacm_initialize(0, NULL);
+ ret = cdcacm_initialize(CONFIG_NSH_UBSDEV_MINOR, NULL);
#else
- ret = usbdev_serialinitialize(0);
+ ret = usbdev_serialinitialize(CONFIG_NSH_UBSDEV_MINOR);
#endif
DEBUGASSERT(ret == OK);
+#endif
/* Make sure the stdin, stdout, and stderr are closed */
@@ -122,14 +128,16 @@ int nsh_usbconsole(void)
{
/* Try to open the console */
- fd = open("/dev/console", O_RDWR);
+ fd = open(CONFIG_NSH_USBCONDEV, O_RDWR);
if (fd < 0)
{
+ int errval = errno;
+
/* ENOTCONN means that the USB device is not yet connected. Anything
* else is bad.
*/
- DEBUGASSERT(errno == ENOTCONN);
+ DEBUGASSERT(errval == ENOTCONN);
/* Sleep a bit and try again */