diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-05-25 22:10:40 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2012-05-25 22:10:40 +0000 |
commit | 983e72ea391c136624340ea64e19c20adcbf970d (patch) | |
tree | fa1aaf27248cfc57d4bc9c9f1f066b98e93d0191 /apps/nshlib | |
parent | e7f5bd322fe485053559d976eccb00fe65077782 (diff) | |
download | px4-firmware-983e72ea391c136624340ea64e19c20adcbf970d.tar.gz px4-firmware-983e72ea391c136624340ea64e19c20adcbf970d.tar.bz2 px4-firmware-983e72ea391c136624340ea64e19c20adcbf970d.zip |
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/nshlib')
-rw-r--r-- | apps/nshlib/README.txt | 27 | ||||
-rw-r--r-- | apps/nshlib/nsh.h | 36 | ||||
-rw-r--r-- | apps/nshlib/nsh_usbdev.c | 16 |
3 files changed, 75 insertions, 4 deletions
diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt index ee47767a9..42e831ddc 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 bdd12658e..babdedd91 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 a784c6b77..2b31a1a14 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 */ |