Merge branch 'master' of file:///Users/Shared/NuttX

git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5231 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
px4dev
2012-10-13 00:08:02 -07:00
58 changed files with 2553 additions and 813 deletions
+26 -3
View File
@@ -279,14 +279,14 @@
* apps/*/Make.defs: Numerous fixes needed to use the automated
configuration (from Richard Cochran).
6.22 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
6.22 2012-09-29 Gregory Nutt <gnutt@nuttx.org>
* apps/netutils/thttpd/thttpd_cgi.c: Missing NULL in argv[]
list (contributed by Kate).
* apps/nshlib/nsh_parse.c: CONFIG_NSH_DISABLE_WGET not CONFIG_NSH_DISABLE_GET
in one location (found by Kate).
* apps/examples/ostest/prioinherit.c: Limit the number of test
threds to no more than 3 of each priority. Bad things happen
threads to no more than 3 of each priority. Bad things happen
when the existing logic tried to created several hundred test
treads!
* apps/nshlib/nsh.h: Both CONFIG_LIBC_STRERROR and CONFIG_NSH_STRERROR
@@ -341,7 +341,30 @@
* apps/netutils/webserver/httpd.c: Add support for Keep-alive connections
(from Kate).
* apps/NxWidget/Kconfig: This is a kludge. I created this NxWidgets
directory that ONLY contains Kconfig. NxWidgets does not like in
directory that ONLY contains Kconfig. NxWidgets does not live in
either the nuttx/ or the apps/ source trees. This kludge makes it
possible to configure NxWidgets/NxWM without too much trouble (with
the tradeoff being a kind ugly structure and some maintenance issues).
* apps/examples/Make.defs: Missing support for apps/examples/watchdog.
* apps/NxWidgets/Kconfig: Add option to turn on the memory monitor
feature of the NxWidgets/NxWM unit tests.
6.23 2012-xx-xx Gregory Nutt <gnutt@nuttx.org>
* vsn: Moved all NSH commands from vsn/ to system/. Deleted the vsn/
directory.
* Makefile: Change order of includes when CONFIG_NEWCONFIG=y. In
that case, namedapp must be included first so that the namedapp
context is established first. If the namedapp context is established
later, it will overwrite any existing namedapp_list.h and nameapp_proto.h
files.
* CONFIG_EXAMPLES_*: To make things consistent, changed all occurrences
of CONFIG_EXAMPLE_* to CONFIG_EXAMPLES_*.
* Kconfig: Fleshed out apps/examples/adc/Kconfig and apps/examples/wget/Kconfig.
There are still a LOT of empty, stub Kconfig files.
* Kconfig: Fleshed out apps/examples/buttons/Kconfig. There are still a LOT
of empty, stub Kconfig files.
* apps/netutils/webserver/httpd.c: Fix a bug that I introduced in
recent check-ins (Darcy Gong).
* apps/netutils/webclient/webclient.c: Fix another but that I introduced
when I was trying to add correct handling for loss of connection (Darcy Gong)
-4
View File
@@ -34,7 +34,3 @@ endmenu
menu "System NSH Add-Ons"
source "$APPSDIR/system/Kconfig"
endmenu
menu "VSN board Add-Ons"
source "$APPSDIR/vsn/Kconfig"
endmenu
+5 -4
View File
@@ -46,10 +46,10 @@ APPDIR = ${shell pwd}
# appears in this directory as .config)
# SUBDIRS is the list of all directories containing Makefiles. It is used
# only for cleaning. namedapp must always be the first in the list. This
# list can be extended by the .config file as well
# list can be extended by the .config file as well.
CONFIGURED_APPS =
#SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system vsn
#SUBDIRS = examples graphics interpreters modbus namedapp nshlib netutils system
ALL_SUBDIRS = $(dir $(shell /usr/bin/find . -name Makefile))
SUBDIRS = namedapp/ $(filter-out ./ ./namedapp/ ./examples/,$(ALL_SUBDIRS))
@@ -73,15 +73,16 @@ SUBDIRS = namedapp/ $(filter-out ./ ./namedapp/ ./examples/,$(ALL_SUBDIRS))
ifeq ($(CONFIG_NUTTX_NEWCONFIG),y)
# namedapp/Make.defs must be included first
-include namedapp/Make.defs
-include examples/Make.defs
-include graphics/Make.defs
-include interpreters/Make.defs
-include modbus/Make.defs
-include namedapp/Make.defs
-include netutils/Make.defs
-include nshlib/Make.defs
-include system/Make.defs
-include vsn/Make.defs
# INSTALLED_APPS is the list of currently available application directories. It
# is the same as CONFIGURED_APPS, but filtered to exclude any non-existent
+1 -1
View File
@@ -107,7 +107,7 @@ NuttX is configured. .config is included in the toplevel apps/Makefile.
As a minimum, this configuration file must define files to add to the
CONFIGURED_APPS list like:
CONFIGURED_APPS += examples/hello vsn/poweroff
CONFIGURED_APPS += examples/hello system/poweroff
Named Start-Up main() function
------------------------------
+5 -1
View File
@@ -58,7 +58,7 @@ ifeq ($(CONFIG_EXAMPLES_DHCPD),y)
CONFIGURED_APPS += examples/dhcpd
endif
ifeq ($(CONFIG_EXAMPLE_DISCOVER),y)
ifeq ($(CONFIG_EXAMPLES_DISCOVER),y)
CONFIGURED_APPS += examples/discover
endif
@@ -218,6 +218,10 @@ ifeq ($(CONFIG_EXAMPLES_USBTERM),y)
CONFIGURED_APPS += examples/usbterm
endif
ifeq ($(CONFIG_EXAMPLES_WATCHDOG),y)
CONFIGURED_APPS += examples/watchdog
endif
ifeq ($(CONFIG_EXAMPLES_WGET),y)
CONFIGURED_APPS += examples/wget
endif
+57 -57
View File
@@ -60,20 +60,20 @@ examples/buttons
This is a simple configuration that may be used to test the board-
specific button interfaces. Configuration options:
CONFIG_ARCH_BUTTONS - Must be defined for button support
CONFIG_EXAMPLE_BUTTONS_MIN - Lowest button number (MIN=0)
CONFIG_EXAMPLE_BUTTONS_MAX - Highest button number (MAX=7)
CONFIG_ARCH_BUTTONS - Must be defined for button support
CONFIG_EXAMPLES_BUTTONS_MIN - Lowest button number (MIN=0)
CONFIG_EXAMPLES_BUTTONS_MAX - Highest button number (MAX=7)
CONFIG_ARCH_IRQBUTTONS - Must be defined for interrupting button support
CONFIG_EXAMPLE_IRQBUTTONS_MIN - Lowest interrupting button number (MIN=0)
CONFIG_EXAMPLE_IRQBUTTONS_MAX - Highest interrupting button number (MAX=7)
CONFIG_ARCH_IRQBUTTONS - Must be defined for interrupting button support
CONFIG_EXAMPLES_IRQBUTTONS_MIN - Lowest interrupting button number (MIN=0)
CONFIG_EXAMPLES_IRQBUTTONS_MAX - Highest interrupting button number (MAX=7)
Name strings for buttons:
CONFIG_EXAMPLE_BUTTONS_NAME0, CONFIG_EXAMPLE_BUTTONS_NAME1,
CONFIG_EXAMPLE_BUTTONS_NAME2, CONFIG_EXAMPLE_BUTTONS_NAME3,
CONFIG_EXAMPLE_BUTTONS_NAME4, CONFIG_EXAMPLE_BUTTONS_NAME5,
CONFIG_EXAMPLE_BUTTONS_NAME6, CONFIG_EXAMPLE_BUTTONS_NAME7,
CONFIG_EXAMPLES_BUTTONS_NAME0, CONFIG_EXAMPLES_BUTTONS_NAME1,
CONFIG_EXAMPLES_BUTTONS_NAME2, CONFIG_EXAMPLES_BUTTONS_NAME3,
CONFIG_EXAMPLES_BUTTONS_NAME4, CONFIG_EXAMPLES_BUTTONS_NAME5,
CONFIG_EXAMPLES_BUTTONS_NAME6, CONFIG_EXAMPLES_BUTTONS_NAME7,
Additional architecture-/board- specific configuration settings may also
be required.
@@ -260,10 +260,10 @@ examples/dhcpd
configuration settings)
CONFIG_NET_BROADCAST=y - UDP broadcast support is needed.
CONFIG_EXAMPLE_DHCPD_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLE_DHCPD_IPADDR - Target IP address
CONFIG_EXAMPLE_DHCPD_DRIPADDR - Default router IP addess
CONFIG_EXAMPLE_DHCPD_NETMASK - Network mask
CONFIG_EXAMPLES_DHCPD_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLES_DHCPD_IPADDR - Target IP address
CONFIG_EXAMPLES_DHCPD_DRIPADDR - Default router IP addess
CONFIG_EXAMPLES_DHCPD_NETMASK - Network mask
See also CONFIG_NETUTILS_DHCPD_* settings described elsewhere
and used in netutils/dhcpd/dhcpd.c. These settings are required
@@ -291,11 +291,11 @@ examples/discover
NuttX configuration settings:
CONFIG_EXAMPLE_DISCOVER_DHCPC - DHCP Client
CONFIG_EXAMPLE_DISCOVER_NOMAC - Use canned MAC address
CONFIG_EXAMPLE_DISCOVER_IPADDR - Target IP address
CONFIG_EXAMPLE_DISCOVER_DRIPADDR - Router IP address
CONFIG_EXAMPLE_DISCOVER_NETMASK - Network Mask
CONFIG_EXAMPLES_DISCOVER_DHCPC - DHCP Client
CONFIG_EXAMPLES_DISCOVER_NOMAC - Use canned MAC address
CONFIG_EXAMPLES_DISCOVER_IPADDR - Target IP address
CONFIG_EXAMPLES_DISCOVER_DRIPADDR - Router IP address
CONFIG_EXAMPLES_DISCOVER_NETMASK - Network Mask
examples/ftpc
^^^^^^^^^^^^^
@@ -367,12 +367,12 @@ examples/ftpd
If CONFIG_EXAMPLES_FTPD_NONETINIT is not defined, then the following may
be specified to customized the network configuration:
CONFIG_EXAMPLE_FTPD_NOMAC - If the hardware has no MAC address of its
CONFIG_EXAMPLES_FTPD_NOMAC - If the hardware has no MAC address of its
own, define this =y to provide a bogus address for testing.
CONFIG_EXAMPLE_FTPD_IPADDR - The target IP address. Default 10.0.0.2
CONFIG_EXAMPLE_FTPD_DRIPADDR - The default router address. Default
CONFIG_EXAMPLES_FTPD_IPADDR - The target IP address. Default 10.0.0.2
CONFIG_EXAMPLES_FTPD_DRIPADDR - The default router address. Default
10.0.0.1
CONFIG_EXAMPLE_FTPD_NETMASK - The network mask. Default: 255.255.255.0
CONFIG_EXAMPLES_FTPD_NETMASK - The network mask. Default: 255.255.255.0
Other required configuration settings: Of course TCP networking support
is required. But here are a couple that are less obvious:
@@ -465,15 +465,15 @@ examples/igmp
does not do much of value -- Much more is needed in order to verify
the IGMP features!
* CONFIG_EXAMPLE_IGMP_NOMAC
* CONFIG_EXAMPLES_IGMP_NOMAC
Set if the hardware has no MAC address; one will be assigned
* CONFIG_EXAMPLE_IGMP_IPADDR
* CONFIG_EXAMPLES_IGMP_IPADDR
Target board IP address
* CONFIG_EXAMPLE_IGMP_DRIPADDR
* CONFIG_EXAMPLES_IGMP_DRIPADDR
Default router address
* CONFIG_EXAMPLE_IGMP_NETMASK
* CONFIG_EXAMPLES_IGMP_NETMASK
Network mask
* CONFIG_EXAMPLE_IGMP_GRPADDR
* CONFIG_EXAMPLES_IGMP_GRPADDR
Multicast group address
Applications using this example will need to provide an appconfig
@@ -1023,10 +1023,10 @@ examples/poll
CONFIG_NSOCKET_DESCRIPTORS - Defined to be greater than 0
CONFIG_NET_NTCP_READAHEAD_BUFFERS - Defined to be greater than zero
CONFIG_EXAMPLE_POLL_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLE_POLL_IPADDR - Target IP address
CONFIG_EXAMPLE_POLL_DRIPADDR - Default router IP addess
CONFIG_EXAMPLE_POLL_NETMASK - Network mask
CONFIG_EXAMPLES_POLL_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLES_POLL_IPADDR - Target IP address
CONFIG_EXAMPLES_POLL_DRIPADDR - Default router IP addess
CONFIG_EXAMPLES_POLL_NETMASK - Network mask
In order to for select to work with incoming connections, you
must also select:
@@ -1163,14 +1163,14 @@ examples/sendmail
Settings unique to this example include:
CONFIG_EXAMPLE_SENDMAIL_NOMAC - May be defined to use software assigned MAC (optional)
CONFIG_EXAMPLE_SENDMAIL_IPADDR - Target IP address (required)
CONFIG_EXAMPLE_SENDMAIL_DRIPADDR - Default router IP addess (required)
CONFIG_EXAMPLE_SENDMAILT_NETMASK - Network mask (required)
CONFIG_EXAMPLE_SENDMAIL_RECIPIENT - The recipient of the email (required)
CONFIG_EXAMPLE_SENDMAIL_SENDER - Optional. Default: "nuttx-testing@example.com"
CONFIG_EXAMPLE_SENDMAIL_SUBJECT - Optional. Default: "Testing SMTP from NuttX"
CONFIG_EXAMPLE_SENDMAIL_BODY - Optional. Default: "Test message sent by NuttX"
CONFIG_EXAMPLES_SENDMAIL_NOMAC - May be defined to use software assigned MAC (optional)
CONFIG_EXAMPLES_SENDMAIL_IPADDR - Target IP address (required)
CONFIG_EXAMPLES_SENDMAIL_DRIPADDR - Default router IP addess (required)
CONFIG_EXAMPLES_SENDMAILT_NETMASK - Network mask (required)
CONFIG_EXAMPLES_SENDMAIL_RECIPIENT - The recipient of the email (required)
CONFIG_EXAMPLES_SENDMAIL_SENDER - Optional. Default: "nuttx-testing@example.com"
CONFIG_EXAMPLES_SENDMAIL_SUBJECT - Optional. Default: "Testing SMTP from NuttX"
CONFIG_EXAMPLES_SENDMAIL_BODY - Optional. Default: "Test message sent by NuttX"
NOTE: This test has not been verified on the NuttX target environment.
As of this writing, unit-tested in the Cygwin/Linux host environment.
@@ -1213,12 +1213,12 @@ examples/telnetd
Default: SCHED_PRIORITY_DEFAULT
CONFIG_EXAMPLES_TELNETD_CLIENTSTACKSIZE - Stack size allocated for the
Telnet client. Default: 2048
CONFIG_EXAMPLE_TELNETD_NOMAC - If the hardware has no MAC address of its
CONFIG_EXAMPLES_TELNETD_NOMAC - If the hardware has no MAC address of its
own, define this =y to provide a bogus address for testing.
CONFIG_EXAMPLE_TELNETD_IPADDR - The target IP address. Default 10.0.0.2
CONFIG_EXAMPLE_TELNETD_DRIPADDR - The default router address. Default
CONFIG_EXAMPLES_TELNETD_IPADDR - The target IP address. Default 10.0.0.2
CONFIG_EXAMPLES_TELNETD_DRIPADDR - The default router address. Default
10.0.0.1
CONFIG_EXAMPLE_TELNETD_NETMASK - The network mask. Default: 255.255.255.0
CONFIG_EXAMPLES_TELNETD_NETMASK - The network mask. Default: 255.255.255.0
The appconfig file (apps/.config) should include:
@@ -1240,9 +1240,9 @@ examples/thttpd
CGI programs. see configs/README.txt for most THTTPD settings.
In addition to those, this example accepts:
CONFIG_EXAMPLE_THTTPD_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLE_THTTPD_DRIPADDR - Default router IP addess
CONFIG_EXAMPLE_THTTPD_NETMASK - Network mask
CONFIG_EXAMPLES_THTTPD_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLES_THTTPD_DRIPADDR - Default router IP addess
CONFIG_EXAMPLES_THTTPD_NETMASK - Network mask
Applications using this example will need to provide an appconfig
file in the configuration directory with instruction to build applications
@@ -1335,11 +1335,11 @@ examples/uip
This is a port of uIP tiny webserver example application. Settings
specific to this example include:
CONFIG_EXAMPLE_UIP_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLE_UIP_IPADDR - Target IP address
CONFIG_EXAMPLE_UIP_DRIPADDR - Default router IP addess
CONFIG_EXAMPLE_UIP_NETMASK - Network mask
CONFIG_EXAMPLE_UIP_DHCPC - Select to get IP address via DHCP
CONFIG_EXAMPLES_UIP_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLES_UIP_IPADDR - Target IP address
CONFIG_EXAMPLES_UIP_DRIPADDR - Default router IP addess
CONFIG_EXAMPLES_UIP_NETMASK - Network mask
CONFIG_EXAMPLES_UIP_DHCPC - Select to get IP address via DHCP
If you use DHCPC, then some special configuration network options are
required. These include:
@@ -1637,11 +1637,11 @@ examples/wget
A simple web client example. It will obtain a file from a server using the HTTP
protocol. Settings unique to this example include:
CONFIG_EXAMPLE_WGET_URL - The URL of the file to get
CONFIG_EXAMPLE_WGET_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLE_WGET_IPADDR - Target IP address
CONFIG_EXAMPLE_WGET_DRIPADDR - Default router IP addess
CONFIG_EXAMPLE_WGET_NETMASK - Network mask
CONFIG_EXAMPLES_WGET_URL - The URL of the file to get
CONFIG_EXAMPLES_WGET_NOMAC - (May be defined to use software assigned MAC)
CONFIG_EXAMPLES_WGET_IPADDR - Target IP address
CONFIG_EXAMPLES_WGET_DRIPADDR - Default router IP addess
CONFIG_EXAMPLES_WGET_NETMASK - Network mask
This example uses netutils/webclient. Additional configuration settings apply
to that code as follows (but built-in defaults are probably OK):
+24
View File
@@ -6,8 +6,32 @@
config EXAMPLES_ADC
bool "ADC example"
default n
depends on ADC
---help---
Enable the ADC example
if EXAMPLES_ADC
config EXAMPLES_ADC_DEVPATH
string "ADC device path"
default "/dev/adc0"
---help---
The default path to the ADC device. Default: /dev/adc0
config EXAMPLES_ADC_NSAMPLES
int "Number of Sample Groups"
default 0
depends on !NSH_BUILTIN_APPS
---help---
If NSH_BUILTIN_APPS is defined, then the number of samples is provided
on the command line and this value is ignored. Otherwise, this number
of samples is collected and the program terminates. Default: 0 (samples
are collected indefinitely).
config EXAMPLES_ADC_GROUPSIZE
int "Number of Samples per Group"
default 4
---help---
The number of samples to read at once. Default: 4
endif
+11 -3
View File
@@ -57,6 +57,14 @@
* Pre-processor Definitions
****************************************************************************/
/* Use CONFIG_EXAMPLES_ADC_NSAMPLES == 0 to mean to collect samples
* indefinitely.
*/
#ifndef CONFIG_EXAMPLES_ADC_NSAMPLES
# define CONFIG_EXAMPLES_ADC_NSAMPLES 0
#endif
/****************************************************************************
* Private Types
****************************************************************************/
@@ -249,7 +257,7 @@ int adc_main(int argc, char *argv[])
adc_devpath(&g_adcstate, CONFIG_EXAMPLES_ADC_DEVPATH);
#ifdef CONFIG_EXAMPLES_ADC_NSAMPLES
#if CONFIG_EXAMPLES_ADC_NSAMPLES > 0
g_adcstate.count = CONFIG_EXAMPLES_ADC_NSAMPLES;
#else
g_adcstate.count = 1;
@@ -267,7 +275,7 @@ int adc_main(int argc, char *argv[])
* samples that we collect before returning. Otherwise, we never return
*/
#if defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_EXAMPLES_ADC_NSAMPLES)
#if defined(CONFIG_NSH_BUILTIN_APPS) || CONFIG_EXAMPLES_ADC_NSAMPLES > 0
message("adc_main: g_adcstate.count: %d\n", g_adcstate.count);
#endif
@@ -290,7 +298,7 @@ int adc_main(int argc, char *argv[])
#if defined(CONFIG_NSH_BUILTIN_APPS)
for (; g_adcstate.count > 0; g_adcstate.count--)
#elif defined(CONFIG_EXAMPLES_ADC_NSAMPLES)
#elif CONFIG_EXAMPLES_ADC_NSAMPLES > 0
for (g_adcstate.count = 0; g_adcstate.count < CONFIG_EXAMPLES_ADC_NSAMPLES; g_adcstate.count++)
#else
for (;;)
+51 -1
View File
@@ -7,7 +7,57 @@ config EXAMPLES_BUTTONS
bool "Buttons example"
default n
---help---
Enable the buttons example
Enable the buttons example. May require ARCH_BUTTONS on some boards.
if EXAMPLES_BUTTONS
config EXAMPLES_BUTTONS_MIN
int "Lowest Button Number"
default 0
config EXAMPLES_BUTTONS_MAX
int "Highest Button Number"
default 7
if ARCH_IRQBUTTONS
config EXAMPLES_IRQBUTTONS_MIN
int "Lowest Interrupting Button Number"
default 0
config EXAMPLES_IRQBUTTONS_MAX
int "Highest Interrupting Button Number"
default 7
config EXAMPLES_BUTTONS_NAME0
string "Button 0 Name"
default "Button 0"
config EXAMPLES_BUTTONS_NAME1
string "Button 1 Name"
default "Button 1"
config EXAMPLES_BUTTONS_NAME2
string "Button 2 Name"
default "Button 2"
config EXAMPLES_BUTTONS_NAME3
string "Button 3 Name"
default "Button 3"
config EXAMPLES_BUTTONS_NAME4
string "Button 4 Name"
default "Button 4"
config EXAMPLES_BUTTONS_NAME5
string "Button 5 Name"
default "Button 5"
config EXAMPLES_BUTTONS_NAME6
string "Button 6 Name"
default "Button 6"
config EXAMPLES_BUTTONS_NAME7
string "Button 7 Name"
default "Button 7"
endif
endif
+44 -44
View File
@@ -61,60 +61,60 @@
# error "CONFIG_ARCH_BUTTONS is not defined in the configuration"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME0
# define CONFIG_EXAMPLE_BUTTONS_NAME0 "BUTTON0"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME0
# define CONFIG_EXAMPLES_BUTTONS_NAME0 "BUTTON0"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME1
# define CONFIG_EXAMPLE_BUTTONS_NAME1 "BUTTON1"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME1
# define CONFIG_EXAMPLES_BUTTONS_NAME1 "BUTTON1"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME2
# define CONFIG_EXAMPLE_BUTTONS_NAME2 "BUTTON2"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME2
# define CONFIG_EXAMPLES_BUTTONS_NAME2 "BUTTON2"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME3
# define CONFIG_EXAMPLE_BUTTONS_NAME3 "BUTTON3"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME3
# define CONFIG_EXAMPLES_BUTTONS_NAME3 "BUTTON3"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME4
# define CONFIG_EXAMPLE_BUTTONS_NAME4 "BUTTON4"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME4
# define CONFIG_EXAMPLES_BUTTONS_NAME4 "BUTTON4"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME5
# define CONFIG_EXAMPLE_BUTTONS_NAME5 "BUTTON5"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME5
# define CONFIG_EXAMPLES_BUTTONS_NAME5 "BUTTON5"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME6
# define CONFIG_EXAMPLE_BUTTONS_NAME6 "BUTTON6"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME6
# define CONFIG_EXAMPLES_BUTTONS_NAME6 "BUTTON6"
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_NAME7
# define CONFIG_EXAMPLE_BUTTONS_NAME7 "BUTTON7"
#ifndef CONFIG_EXAMPLES_BUTTONS_NAME7
# define CONFIG_EXAMPLES_BUTTONS_NAME7 "BUTTON7"
#endif
#define BUTTON_MIN 0
#define BUTTON_MAX 7
#ifndef CONFIG_EXAMPLE_BUTTONS_MIN
# define CONFIG_EXAMPLE_BUTTONS_MIN BUTTON_MIN
#ifndef CONFIG_EXAMPLES_BUTTONS_MIN
# define CONFIG_EXAMPLES_BUTTONS_MIN BUTTON_MIN
#endif
#ifndef CONFIG_EXAMPLE_BUTTONS_MAX
# define CONFIG_EXAMPLE_BUTTONS_MAX BUTTON_MAX
#ifndef CONFIG_EXAMPLES_BUTTONS_MAX
# define CONFIG_EXAMPLES_BUTTONS_MAX BUTTON_MAX
#endif
#if CONFIG_EXAMPLE_BUTTONS_MIN > CONFIG_EXAMPLE_BUTTONS_MAX
# error "CONFIG_EXAMPLE_BUTTONS_MIN > CONFIG_EXAMPLE_BUTTONS_MAX"
#if CONFIG_EXAMPLES_BUTTONS_MIN > CONFIG_EXAMPLES_BUTTONS_MAX
# error "CONFIG_EXAMPLES_BUTTONS_MIN > CONFIG_EXAMPLES_BUTTONS_MAX"
#endif
#if CONFIG_EXAMPLE_BUTTONS_MAX > 7
# error "CONFIG_EXAMPLE_BUTTONS_MAX > 7"
#if CONFIG_EXAMPLES_BUTTONS_MAX > 7
# error "CONFIG_EXAMPLES_BUTTONS_MAX > 7"
#endif
#ifndef CONFIG_EXAMPLE_IRQBUTTONS_MIN
# define CONFIG_EXAMPLE_IRQBUTTONS_MIN CONFIG_EXAMPLE_BUTTONS_MIN
#ifndef CONFIG_EXAMPLES_IRQBUTTONS_MIN
# define CONFIG_EXAMPLES_IRQBUTTONS_MIN CONFIG_EXAMPLES_BUTTONS_MIN
#endif
#ifndef CONFIG_EXAMPLE_IRQBUTTONS_MAX
# define CONFIG_EXAMPLE_IRQBUTTONS_MAX CONFIG_EXAMPLE_BUTTONS_MAX
#ifndef CONFIG_EXAMPLES_IRQBUTTONS_MAX
# define CONFIG_EXAMPLES_IRQBUTTONS_MAX CONFIG_EXAMPLES_BUTTONS_MAX
#endif
#if CONFIG_EXAMPLE_IRQBUTTONS_MIN > CONFIG_EXAMPLE_IRQBUTTONS_MAX
# error "CONFIG_EXAMPLE_IRQBUTTONS_MIN > CONFIG_EXAMPLE_IRQBUTTONS_MAX"
#if CONFIG_EXAMPLES_IRQBUTTONS_MIN > CONFIG_EXAMPLES_IRQBUTTONS_MAX
# error "CONFIG_EXAMPLES_IRQBUTTONS_MIN > CONFIG_EXAMPLES_IRQBUTTONS_MAX"
#endif
#if CONFIG_EXAMPLE_IRQBUTTONS_MAX > 7
# error "CONFIG_EXAMPLE_IRQBUTTONS_MAX > 7"
#if CONFIG_EXAMPLES_IRQBUTTONS_MAX > 7
# error "CONFIG_EXAMPLES_IRQBUTTONS_MAX > 7"
#endif
#ifndef MIN
@@ -124,8 +124,8 @@
# define MAX(a,b) (a > b ? a : b)
#endif
#define MIN_BUTTON MIN(CONFIG_EXAMPLE_BUTTONS_MIN, CONFIG_EXAMPLE_IRQBUTTONS_MIN)
#define MAX_BUTTON MAX(CONFIG_EXAMPLE_BUTTONS_MAX, CONFIG_EXAMPLE_IRQBUTTONS_MAX)
#define MIN_BUTTON MIN(CONFIG_EXAMPLES_BUTTONS_MIN, CONFIG_EXAMPLES_IRQBUTTONS_MIN)
#define MAX_BUTTON MAX(CONFIG_EXAMPLES_BUTTONS_MAX, CONFIG_EXAMPLES_IRQBUTTONS_MAX)
#define NUM_BUTTONS (MAX_BUTTON - MIN_BUTTON + 1)
#define BUTTON_INDEX(b) ((b)-MIN_BUTTON)
@@ -187,7 +187,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
{
#if MIN_BUTTON < 1
{
CONFIG_EXAMPLE_BUTTONS_NAME0,
CONFIG_EXAMPLES_BUTTONS_NAME0,
#ifdef CONFIG_ARCH_IRQBUTTONS
button0_handler
#endif
@@ -195,7 +195,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
#endif
#if MIN_BUTTON < 2 && MAX_BUTTON > 0
{
CONFIG_EXAMPLE_BUTTONS_NAME1,
CONFIG_EXAMPLES_BUTTONS_NAME1,
#ifdef CONFIG_ARCH_IRQBUTTONS
button1_handler
#endif
@@ -203,7 +203,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
#endif
#if MIN_BUTTON < 3 && MAX_BUTTON > 1
{
CONFIG_EXAMPLE_BUTTONS_NAME2,
CONFIG_EXAMPLES_BUTTONS_NAME2,
#ifdef CONFIG_ARCH_IRQBUTTONS
button2_handler
#endif
@@ -211,7 +211,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
#endif
#if MIN_BUTTON < 4 && MAX_BUTTON > 2
{
CONFIG_EXAMPLE_BUTTONS_NAME3,
CONFIG_EXAMPLES_BUTTONS_NAME3,
#ifdef CONFIG_ARCH_IRQBUTTONS
button3_handler
#endif
@@ -219,7 +219,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
#endif
#if MIN_BUTTON < 5 && MAX_BUTTON > 3
{
CONFIG_EXAMPLE_BUTTONS_NAME4,
CONFIG_EXAMPLES_BUTTONS_NAME4,
#ifdef CONFIG_ARCH_IRQBUTTONS
button4_handler
#endif
@@ -227,7 +227,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
#endif
#if MIN_BUTTON < 6 && MAX_BUTTON > 4
{
CONFIG_EXAMPLE_BUTTONS_NAME5,
CONFIG_EXAMPLES_BUTTONS_NAME5,
#ifdef CONFIG_ARCH_IRQBUTTONS
button5_handler
#endif
@@ -235,7 +235,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
#endif
#if MIN_BUTTON < 7 && MAX_BUTTON > 5
{
CONFIG_EXAMPLE_BUTTONS_NAME6,
CONFIG_EXAMPLES_BUTTONS_NAME6,
#ifdef CONFIG_ARCH_IRQBUTTONS
button6_handler
#endif
@@ -243,7 +243,7 @@ static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
#endif
#if MAX_BUTTON > 6
{
CONFIG_EXAMPLE_BUTTONS_NAME7,
CONFIG_EXAMPLES_BUTTONS_NAME7,
#ifdef CONFIG_ARCH_IRQBUTTONS
button7_handler
#endif
@@ -419,7 +419,7 @@ int buttons_main(int argc, char *argv[])
/* Register to recieve button interrupts */
#ifdef CONFIG_ARCH_IRQBUTTONS
for (i = CONFIG_EXAMPLE_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLE_IRQBUTTONS_MAX; i++)
for (i = CONFIG_EXAMPLES_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLES_IRQBUTTONS_MAX; i++)
{
xcpt_t oldhandler = up_irqbutton(i, g_buttoninfo[BUTTON_INDEX(i)].handler);
@@ -488,7 +488,7 @@ int buttons_main(int argc, char *argv[])
/* Un-register button handlers */
#if defined(CONFIG_ARCH_IRQBUTTONS) && defined(CONFIG_NSH_BUILTIN_APPS)
for (i = CONFIG_EXAMPLE_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLE_IRQBUTTONS_MAX; i++)
for (i = CONFIG_EXAMPLES_IRQBUTTONS_MIN; i <= CONFIG_EXAMPLES_IRQBUTTONS_MAX; i++)
{
(void)up_irqbutton(i, NULL);
}
+5 -5
View File
@@ -290,14 +290,14 @@ static inline bool net_mksocket(struct net_listener_s *nls)
static void net_configure(void)
{
struct in_addr addr;
#if defined(CONFIG_EXAMPLE_POLL_NOMAC)
#if defined(CONFIG_EXAMPLES_POLL_NOMAC)
uint8_t mac[IFHWADDRLEN];
#endif
/* Configure uIP */
/* Many embedded network interfaces must have a software assigned MAC */
#ifdef CONFIG_EXAMPLE_POLL_NOMAC
#ifdef CONFIG_EXAMPLES_POLL_NOMAC
mac[0] = 0x00;
mac[1] = 0xe0;
mac[2] = 0xde;
@@ -309,17 +309,17 @@ static void net_configure(void)
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLE_POLL_IPADDR);
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_IPADDR);
uip_sethostaddr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLE_POLL_DRIPADDR);
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_DRIPADDR);
uip_setdraddr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLE_POLL_NETMASK);
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_NETMASK);
uip_setnetmask("eth0", &addr);
}
+5 -5
View File
@@ -83,14 +83,14 @@
static void net_configure(void)
{
struct in_addr addr;
#if defined(CONFIG_EXAMPLE_POLL_NOMAC)
#if defined(CONFIG_EXAMPLES_POLL_NOMAC)
uint8_t mac[IFHWADDRLEN];
#endif
/* Configure uIP */
/* Many embedded network interfaces must have a software assigned MAC */
#ifdef CONFIG_EXAMPLE_POLL_NOMAC
#ifdef CONFIG_EXAMPLES_POLL_NOMAC
mac[0] = 0x00;
mac[1] = 0xe0;
mac[2] = 0xde;
@@ -102,17 +102,17 @@ static void net_configure(void)
/* Set up our host address */
addr.s_addr = HTONL(CONFIG_EXAMPLE_POLL_IPADDR);
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_IPADDR);
uip_sethostaddr("eth0", &addr);
/* Set up the default router address */
addr.s_addr = HTONL(CONFIG_EXAMPLE_POLL_DRIPADDR);
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_DRIPADDR);
uip_setdraddr("eth0", &addr);
/* Setup the subnet mask */
addr.s_addr = HTONL(CONFIG_EXAMPLE_POLL_NETMASK);
addr.s_addr = HTONL(CONFIG_EXAMPLES_POLL_NETMASK);
uip_setnetmask("eth0", &addr);
}
+43 -15
View File
@@ -291,19 +291,18 @@ config NSH_CONSOLE
console front-end is selected (/dev/console).
Normally, the serial console device is a UART and RS-232
interface. However, if CONFIG_USBDEV is defined, then a USB
interface. However, if USBDEV is defined, then a USB
serial device may, instead, be used if the one of
the following are defined:
CONFIG_PL2303 and CONFIG_PL2303_CONSOLE - Sets up the
Prolifics PL2303 emulation as a console device at /dev/console.
PL2303 and PL2303_CONSOLE - Set up the Prolifics PL2303
emulation as a console device at /dev/console.
CONFIG_CDCACM and CONFIG_CDCACM_CONSOLE - Sets up the
CDC/ACM serial device as a console device at dev/console.
CDCACM and CDCACM_CONSOLE - Set up the CDC/ACM serial
device as a console device at dev/console.
CONFIG_NSH_USBCONSOLE and CONFIG_NSH_USBCONDEV - Sets up the
some other USB serial device as the NSH console (not necessarily
dev/console).
NSH_USBCONSOLE and NSH_USBCONDEV - Sets up some other USB
serial device as the NSH console (not necessarily dev/console).
config NSH_USBCONSOLE
bool "Use a USB console"
@@ -311,20 +310,20 @@ config NSH_USBCONSOLE
depends on NSH_CONSOLE && USBDEV
---help---
If defined, then the an arbitrary USB device may be used
to as the NSH console. In this case, CONFIG_NSH_USBCONDEV
must be defined to indicate which USB device to use as
the console.
to as the NSH console. In this case, NSH_USBCONDEV must
be defined to indicate which USB device to use as the
console.
config NSH_USBCONDEV
string "USB console device"
default "/dev/ttyACM0"
depends on NSH_USBCONSOLE
---help---
If CONFIG_NSH_USBCONSOLE is set to 'y', then CONFIG_NSH_USBCONDEV
must also be set to select the USB device used to support
the NSH console. This should be set to the quoted name of a
If NSH_USBCONSOLE is set to 'y', then NSH_USBCONDEV must
also be set to select the USB device used to support the
NSH console. This should be set to the quoted name of a
readable/write-able USB driver such as:
CONFIG_NSH_USBCONDEV="/dev/ttyACM0".
NSH_USBCONDEV="/dev/ttyACM0".
config UBSDEV_MINOR
int "USB console device minor number"
@@ -448,6 +447,35 @@ config NSH_IOBUFFER_SIZE
---help---
Determines the size of the I/O buffer to use for sending/
receiving TELNET commands/reponses. Default: 512
config NSH_TELNET_LOGIN
bool "Telnet Login"
default n
---help---
If defined, then the Telnet user will be required to provide a
username and password to start the NSH shell.
if NSH_TELNET_LOGIN
config NSH_TELNET_USERNAME
string "Login Username"
default "admin"
---help---
Login user name. Default: "admin"
config NSH_TELNET_PASSWORD
string "Login Password"
default "nuttx"
---help---
Login password: Default: "nuttx"
config NSH_TELNET_FAILCOUNT
int "Login Retry Count"
default 3
---help---
Number of login retry attempts.
endif
endif
config NSH_DHCPC
+34 -1
View File
@@ -164,10 +164,19 @@
* Default: SCHED_PRIORITY_DEFAULT
* CONFIG_NSH_TELNETD_DAEMONSTACKSIZE - Stack size allocated for the
* Telnet daemon. Default: 2048
* CONFIG_NSH_TELNETD_CLIENTPRIO- Priority of the Telnet client.
* CONFIG_NSH_TELNETD_CLIENTPRIO - Priority of the Telnet client.
* Default: SCHED_PRIORITY_DEFAULT
* CONFIG_NSH_TELNETD_CLIENTSTACKSIZE - Stack size allocated for the
* Telnet client. Default: 2048
* CONFIG_NSH_TELNET_LOGIN - Support a simple Telnet login.
*
* If CONFIG_NSH_TELNET_LOGIN is defined, then these additional
* options may be specified:
*
* CONFIG_NSH_TELNET_USERNAME - Login user name. Default: "admin"
* CONFIG_NSH_TELNET_PASSWORD - Login password: Default: "nuttx"
* CONFIG_NSH_TELNET_FAILCOUNT - Number of login retry attempts.
* Default 3.
*/
#ifndef CONFIG_NSH_TELNETD_PORT
@@ -190,6 +199,22 @@
# define CONFIG_NSH_TELNETD_CLIENTSTACKSIZE 2048
#endif
#ifdef CONFIG_NSH_TELNET_LOGIN
# ifndef CONFIG_NSH_TELNET_USERNAME
# define CONFIG_NSH_TELNET_USERNAME "admin"
# endif
# ifndef CONFIG_NSH_TELNET_PASSWORD
# define CONFIG_NSH_TELNET_PASSWORD "nuttx"
# endif
# ifndef CONFIG_NSH_TELNET_FAILCOUNT
# define CONFIG_NSH_TELNET_FAILCOUNT 3
# endif
#endif /* CONFIG_NSH_TELNET_LOGIN */
/* Verify support for ROMFS /etc directory support options */
#ifdef CONFIG_NSH_ROMFSETC
@@ -364,6 +389,14 @@ typedef int (*cmd_t)(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv);
****************************************************************************/
extern const char g_nshgreeting[];
#if defined(CONFIG_NSH_TELNET_LOGIN) && defined(CONFIG_NSH_TELNET)
extern const char g_telnetgreeting[];
extern const char g_userprompt[];
extern const char g_passwordprompt[];
extern const char g_loginsuccess[];
extern const char g_badcredentials[];
extern const char g_loginfailure[];
#endif
extern const char g_nshprompt[];
extern const char g_nshsyntax[];
extern const char g_fmtargrequired[];
+10 -5
View File
@@ -75,12 +75,17 @@ struct serialsave_s
static FAR struct nsh_vtbl_s *nsh_consoleclone(FAR struct nsh_vtbl_s *vtbl);
#endif
static void nsh_consolerelease(FAR struct nsh_vtbl_s *vtbl);
static ssize_t nsh_consolewrite(FAR struct nsh_vtbl_s *vtbl, FAR const void *buffer, size_t nbytes);
static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl, const char *fmt, ...);
static ssize_t nsh_consolewrite(FAR struct nsh_vtbl_s *vtbl,
FAR const void *buffer, size_t nbytes);
static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl,
FAR const char *fmt, ...);
static FAR char *nsh_consolelinebuffer(FAR struct nsh_vtbl_s *vtbl);
static void nsh_consoleredirect(FAR struct nsh_vtbl_s *vtbl, int fd, FAR uint8_t *save);
static void nsh_consoleundirect(FAR struct nsh_vtbl_s *vtbl, FAR uint8_t *save);
static void nsh_consoleexit(FAR struct nsh_vtbl_s *vtbl, int exitstatus);
static void nsh_consoleredirect(FAR struct nsh_vtbl_s *vtbl, int fd,
FAR uint8_t *save);
static void nsh_consoleundirect(FAR struct nsh_vtbl_s *vtbl,
FAR uint8_t *save);
static void nsh_consoleexit(FAR struct nsh_vtbl_s *vtbl, int exitstatus)
noreturn_function;
/****************************************************************************
* Private Data
+1 -1
View File
@@ -109,7 +109,7 @@ struct nsh_vtbl_s
FAR char *(*linebuffer)(FAR struct nsh_vtbl_s *vtbl);
void (*redirect)(FAR struct nsh_vtbl_s *vtbl, int fd, FAR uint8_t *save);
void (*undirect)(FAR struct nsh_vtbl_s *vtbl, FAR uint8_t *save);
void (*exit)(FAR struct nsh_vtbl_s *vtbl, int exitstatus);
void (*exit)(FAR struct nsh_vtbl_s *vtbl, int exitstatus) noreturn_function;
/* Parser state data */
+11
View File
@@ -395,6 +395,17 @@ const char g_nshgreeting[] = "\nNuttShell (NSH) NuttX-" CONFIG_VERSION_STR
const char g_nshgreeting[] = "\nNuttShell (NSH)\n";
#endif
/* Telnet login prompts */
#if defined(CONFIG_NSH_TELNET_LOGIN) && defined(CONFIG_NSH_TELNET)
const char g_telnetgreeting[] = "\nWelcome to NuttShell(NSH) Telnet Server...\n";
const char g_userprompt[] = "login: ";
const char g_passwordprompt[] = "password: ";
const char g_loginsuccess[] = "\nUser Logged-in!\n";
const char g_badcredentials[] = "\nInvalid username or password\n";
const char g_loginfailure[] = "Login failed!\n";
#endif
/* The NSH prompt */
const char g_nshprompt[] = "nsh> ";
+109 -1
View File
@@ -43,6 +43,7 @@
#include <unistd.h>
#include <assert.h>
#include <debug.h>
#include <string.h>
#include <apps/netutils/telnetd.h>
@@ -55,6 +56,18 @@
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_NSH_TELNET_LOGIN
# define TELNET_IAC 255
# define TELNET_WILL 251
# define TELNET_WONT 252
# define TELNET_DO 253
# define TELNET_DONT 254
# define TELNET_USE_ECHO 1
# define TELNET_NOTUSE_ECHO 0
#endif /* CONFIG_NSH_TELNET_LOGIN */
/****************************************************************************
* Private Types
****************************************************************************/
@@ -75,6 +88,91 @@
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: nsh_telnetecho
****************************************************************************/
#ifdef CONFIG_NSH_TELNET_LOGIN
void nsh_telnetecho(struct console_stdio_s *pstate, uint8_t is_use)
{
uint8_t optbuf[4];
optbuf[0] = TELNET_IAC;
optbuf[1] = (is_use == TELNET_USE_ECHO) ? TELNET_WILL : TELNET_DO;
optbuf[2] = 1;
optbuf[3] = 0;
fputs((char *)optbuf, pstate->cn_outstream);
fflush(pstate->cn_outstream);
}
#endif
/****************************************************************************
* Name: nsh_telnetlogin
****************************************************************************/
#ifdef CONFIG_NSH_TELNET_LOGIN
int nsh_telnetlogin(struct console_stdio_s *pstate)
{
char username[16];
char password[16];
uint8_t i;
/* Present the NSH Telnet greeting */
fputs(g_telnetgreeting, pstate->cn_outstream);
fflush(pstate->cn_outstream);
/* Loop for the configured number of retries */
for(i = 0; i < CONFIG_NSH_TELNET_FAILCOUNT; i++)
{
/* Ask for the login username */
fputs(g_userprompt, pstate->cn_outstream);
fflush(pstate->cn_outstream);
if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN, INSTREAM(pstate)) != NULL)
{
strcpy(username, pstate->cn_line);
username[strlen(pstate->cn_line) - 1] = 0;
}
/* Ask for the login password */
fputs(g_passwordprompt, pstate->cn_outstream);
fflush(pstate->cn_outstream);
nsh_telnetecho(pstate, TELNET_NOTUSE_ECHO);
if (fgets(pstate->cn_line, CONFIG_NSH_LINELEN, INSTREAM(pstate)) != NULL)
{
/* Verify the username and password */
strcpy(password,pstate->cn_line);
password[strlen(pstate->cn_line) - 1] = 0;
if (strcmp(password, CONFIG_NSH_TELNET_PASSWORD) == 0 &&
strcmp(username, CONFIG_NSH_TELNET_USERNAME) == 0)
{
fputs(g_loginsuccess, pstate->cn_outstream);
fflush(pstate->cn_outstream);
nsh_telnetecho(pstate, TELNET_USE_ECHO);
return OK;
}
else
{
fputs(g_badcredentials, pstate->cn_outstream);
fflush(pstate->cn_outstream);
}
}
nsh_telnetecho(pstate, TELNET_USE_ECHO);
}
/* Too many failed login attempts */
fputs(g_loginfailure, pstate->cn_outstream);
fflush(pstate->cn_outstream);
return -1;
}
#endif /* CONFIG_NSH_TELNET_LOGIN */
/****************************************************************************
* Public Functions
****************************************************************************/
@@ -90,7 +188,17 @@ int nsh_telnetmain(int argc, char *argv[])
dbg("Session [%d] Started\n", getpid());
/* Present a greeting */
/* Login User and Password Check */
#ifdef CONFIG_NSH_TELNET_LOGIN
if (nsh_telnetlogin(pstate) != OK)
{
nsh_exit(&pstate->cn_vtbl, 1);
return -1; /* nsh_exit does not return */
}
#endif /* CONFIG_NSH_TELNET_LOGIN */
/* Present the NSH greeting */
fputs(g_nshgreeting, pstate->cn_outstream);
fflush(pstate->cn_outstream);
+18 -2
View File
@@ -3,7 +3,7 @@
# see misc/tools/kconfig-language.txt.
#
menu "Custom free memory command"
menu "Custom Free Memory Command"
source "$APPSDIR/system/free/Kconfig"
endmenu
@@ -15,6 +15,22 @@ menu "FLASH Program Installation"
source "$APPSDIR/system/install/Kconfig"
endmenu
menu "readline() support"
menu "readline()"
source "$APPSDIR/system/readline/Kconfig"
endmenu
menu "Power Off"
source "$APPSDIR/system/poweroff/Kconfig"
endmenu
menu "RAMTRON"
source "$APPSDIR/system/ramtron/Kconfig"
endmenu
menu "SD Card"
source "$APPSDIR/system/sdcard/Kconfig"
endmenu
menu "Sysinfo"
source "$APPSDIR/system/sysinfo/Kconfig"
endmenu
+17
View File
@@ -49,3 +49,20 @@ endif
ifeq ($(CONFIG_SYSTEM_READLINE),y)
CONFIGURED_APPS += system/readline
endif
ifeq ($(CONFIG_SYSTEM_POWEROFF),y)
CONFIGURED_APPS += system/poweroff
endif
ifeq ($(CONFIG_SYSTEM_RAMTRON),y)
CONFIGURED_APPS += system/ramtron
endif
ifeq ($(CONFIG_SYSTEM_SDCARD),y)
CONFIGURED_APPS += system/sdcard
endif
ifeq ($(CONFIG_SYSTEM_SYSINFO),y)
CONFIGURED_APPS += system/sysinfo
endif
+1 -1
View File
@@ -37,7 +37,7 @@
# Sub-directories containing system task
SUBDIRS = free i2c install readline
SUBDIRS = free i2c install readline poweroff ramtron sdcard sysinfo
# Create the list of installed runtime modules (INSTALLED_DIRS)
+45 -37
View File
@@ -33,57 +33,65 @@
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/progmem.h>
#include <stdio.h>
#include <stdlib.h>
/****************************************************************************
* Private Functions
****************************************************************************/
/* \todo Max block size only works on uniform prog mem */
void free_getprogmeminfo(struct mallinfo * mem)
{
uint16_t page = 0, stpage = 0xFFFF;
uint16_t pagesize = 0;
int status;
mem->arena = 0;
mem->fordblks = 0;
mem->uordblks = 0;
mem->mxordblk = 0;
for (status=0, page=0; status >= 0; page++) {
status = up_progmem_ispageerased(page);
pagesize = up_progmem_pagesize(page);
mem->arena += pagesize;
/* Is this beginning of new free space section */
if (status == 0) {
if (stpage == 0xFFFF) stpage = page;
mem->fordblks += pagesize;
}
else if (status != 0) {
mem->uordblks += pagesize;
if (stpage != 0xFFFF && up_progmem_isuniform()) {
stpage = page - stpage;
if (stpage > mem->mxordblk)
mem->mxordblk = stpage;
stpage = 0xFFFF;
/* TODO Max block size only works on uniform prog mem */
static void free_getprogmeminfo(struct mallinfo * mem)
{
uint16_t page = 0, stpage = 0xFFFF;
uint16_t pagesize = 0;
int status;
mem->arena = 0;
mem->fordblks = 0;
mem->uordblks = 0;
mem->mxordblk = 0;
for (status=0, page=0; status >= 0; page++)
{
status = up_progmem_ispageerased(page);
pagesize = up_progmem_pagesize(page);
mem->arena += pagesize;
/* Is this beginning of new free space section */
if (status == 0)
{
if (stpage == 0xFFFF) stpage = page;
mem->fordblks += pagesize;
}
else if (status != 0)
{
mem->uordblks += pagesize;
if (stpage != 0xFFFF && up_progmem_isuniform())
{
stpage = page - stpage;
if (stpage > mem->mxordblk)
{
mem->mxordblk = stpage;
}
stpage = 0xFFFF;
}
}
}
mem->mxordblk *= pagesize;
}
mem->mxordblk *= pagesize;
}
/****************************************************************************
* Public Functions
+1 -1
View File
@@ -1,5 +1,5 @@
############################################################################
# apps/system/i2c
# apps/system/i2c/Makefile
#
# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
+342 -284
View File
@@ -33,6 +33,10 @@
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/progmem.h>
#include <sys/stat.h>
@@ -43,9 +47,8 @@
#include <string.h>
#include <errno.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
#define ACTION_INSTALL 0x01
@@ -55,12 +58,11 @@
#define INSTALL_PROGRAMBLOCKSIZE 1024
/****************************************************************************
* Private data
****************************************************************************/
const char *install_help =
static const char *install_help =
"Installs XIP program into flash and creates a start-up script in the\n"
"destination directory.\n\n"
"Usage:\t%s [options] source-file.xip destination-directory\n\n"
@@ -72,341 +74,397 @@ const char *install_help =
"\t--force\t\t\tReplaces existing installation\n"
"\t--start <page>\t\tInstalls application at or after <page>\n"
"\t--margin <pages>\tLeave some free space after the kernel (default 16)\n";
const char *install_script_text =
static const char *install_script_text =
"# XIP stacksize=%x priority=%x size=%x\n";
const char *install_script_exec =
static const char *install_script_exec =
"exec 0x%x\n";
/****************************************************************************
* Private functions
****************************************************************************/
int install_getstartpage(int startpage, int pagemargin, int desiredsize)
static int install_getstartpage(int startpage, int pagemargin, int desiredsize)
{
uint16_t page = 0, stpage = 0xFFFF;
uint16_t pagesize = 0;
int maxlen = -1;
int maxlen_start = 0xFFFF;
int status;
for (status=0, page=0; status >= 0; page++) {
status = up_progmem_ispageerased(page);
pagesize = up_progmem_pagesize(page);
/* Is this beginning of new free space section */
if (status == 0) {
if (stpage == 0xFFFF) stpage = page;
uint16_t page = 0, stpage = 0xffff;
uint16_t pagesize = 0;
int maxlen = -1;
int maxlen_start = 0xffff;
int status;
for (status=0, page=0; status >= 0; page++)
{
status = up_progmem_ispageerased(page);
pagesize = up_progmem_pagesize(page);
/* Is this beginning of new free space section */
if (status == 0)
{
if (stpage == 0xffff) stpage = page;
}
else if (status != 0) {
else if (status != 0)
{
if (stpage != 0xffff)
{
if ((page - stpage) > maxlen)
{
if (maxlen==-1)
{
/* First time found sth? */
if (stpage != 0xFFFF) {
if ( (page - stpage) > maxlen) {
stpage += pagemargin;
maxlen = 0;
}
if (maxlen==-1) { /* First time found sth? */
stpage += pagemargin;
maxlen = 0;
if(stpage < startpage)
{
stpage = startpage;
}
if(stpage < startpage)
stpage = startpage;
if (page > stpage) {
maxlen = page - stpage;
maxlen_start = stpage;
if (page > stpage)
{
maxlen = page - stpage;
maxlen_start = stpage;
}
if (maxlen*pagesize >= desiredsize) {
/* printf("Found page at %d ... %d\n", stpage, page); */
return maxlen_start*pagesize;
if (maxlen*pagesize >= desiredsize)
{
/* printf("Found page at %d ... %d\n", stpage, page); */
return maxlen_start*pagesize;
}
}
stpage = 0xFFFF;
stpage = 0xffff;
}
}
}
/* Requested space is not available */
return -1;
/* Requested space is not available */
return -1;
}
int install_programflash(int startaddr, const char *source)
static int install_programflash(int startaddr, const char *source)
{
int status;
int count;
int totalsize = 0;
char *buf;
FILE *fp;
if ( (buf = malloc(INSTALL_PROGRAMBLOCKSIZE)) == NULL )
return -errno;
if ( (fp=fopen(source, "r")) ) {
do {
count = fread(buf, 1, INSTALL_PROGRAMBLOCKSIZE, fp);
if ( (status = up_progmem_write(startaddr, buf, count)) < 0) {
totalsize = status;
break;
}
startaddr += count;
totalsize += count;
}
while(count);
int status;
int count;
int totalsize = 0;
char *buf;
FILE *fp;
if ((buf = malloc(INSTALL_PROGRAMBLOCKSIZE)) == NULL)
{
return -ENOMEM;
}
else totalsize = -errno;
fclose(fp);
free(buf);
return totalsize;
if ((fp = fopen(source, "r")))
{
do
{
count = fread(buf, 1, INSTALL_PROGRAMBLOCKSIZE, fp);
if ((status = up_progmem_write(startaddr, buf, count)) < 0)
{
totalsize = status;
break;
}
startaddr += count;
totalsize += count;
}
while(count);
}
else
{
totalsize = -errno;
}
fclose(fp);
free(buf);
return totalsize;
}
void install_getscriptname(char *scriptname, const char *progname, const char *destdir)
static void install_getscriptname(char *scriptname, const char *progname, const char *destdir)
{
const char * progonly;
const char * progonly;
/* I.e. as /usr/bin */
strcpy(scriptname, destdir);
/* extract from i.e. /sdcard/demo -> /demo, together with / */
progonly = strrchr(progname, '/');
strcat(scriptname, progonly);
/* I.e. as /usr/bin */
strcpy(scriptname, destdir);
/* extract from i.e. /sdcard/demo -> /demo, together with / */
progonly = strrchr(progname, '/');
strcat(scriptname, progonly);
}
int install_getprogsize(const char *progname)
static int install_getprogsize(const char *progname)
{
struct stat fileinfo;
if ( stat(progname, &fileinfo) < 0 )
return -1;
return fileinfo.st_size;
struct stat fileinfo;
if (stat(progname, &fileinfo) < 0)
{
return -1;
}
return fileinfo.st_size;
}
int install_alreadyexists(const char *scriptname)
static int install_alreadyexists(const char *scriptname)
{
FILE *fp;
if ( (fp=fopen(scriptname, "r"))==NULL )
return 0;
fclose(fp);
FILE *fp;
if ((fp = fopen(scriptname, "r")) == NULL)
{
return 0;
}
fclose(fp);
return 1;
}
int install_createscript(int addr, int stacksize, int progsize,
int priority, const char *scriptname)
static int install_createscript(int addr, int stacksize, int progsize,
int priority, const char *scriptname)
{
FILE *fp;
if ( (fp=fopen(scriptname, "w+"))==NULL )
return -errno;
fprintf(fp, install_script_text, stacksize, priority, progsize);
fprintf(fp, install_script_exec, addr);
fflush(fp);
fclose(fp);
FILE *fp;
return 0;
if ((fp = fopen(scriptname, "w+")) == NULL)
{
return -errno;
}
fprintf(fp, install_script_text, stacksize, priority, progsize);
fprintf(fp, install_script_exec, addr);
fflush(fp);
fclose(fp);
return 0;
}
int install_getlasthexvalue(FILE *fp, char delimiter)
static int install_getlasthexvalue(FILE *fp, char delimiter)
{
char buf[128];
char *p;
if (fgets(buf, 127, fp)) {
if ( (p = strrchr(buf, delimiter)) ) {
return strtol(p+1, NULL, 16);
char buf[128];
char *p;
if (fgets(buf, 127, fp))
{
if ((p = strrchr(buf, delimiter)))
{
return strtol(p+1, NULL, 16);
}
}
return -1;
return -1;
}
int install_remove(const char *scriptname)
static int install_remove(const char *scriptname)
{
FILE *fp;
int progsize, addr, freedsize;
uint16_t page;
int status = 0;
/* Parse script */
if ( (fp=fopen(scriptname, "r")) ) {
progsize = install_getlasthexvalue(fp,'=');
addr = install_getlasthexvalue(fp,' ');
freedsize = progsize;
FILE *fp;
int progsize, addr, freedsize;
uint16_t page;
int status = 0;
/* Parse script */
if ((fp = fopen(scriptname, "r")))
{
progsize = install_getlasthexvalue(fp,'=');
addr = install_getlasthexvalue(fp,' ');
freedsize = progsize;
}
else return -errno;
fclose(fp);
/* Remove pages */
if (progsize <= 0 || addr <= 0)
return -EIO;
do {
if ((page = up_progmem_getpage(addr)) < 0) {
status = -page;
break;
else
{
return -errno;
}
fclose(fp);
/* Remove pages */
if (progsize <= 0 || addr <= 0)
{
return -EIO;
}
do
{
if ((page = up_progmem_getpage(addr)) < 0)
{
status = -page;
break;
}
if ( up_progmem_erasepage(page) < 0) {
status = -page;
break;
if (up_progmem_erasepage(page) < 0)
{
status = -page;
break;
}
addr += up_progmem_pagesize(page);
progsize -= up_progmem_pagesize(page);
} while(progsize > 0);
if (status < 0) return status;
/* Remove script file */
if (unlink(scriptname) < 0) return -errno;
return freedsize;
addr += up_progmem_pagesize(page);
progsize -= up_progmem_pagesize(page);
}
while(progsize > 0);
if (status < 0)
{
return status;
}
/* Remove script file */
if (unlink(scriptname) < 0)
{
return -errno;
}
return freedsize;
}
/****************************************************************************
* Start
* Public Functions
****************************************************************************/
int install_main(int argc, char *argv[])
{
int i;
int progsize;
int scrsta;
int stacksize = 4096;
int priority = SCHED_PRIORITY_DEFAULT;
int pagemargin = 16;
int startpage = 0;
int startaddr = 0;
int action = ACTION_INSTALL;
char scriptname[128];
/* Supported? */
if ( !up_progmem_isuniform() ) {
fprintf(stderr, "Error: install supports uniform organization only.\n");
return -1;
}
/* Parse arguments */
for (i=1; i<argc; i++) {
if (argv[i][0]=='-' && argv[i][1]=='-' && i<=argc) {
if (strcmp(argv[i]+2, "stack")==0) {
stacksize = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "priority")==0) {
priority = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "start")==0) {
startpage = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "margin")==0) {
pagemargin = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "remove")==0) {
action = ACTION_REMOVE;
}
else if (strcmp(argv[i]+2, "force")==0) {
action = ACTION_REINSTALL;
}
else fprintf(stderr, "Unknown option: %s\n", argv[i]);
}
else break;
}
/* Do the job */
switch(action & 1) {
case ACTION_REMOVE:
if (i > argc-1) {
action = ACTION_INSUFPARAM;
break; /* are there sufficient parameters */
}
if ( (scrsta=install_remove(argv[i])) < 0) {
fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta) );
return -1;
}
printf("Removed %s and freed %d bytes\n", argv[i], scrsta);
return 0;
case ACTION_INSTALL:
if (i > argc-2) {
action = ACTION_INSUFPARAM;
break; /* are there sufficient parameters */
}
install_getscriptname(scriptname, argv[i], argv[i+1]);
// script-exists?
if (install_alreadyexists(scriptname)==1) {
if (action != ACTION_REINSTALL) {
fprintf(stderr, "Program with that name already exists.\n");
return -EEXIST;
}
if ( (scrsta=install_remove(scriptname)) < 0) {
fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta) );
return -1;
}
printf("Replacing %s\n", scriptname);
}
startaddr = install_getstartpage(startpage, pagemargin, install_getprogsize(argv[i]) );
if (startpage < 0) {
fprintf(stderr, "Not enough memory\n");
return -ENOMEM;
}
if ( (progsize = install_programflash(startaddr, argv[i])) <= 0) {
fprintf(stderr, "Error writing program memory: %s\n"
"Note: Flash pages are not released, so you may try again and program will be\n"
" written in other pages.\n", strerror(-progsize) );
return -EIO;
}
if ( (scrsta = install_createscript(startaddr, stacksize, progsize,
priority, scriptname)) < 0) {
fprintf(stderr, "Error writing program script at %s: %s\n",
argv[i+1], strerror(-scrsta) );
return -EIO;
}
printf("Installed application of size %d bytes to program memory [%xh - %xh].\n",
progsize, startaddr, startaddr + progsize);
int i;
int progsize;
int scrsta;
int stacksize = 4096;
int priority = SCHED_PRIORITY_DEFAULT;
int pagemargin = 16;
int startpage = 0;
int startaddr = 0;
int action = ACTION_INSTALL;
char scriptname[128];
return 0;
/* Supported? */
if (!up_progmem_isuniform())
{
fprintf(stderr, "Error: install supports uniform organization only.\n");
return -1;
}
fprintf(stderr, install_help, argv[0], argv[0]);
return -1;
/* Parse arguments */
for (i=1; i<argc; i++)
{
if (argv[i][0]=='-' && argv[i][1]=='-' && i<=argc)
{
if (strcmp(argv[i]+2, "stack")==0)
{
stacksize = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "priority")==0)
{
priority = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "start")==0)
{
startpage = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "margin")==0)
{
pagemargin = atoi(argv[++i]);
}
else if (strcmp(argv[i]+2, "remove")==0)
{
action = ACTION_REMOVE;
}
else if (strcmp(argv[i]+2, "force")==0)
{
action = ACTION_REINSTALL;
}
else fprintf(stderr, "Unknown option: %s\n", argv[i]);
}
else
{
break;
}
}
/* Do the job */
switch(action & 1)
{
case ACTION_REMOVE:
if (i > argc-1)
{
action = ACTION_INSUFPARAM;
break; /* are there sufficient parameters */
}
if ((scrsta=install_remove(argv[i])) < 0)
{
fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta));
return -1;
}
printf("Removed %s and freed %d bytes\n", argv[i], scrsta);
return 0;
case ACTION_INSTALL:
if (i > argc-2)
{
action = ACTION_INSUFPARAM;
break; /* are there sufficient parameters */
}
install_getscriptname(scriptname, argv[i], argv[i+1]);
/* script-exists? */
if (install_alreadyexists(scriptname) == 1)
{
if (action != ACTION_REINSTALL)
{
fprintf(stderr, "Program with that name already exists.\n");
return -EEXIST;
}
if ((scrsta = install_remove(scriptname)) < 0)
{
fprintf(stderr, "Could not remove program: %s\n", strerror(-scrsta));
return -1;
}
printf("Replacing %s\n", scriptname);
}
startaddr = install_getstartpage(startpage, pagemargin, install_getprogsize(argv[i]));
if (startpage < 0)
{
fprintf(stderr, "Not enough memory\n");
return -ENOMEM;
}
if ((progsize = install_programflash(startaddr, argv[i])) <= 0)
{
fprintf(stderr, "Error writing program memory: %s\n"
"Note: Flash pages are not released, so you may try again and program will be\n"
" written in other pages.\n", strerror(-progsize));
return -EIO;
}
if ((scrsta = install_createscript(startaddr, stacksize, progsize,
priority, scriptname)) < 0)
{
fprintf(stderr, "Error writing program script at %s: %s\n",
argv[i+1], strerror(-scrsta));
return -EIO;
}
printf("Installed application of size %d bytes to program memory [%xh - %xh].\n",
progsize, startaddr, startaddr + progsize);
return 0;
}
fprintf(stderr, install_help, argv[0], argv[0]);
return -1;
}
+1 -1
View File
@@ -1,5 +1,5 @@
/****************************************************************************
* lib/stdio/lib_fgets.c
* apps/system/readline/readline.c
*
* Copyright (C) 2007-2008, 2011-2012 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>