Merge branch 'master' into bug_fix_by_sony

This commit is contained in:
Masayuki Ishikawa 2017-05-22 09:13:02 +09:00
commit 41dee001ad
19 changed files with 865 additions and 21 deletions

View File

@ -21,15 +21,15 @@ config EXAMPLES_BUTTONS_PROGNAME
program is installed.
config EXAMPLES_BUTTONS_PRIORITY
int "LED task priority"
int "Button task priority"
default 100
config EXAMPLES_BUTTONS_STACKSIZE
int "LED stack size"
int "Button stack size"
default 2048
config EXAMPLES_BUTTONS_DEVPATH
string "LED device path"
string "Button device path"
default "/dev/buttons"
config EXAMPLES_BUTTONS_NAMES

View File

@ -541,6 +541,7 @@ int dhcpc_request(FAR void *handle, FAR struct dhcpc_state *presult)
{
return ERROR;
}
retries++;
/* Get the ACK/NAK response to the REQUEST (or timeout) */

View File

@ -1009,10 +1009,34 @@ config NSH_NETINIT
if NSH_NETINIT
config NSH_NETLOCAL
bool "Local network initialization"
default n
---help---
If this option is selected, then NSH will only initialize the local
attributes of the network: The MAC address if needed and any IP
addresses as needed. More importantly, it will not do the following:
- It will not bring the network up. That can be done later with the
NSH ifup command.
- It will not associate any wireless devices to an access point.
- It will not attempt to obtain an IP address if DHCPC is selected.
This may be done later from the NSH command line with the
apps/system/dhcpc 'renew' command.
- It will not start the NTPC daemon. This may be done later from
the NSH command line with the apps/system/ntpc 'ntpcstart' command.
This option permits you to divide the network configuration into two
parts: The local configuration of the network device and the dynamic
configuration of the device in the network. This may be important in
an environment when, for example, you need to manually scan for
available access points and associate the wireless driver with an
access point.
config NSH_NETINIT_THREAD
bool "Network initialization thread"
default n
depends on !DISABLE_PTHREAD
depends on !DISABLE_PTHREAD && !NSH_NETLOCAL
---help---
NSH is brought up through a series of sequential initialization
steps. This includes networking. If the network is available on

View File

@ -74,9 +74,15 @@ endif
ifeq ($(CONFIG_NET),y)
CSRCS += nsh_netinit.c nsh_netcmds.c
ifeq ($(CONFIG_WIRELESS_WAPI),y)
ifeq ($(CONFIG_NSH_NETINIT),y)
ifneq ($(CONFIG_NSH_NETLOCAL),y)
CSRCS += nsh_associate.c
endif
endif
endif
ifeq ($(CONFIG_NET_ROUTE),y)
CSRCS += nsh_routecmds.c
endif

View File

@ -248,11 +248,12 @@ static void nsh_netinit_configure(void)
struct in_addr addr;
#endif
#if defined(CONFIG_NSH_DHCPC)
#if defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL)
FAR void *handle;
#endif
#if (defined(CONFIG_NSH_DHCPC) || defined(CONFIG_NSH_NOMAC)) && defined(HAVE_MAC)
#if (((defined(CONFIG_NSH_DHCPC) && !defined(CONFIG_NSH_NETLOCAL)) || \
defined(CONFIG_NSH_NOMAC)) && defined(HAVE_MAC))
#if defined(CONFIG_NET_ETHERNET)
uint8_t mac[IFHWADDRLEN];
#elif defined(CONFIG_NET_6LOWPAN)
@ -358,9 +359,10 @@ static void nsh_netinit_configure(void)
netlib_set_ipv4dnsaddr(&addr);
#endif
/* New versions of netlib_set_ipvXaddr will not bring the network up,
* So ensure the network is really up at this point.
*/
/* That completes the 'local' initialization of the network device. */
#ifndef CONFIG_NSH_NETLOCAL
/* Bring the network up. */
netlib_ifup("eth0");
@ -413,6 +415,7 @@ static void nsh_netinit_configure(void)
ntpc_start();
#endif
#endif /* CONFIG_NSH_NETLOCAL */
#endif /* NSH_HAVE_NETDEV */
ninfo("Exit\n");

11
system/dhcpc/.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
/Make.dep
/.depend
/.built
/*.asm
/*.obj
/*.rel
/*.lst
/*.sym
/*.adb
/*.lib
/*.src

32
system/dhcpc/Kconfig Normal file
View File

@ -0,0 +1,32 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config SYSTEM_DHCPC
bool "DHCP Address Renewal"
default n
select NETUTILS_DHCPC
depends on NET_UDP && NET_BROADCAST && NET_IPv4 && NET_ETHERNET
---help---
Enble the DHCP client 'renew' command
if SYSTEM_DHCPC
config SYSTEM_DHCPC_PROGNAME
string "Program name"
default "renew"
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
config SYSTEM_DHCPC_PRIORITY
int "DHCPC task priority"
default 100
config SYSTEM_DHCPC_STACKSIZE
int "DHCPC stack size"
default 2048
endif

40
system/dhcpc/Make.defs Normal file
View File

@ -0,0 +1,40 @@
############################################################################
# apps/system/dhcpc/Make.defs
# Adds selected applications to apps/ build
#
# 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.
#
############################################################################
ifeq ($(CONFIG_SYSTEM_DHCPC),y)
CONFIGURED_APPS += system/dhcpc
endif

142
system/dhcpc/Makefile Normal file
View File

@ -0,0 +1,142 @@
############################################################################
# apps/system/dhcpc/Makefile
#
# 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.
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# DHCPC address renewal built-in application info
CONFIG_SYSTEM_DHCPC_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_SYSTEM_DHCPC_STACKSIZE ?= 2048
APPNAME = renew
PRIORITY = $(CONFIG_SYSTEM_DHCPC_PRIORITY)
STACKSIZE = $(CONFIG_SYSTEM_DHCPC_STACKSIZE)
CONFIG_SYSTEM_DHCPC_PROGNAME ?= renew$(EXEEXT)
PROGNAME = $(CONFIG_SYSTEM_DHCPC_PROGNAME)
# DHCPC address renewal
ASRCS =
CSRCS =
MAINSRC = dhcpc_main.c
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)
ifneq ($(CONFIG_BUILD_KERNEL),y)
OBJS += $(MAINOBJ)
endif
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
BIN = ..\..\libapps$(LIBEXT)
else
ifeq ($(WINTOOL),y)
BIN = ..\\..\\libapps$(LIBEXT)
else
BIN = ../../libapps$(LIBEXT)
endif
endif
ifeq ($(WINTOOL),y)
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
else
INSTALL_DIR = $(BIN_DIR)
endif
ROOTDEPPATH = --dep-path .
# Common build
VPATH =
all: .built
.PHONY: clean depend distclean
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
.built: $(OBJS)
$(call ARCHIVE, $(BIN), $(OBJS))
@touch .built
ifeq ($(CONFIG_BUILD_KERNEL),y)
$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ)
@echo "LD: $(PROGNAME)"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS)
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME)
install: $(BIN_DIR)$(DELIM)$(PROGNAME)
else
install:
endif
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME)_main.bdat
else
context:
endif
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
depend: .depend
clean:
$(call DELFILE, .built)
$(call CLEAN)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep
.PHONY: preconfig
preconfig:

138
system/dhcpc/dhcpc_main.c Normal file
View File

@ -0,0 +1,138 @@
/****************************************************************************
* system/dhcpc/dhcpc_main.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>
#include <stdlib.h>
#include <stdio.h>
#include <net/if.h>
#include "netutils/netlib.h"
#include "netutils/dhcpc.h"
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* dhcpc_showusage
****************************************************************************/
static void dhcpc_showusage(FAR const char *progname, int exitcode)
{
fprintf(stderr, "Usage: %s <device-name>\n", progname);
exit(exitcode);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* dhcpc_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int dhcpc_main(int argc, char *argv[])
#endif
{
FAR const char *devname;
FAR void *handle;
uint8_t mac[IFHWADDRLEN];
struct dhcpc_state ds;
int ret;
/* One and only one argument is expected: The network device name. */
if (argc != 2)
{
fprintf(stderr, "ERROR: Invalid number of arguments\n");
dhcpc_showusage(argv[0], EXIT_FAILURE);
}
devname = argv[1];
/* Get the MAC address of the NIC */
netlib_getmacaddr(devname, mac);
/* Set up the DHCPC modules */
handle = dhcpc_open(devname, &mac, IFHWADDRLEN);
if (handle == NULL)
{
fprintf(stderr, "ERROR: dhcpc_open() for '%s' failed\n", devname);
return EXIT_FAILURE;
}
/* Get an IP address. */
ret = dhcpc_request(handle, &ds);
if (ret < 0)
{
(void)dhcpc_close(handle);
fprintf(stderr, "ERROR: dhcpc_request() failed\n");
return EXIT_FAILURE;
}
/* Save the addresses that we obtained. */
netlib_set_ipv4addr(devname, &ds.ipaddr);
if (ds.netmask.s_addr != 0)
{
netlib_set_ipv4netmask(devname, &ds.netmask);
}
if (ds.default_router.s_addr != 0)
{
netlib_set_dripv4addr(devname, &ds.default_router);
}
if (ds.dnsaddr.s_addr != 0)
{
netlib_set_ipv4dnsaddr(&ds.dnsaddr);
}
dhcpc_close(handle);
return EXIT_SUCCESS;
}

11
system/ntpc/.gitignore vendored Normal file
View File

@ -0,0 +1,11 @@
/Make.dep
/.depend
/.built
/*.asm
/*.obj
/*.rel
/*.lst
/*.sym
/*.adb
/*.lib
/*.src

25
system/ntpc/Kconfig Normal file
View File

@ -0,0 +1,25 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config SYSTEM_NTPC
bool "NTP Daemon Commands"
default n
select NETUTILS_NTPCLIENT
depends on NET_UDP
---help---
Enble the NTP client 'start' and 'stop' commands
if SYSTEM_NTPC
config SYSTEM_NTPC_PRIORITY
int "NTPC task priority"
default 100
config SYSTEM_NTPC_STACKSIZE
int "NTPC stack size"
default 2048
endif

39
system/ntpc/Make.defs Normal file
View File

@ -0,0 +1,39 @@
############################################################################
# apps/system/ntpc/Make.defs
# Adds selected applications to apps/ build
#
# 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.
#
############################################################################
ifeq ($(CONFIG_SYSTEM_NTPC),y)
CONFIGURED_APPS += system/ntpc
endif

155
system/ntpc/Makefile Normal file
View File

@ -0,0 +1,155 @@
############################################################################
# apps/system/ntpc/Makefile
#
# 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.
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# NTPC address renewal built-in application info
CONFIG_SYSTEM_NTPC_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_SYSTEM_NTPC_STACKSIZE ?= 2048
APPNAME1 = ntpstart
APPNAME2 = ntpstop
PRIORITY = $(CONFIG_SYSTEM_NTPC_PRIORITY)
STACKSIZE = $(CONFIG_SYSTEM_NTPC_STACKSIZE)
PROGNAME1 = ntpstart$(EXEEXT)
PROGNAME2 = ntpstop$(EXEEXT)
# NTPC address renewal
ASRCS =
CSRCS =
MAINSRC1 = ntpcstart_main.c
MAINSRC2 = ntpcstop_main.c
MAINSRC = $(MAINSRC1) $(MAINSRC2)
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
MAINOBJ1 = $(MAINSRC1:.c=$(OBJEXT))
MAINOBJ2 = $(MAINSRC2:.c=$(OBJEXT))
MAINOBJ = $(MAINOBJ1) $(MAINOBJ2)
SRCS = $(ASRCS) $(CSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS)
ifneq ($(CONFIG_BUILD_KERNEL),y)
OBJS += $(MAINOBJ)
endif
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
BIN = ..\..\libapps$(LIBEXT)
else
ifeq ($(WINTOOL),y)
BIN = ..\\..\\libapps$(LIBEXT)
else
BIN = ../../libapps$(LIBEXT)
endif
endif
ifeq ($(WINTOOL),y)
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
else
INSTALL_DIR = $(BIN_DIR)
endif
ROOTDEPPATH = --dep-path .
# Common build
VPATH =
all: .built
.PHONY: clean depend distclean
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
.built: $(OBJS)
$(call ARCHIVE, $(BIN), $(OBJS))
@touch .built
ifeq ($(CONFIG_BUILD_KERNEL),y)
$(BIN_DIR)$(DELIM)$(PROGNAME1): $(OBJS) $(MAINOBJ1)
@echo "LD: $(PROGNAME1)"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME1) $(ARCHCRT0OBJ) $(MAINOBJ1) $(LDLIBS)
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME1)
$(BIN_DIR)$(DELIM)$(PROGNAME2): $(OBJS) $(MAINOBJ2)
@echo "LD: $(PROGNAME2)"
$(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME2) $(ARCHCRT0OBJ) $(MAINOBJ2) $(LDLIBS)
$(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME2)
install: $(BIN_DIR)$(DELIM)$(PROGNAME1) $(BIN_DIR)$(DELIM)$(PROGNAME2)
else
install:
endif
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME1),$(PRIORITY),$(STACKSIZE),$(APPNAME1)_main)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME2),$(PRIORITY),$(STACKSIZE),$(APPNAME2)_main)
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME1)_main.bdat $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME2)_main.bdat
else
context:
endif
.depend: Makefile $(SRCS)
@$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
@touch $@
depend: .depend
clean:
$(call DELFILE, .built)
$(call CLEAN)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep
.PHONY: preconfig
preconfig:

View File

@ -0,0 +1,70 @@
/****************************************************************************
* system/ntpc/ntpcstart_main.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>
#include <stdlib.h>
#include <stdio.h>
#include "netutils/ntpclient.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* ntpcstart_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int ntpcstart_main(int argc, char *argv[])
#endif
{
int pid = ntpc_start();
if (pid < 0)
{
fprintf(stderr, "ERROR: ntpc_start() failed\n");
return EXIT_FAILURE;
}
printf("Started the NTP daemon as PID=%d\n", pid);
return EXIT_SUCCESS;
}

View File

@ -0,0 +1,70 @@
/****************************************************************************
* system/ntpc/ntpc_main.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>
#include <stdlib.h>
#include <stdio.h>
#include "netutils/ntpclient.h"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* ntpcstop_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int ntpcstop_main(int argc, char *argv[])
#endif
{
int ret = ntpc_stop();
if (ret < 0)
{
fprintf(stderr, "ERROR: ntpc_stop() failed\n");
return EXIT_FAILURE;
}
printf("Stopped the NTP daemon\n");
return EXIT_SUCCESS;
}

View File

@ -8,3 +8,23 @@ config SYSTEM_RAMTEST
default n
---help---
Enable a simple RAM test.
if SYSTEM_RAMTEST
config SYSTEM_RAMTEST_PROGNAME
string "Program name"
default "ramtest"
depends on BUILD_KERNEL
---help---
This is the name of the program that will be use when the NSH ELF
program is installed.
config SYSTEM_RAMTEST_PRIORITY
int "RAM test task priority"
default 100
config SYSTEM_RAMTEST_STACKSIZE
int "RAM test stack size"
default 1024
endif

View File

@ -1,7 +1,7 @@
############################################################################
# apps/system/ramtest/Makefile
#
# Copyright (C) 2013 Gregory Nutt. All rights reserved.
# Copyright (C) 2013, 2017 Gregory Nutt. All rights reserved.
# Author: Gregory Nutt <gnutt@nuttx.org>
#
# Redistribution and use in source and binary forms, with or without
@ -39,8 +39,15 @@ include $(APPDIR)/Make.defs
# RAM test
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 768
CONFIG_SYSTEM_RAMTEST_PRIORITY ?= SCHED_PRIORITY_DEFAULT
CONFIG_SYSTEM_RAMTEST_STACKSIZE ?= 1024
APPNAME = ramtest
PRIORITY = $(CONFIG_SYSTEM_RAMTEST_PRIORITY)
STACKSIZE = $(CONFIG_SYSTEM_RAMTEST_STACKSIZE)
CONFIG_SYSTEM_RAMTEST_PROGNAME ?= ramtest$(EXEEXT)
PROGNAME = $(CONFIG_SYSTEM_RAMTEST_PROGNAME)
ASRCS =
CSRCS =
@ -73,9 +80,6 @@ else
INSTALL_DIR = $(BIN_DIR)
endif
CONFIG_XYZ_PROGNAME ?= ramtest$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Common build
@ -111,10 +115,10 @@ endif
# Register application
ifeq ($(CONFIG_NSH_BUILTIN_APPS),y)
$(BUILTIN_REGISTRY)$(DELIM)ramtest.bdat: $(DEPCONFIG) Makefile
$(call REGISTER,"ramtest",$(PRIORITY),$(STACKSIZE),ramtest_main)
$(BUILTIN_REGISTRY)$(DELIM)$(APPNAME).bdat: $(DEPCONFIG) Makefile
$(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main)
context: $(BUILTIN_REGISTRY)$(DELIM)ramtest.bdat
context: $(BUILTIN_REGISTRY)$(DELIM)$(APPNAME).bdat
else
context:
endif

View File

@ -224,7 +224,57 @@ static int wapi_event_stream_extract(FAR struct wapi_event_stream_s *stream,
{
#warning Missing logic
// return iw_extract_event_stream((struct stream_descr *)stream, iwe, 0);
return -ENOSYS;
int ret;
struct iw_event *iwe_stream;
if (stream->current + offsetof(struct iw_event, u) > stream->end)
{
/* Nothing to process */
return 0;
}
iwe_stream = (struct iw_event*)stream->current;
if (stream->current + iwe_stream->len > stream->end ||
iwe_stream->len < offsetof(struct iw_event, u))
{
return -1;
}
ret = 1;
switch (iwe_stream->cmd)
{
case SIOCGIWESSID:
case IWEVGENIE:
iwe->cmd = iwe_stream->cmd;
iwe->len = offsetof(struct iw_event, u) + sizeof(struct iw_point);
iwe->u.data.flags = iwe_stream->u.data.flags;
iwe->u.data.length = iwe_stream->u.data.length;
iwe->u.data.pointer = (FAR void*)(stream->current +
offsetof(struct iw_event, u) +
(unsigned long)iwe_stream->u.data.pointer);
break;
default:
if (iwe_stream->len > sizeof(*iwe))
{
WAPI_ERROR("Unhandled event size 0x%x %d\n", iwe_stream->cmd,
iwe_stream->len);
iwe->cmd = 0;
iwe->len = offsetof(struct iw_event, u);
break;
}
memcpy(iwe, iwe_stream, iwe_stream->len);
}
/* Update stream to next event */
stream->current += iwe_stream->len;
return ret;
}
/****************************************************************************
@ -1113,6 +1163,8 @@ alloc:
return -errcode;
}
printf("got %d bytes\n", wrq.u.data.length);
/* We have the results, process them. */
if (wrq.u.data.length)
@ -1125,7 +1177,8 @@ alloc:
{
/* Get the next event from the stream */
if ((ret = wapi_event_stream_extract(&stream, &iwe)) >= 0)
ret = wapi_event_stream_extract(&stream, &iwe);
if (ret > 0)
{
int eventret = wapi_scan_event(&iwe, aps);
if (eventret < 0)
@ -1133,7 +1186,7 @@ alloc:
ret = eventret;
}
}
else
else if (ret < 0)
{
WAPI_ERROR("ERROR: wapi_event_stream_extract() failed!\n");
}