summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2013-09-09 15:02:33 -0600
committerGregory Nutt <gnutt@nuttx.org>2013-09-09 15:02:33 -0600
commit91becdb75746f65f27d6e87bd8d3d9f926ddbefe (patch)
treef1a77cb8abe7b31cea329a0ef13897a88bf27645 /apps
parent845f1694727937478ab8487d2b7a2150ad0cc858 (diff)
downloadnuttx-91becdb75746f65f27d6e87bd8d3d9f926ddbefe.tar.gz
nuttx-91becdb75746f65f27d6e87bd8d3d9f926ddbefe.tar.bz2
nuttx-91becdb75746f65f27d6e87bd8d3d9f926ddbefe.zip
USB monitor extended so that it can also be used with USB host trace data
Diffstat (limited to 'apps')
-rw-r--r--apps/ChangeLog.txt2
-rw-r--r--apps/system/usbmonitor/Kconfig23
-rw-r--r--apps/system/usbmonitor/usbmonitor.c86
3 files changed, 66 insertions, 45 deletions
diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt
index 4d076afa1..6ae95a206 100644
--- a/apps/ChangeLog.txt
+++ b/apps/ChangeLog.txt
@@ -641,4 +641,6 @@
a pthread, but we are stuck with that for now. The work-around
is the msconn now daemonizes itself so that it so taht the pthread
is created in a different task group (2013-9-7).
+ * apps/system/usbmonitor: The USB monitor has been extended so
+ that it can be used with USB device or host trace data (2013-9-9).
diff --git a/apps/system/usbmonitor/Kconfig b/apps/system/usbmonitor/Kconfig
index bb784b299..6b298309e 100644
--- a/apps/system/usbmonitor/Kconfig
+++ b/apps/system/usbmonitor/Kconfig
@@ -6,12 +6,12 @@
config SYSTEM_USBMONITOR
bool "USB Monitor"
default n
- depends on USBDEV && USBDEV_TRACE
+ depends on (USBDEV && USBDEV_TRACE) || (USBHOST && USBHOST_TRACE)
---help---
- If USB device tracing is enabled (USBDEV_TRACE), then this option
- will select the USB monitor. The USB monitor is a daemon that will
- periodically collect the buffered USB trace data and dump it to the
- SYSLOG device.
+ If USB device tracing (USBDEV_TRACE) AND/OR USB host tracing
+ (USBHOST_TRACE) are enabled then this option will select the USB
+ monitor. The USB monitor is a daemon that will periodically collect
+ the buffered USB trace data and dump it to the SYSLOG device.
if SYSTEM_USBMONITOR
@@ -34,34 +34,37 @@ config SYSTEM_USBMONITOR_INTERVAL
The rate in seconds that the USB monitor will wait before dumping
the next set of buffered USB trace data. Default: 2 seconds.
+if USBDEV && USBDEV_TRACE
config SYSTEM_USBMONITOR_TRACEINIT
- bool "Show initialization events"
+ bool "Show USB device initialization events"
default n
---help---
Show initialization events
config SYSTEM_USBMONITOR_TRACECLASS
- bool "Show class driver events"
+ bool "Show USB device class driver events"
default n
---help---
Show class driver events
config SYSTEM_USBMONITOR_TRACETRANSFERS
- bool "Show data transfer events"
+ bool "Show USB device data transfer events"
default n
---help---
Show data transfer events
config SYSTEM_USBMONITOR_TRACECONTROLLER
- bool "Show controller events"
+ bool "Show USB device controller events"
default n
---help---
Show controller events
config SYSTEM_USBMONITOR_TRACEINTERRUPTS
- bool "Show interrupt-related events"
+ bool "Show USB device interrupt-related events"
default n
---help---
Show interrupt-related events
+
+endif
endif
diff --git a/apps/system/usbmonitor/usbmonitor.c b/apps/system/usbmonitor/usbmonitor.c
index 7823eb5e7..447bff57b 100644
--- a/apps/system/usbmonitor/usbmonitor.c
+++ b/apps/system/usbmonitor/usbmonitor.c
@@ -48,6 +48,7 @@
#include <errno.h>
#include <nuttx/usb/usbdev_trace.h>
+#include <nuttx/usb/usbhost_trace.h>
#ifdef CONFIG_SYSTEM_USBMONITOR
@@ -71,46 +72,50 @@
# define CONFIG_SYSTEM_USBMONITOR_INTERVAL 2
#endif
-#ifdef CONFIG_SYSTEM_USBMONITOR_TRACEINIT
-# define TRACE_INIT_BITS (TRACE_INIT_BIT)
-#else
-# define TRACE_INIT_BITS (0)
-#endif
-
-#define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
+/* USB device trace selection */
-#ifdef CONFIG_SYSTEM_USBMONITOR_TRACECLASS
-# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|\
- TRACE_CLASSSTATE_BIT)
-#else
-# define TRACE_CLASS_BITS (0)
-#endif
+#ifdef USBDEV_TRACE
+# ifdef CONFIG_SYSTEM_USBMONITOR_TRACEINIT
+# define TRACE_INIT_BITS (TRACE_INIT_BIT)
+# else
+# define TRACE_INIT_BITS (0)
+# endif
-#ifdef CONFIG_SYSTEM_USBMONITOR_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_SYSTEM_USBMONITOR_TRACECONTROLLER
-# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT)
-#else
-# define TRACE_CONTROLLER_BITS (0)
-#endif
+# define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
-#ifdef CONFIG_SYSTEM_USBMONITOR_TRACEINTERRUPTS
-# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|\
- TRACE_INTEXIT_BIT)
-#else
-# define TRACE_INTERRUPT_BITS (0)
+# ifdef CONFIG_SYSTEM_USBMONITOR_TRACECLASS
+# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|\
+ TRACE_CLASSSTATE_BIT)
+# else
+# define TRACE_CLASS_BITS (0)
+# endif
+
+# ifdef CONFIG_SYSTEM_USBMONITOR_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_SYSTEM_USBMONITOR_TRACECONTROLLER
+# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT)
+# else
+# define TRACE_CONTROLLER_BITS (0)
+# endif
+
+# ifdef CONFIG_SYSTEM_USBMONITOR_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
-#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|\
- TRACE_CLASS_BITS|TRACE_TRANSFER_BITS|\
- TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS)
-
/****************************************************************************
* Private Types
****************************************************************************/
@@ -132,11 +137,13 @@ static struct usbmon_state_s g_usbmonitor;
* Private Functions
****************************************************************************/
+#ifdef CONFIG_USBDEV_TRACE
static int usbmonitor_tracecallback(struct usbtrace_s *trace, void *arg)
{
usbtrace_trprintf((trprintf_t)syslog, trace->event, trace->value);
return 0;
}
+#endif
static int usbmonitor_daemon(int argc, char **argv)
{
@@ -147,7 +154,12 @@ static int usbmonitor_daemon(int argc, char **argv)
while (!g_usbmonitor.stop)
{
sleep(CONFIG_SYSTEM_USBMONITOR_INTERVAL);
+#ifdef CONFIG_USBDEV_TRACE
(void)usbtrace_enumerate(usbmonitor_tracecallback, NULL);
+#endif
+#ifdef CONFIG_USBHOST_TRACE
+ (void)usbhost_trdump();
+#endif
}
/* Stopped */
@@ -174,9 +186,11 @@ int usbmonitor_start(int argc, char **argv)
/* No.. start it now */
+#ifdef CONFIG_USBDEV_TRACE
/* First, initialize any USB tracing options that were requested */
usbtrace_enable(TRACE_BITSET);
+#endif
/* Then start the USB monitoring daemon */
@@ -222,9 +236,11 @@ int usbmonitor_stop(int argc, char **argv)
syslog(USBMON_PREFIX "Stopping: %d\n", g_usbmonitor.pid);
g_usbmonitor.stop = true;
+#ifdef CONFIG_USBDEV_TRACE
/* We may as well disable tracing since there is no listener */
usbtrace_enable(0);
+#endif
}
syslog(USBMON_PREFIX "Stopped: %d\n", g_usbmonitor.pid);