From c5e99745234775f3b1feeb283679a278a9417408 Mon Sep 17 00:00:00 2001 From: patacongo Date: Tue, 29 Jan 2013 17:42:58 +0000 Subject: The USB monitor now works with the stm32f4discover/nsh configuration (but not with the usbnsh configuration) git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5580 42af7a65-404d-4744-a932-0658087f49c3 --- apps/nshlib/Kconfig | 20 ++++++++++-- apps/nshlib/README.txt | 12 +++++--- apps/nshlib/nsh.h | 80 ++++++++++++++++++++++++++++-------------------- apps/nshlib/nsh_usbdev.c | 23 +++++++++----- 4 files changed, 86 insertions(+), 49 deletions(-) (limited to 'apps/nshlib') diff --git a/apps/nshlib/Kconfig b/apps/nshlib/Kconfig index f6a5aa045..589476baf 100644 --- a/apps/nshlib/Kconfig +++ b/apps/nshlib/Kconfig @@ -406,7 +406,7 @@ config NSH_USBCONDEV readable/write-able USB driver such as: NSH_USBCONDEV="/dev/ttyACM0". -config UBSDEV_MINOR +config USBDEV_MINOR int "USB console device minor number" default 0 depends on NSH_USBCONSOLE @@ -414,8 +414,22 @@ config UBSDEV_MINOR If there are more than one USB devices, then a USB device minor number may also need to be provided. Default: 0 -menu "USB Trace Support" +comment "USB Trace Support" +config NSH_USBDEV_TRACE + bool "Enable Builtin USB Trace Support" + default n depends on USBDEV && (DEBUG || USBDEV_TRACE) + ---help--- + Enable builtin USB trace support in NSH. If selected, buffered USB + trace data will be presented each time a command is provided to NSH. + The USB trace data will be sent to the console unless DEBUG set or + unless you are using a USB console. In those cases, the trace data + will go to the SYSLOG device. + + If not enabled, the USB trace support can be provided by external + logic such as apps/system/usbmonitor. + +if NSH_USBDEV_TRACE config NSH_USBDEV_TRACEINIT bool "Show initialization events" @@ -447,7 +461,7 @@ config NSH_USBDEV_TRACEINTERRUPTS ---help--- Show interrupt-related events -endmenu +endif config NSH_CONDEV bool "Default console device" diff --git a/apps/nshlib/README.txt b/apps/nshlib/README.txt index 006839628..a03f4a8ee 100644 --- a/apps/nshlib/README.txt +++ b/apps/nshlib/README.txt @@ -1025,12 +1025,16 @@ NSH-Specific Configuration Settings If there are more than one USB devices, then a USB device minor number may also need to be provided: - CONFIG_NSH_UBSDEV_MINOR + CONFIG_NSH_USBDEV_MINOR The minor device number of the USB device. Default: 0 - If USB tracing is enabled (CONFIG_USBDEV_TRACE), then NSH will - initialize USB tracing as requested by the following. Default: - Only USB errors are traced. + CONFIG_NSH_USBDEV_TRACE + If USB tracing is enabled (CONFIG_USBDEV_TRACE), then NSH can + be configured to show the buffered USB trace data afer each + NSH command: + + If CONFIG_NSH_USBDEV_TRACE is selected, then USB trace data + can be filtered as follows. Default: Only USB errors are traced. CONFIG_NSH_USBDEV_TRACEINIT Show initialization events diff --git a/apps/nshlib/nsh.h b/apps/nshlib/nsh.h index 64099a8df..705375e7e 100644 --- a/apps/nshlib/nsh.h +++ b/apps/nshlib/nsh.h @@ -1,7 +1,7 @@ /**************************************************************************** * apps/nshlib/nsh.h * - * Copyright (C) 2007-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2013 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -93,7 +93,9 @@ # 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 */ +/* 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 @@ -106,8 +108,8 @@ /* The default USB console device minor number is 0*/ -# ifndef CONFIG_NSH_UBSDEV_MINOR -# define CONFIG_NSH_UBSDEV_MINOR 0 +# ifndef CONFIG_NSH_USBDEV_MINOR +# define CONFIG_NSH_USBDEV_MINOR 0 # endif /* The default console device is always /dev/console */ @@ -118,42 +120,52 @@ /* USB trace settings */ -#ifdef CONFIG_NSH_USBDEV_TRACEINIT -# define TRACE_INIT_BITS (TRACE_INIT_BIT) -#else -# define TRACE_INIT_BITS (0) -#endif +#ifndef CONFIG_USBDEV_TRACE +# undef CONFIG_NSH_USBDEV_TRACE +#endif -#define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT) +#ifdef CONFIG_NSH_USBDEV_TRACE +# ifdef CONFIG_NSH_USBDEV_TRACEINIT +# define TRACE_INIT_BITS (TRACE_INIT_BIT) +# else +# define TRACE_INIT_BITS (0) +# endif -#ifdef CONFIG_NSH_USBDEV_TRACECLASS -# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|TRACE_CLASSSTATE_BIT) -#else -# define TRACE_CLASS_BITS (0) -#endif +# define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT) -#ifdef CONFIG_NSH_USBDEV_TRACETRANSFERS -# define TRACE_TRANSFER_BITS (TRACE_OUTREQQUEUED_BIT|TRACE_INREQQUEUED_BIT|TRACE_READ_BIT|\ - TRACE_WRITE_BIT|TRACE_COMPLETE_BIT) -#else -# define TRACE_TRANSFER_BITS (0) -#endif +# ifdef CONFIG_NSH_USBDEV_TRACECLASS +# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|\ + TRACE_CLASSSTATE_BIT) +# else +# define TRACE_CLASS_BITS (0) +# endif -#ifdef CONFIG_NSH_USBDEV_TRACECONTROLLER -# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT) -#else -# define TRACE_CONTROLLER_BITS (0) -#endif +# ifdef CONFIG_NSH_USBDEV_TRACETRANSFERS +# define TRACE_TRANSFER_BITS (TRACE_OUTREQQUEUED_BIT|TRACE_INREQQUEUED_BIT|\ + TRACE_READ_BIT|TRACE_WRITE_BIT|\ + TRACE_COMPLETE_BIT) +# else +# define TRACE_TRANSFER_BITS (0) +# endif -#ifdef CONFIG_NSH_USBDEV_TRACEINTERRUPTS -# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|TRACE_INTEXIT_BIT) -#else -# define TRACE_INTERRUPT_BITS (0) -#endif +# ifdef CONFIG_NSH_USBDEV_TRACECONTROLLER +# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT) +# else +# define TRACE_CONTROLLER_BITS (0) +# endif -#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|TRACE_CLASS_BITS|\ - TRACE_TRANSFER_BITS|TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS) +# ifdef CONFIG_NSH_USBDEV_TRACEINTERRUPTS +# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|\ + TRACE_INTEXIT_BIT) +# else +# define TRACE_INTERRUPT_BITS (0) +# endif +# define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|\ + TRACE_CLASS_BITS|TRACE_TRANSFER_BITS|\ + TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS) + +# endif #endif /* If Telnet is selected for the NSH console, then we must configure @@ -515,7 +527,7 @@ void nsh_dumpbuffer(FAR struct nsh_vtbl_s *vtbl, const char *msg, /* USB debug support */ -#if defined(CONFIG_USBDEV_TRACE) && defined(HAVE_USB_CONSOLE) +#if defined(CONFIG_NSH_USBDEV_TRACE) && defined(HAVE_USB_CONSOLE) void nsh_usbtrace(void); #else # define nsh_usbtrace() diff --git a/apps/nshlib/nsh_usbdev.c b/apps/nshlib/nsh_usbdev.c index d137e3dae..2064cbd84 100644 --- a/apps/nshlib/nsh_usbdev.c +++ b/apps/nshlib/nsh_usbdev.c @@ -61,9 +61,15 @@ /**************************************************************************** * Definitions ****************************************************************************/ - -#if defined(CONFIG_DEBUG) || defined(CONFIG_NSH_USBCONSOLE) -# define trmessage lowsyslog +/* Output USB trace data to the console device using printf() unless (1) + * debug is enabled, then we want to keep the trace output in sync with the + * debug output by using syslog()we are using a USB console. In that case, + * we don't want the trace output on the USB console; let's try sending it + * a SYSLOG device (hopefully one is set up!) + */ + +#if defined(CONFIG_DEBUG) || defined(HAVE_USB_CONSOLE) +# define trmessage syslog #else # define trmessage printf #endif @@ -92,7 +98,7 @@ * Name: nsh_tracecallback ****************************************************************************/ -#ifdef CONFIG_USBDEV_TRACE +#ifdef CONFIG_NSH_USBDEV_TRACE static int nsh_tracecallback(struct usbtrace_s *trace, void *arg) { usbtrace_trprintf((trprintf_t)trmessage, trace->event, trace->value); @@ -119,7 +125,7 @@ int nsh_usbconsole(void) /* Initialize any USB tracing options that were requested */ -#ifdef CONFIG_USBDEV_TRACE +#ifdef CONFIG_NSH_USBDEV_TRACE usbtrace_enable(TRACE_BITSET); #endif @@ -133,9 +139,9 @@ int nsh_usbconsole(void) #if defined(CONFIG_PL2303) || defined(CONFIG_CDCACM) #ifdef CONFIG_CDCACM - ret = cdcacm_initialize(CONFIG_NSH_UBSDEV_MINOR, NULL); + ret = cdcacm_initialize(CONFIG_NSH_USBDEV_MINOR, NULL); #else - ret = usbdev_serialinitialize(CONFIG_NSH_UBSDEV_MINOR); + ret = usbdev_serialinitialize(CONFIG_NSH_USBDEV_MINOR); #endif DEBUGASSERT(ret == OK); #endif @@ -224,6 +230,7 @@ int nsh_usbconsole(void) (void)fdopen(0, "r"); (void)fdopen(1, "a"); (void)fdopen(2, "a"); + return OK; } @@ -233,7 +240,7 @@ int nsh_usbconsole(void) * Name: nsh_usbtrace ****************************************************************************/ -#if defined(CONFIG_USBDEV_TRACE) && defined(HAVE_USB_CONSOLE) +#if defined(CONFIG_NSH_USBDEV_TRACE) && defined(HAVE_USB_CONSOLE) void nsh_usbtrace(void) { (void)usbtrace_enumerate(nsh_tracecallback, NULL); -- cgit v1.2.3