Merged nuttx/apps/master into master

This commit is contained in:
Masayuki Ishikawa 2017-03-21 14:22:28 +09:00
commit ea99b2fc5a
27 changed files with 824 additions and 878 deletions

View File

@ -1827,4 +1827,44 @@
(2016-12-19).
* Add platform support for the Olimex STM32 P407 (2016-12-21).
7.20 2017-xx-xx Gregory Nutt <gnutt@nuttx.org>
7.20 2017-03-08 Gregory Nutt <gnutt@nuttx.org>
* OS test: Was ignoring CONFIG_EXAMPLES_OSTEST_FPUTESTDISABLE (2016-12-29).
* apps/examples/nxtext: Make line spacing configurable (2017-01-03).
* apps/graphics/traveler/tools: Fix linkage issue. The -lm should come
after -o binname. From Alan Carvalho de Assis (2017-01-07).
* apps/system/zmodem/host/nuttx/compiler.h synchronized with
nuttx/nuttx/include/nuttx/compiler.h. From Aleksandr Vyhovanec
(2017-01-09).
* examples/sotest: Add a test for shared libraries (2017-01-23).
* examples/ostest: Add new error print and modify comments in cancel
test. From Juha Niskanen (2017-01-24)
* In apps/examples/mtdpart/mtdpart_main.c where
CONFIG_EXAMPLES_MTDPART_NPARTITIONS defining is checked should be
#ifndef instead of #ifdef. Noted by Oleg Evseev (2017-01-30).
* NSH: Add support for the 'ln' command (2017-02-02).
* NSH ls command: if node is a symobolic link, use readlink() to get and
the display the target of the symblic link (2017-02-03).
* NSH: Add readlink command (2017-02-05).
* examples/ostest: Add a test of setvbuf() (2017-02-09).
* apps/examples/stat: Add a simple test for stat(), fstat(), and
statfs() (2017-02-13).
* strcasecmp, strncasecmp, bzero, bcmp, and bcopy should be defined in
strings.h, not string.h. bzero, bcmp, and bcopy are legacy functions;
the contemporary counterparts should be used instead (2017-02-16).
* examples/stat: Add test for fstatfs() (2017-02-17).
* C files that reference ANIOC_TRIGGER now need to include
nuttx/analog/ioctl.h (2017-02-25).
* Add platform files for nucleo-f334r8. From Mateusz Szafoni (2017-02-26).
* NSH: Eliminate a warning when all memory inspection commands are
disabled (2017-02-27).
* netutils/webserver: Needs to include strings.h for strcasecmp()
(2017-02-27).
* nxplayer: Needs to include strings.h for strcasecp() (2017-02-27).
* Remove an unused variable when calling sigwaitinfo() and
sigtimedwait(). From Masayuki Ishikawa (2017-03-02).
* The CONFIG_NETUTILS_HTTPD_PATH constant is used by httpd_mmap.c and
httpd_sendfile.c but It was not present in Kconfig menu. From Maciej
Wójcik (2017-03-05).
7.21 2017-xx-xx Gregory Nutt <gnutt@nuttx.org>

View File

@ -2212,81 +2212,6 @@ examples/usbserial
The host and target will exchange are variety of very small and very large
serial messages.
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.
Usage:
- Build the example and load into the target FLASH
- Connect on terminal to the target RS-232 connect and configure
for 115200 8N1. For example, suppose this Tera Term on a Windows
box.
- Power up the target board
- Connect the USB to a Linux box. Use the Linux dmesg command to
assure that the connect was successful. The USB CDC ACM device
should appear as /dev/ttyACM0
- On the Linux box, open minicom with tty=/dev/ttyACM0.
Configure minicom so that (1) local characters are echoed and (2)
so that no CR is required.
- Now what you type on the target Tera Term window should echo on
the Linux minicom window and, conversely, what you type on the
minicom winow should be echo in the target Tera Term window.
Configuration options:
CONFIG_NSH_BUILTIN_APPS - 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_DEVINIT - If defined, then the example will
call a user provided function as part of its initialization:
int usbterm_devinit(void);
And another user provided function at termination:
void usbterm_devuninit(void);
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_FEATURES 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.
NOTE: By default, USBterm uses readline to get data from stdin. So your
defconfig file must have the following build path:
CONFIG_SYSTEM_READLINE=y
NOTE: If you use the USBterm task over a telnet NSH connection, then you
should set the following configuration item:
CONFIG_EXAMPLES_USBTERM_FGETS=y
By default, the USBterm client will use readline() to get characters from
the console. Readline includes and command-line editor and echos
characters received in stdin back through stdout. Neither of these
behaviors are desire-able if Telnet is used.
Error results are always shown in the trace output
Other relevant configuration options: CONFIG_CDCACM selected by the
Prolifics emulation (not defined) and the CDC serial implementation
(when defined). CONFIG_USBDEV_TRACE_INITIALIDSET.
examples/ustream
^^^^^^^^^^^^^^^^

View File

@ -395,7 +395,6 @@ int main(int argc, FAR char *argv[])
int buttons_main(int argc, FAR char *argv[])
#endif
{
FAR char *buttonargv[2];
int ret;
printf("buttons_main: Starting the button_daemon\n");
@ -405,12 +404,9 @@ int buttons_main(int argc, FAR char *argv[])
return EXIT_SUCCESS;
}
buttonargv[0] = "button_daemon";
buttonargv[1] = NULL;
ret = task_create("button_daemon", CONFIG_EXAMPLES_BUTTONS_PRIORITY,
CONFIG_EXAMPLES_BUTTONS_STACKSIZE, button_daemon,
(FAR char * const *)buttonargv);
NULL);
if (ret < 0)
{
int errcode = errno;

View File

@ -6,24 +6,11 @@
config EXAMPLES_HIDKBD
bool "USB HID keyboard example"
default n
depends on !BUILD_PROTECTED && !BUILD_KERNEL
---help---
Enable the USB HID keyboard example
if EXAMPLES_HIDKBD
config EXAMPLES_HIDKBD_DEFPRIO
int "Waiter Thread Priority"
default 50
---help---
Priority of "waiter" thread. Default: 50
config EXAMPLES_HIDKBD_STACKSIZE
int "Waiter Thread Stack Size"
default 1024
---help---
Stacksize of "waiter" thread. Default 1024
config EXAMPLES_HIDKBD_DEVNAME
string "Keyboard Device Name"
default "/dev/kbda"

View File

@ -1,7 +1,7 @@
############################################################################
# apps/examples/hidkbd/Makefile
#
# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
# Copyright (C) 2011-2012, 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -37,13 +37,20 @@
# USB Host HID keyboard Example
CONFIG_EXAMPLES_HIDKBD_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_EXAMPLES_HIDKBD_STACKSIZE ?= 2048
APPNAME = hidkbd
PRIORITY = $(CONFIG_EXAMPLES_HIDKBD_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_HIDKBD_STACKSIZE)
# Hello, World! Example
ASRCS =
CSRCS =
MAINSRC = hidkbd_main.c
CONFIG_XYZ_PROGNAME ?= hidkbd$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
CONFIG_EXAMPLES_HIDKBD_PROGNAME ?= hidkbd$(EXEEXT)
PROGNAME = $(CONFIG_EXAMPLES_HIDKBD_PROGNAME)
include $(APPDIR)/Application.mk

View File

@ -1,7 +1,7 @@
/****************************************************************************
* examples/hidkbd/hidkbd_main.c
*
* Copyright (C) 2011, 2013-2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2011, 2013-2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -39,16 +39,9 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <sched.h>
#include <string.h>
#include <ctype.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/usb/usbhost.h>
@ -79,14 +72,6 @@
/* Provide some default values for other configuration settings */
#ifndef CONFIG_EXAMPLES_HIDKBD_DEFPRIO
# define CONFIG_EXAMPLES_HIDKBD_DEFPRIO 50
#endif
#ifndef CONFIG_EXAMPLES_HIDKBD_STACKSIZE
# define CONFIG_EXAMPLES_HIDKBD_STACKSIZE 1024
#endif
#ifndef CONFIG_EXAMPLES_HIDKBD_DEVNAME
# define CONFIG_EXAMPLES_HIDKBD_DEVNAME "/dev/kbda"
#endif
@ -108,22 +93,6 @@ struct hidbkd_instream_s
};
#endif
/****************************************************************************
* Private Data
****************************************************************************/
static FAR struct usbhost_connection_s *g_usbconn;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/* The platform-specific code must provide a wrapper called
* arch_usbhost_initialize() that will perform the actual USB host
* initialization.
*/
FAR struct usbhost_connection_s *arch_usbhost_initialize(void);
/****************************************************************************
* Private Functions
****************************************************************************/
@ -223,41 +192,6 @@ static void hidkbd_decode(FAR char *buffer, ssize_t nbytes)
}
#endif
/****************************************************************************
* Name: hidkbd_waiter
*
* Description:
* Wait for USB devices to be connected.
*
****************************************************************************/
static int hidkbd_waiter(int argc, char *argv[])
{
FAR struct usbhost_hubport_s *hport;
printf("hidkbd_waiter: Running\n");
for (;;)
{
/* Wait for the device to change state */
DEBUGVERIFY(CONN_WAIT(g_usbconn, &hport));
printf("hidkbd_waiter: %s\n", hport->connected ? "connected" : "disconnected");
/* Did we just become connected? */
if (hport->connected)
{
/* Yes.. enumerate the newly connected device */
(void)CONN_ENUMERATE(g_usbconn, hport);
}
}
/* Keep the compiler from complaining */
return 0;
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -273,88 +207,58 @@ int hidkbd_main(int argc, char *argv[])
#endif
{
char buffer[256];
pid_t pid;
ssize_t nbytes;
int fd;
int ret;
/* First, register all of the USB host HID keyboard class driver */
printf("hidkbd_main: Register class drivers\n");
ret = usbhost_kbdinit();
if (ret != OK)
{
printf("hidkbd_main: Failed to register the KBD class\n");
}
/* Then get an instance of the USB host interface. The platform-specific
* code must provide a wrapper called arch_usbhost_initialize() that will
* perform the actual USB host initialization.
/* Eventually logic here will open the kbd device and perform the HID
* keyboard test.
*/
printf("hidkbd_main: Initialize USB host keyboard driver\n");
g_usbconn = arch_usbhost_initialize();
if (g_usbconn)
for (;;)
{
/* Start a thread to handle device connection. */
printf("hidkbd_main: Start hidkbd_waiter\n");
pid = task_create("usbhost", CONFIG_EXAMPLES_HIDKBD_DEFPRIO,
CONFIG_EXAMPLES_HIDKBD_STACKSIZE,
(main_t)hidkbd_waiter, (FAR char * const *)NULL);
UNUSED(pid);
/* Now just sleep. Eventually logic here will open the kbd device and
* perform the HID keyboard test.
/* Open the keyboard device. Loop until the device is successfully
* opened.
*/
for (;;)
do
{
/* Open the keyboard device. Loop until the device is successfully
* opened.
*/
do
printf("Opening device %s\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME);
fd = open(CONFIG_EXAMPLES_HIDKBD_DEVNAME, O_RDONLY);
if (fd < 0)
{
printf("Opening device %s\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME);
fd = open(CONFIG_EXAMPLES_HIDKBD_DEVNAME, O_RDONLY);
if (fd < 0)
{
printf("Failed: %d\n", errno);
fflush(stdout);
sleep(3);
}
printf("Failed: %d\n", errno);
fflush(stdout);
sleep(3);
}
while (fd < 0);
}
while (fd < 0);
printf("Device %s opened\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME);
fflush(stdout);
printf("Device %s opened\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME);
fflush(stdout);
/* Loop until there is a read failure (or EOF?) */
/* Loop until there is a read failure (or EOF?) */
do
do
{
/* Read a buffer of data */
nbytes = read(fd, buffer, 256);
if (nbytes > 0)
{
/* Read a buffer of data */
nbytes = read(fd, buffer, 256);
if (nbytes > 0)
{
/* On success, echo the buffer to stdout */
/* On success, echo the buffer to stdout */
#ifdef CONFIG_EXAMPLES_HIDKBD_ENCODED
hidkbd_decode(buffer, nbytes);
hidkbd_decode(buffer, nbytes);
#else
(void)write(1, buffer, nbytes);
(void)write(1, buffer, nbytes);
#endif
}
}
while (nbytes > 0);
printf("Closing device %s: %d\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME, (int)nbytes);
fflush(stdout);
close(fd);
}
while (nbytes > 0);
printf("Closing device %s: %d\n", CONFIG_EXAMPLES_HIDKBD_DEVNAME, (int)nbytes);
fflush(stdout);
close(fd);
}
return 0;

View File

@ -6,6 +6,7 @@
config EXAMPLES_NRF24L01TERM
bool "Basic nRF24L01 terminal"
default n
depends on DRIVERS_WIRELESS
if EXAMPLES_NRF24L01TERM
endif

View File

@ -44,11 +44,11 @@ config EXAMPLES_PWM_DUTYPCT1
config EXAMPLES_PWM_CHANNEL1
int "First PWM channel number"
default 1
range 1 4
range 1 6
---help---
The first PWM channel number. Default: 1
if PWM_NCHANNELS = 2 || PWM_NCHANNELS = 3 || PWM_NCHANNELS = 4
if PWM_NCHANNELS = 2 || PWM_NCHANNELS = 3 || PWM_NCHANNELS = 4 || PWM_NCHANNELS = 5 || PWM_NCHANNELS = 6
config EXAMPLES_PWM_DUTYPCT2
int "Second PWM duty percentage"
@ -60,13 +60,13 @@ config EXAMPLES_PWM_DUTYPCT2
config EXAMPLES_PWM_CHANNEL2
int "Second PWM channel number"
default 2
range 1 4
range 1 6
---help---
The second PWM channel number. Default: 2
endif
if PWM_NCHANNELS = 3 || PWM_NCHANNELS = 4
if PWM_NCHANNELS = 3 || PWM_NCHANNELS = 4 || PWM_NCHANNELS = 5 || PWM_NCHANNELS = 6
config EXAMPLES_PWM_DUTYPCT3
int "Third PWM duty percentage"
@ -78,13 +78,13 @@ config EXAMPLES_PWM_DUTYPCT3
config EXAMPLES_PWM_CHANNEL3
int "Third PWM channel number"
default 3
range 1 4
range 1 6
---help---
The third PWM channel number. Default: 3
endif
if PWM_NCHANNELS = 4
if PWM_NCHANNELS = 4 || PWM_NCHANNELS = 5 || PWM_NCHANNELS = 6
config EXAMPLES_PWM_DUTYPCT4
int "Fourth PWM duty percentage"
@ -96,12 +96,48 @@ config EXAMPLES_PWM_DUTYPCT4
config EXAMPLES_PWM_CHANNEL4
int "Fourth PWM channel number"
default 4
range 1 4
range 1 6
---help---
The fourth PWM channel number. Default: 4
endif
if PWM_NCHANNELS = 5 || PWM_NCHANNELS = 6
config EXAMPLES_PWM_DUTYPCT5
int "Fifth PWM duty percentage"
default 50
range 1 99
---help---
The fifth PWM duty as a percentage. Default: 50%
config EXAMPLES_PWM_CHANNEL5
int "Fifth PWM channel number"
default 5
range 1 6
---help---
The fifth PWM channel number. Default: 5
endif
if PWM_NCHANNELS = 6
config EXAMPLES_PWM_DUTYPCT6
int "Sixth PWM duty percentage"
default 50
range 1 99
---help---
The sixth PWM duty as a percentage. Default: 50%
config EXAMPLES_PWM_CHANNEL5
int "Sixth PWM channel number"
default 6
range 1 6
---help---
The sixth PWM channel number. Default: 6
endif
endif
if !PWM_MULTICHAN

View File

@ -1,64 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_USBTERM
bool "USB serial terminal example"
default n
---help---
Enable the USB serial terminal example
if EXAMPLES_USBTERM
config EXAMPLES_USBTERM_TRACEINIT
bool "USB Trace Initialization"
default n
depends on USBDEV_TRACE || DEBUG_USB
---help---
If USBDEV_TRACE is enabled (or CONFIG_DEBUG_FEATURES and CONFIG_DEBUG_USB),
then the example code will also manage the USB trace output. The
amount of trace output can be controlled this configuration value:
This setting will show USB initialization events
config EXAMPLES_USBTERM_TRACECLASS
bool "USB Trace Class"
default n
depends on USBDEV_TRACE || DEBUG_USB
---help---
If USBDEV_TRACE is enabled (or CONFIG_DEBUG_FEATURES and CONFIG_DEBUG_USB),
then the example code will also manage the USB trace output. The
amount of trace output can be controlled this configuration value:
This setting will show USB class driver events
config EXAMPLES_USBTERM_TRACETRANSFERS
bool "USB Trace Transfers"
default n
depends on USBDEV_TRACE || DEBUG_USB
---help---
If USBDEV_TRACE is enabled (or CONFIG_DEBUG_FEATURES and CONFIG_DEBUG_USB),
then the example code will also manage the USB trace output. The
amount of trace output can be controlled this configuration value:
This setting will show USB data transfer events
config EXAMPLES_USBTERM_TRACECONTROLLER
bool "USB Trace Device Controller Events"
default n
depends on USBDEV_TRACE || DEBUG_USB
---help---
If USBDEV_TRACE is enabled (or CONFIG_DEBUG_FEATURES and CONFIG_DEBUG_USB),
then the example code will also manage the USB trace output. The
amount of trace output can be controlled this configuration value:
This setting will show USB device controller events
config EXAMPLES_USBTERM_TRACEINTERRUPTS
bool "USB Trace Device Controller Interrupt Events"
default n
depends on USBDEV_TRACE || DEBUG_USB
---help---
If USBDEV_TRACE is enabled (or CONFIG_DEBUG_FEATURES and CONFIG_DEBUG_USB),
then the example code will also manage the USB trace output. The
amount of trace output can be controlled this configuration value:
This setting will show USB device controller interrupt-related events.
endif

View File

@ -1,165 +0,0 @@
/****************************************************************************
* examples/usbterm/usbterm.h
*
* Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <semaphore.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_EXAMPLES_USBTERM_BUFLEN
# define CONFIG_EXAMPLES_USBTERM_BUFLEN 256
#endif
#ifndef CONFIG_USBDEV_TRACE_INITIALIDSET
# define CONFIG_USBDEV_TRACE_INITIALIDSET 0
#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)
#ifdef CONFIG_CDCACM
# define USBTERM_DEVNAME "/dev/ttyACM0"
#else
# define USBTERM_DEVNAME "/dev/ttyUSB0"
#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 */
bool peer; /* True: A peer is connected to the serial port on
* the remote host */
/* Buffers for incoming and outgoing data */
char inbuffer[CONFIG_EXAMPLES_USBTERM_BUFLEN];
char outbuffer[CONFIG_EXAMPLES_USBTERM_BUFLEN];
};
/****************************************************************************
* Public Data
****************************************************************************/
/* USB terminal state data */
extern struct usbterm_globals_s g_usbterm;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name:
*
* Description:
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
* call this user provided function as part of its initialization.
*
****************************************************************************/
#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT
int usbterm_devinit(void);
#endif
/****************************************************************************
* Name:
*
* Description:
* If CONFIG_EXAMPLES_USBTERM_DEVINIT is defined, then the example will
* call this user provided function as part of its termination sequeunce.
*
****************************************************************************/
#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT
void usbterm_devuninit(void);
#endif
#endif /* __APPS_EXAMPLES_USBTERM_USBTERM_H */

View File

@ -1,388 +0,0 @@
/****************************************************************************
* examples/usbterm/usbterm_main.c
*
* Copyright (C) 2011-2013, 2015-2016 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/boardctl.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <fcntl.h>
#include <errno.h>
#include <debug.h>
#include "system/readline.h"
#include <nuttx/usb/usbdev.h>
#include <nuttx/usb/usbdev_trace.h>
#ifdef CONFIG_CDCACM
# include <nuttx/usb/cdcacm.h>
#endif
#ifdef CONFIG_CDCACM
# include <nuttx/usb/pl2303.h>
#endif
#include "usbterm.h"
/****************************************************************************
* 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: usbterm_listener
*
* Description:
* Entry point for the listener thread.
*
****************************************************************************/
static FAR void *usbterm_listener(FAR void *parameter)
{
printf("usbterm_listener: Waiting for remote input\n");
for (;;)
{
/* Display the prompt string on the remote USB serial connection -- only
* if we know that there is someone listening at the other end. The
* remote side must initiate the the conversation.
*/
if (g_usbterm.peer)
{
fputs("\rusbterm> ", 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))
{
/* If we receive anything, then we can be assured that there is someone
* with the serial driver open on the remote host.
*/
g_usbterm.peer = true;
/* Echo the line on the local stdout */
fputs(g_usbterm.inbuffer, stdout);
/* Display the prompt string on stdout */
fputs("usbterm> ", 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: usbterm_main
*
* Description:
* Main entry point for the USB serial terminal example.
*
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int usbterm_main(int argc, char *argv[])
#endif
{
struct boardioc_usbdev_ctrl_s ctrl;
FAR void *handle;
pthread_attr_t attr;
int ret;
/* Initialize global data */
memset(&g_usbterm, 0, sizeof(struct usbterm_globals_s));
/* Initialization of the USB hardware may be performed by logic external to
* this test.
*/
#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT
printf("usbterm_main: Performing external device initialization\n");
ret = usbterm_devinit();
if (ret != OK)
{
printf("usbterm_main: usbterm_devinit failed: %d\n", ret);
goto errout;
}
#endif
/* Initialize the USB serial driver */
printf("usbterm_main: Registering USB serial driver\n");
#ifdef CONFIG_CDCACM
ctrl.usbdev = BOARDIOC_USBDEV_CDCACM;
ctrl.action = BOARDIOC_USBDEV_CONNECT;
ctrl.instance = 0;
ctrl.handle = &handle;
#else
ctrl.usbdev = BOARDIOC_USBDEV_PL2303;
ctrl.action = BOARDIOC_USBDEV_CONNECT;
ctrl.instance = 0;
ctrl.handle = &handle;
#endif
ret = boardctl(BOARDIOC_USBDEV_CONTROL, (uintptr_t)&ctrl);
if (ret < 0)
{
printf("usbterm_main: ERROR: Failed to create the USB serial device: %d\n", -ret);
goto errout_with_devinit;
}
printf("usbterm_main: Successfully registered the serial driver\n");
#if defined(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
{
printf("usbterm_main: Opening USB serial driver\n");
g_usbterm.outstream = fopen(USBTERM_DEVNAME, "w");
if (g_usbterm.outstream == NULL)
{
int errcode = errno;
printf("usbterm_main: ERROR: Failed to open " USBTERM_DEVNAME " for writing: %d\n",
errcode);
/* ENOTCONN means that the USB device is not yet connected */
if (errcode == ENOTCONN)
{
printf("usbterm_main: Not connected. Wait and try again.\n");
sleep(5);
}
else
{
/* Give up on other errors */
goto errout_with_devinit;
}
}
/* If USB tracing is enabled, then dump all collected trace data to stdout */
dumptrace();
}
while (g_usbterm.outstream == NULL);
/* Open the USB serial device for reading. Since we are already connected, this
* should not fail.
*/
g_usbterm.instream = fopen(USBTERM_DEVNAME, "r");
if (g_usbterm.instream == NULL)
{
printf("usbterm_main: ERROR: Failed to open " USBTERM_DEVNAME " for reading: %d\n", errno);
goto errout_with_outstream;
}
printf("usbterm_main: Successfully opened the serial driver\n");
/* Start the USB term listener thread */
printf("usbterm_main: Starting the listener thread\n");
ret = pthread_attr_init(&attr);
if (ret != OK)
{
printf("usbterm_main: 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)
{
printf("usbterm_main: Error in thread creation: %d\n", ret);
goto errout_with_streams;
}
/* Send messages and get responses -- forever */
printf("usbterm_main: Waiting for local input\n");
for (;;)
{
/* Display the prompt string on stdout */
fputs("usbterm> ", stdout);
fflush(stdout);
/* Get the next line of input */
#ifdef CONFIG_EXAMPLES_USBTERM_FGETS
/* fgets returns NULL on end-of-file or any I/O error */
if (fgets(g_usbterm.outbuffer, CONFIG_EXAMPLES_USBTERM_BUFLEN, stdin) == NULL)
{
printf("ERROR: fgets failed: %d\n", errno);
return 1;
}
#else
ret = readline(g_usbterm.outbuffer, CONFIG_EXAMPLES_USBTERM_BUFLEN, stdin, stdout);
/* Readline normally returns the number of characters read,
* but will return EOF on end of file or if an error occurs. Either
* will cause the session to terminate.
*/
if (ret == EOF)
{
printf("ERROR: readline failed: %d\n", ret);
return 1;
}
#endif
/* Is there anyone listening on the other end? */
else if (g_usbterm.peer)
{
/* Yes.. Send the line of input via USB */
fputs(g_usbterm.outbuffer, g_usbterm.outstream);
/* Display the prompt string on the remote USB serial connection */
fputs("\rusbterm> ", g_usbterm.outstream);
fflush(g_usbterm.outstream);
}
else
{
printf("Still waiting for remote peer. Please try again later.\n");
}
/* 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_with_devinit:
#ifdef CONFIG_EXAMPLES_USBTERM_DEVINIT
usbterm_devuninit();
errout:
#endif
printf("usbterm_main: Aborting\n");
return 1;
}

36
examples/xbc_test/Kconfig Normal file
View File

@ -0,0 +1,36 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_XBC_TEST
bool "XBox Controller Test example"
default n
---help---
Enable the XBox Controller Test example
if EXAMPLES_XBC_TEST
config EXAMPLES_XBC_TEST_PROGNAME
string "Program name"
default "xbc_test"
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
config EXAMPLES_XBC_DEVNAME
string "XBox Controller Device Name"
default "/dev/xboxa"
---help---
Name of XBox controller device to be used. Default: "/dev/xboxa"
config EXAMPLES_XBC_TEST_PRIORITY
int "Xbc_test task priority"
default 100
config EXAMPLES_XBC_TEST_STACKSIZE
int "XBox Controller Test stack size"
default 2048
endif

View File

@ -1,9 +1,13 @@
############################################################################
# apps/examples/usbterm/Makefile
# apps/examples/xbc_test/Make.defs
# Adds selected applications to apps/ build
#
# Copyright (C) 2011-2013 Gregory Nutt. All rights reserved.
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Copyright (C) 2017 Brian Webb. All rights reserved.
# Author: Brian Webb <webbbn@gmail.com>
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
# are met:
@ -33,21 +37,6 @@
#
############################################################################
-include $(TOPDIR)/Make.defs
# USB terminal example
ASRCS =
CSRCS =
MAINSRC = usbterm_main.c
CONFIG_XYZ_PROGNAME ?= usbterm$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
# Built-in application info
APPNAME = usbterm
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
include $(APPDIR)/Application.mk
ifeq ($(CONFIG_EXAMPLES_XBC_TEST),y)
CONFIGURED_APPS += examples/xbc_test
endif

View File

@ -0,0 +1,59 @@
############################################################################
# apps/examples/hello/Makefile
#
# Copyright (C) 2008, 2010-2013 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Copyright (C) 2017 Brian Webb. All rights reserved.
# Author: Brian Webb <webbbn@gmail.com>
#
# 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)/Make.defs
# XBox controller driver test built-in application info
CONFIG_EXAMPLES_XBC_TEST_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_EXAMPLES_XBC_TEST_STACKSIZE ?= 2048
APPNAME = xbc_test
PRIORITY = $(CONFIG_EXAMPLES_XBC_TEST_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_XBC_TEST_STACKSIZE)
# Xbc_Test, World! Example
ASRCS =
CSRCS =
MAINSRC = xbc_test_main.c
CONFIG_EXAMPLES_XBC_TEST_PROGNAME ?= xbc_test$(EXEEXT)
PROGNAME = $(CONFIG_EXAMPLES_XBC_TEST_PROGNAME)
include $(APPDIR)/Application.mk

View File

@ -0,0 +1,157 @@
/****************************************************************************
* examples/xbc_test/xbc_test_main.c
*
* Copyright (C) 2008, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Copyright (C) 2017 Brian Webb. All rights reserved.
* Author: Brian Webb <webbbn@gmail.com>
*
* 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 <nuttx/config.h>
#include <sys/ioctl.h>
#include <stdio.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
#include <nuttx/input/xbox-controller.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Sanity checking */
#ifndef CONFIG_USBHOST
# error "CONFIG_USBHOST is not defined"
#endif
#ifdef CONFIG_USBHOST_INT_DISABLE
# error "Interrupt endpoints are disabled (CONFIG_USBHOST_INT_DISABLE)"
#endif
#ifndef CONFIG_NFILE_DESCRIPTORS
# error "CONFIG_NFILE_DESCRIPTORS > 0 needed"
#endif
/* Provide some default values for other configuration settings */
#ifndef CONFIG_EXAMPLES_XBC_DEVNAME
# define CONFIG_EXAMPLES_XBC_DEVNAME "/dev/xboxa"
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* hello_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int xbc_test_main(int argc, char *argv[])
#endif
{
char buffer[256];
ssize_t nbytes;
int fd;
/* Eventually logic here will open the controller device and perform the
* controller test.
*/
for (;;)
{
/* Open the controller device. Loop until the device is successfully
* opened.
*/
do
{
printf("Opening device %s\n", CONFIG_EXAMPLES_XBC_DEVNAME);
fd = open(CONFIG_EXAMPLES_XBC_DEVNAME, O_RDONLY);
if (fd < 0)
{
printf("Failed: %d\n", errno);
fflush(stdout);
sleep(3);
}
}
while (fd < 0);
printf("Device %s opened\n", CONFIG_EXAMPLES_XBC_DEVNAME);
fflush(stdout);
/* Loop until there is a read failure (or EOF?) */
do
{
/* Read a buffer of data */
nbytes = read(fd, buffer, 256);
if (nbytes > 0)
{
/* On success, echo the buffer to stdout */
printf("%d bytes read\n", nbytes);
if (nbytes == sizeof(struct xbox_controller_buttonstate_s))
{
struct xbox_controller_buttonstate_s *rpt = (struct xbox_controller_buttonstate_s*)buffer;
printf("guide: %d sync: %d start: %d back: %d a: %d b: %d x: %d y: %d\n",
rpt->guide, rpt->sync, rpt->start, rpt->back, rpt->a, rpt->b, rpt->x, rpt->y);
printf("dpad_u: %d d: %d l: %d r: %d bump_l: %d r: %d stick_l: %d r: %d\n",
rpt->dpad_up, rpt->dpad_down, rpt->dpad_left, rpt->dpad_right,
rpt->bumper_left, rpt->bumper_right, rpt->stick_click_left, rpt->stick_click_right);
printf("stick_left_x: %d y: %d right_x: %d y: %d trigger_l: %d r: %d\n",
rpt->stick_left_x, rpt->stick_left_y, rpt->stick_right_x, rpt->stick_right_y,
rpt->trigger_left, rpt->trigger_right);
}
}
}
while (nbytes > 0);
printf("Closing device %s: %d\n", CONFIG_EXAMPLES_XBC_DEVNAME, (int)nbytes);
fflush(stdout);
close(fd);
break;
}
return 0;
}

View File

@ -3,7 +3,7 @@
* Various non-standard APIs to support netutils. All non-standard and
* intended only for internal use.
*
* Copyright (C) 2007, 2009, 2011m 2015 Gregory Nutt. All rights reserved.
* Copyright (C) 2007, 2009, 2011, 2015, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Some of these APIs derive from uIP. uIP also has a BSD style license:
@ -135,6 +135,11 @@ uint8_t netlib_ipv6netmask2prefix(FAR const uint16_t *mask);
void netlib_prefix2ipv6netmask(uint8_t preflen, FAR struct in6_addr *netmask);
#endif
#ifdef CONFIG_NETDEV_WIRELESS_IOCTL
int netlib_getessid(FAR const char *ifname, FAR char *essid, size_t idlen);
int netlib_setessid(FAR const char *ifname, FAR const char *essid);
#endif
#ifdef CONFIG_NET_ARP
/* ARP Table Support */

View File

@ -74,6 +74,12 @@ CSRCS += netlib_server.c netlib_listenon.c
endif
endif
# These require wireless IOCTL support */
ifeq ($(CONFIG_NETDEV_WIRELESS_IOCTL),y)
CSRCS += netlib_getessid.c netlib_setessid.c
endif
# No MAC address support for SLIP (Ethernet only)
ifeq ($(CONFIG_NET_ETHERNET),y)

View File

@ -0,0 +1,127 @@
/****************************************************************************
* netutils/netlib/netlib_getessid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <netinet/in.h>
#include <net/if.h>
#include <nuttx/wireless/wireless.h>
#include "netutils/netlib.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The address family that we used to create the socket and in the IOCTL
* data really does not matter. It should, however, be valid in the current
* configuration.
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_INETX AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_INETX AF_INET6
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: netlib_getessid
*
* Description:
* Get the wireless access point ESSID
*
* Parameters:
* ifname The name of the interface to use
* essid Location to store the returned ESSID, size must be
* IW_ESSID_MAX_SIZE + 1 or larger
* idlen size of memory set asdie for the ESSID.
*
* Return:
* 0 on success; -1 on failure (errno may not be set)
*
****************************************************************************/
int netlib_getessid(FAR const char *ifname, FAR char *essid, size_t idlen)
{
int ret = ERROR;
if (ifname != NULL && essid != NULL && idlen > IW_ESSID_MAX_SIZE)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct iwreq req;
/* Put the driver name into the request */
memset(&req, 0, sizeof(struct iwreq));
strncpy(req.ifrn_name, ifname, IFNAMSIZ);
/* Put pointer to receive the ESSID into the request */
req.u.essid.pointer = (FAR void *)essid;
/* Perform the ioctl to get the ESSID */
ret = ioctl(sockfd, SIOCGIWESSID, (unsigned long)&req);
close(sockfd);
}
}
return ret;
}
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -0,0 +1,127 @@
/****************************************************************************
* netutils/netlib/netlib_setessid.c
*
* Copyright (C) 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#if defined(CONFIG_NET) && CONFIG_NSOCKET_DESCRIPTORS > 0
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <stdint.h>
#include <unistd.h>
#include <string.h>
#include <errno.h>
#include <netinet/in.h>
#include <net/if.h>
#include <nuttx/wireless/wireless.h>
#include "netutils/netlib.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The address family that we used to create the socket and in the IOCTL
* data really does not matter. It should, however, be valid in the current
* configuration.
*/
#if defined(CONFIG_NET_IPv4)
# define PF_INETX PF_INET
# define AF_INETX AF_INET
#elif defined(CONFIG_NET_IPv6)
# define PF_INETX PF_INET6
# define AF_INETX AF_INET6
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: netlib_setessid
*
* Description:
* Set the wireless access point ESSID
*
* Parameters:
* ifname The name of the interface to use
* essid Wireless ESSD address to set, size must be less then or equal
* to IW_ESSID_MAX_SIZE + 1 (including the NUL string terminator).
*
* Return:
* 0 on success; -1 on failure (errno may not be set)
*
****************************************************************************/
int netlib_setessid(FAR const char *ifname, FAR const char *essid)
{
int ret = ERROR;
if (ifname != NULL && essid != NULL)
{
/* Get a socket (only so that we get access to the INET subsystem) */
int sockfd = socket(PF_INETX, NETLIB_SOCK_IOCTL, 0);
if (sockfd >= 0)
{
struct iwreq req;
/* Put the driver name into the request */
strncpy(req.ifrn_name, ifname, IFNAMSIZ);
/* Put the new ESSID into the request */
req.u.essid.pointer = (FAR void *)essid;
req.u.essid.length = strlen(essid) + 1;
req.u.essid.flags = 1;
/* Perform the ioctl to set the ESSID */
ret = ioctl(sockfd, SIOCSIWESSID, (unsigned long)&req);
close(sockfd);
}
}
return ret;
}
#endif /* CONFIG_NET && CONFIG_NSOCKET_DESCRIPTORS */

View File

@ -127,6 +127,11 @@ config NETUTILS_HTTPD_SENDFILE
endchoice
config NETUTILS_HTTPD_PATH
string "Location of the files"
depends on NETUTILS_HTTPD_MMAP || NETUTILS_HTTPD_SENDFILE
default "/mnt"
config NETUTILS_HTTPD_KEEPALIVE_DISABLE
bool "Keepalive Disable"
default y if !NETUTILS_HTTPD_TIMEOUT

View File

@ -1,7 +1,7 @@
/****************************************************************************
* apps/nshlib/nsh_parse.c
*
* Copyright (C) 2007-2013, 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2007-2013, 2014, 2017 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -1180,7 +1180,11 @@ static FAR char *nsh_argexpand(FAR struct nsh_vtbl_s *vtbl, FAR char *cmdline,
else
#endif
{
/* Just to catch any dangling else clauses */
/* Not a special character... skip to the next character in the
* cmdline.
*/
working++;
}
}
}

View File

@ -108,24 +108,30 @@ struct nsh_taskstatus_s
/* Status strings */
#ifndef CONFIG_NSH_DISABLE_PS
#if 0 /* Not used */
static const char g_name[] = "Name:";
#endif
static const char g_type[] = "Type:";
#ifdef CONFIG_SCHED_HAVE_PARENT
#ifdef HAVE_GROUPID
static const char g_groupid[] = "Group:";
#else
static const char g_ppid[] = "PPID:";
#endif
#endif
#endif /* CONFIG_SCHED_HAVE_PARENT */
#ifdef CONFIG_SMP
static const char g_cpu[] = "CPU:";
#endif
static const char g_state[] = "State:";
static const char g_flags[] = "Flags:";
static const char g_priority[] = "Priority:";
static const char g_scheduler[] = "Scheduler:";
#ifndef CONFIG_DISABLE_SIGNALS
static const char g_sigmask[] = "SigMask:";
#endif
@ -135,7 +141,8 @@ static const char g_stacksize[] = "StackSize:";
#ifdef CONFIG_STACK_COLORATION
static const char g_stackused[] = "StackUsed:";
#endif
#endif
#endif /* !CONFIG_NSH_DISABLE_PSSTACKUSAGE */
#endif /* !CONFIG_NSH_DISABLE_PS */
/****************************************************************************
* Private Functions

View File

@ -86,7 +86,9 @@
* Private Data
****************************************************************************/
#ifndef CONFIG_NSH_DISABLE_UNAME
static const char g_unknown[] = "unknown";
#endif
/****************************************************************************
* Public Functions

View File

@ -0,0 +1,8 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_BAMBINO_200E
endif

View File

@ -1,6 +1,5 @@
############################################################################
# apps/examples/usbterm/Make.defs
# Adds selected applications to apps/ build
# apps/platform/lpc4330-bambino/Make.defs
#
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
@ -34,6 +33,8 @@
#
############################################################################
ifeq ($(CONFIG_EXAMPLES_USBTERM),y)
CONFIGURED_APPS += examples/usbterm
# Add platform specific sources to ASRCS and CSRCS
ifeq ($(CONFIG_HAVE_CXX),y)
CSRCS += lpc43_cxxinitialize.c
endif

View File

@ -0,0 +1,134 @@
/****************************************************************************
* apps/platform/lpc4330-bambino/src/lpc43_cxxinitialize.c
*
* Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* 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 <nuttx/config.h>
#include <debug.h>
#include <nuttx/arch.h>
#if defined(CONFIG_HAVE_CXX) && defined(CONFIG_HAVE_CXXINITIALIZE)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing the static
* constructors
*/
#ifdef CONFIG_DEBUG_CXX
# define cxxinfo _info
#else
# define cxxinfo(x...)
#endif
/****************************************************************************
* Private Types
****************************************************************************/
/* This type defines one entry in initialization array */
typedef void (*initializer_t)(void);
/****************************************************************************
* External References
****************************************************************************/
/* _sinit and _einit are symbols exported by the linker script that mark the
* beginning and the end of the C++ initialization section.
*/
extern initializer_t _sinit;
extern initializer_t _einit;
/* _stext and _etext are symbols exported by the linker script that mark the
* beginning and the end of text.
*/
extern uint32_t _stext;
extern uint32_t _etext;
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_cxxinitialize
*
* Description:
* If C++ and C++ static constructors are supported, then this function
* must be provided by board-specific logic in order to perform
* initialization of the static C++ class instances.
*
* This function should then be called in the application-specific
* user_start logic in order to perform the C++ initialization. NOTE
* that no component of the core NuttX RTOS logic is involved; this
* function definition only provides the 'contract' between application
* specific C++ code and platform-specific toolchain support.
*
****************************************************************************/
void up_cxxinitialize(void)
{
initializer_t *initp;
cxxinfo("_sinit: %p _einit: %p _stext: %p _etext: %p\n",
&_sinit, &_einit, &_stext, &_etext);
/* Visit each entry in the initialization table */
for (initp = &_sinit; initp != &_einit; initp++)
{
initializer_t initializer = *initp;
cxxinfo("initp: %p initializer: %p\n", initp, initializer);
/* Make sure that the address is non-NULL and lies in the text region
* defined by the linker script. Some toolchains may put NULL values
* or counts in the initialization table.
*/
if ((void *)initializer > (void *)&_stext &&
(void *)initializer < (void *)&_etext)
{
cxxinfo("Calling %p\n", initializer);
initializer();
}
}
}
#endif /* CONFIG_HAVE_CXX && CONFIG_HAVE_CXXINITIALIZE */