Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
nuttx-apps
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
f4grx
nuttx-apps
Commits
645d02ac
Commit
645d02ac
authored
11 years ago
by
Gregory Nutt
Browse files
Options
Downloads
Patches
Plain Diff
USB monitor extended so that it can also be used with USB host trace data
parent
0f83209b
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
ChangeLog.txt
+2
-0
2 additions, 0 deletions
ChangeLog.txt
system/usbmonitor/Kconfig
+13
-10
13 additions, 10 deletions
system/usbmonitor/Kconfig
system/usbmonitor/usbmonitor.c
+51
-35
51 additions, 35 deletions
system/usbmonitor/usbmonitor.c
with
66 additions
and
45 deletions
ChangeLog.txt
+
2
−
0
View file @
645d02ac
...
@@ -641,4 +641,6 @@
...
@@ -641,4 +641,6 @@
a pthread, but we are stuck with that for now. The work-around
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 the msconn now daemonizes itself so that it so taht the pthread
is created in a different task group (2013-9-7).
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).
This diff is collapsed.
Click to expand it.
system/usbmonitor/Kconfig
+
13
−
10
View file @
645d02ac
...
@@ -6,12 +6,12 @@
...
@@ -6,12 +6,12 @@
config SYSTEM_USBMONITOR
config SYSTEM_USBMONITOR
bool "USB Monitor"
bool "USB Monitor"
default n
default n
depends on USBDEV && USBDEV_TRACE
depends on
(
USBDEV && USBDEV_TRACE
) || (USBHOST && USBHOST_TRACE)
---help---
---help---
If USB device tracing
is enabled
(USBDEV_TRACE)
, then this option
If USB device tracing (USBDEV_TRACE)
AND/OR USB host tracing
will select the USB monitor. The USB monitor is a daemon that will
(USBHOST_TRACE) are enabled then this option will select the USB
periodically collect the buffered USB trace data and dump it to the
monitor. The USB monitor is a daemon that will periodically collect
SYSLOG device.
the buffered USB trace data and dump it to the
SYSLOG device.
if SYSTEM_USBMONITOR
if SYSTEM_USBMONITOR
...
@@ -34,34 +34,37 @@ config SYSTEM_USBMONITOR_INTERVAL
...
@@ -34,34 +34,37 @@ config SYSTEM_USBMONITOR_INTERVAL
The rate in seconds that the USB monitor will wait before dumping
The rate in seconds that the USB monitor will wait before dumping
the next set of buffered USB trace data. Default: 2 seconds.
the next set of buffered USB trace data. Default: 2 seconds.
if USBDEV && USBDEV_TRACE
config SYSTEM_USBMONITOR_TRACEINIT
config SYSTEM_USBMONITOR_TRACEINIT
bool "Show initialization events"
bool "Show
USB device
initialization events"
default n
default n
---help---
---help---
Show initialization events
Show initialization events
config SYSTEM_USBMONITOR_TRACECLASS
config SYSTEM_USBMONITOR_TRACECLASS
bool "Show class driver events"
bool "Show
USB device
class driver events"
default n
default n
---help---
---help---
Show class driver events
Show class driver events
config SYSTEM_USBMONITOR_TRACETRANSFERS
config SYSTEM_USBMONITOR_TRACETRANSFERS
bool "Show data transfer events"
bool "Show
USB device
data transfer events"
default n
default n
---help---
---help---
Show data transfer events
Show data transfer events
config SYSTEM_USBMONITOR_TRACECONTROLLER
config SYSTEM_USBMONITOR_TRACECONTROLLER
bool "Show controller events"
bool "Show
USB device
controller events"
default n
default n
---help---
---help---
Show controller events
Show controller events
config SYSTEM_USBMONITOR_TRACEINTERRUPTS
config SYSTEM_USBMONITOR_TRACEINTERRUPTS
bool "Show interrupt-related events"
bool "Show
USB device
interrupt-related events"
default n
default n
---help---
---help---
Show interrupt-related events
Show interrupt-related events
endif
endif
endif
This diff is collapsed.
Click to expand it.
system/usbmonitor/usbmonitor.c
+
51
−
35
View file @
645d02ac
...
@@ -48,6 +48,7 @@
...
@@ -48,6 +48,7 @@
#include
<errno.h>
#include
<errno.h>
#include
<nuttx/usb/usbdev_trace.h>
#include
<nuttx/usb/usbdev_trace.h>
#include
<nuttx/usb/usbhost_trace.h>
#ifdef CONFIG_SYSTEM_USBMONITOR
#ifdef CONFIG_SYSTEM_USBMONITOR
...
@@ -71,46 +72,50 @@
...
@@ -71,46 +72,50 @@
# define CONFIG_SYSTEM_USBMONITOR_INTERVAL 2
# define CONFIG_SYSTEM_USBMONITOR_INTERVAL 2
#endif
#endif
#ifdef CONFIG_SYSTEM_USBMONITOR_TRACEINIT
/* USB device trace selection */
# define TRACE_INIT_BITS (TRACE_INIT_BIT)
#else
# define TRACE_INIT_BITS (0)
#endif
#define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
#ifdef
CONFIG_SYSTEM_USBMONITOR
_TRACE
CLASS
#ifdef
USBDEV
_TRACE
# def
ine TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|\
#
if
def
CONFIG_SYSTEM_USBMONITOR_TRACEINIT
TRACE_
CLASSSTATE
_BIT)
#
define TRACE_INIT_BITS
(
TRACE_
INIT
_BIT)
#else
#
else
# define TRACE_
CLASS
_BITS (0)
#
define TRACE_
INIT
_BITS
(0)
#endif
#
endif
#ifdef CONFIG_SYSTEM_USBMONITOR_TRACETRANSFERS
# define TRACE_ERROR_BITS (TRACE_DEVERROR_BIT|TRACE_CLSERROR_BIT)
# 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
# ifdef CONFIG_SYSTEM_USBMONITOR_TRACECLASS
# define TRACE_INTERRUPT_BITS (TRACE_INTENTRY_BIT|TRACE_INTDECODE_BIT|\
# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|\
TRACE_INTEXIT_BIT)
TRACE_CLASSSTATE_BIT)
#else
# else
# define TRACE_INTERRUPT_BITS (0)
# 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
#endif
#define TRACE_BITSET (TRACE_INIT_BITS|TRACE_ERROR_BITS|\
TRACE_CLASS_BITS|TRACE_TRANSFER_BITS|\
TRACE_CONTROLLER_BITS|TRACE_INTERRUPT_BITS)
/****************************************************************************
/****************************************************************************
* Private Types
* Private Types
****************************************************************************/
****************************************************************************/
...
@@ -132,11 +137,13 @@ static struct usbmon_state_s g_usbmonitor;
...
@@ -132,11 +137,13 @@ static struct usbmon_state_s g_usbmonitor;
* Private Functions
* Private Functions
****************************************************************************/
****************************************************************************/
#ifdef CONFIG_USBDEV_TRACE
static
int
usbmonitor_tracecallback
(
struct
usbtrace_s
*
trace
,
void
*
arg
)
static
int
usbmonitor_tracecallback
(
struct
usbtrace_s
*
trace
,
void
*
arg
)
{
{
usbtrace_trprintf
((
trprintf_t
)
syslog
,
trace
->
event
,
trace
->
value
);
usbtrace_trprintf
((
trprintf_t
)
syslog
,
trace
->
event
,
trace
->
value
);
return
0
;
return
0
;
}
}
#endif
static
int
usbmonitor_daemon
(
int
argc
,
char
**
argv
)
static
int
usbmonitor_daemon
(
int
argc
,
char
**
argv
)
{
{
...
@@ -147,7 +154,12 @@ static int usbmonitor_daemon(int argc, char **argv)
...
@@ -147,7 +154,12 @@ static int usbmonitor_daemon(int argc, char **argv)
while
(
!
g_usbmonitor
.
stop
)
while
(
!
g_usbmonitor
.
stop
)
{
{
sleep
(
CONFIG_SYSTEM_USBMONITOR_INTERVAL
);
sleep
(
CONFIG_SYSTEM_USBMONITOR_INTERVAL
);
#ifdef CONFIG_USBDEV_TRACE
(
void
)
usbtrace_enumerate
(
usbmonitor_tracecallback
,
NULL
);
(
void
)
usbtrace_enumerate
(
usbmonitor_tracecallback
,
NULL
);
#endif
#ifdef CONFIG_USBHOST_TRACE
(
void
)
usbhost_trdump
();
#endif
}
}
/* Stopped */
/* Stopped */
...
@@ -174,9 +186,11 @@ int usbmonitor_start(int argc, char **argv)
...
@@ -174,9 +186,11 @@ int usbmonitor_start(int argc, char **argv)
/* No.. start it now */
/* No.. start it now */
#ifdef CONFIG_USBDEV_TRACE
/* First, initialize any USB tracing options that were requested */
/* First, initialize any USB tracing options that were requested */
usbtrace_enable
(
TRACE_BITSET
);
usbtrace_enable
(
TRACE_BITSET
);
#endif
/* Then start the USB monitoring daemon */
/* Then start the USB monitoring daemon */
...
@@ -222,9 +236,11 @@ int usbmonitor_stop(int argc, char **argv)
...
@@ -222,9 +236,11 @@ int usbmonitor_stop(int argc, char **argv)
syslog
(
USBMON_PREFIX
"Stopping: %d
\n
"
,
g_usbmonitor
.
pid
);
syslog
(
USBMON_PREFIX
"Stopping: %d
\n
"
,
g_usbmonitor
.
pid
);
g_usbmonitor
.
stop
=
true
;
g_usbmonitor
.
stop
=
true
;
#ifdef CONFIG_USBDEV_TRACE
/* We may as well disable tracing since there is no listener */
/* We may as well disable tracing since there is no listener */
usbtrace_enable
(
0
);
usbtrace_enable
(
0
);
#endif
}
}
syslog
(
USBMON_PREFIX
"Stopped: %d
\n
"
,
g_usbmonitor
.
pid
);
syslog
(
USBMON_PREFIX
"Stopped: %d
\n
"
,
g_usbmonitor
.
pid
);
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment