diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index 8e4d858f9..5dad355a7 100755 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -114,4 +114,7 @@ * apps/graphics/tiff: Add a library that can be used to create TIFF files. * apps/examples/tiff: Add a unit test for the TIFF file creation logic * apps/examples/lcdrw: Add a test to verify if you can or can or read - data from an LCD correctly. \ No newline at end of file + data from an LCD correctly. + * apps/examples/usbterm: A USB terminal example.. more of a USB chat or + serial bridge: Data received on local console echoed via USB serial; + data received on USB serial is echoed on the local console. diff --git a/apps/examples/Makefile b/apps/examples/Makefile index b20d6e7df..48e450bd5 100644 --- a/apps/examples/Makefile +++ b/apps/examples/Makefile @@ -40,7 +40,7 @@ SUBDIRS = buttons dhcpd ftpc hello helloxx hidkbd igmp lcdrw mm mount \ nettest nsh null nx nxffs nxflat nxhello nximage nxlines \ nxtext ostest pashello pipe poll rgmp romfs sendmail serloop \ - thttpd tiff udp uip usbserial usbstorage wget wlan + thttpd tiff udp uip usbserial usbstorage usbterm wget wlan # Sub-directories that might need context setup @@ -70,6 +70,9 @@ endif ifeq ($(CONFIG_EXAMPLES_USBSTRG_BUILTIN),y) CNTXTDIRS += usbstorage endif +ifeq ($(CONFIG_EXAMPLES_USBTERM_BUILTIN),y) +CNTXTDIRS += usbterm +endif all: nothing .PHONY: nothing context depend clean distclean diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 6296a655e..0327d6b61 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -966,6 +966,45 @@ examples/usbstorage user-space program. As a result, this example cannot be used if a NuttX is built as a protected, supervisor kernel (CONFIG_NUTTX_KERNEL). +examples/usbterm +^^^^^^^^^^^^^^^^ + + This example implements a little USB terminal.. more of a USB "chat" + edited lines are received from the remote host connected via USB + serial and echoed out the target serial console. Edited lines from + the local target serial console are received and forwarded to the + remote host via USB serial. + + Configuration options: + + CONFIG_EXAMPLES_UBSTERM_BUILTIN - Build the usbterm example as an NSH + built-in command. NOTE: This is not fully functional as of this + writing.. It should work, but there is no mechanism in place yet + to exit the USB terminal program and return to NSH. + CONFIG_EXAMPLES_USBTERM_BUFLEN - The size of the input and output + buffers used for receiving data. Default 256 bytes. + + If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB, or + CONFIG_USBDEV_TRACE), then the example code will also manage the USB trace + output. The amount of trace output can be controlled using: + + CONFIG_EXAMPLES_USBTERM_TRACEINIT + Show initialization events + CONFIG_EXAMPLES_USBTERM_TRACECLASS + Show class driver events + CONFIG_EXAMPLES_USBTERM_TRACETRANSFERS + Show data transfer events + CONFIG_EXAMPLES_USBTERM_TRACECONTROLLER + Show controller events + CONFIG_EXAMPLES_USBTERM_TRACEINTERRUPTS + Show interrupt-related events. + + Error results are always shown in the trace output + + Other relevant configuration options: CONFIG_CDCSER selected by the + Prolifics emulation (not defined) and the CDC serial implementation + (when defined). CONFIG_USBDEV_TRACE_INITIALIDSET. + examples/wget ^^^^^^^^^^^^^ diff --git a/apps/examples/usbterm/Makefile b/apps/examples/usbterm/Makefile new file mode 100644 index 000000000..bc9bb4d41 --- /dev/null +++ b/apps/examples/usbterm/Makefile @@ -0,0 +1,107 @@ +############################################################################ +# apps/examples/usbterm/Makefile +# +# Copyright (C) 2011 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# USB terminal example + +ASRCS = +CSRCS = usbterm_main.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOTDEPPATH = --dep-path . + +# Built-in application info + +APPNAME = usbterm +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + +# Common build + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +.context: +ifeq ($(CONFIG_EXAMPLES_UBSTERM_BUILTIN),y) + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ +endif + +context: .context + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + @$(MAKE) -f Makefile.host clean TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep + diff --git a/apps/examples/usbterm/usbterm.h b/apps/examples/usbterm/usbterm.h new file mode 100644 index 000000000..97ccf5405 --- /dev/null +++ b/apps/examples/usbterm/usbterm.h @@ -0,0 +1,148 @@ +/**************************************************************************** + * examples/usbterm/usbterm.h + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_USBTERM_USBTERM_H +#define __APPS_EXAMPLES_USBTERM_USBTERM_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include + +/**************************************************************************** + * Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifndef CONFIG_EXAMPLES_USBTERM_BUFLEN +# define CONFIG_EXAMPLES_USBTERM_BUFLEN 256 +#endif + +#ifdef CONFIG_EXAMPLES_USBTERM_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) + +#ifdef CONFIG_EXAMPLES_USBTERM_TRACECLASS +# define TRACE_CLASS_BITS (TRACE_CLASS_BIT|TRACE_CLASSAPI_BIT|TRACE_CLASSSTATE_BIT) +#else +# define TRACE_CLASS_BITS (0) +#endif + +#ifdef CONFIG_EXAMPLES_USBTERM_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_EXAMPLES_USBTERM_TRACECONTROLLER +# define TRACE_CONTROLLER_BITS (TRACE_EP_BIT|TRACE_DEV_BIT) +#else +# define TRACE_CONTROLLER_BITS (0) +#endif + +#ifdef CONFIG_EXAMPLES_USBTERM_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) + +/* Debug ********************************************************************/ + +#ifdef CONFIG_CPP_HAVE_VARARGS +# ifdef CONFIG_DEBUG +# define message(...) lib_rawprintf(__VA_ARGS__) +# define trmessage lib_rawprintf +# else +# define message(...) printf(__VA_ARGS__) +# define trmessage printf +# endif +#else +# ifdef CONFIG_DEBUG +# define message lib_lowprintf +# define trmessage lib_lowprintf +# else +# define message printf +# define trmessage printf +# endif +#endif + +#define IOBUFFER_SIZE 256 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* All USB terminal state data is packaged in a single structure to minimize + * name conflicts with other global symbols -- a poor man's name space. + */ + +struct usbterm_globals_s +{ + FILE *instream; /* Stream for incoming USB data */ + FILE *outstream; /* Stream for outgoing USB data */ + pthread_t listener; /* USB terminal listener thread */ + + /* Buffers for incoming and outgoing data */ + + char inbuffer[CONFIG_EXAMPLES_USBTERM_BUFLEN]; + char outbuffer[CONFIG_EXAMPLES_USBTERM_BUFLEN]; +}; + +/**************************************************************************** + * Public Variables + ****************************************************************************/ + +/* USB terminal state data */ + +extern struct usbterm_globals_s g_usbterm; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#endif /* __APPS_EXAMPLES_USBTERM_USBTERM_H */ diff --git a/apps/examples/usbterm/usbterm_main.c b/apps/examples/usbterm/usbterm_main.c new file mode 100644 index 000000000..3cac73c5c --- /dev/null +++ b/apps/examples/usbterm/usbterm_main.c @@ -0,0 +1,307 @@ +/**************************************************************************** + * examples/usbterm/usbterm_main.c + * + * Copyright (C) 2011 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#ifdef CONFIG_CDCSER +# include +#endif + +#include "usbterm.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +/* USB terminal state data */ + +struct usbterm_globals_s g_usbterm; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: trace_callback + * + * Description: + * Callback from USB trace instrumentation. + * + ****************************************************************************/ + +#ifdef CONFIG_USBDEV_TRACE +static int trace_callback(struct usbtrace_s *trace, void *arg) +{ + usbtrace_trprintf((trprintf_t)trmessage, trace->event, trace->value); + return 0; +} +#endif + +/**************************************************************************** + * Name: dumptrace + * + * Description: + * Dump collected trace data. + * + ****************************************************************************/ + +#ifdef CONFIG_USBDEV_TRACE +static void dumptrace(void) +{ + (void)usbtrace_enumerate(trace_callback, NULL); +} +#else +# define dumptrace() +#endif + +/**************************************************************************** + * Name: dumptrace + * + * Description: + * Entry point for the listener thread. + * + ****************************************************************************/ + +FAR void *usbterm_listener(FAR void *parameter) +{ + message("usbterm_listener: Waiting for remote input\n"); + for (;;) + { + /* Display the prompt string on the remote USB serial connection */ + + fputs("usbterm> ", g_usbterm.outstream); + fflush(g_usbterm.outstream); + + /* Get the next line of input from the remote USB serial connection */ + + if (fgets(g_usbterm.inbuffer, CONFIG_EXAMPLES_USBTERM_BUFLEN, g_usbterm.instream)) + { + /* Send the line of input via USB */ + + fputs(g_usbterm.outbuffer, stdout); + fflush(stdout); + } + + /* If USB tracing is enabled, then dump all collected trace data to stdout */ + + dumptrace(); + } + + /* Won't get here */ + + return NULL; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: term_main/user_start + * + * Description: + * Main entry point for the USB serial terminal example. + * + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_USBTERM_BUILTIN +# define MAIN_NAME term_main +# define MAIN_STRING "usbterm_main: " +#else +# define MAIN_NAME user_start +# define MAIN_STRING "user_start: " +#endif + +int MAIN_NAME(int argc, char *argv[]) +{ + pthread_attr_t attr; + int ret; + + /* Initialize the USB serial driver */ + + message(MAIN_STRING "Registering USB serial driver\n"); +#ifdef CONFIG_CDCSER + ret = cdcser_initialize(0); +#else + ret = usbdev_serialinitialize(0); +#endif + if (ret < 0) + { + message(MAIN_STRING "ERROR: Failed to create the USB serial device: %d\n", -ret); + goto errout; + } + message(MAIN_STRING "Successfully registered the serial driver\n"); + +#if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 + /* If USB tracing is enabled and tracing of initial USB events is specified, + * then dump all collected trace data to stdout + */ + + sleep(5); + dumptrace(); +#endif + + /* Then, in any event, configure trace data collection as configured */ + + usbtrace_enable(TRACE_BITSET); + + /* Open the USB serial device for writing */ + + do + { + message(MAIN_STRING "Opening USB serial driver\n"); + + g_usbterm.outstream = fopen("/dev/ttyUSB0", "w"); + if (g_usbterm.outstream == NULL) + { + int errcode = errno; + message(MAIN_STRING "ERROR: Failed to open /dev/ttyUSB0 for writing: %d\n", + errcode); + + /* ENOTCONN means that the USB device is not yet connected */ + + if (errcode == ENOTCONN) + { + message(MAIN_STRING " Not connected. Wait and try again.\n"); + sleep(5); + } + else + { + /* Give up on other errors */ + + goto errout; + } + } + + /* If USB tracing is enabled, then dump all collected trace data to stdout */ + + dumptrace(); + } + while (g_usbterm.outstream < 0); + + /* Open the USB serial device for reading. Since we are already connected, this + * should not fail. + */ + + g_usbterm.instream = fopen("/dev/ttyUSB0", "r"); + if (g_usbterm.instream < 0) + { + message(MAIN_STRING "ERROR: Failed to open /dev/ttyUSB0 for reading: %d\n", errno); + goto errout_with_outstream; + } + + message(MAIN_STRING "Successfully opened the serial driver\n"); + + /* Start the USB term listener thread */ + + message(MAIN_STRING "Starting the listener thread\n"); + + ret = pthread_attr_init(&attr); + if (ret != OK) + { + message(MAIN_STRING "pthread_attr_init failed: %d\n", ret); + goto errout_with_streams; + } + + ret = pthread_create(&g_usbterm.listener, &attr, + usbterm_listener, (pthread_addr_t)0); + if (ret != 0) + { + message(MAIN_STRING "Error in thread creation: %d\n", ret); + goto errout_with_streams; + } + + /* Send messages and get responses -- forever */ + + message(MAIN_STRING "Waiting for local input\n"); + for (;;) + { + /* Display the prompt string on stdout */ + + fputs("usbterm> ", stdout); + fflush(stdout); + + /* Get the next line of input from stdin */ + + if (fgets(g_usbterm.outbuffer, CONFIG_EXAMPLES_USBTERM_BUFLEN, stdin)) + { + /* Send the line of input via USB */ + + fputs(g_usbterm.outbuffer, g_usbterm.outstream); + fflush(g_usbterm.outstream); + } + + /* If USB tracing is enabled, then dump all collected trace data to stdout */ + + dumptrace(); + } + + /* Error exits */ + +errout_with_streams: + fclose(g_usbterm.instream); +errout_with_outstream: + fclose(g_usbterm.outstream); +errout: + message(MAIN_STRING " Aborting\n"); + return 1; +} + diff --git a/nuttx/configs/stm3210e-eval/README.txt b/nuttx/configs/stm3210e-eval/README.txt index 017af14e5..3f260e9a8 100755 --- a/nuttx/configs/stm3210e-eval/README.txt +++ b/nuttx/configs/stm3210e-eval/README.txt @@ -631,6 +631,16 @@ Where is one of the following: -CONFIG_CDCSER=n +CONFIG_CDCSER=y + The example can also be converted to use the alternative + USB serial example at apps/examples/usbterm by changing the + following: + + -CONFIGURED_APPS += examples/usbserial + +CONFIGURED_APPS += examples/usbterm + + In either the original appconfig file (before configuring) + or in the final apps/.config file (after configuring). + usbstorage: ---------- This configuration directory exercises the USB mass storage diff --git a/nuttx/configs/stm3210e-eval/usbserial/defconfig b/nuttx/configs/stm3210e-eval/usbserial/defconfig index ec48e44c9..a23ef58f7 100755 --- a/nuttx/configs/stm3210e-eval/usbserial/defconfig +++ b/nuttx/configs/stm3210e-eval/usbserial/defconfig @@ -884,6 +884,34 @@ CONFIG_EXAMPLES_USBSERIAL_TRACETRANSFERS=n CONFIG_EXAMPLES_USBSERIAL_TRACECONTROLLER=n CONFIG_EXAMPLES_USBSERIAL_TRACEINTERRUPTS=n +# +# Settings for examples/usbterm +# +# CONFIG_EXAMPLES_UBSTERM_BUILTIN - Build the usbterm example as an NSH +# built-in command. NOTE: This is not fully functional as of this +# writing.. It should work, but there is no mechanism in place yet +# to exit the USB terminal program and return to NSH. +# CONFIG_EXAMPLES_USBTERM_BUFLEN - The size of the input and output +# buffers used for receiving data. Default 256 bytes. +# +# If CONFIG_USBDEV_TRACE is enabled (or CONFIG_DEBUG and CONFIG_DEBUG_USB, or +# CONFIG_USBDEV_TRACE), then the example code will also manage the USB trace +# output. The amount of trace output can be controlled using: +# +# CONFIG_EXAMPLES_USBTERM_TRACEINIT - Show initialization events +# CONFIG_EXAMPLES_USBTERM_TRACECLASS - Show class driver events +# CONFIG_EXAMPLES_USBTERM_TRACETRANSFERS - Show data transfer events +# CONFIG_EXAMPLES_USBTERM_TRACECONTROLLER - Show controller events +# CONFIG_EXAMPLES_USBTERM_TRACEINTERRUPTS - Show interrupt-related events +# +CONFIG_EXAMPLES_UBSTERM_BUILTIN=n +CONFIG_EXAMPLES_USBTERM_BUFLEN=256 +CONFIG_EXAMPLES_USBTERM_TRACEINIT=n +CONFIG_EXAMPLES_USBTERM_TRACECLASS=n +CONFIG_EXAMPLES_USBTERM_TRACETRANSFERS=n +CONFIG_EXAMPLES_USBTERM_TRACECONTROLLER=n +CONFIG_EXAMPLES_USBTERM_TRACEINTERRUPTS=n + # # Stack and heap information # diff --git a/nuttx/drivers/usbdev/cdc_serial.c b/nuttx/drivers/usbdev/cdc_serial.c index d5d5739b2..bab4e3951 100644 --- a/nuttx/drivers/usbdev/cdc_serial.c +++ b/nuttx/drivers/usbdev/cdc_serial.c @@ -2170,7 +2170,20 @@ static int usbser_ioctl(FAR struct file *filep,int cmd,unsigned long arg) case CAIOC_NOTIFY: { /* Not yet implemented. I probably won't bother to implement until - * I com up with a usage model that needs it. + * I comr up with a usage model that needs it. + * + * Here is what the needs to be done: + * + * 1. Format and send a request header with: + * + * bmRequestType: + * USB_REQ_DIR_IN|USB_REQ_TYPE_CLASS|USB_REQ_RECIPIENT_INTERFACE + * bRequest: ACM_SERIAL_STATE + * wValue: 0 + * wIndex: 0 + * wLength: Length of data + * + * 2. Followed by the notification data (in a separate packet) */ ret = -ENOSYS;