Merged nuttx/apps into master

This commit is contained in:
nghiaho12 2015-11-03 09:44:21 -08:00
commit 885780df03
364 changed files with 8187 additions and 6669 deletions

1
.gitignore vendored
View file

@ -10,6 +10,7 @@ Make.dep
core
.gdbinit
cscope.out
/Kconfig
/bin
/external
/.context

145
Application.mk Normal file
View file

@ -0,0 +1,145 @@
############################################################################
# apps/Application.mk
#
# Copyright (C) 2015 Gregory Nutt. All rights reserved.
# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
# Authors: Gregory Nutt <gnutt@nuttx.org>
# Paul Alexander Patience <paul-a.patience@polymtl.ca>
#
# 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 $(APPDIR)/Make.defs
CXXEXT ?= .cxx
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(OBJEXT))
ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
MAINOBJ = $(MAINSRC:$(CXXEXT)=$(OBJEXT))
else
MAINOBJ = $(MAINSRC:.c=$(OBJEXT))
endif
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
ifneq ($(CONFIG_BUILD_KERNEL),y)
OBJS += $(MAINOBJ)
endif
ifeq ($(WINTOOL),y)
BIN = "${shell cygpath -w $(APPDIR)$(DELIM)libapps$(LIBEXT)}"
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
else
BIN = $(APPDIR)$(DELIM)libapps$(LIBEXT)
INSTALL_DIR = $(BIN_DIR)
endif
ROOTDEPPATH = --dep-path .
VPATH =
all: .built
.PHONY: clean depend distclean
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
$(CXXOBJS): %$(OBJEXT): %$(CXXEXT)
$(call COMPILEXX, $<, $@)
ifeq ($(suffix $(MAINSRC)),$(CXXEXT))
$(MAINOBJ): %$(OBJEXT): %$(CXXEXT)
$(call COMPILEXX, $<, $@)
else
$(MAINOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
endif
.built: $(OBJS)
$(call ARCHIVE, $(BIN), $(OBJS))
$(Q) 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)
ifneq ($(APPNAME),)
ifneq ($(PRIORITY),)
ifneq ($(STACKSIZE),)
$(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
else
context:
endif
else
context:
endif
else
context:
endif
.depend: Makefile $(SRCS)
ifeq ($(filter %$(CXXEXT),$(SRCS)),)
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
else
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(SRCS) >Make.dep
endif
$(Q) touch $@
depend: .depend
clean:
$(call DELFILE, .built)
$(call CLEAN)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep

View file

@ -1313,7 +1313,7 @@
* apps/nshlib/: The NSH mount command now recognizes the Union file
system type when listing mounted file systems (2015-06-07).
7.11 2015-xx-xx Gregory Nutt <gnutt@nuttx.org>
7.11 2015-08-13 Gregory Nutt <gnutt@nuttx.org>
* apps/netutils/thttpd: Fix compilation problems when
CONFIG_THTTPD_GENERATE_INDICES is defined (2015-06-12).
@ -1359,10 +1359,87 @@
don't have the wherewithal for that change today (2015-04-14)`.
* apps/nshlib and apps/examaples/thttpd: Change decoding to handle the
increased size of the scheduling policy field in the TCB (2015-07-23).
* apps/examples/ostest: Improve syncrhonization in round robin tests.
* apps/examples/ostest: Improve synchronization in round robin tests.
On very fast processors, there are race conditions that make the test
failure. Need better interlocking to assure that the threads actually
do start at the same time (2015-07-24).
* apps/examples/ostest: Add a test for the sporadic scheduler. This
test is failing as of this commit (2015-07-24).
* apps/system/readline: Add support for Unix-style tab complete toi
readline. This currently works only for built-in functions.
Contributed by Nghia Ho (2015-07-28).
* apps/system/readline and apps/nshlib: Extended the tab-completion
support to also expand NSH command names (2015-07-30).
* apps/system/readline and apps/nshlib: Add support for an in-memory
command line history that can be retrieved using the up and down
arrows. Contributed by Nghia Ho (2015-08-09).
* apps/Makefile: No longer depends on hardcoded lists of directories.
Instead, it does a wildcard search to find all appropriate
directories. This means that to install a new application, you
simply have to copy the directory (or link it) into the apps/
directory. If the new directory includes a Makefile and Make.defs
file, then it will automatically be included in the build (2015-08-11).
* apps/Makefile, Kconfig, */Kconfig, tools/mkkconfig.sh: Add the tool
mkkconfig.sh that dynamically builds the apps/Kconfig file at
configuration time. The hardcoded configuration file has been removed
and now the top-level Makefile executes tools/mkkconfig.sh to auto-
generate the top-level Kconfig file. A new apps/ make target call
preconfig: was added to support this operation. Now you do not have
to modify the top-level Kconfig file to add a new directory into the
configuration; the top-level subdirectory simply needs to include a
Kconfig file and it will automatically be included in the
configuration. The native Windows build is temporarily broken until
a new apps/tools/mkconfig.bat script is generated (2015-08-11).
* apps/tools/mkkconfig.bat: Add the Windows script corresponding to
apps/tools/mkkconfig.sh. Needed for a Windows native build. Untested
on initial commit (2015-08-12).
7.12 2015-10-01 Gregory Nutt <gnutt@nuttx.org>
* apps/examples/can: Extend the CAN loopback test by adding more
command line options (2015-08-17).
* apps/examples/usbserial: Can now be run as an NSH builtin-function.
Now uses a configurable IO buffer size (2015-08-20).
* Various Kconfig files in netutils: Fix some changes from from
NETUTILS_DNSCLIENT to NETDB_DNSCLIENT. From Pavel Pisa (2015-08-20).
* system/netdb: Failed to build if CONFIG_NET_HOSTFILE was not defined
because gethostbyaddr() was not available. Noted by OrbitalFox
(2015-08-21).
* apps/system/symtab: Optional canned symtab inclusion to the build. When
option CONFIG_SYSTEM_SYMTAB is selected and symbol table file
libc/symtab/canned_symtab.inc is prepared then application can
use system provided complete symbol table. The option has
substantial effect on system image size. Mainly code/text. If
loading of applications at runtime is not planned do not select
this. From Pavel Pisa (2015-08-23).
* apps/examples/nettest: Add option to suppress network initialization.
This is necessary if the nettest is run from NSH which has already
initialized the network (2015-08-26).
* apps/examples/nettest: Extend test so that can be performed using the
local loopback device (2015-08-26).
* apps/nshlib: Fix error handling in 'cat' command. On a failure to
allocate memory, a file was not being closed. From Bruno Herrera
(2015-08-26).
* apps/nshlib: Fix error handling in 'mv' command. On a failure to
expand the second path, the memory allocated for the expansion of the
first path was not being freed. From Bruno Herrera (2015-08-26).
* apps/examples/netloop: Add a test of the local loopback device
(2015-09-02).
* apps/modbus and apps/include/modbus: Macros PR_BEGIN_EXTERN_C and
PR_END_EXTERN_C were not defined in all contexts. Replace with
explicit expansion in all cases. From Stefan Kolb (2015-09-03).
* apps/canutils/uavcan: Add support for libuavcan. From Paul
Alexander Patience (2015-09-25).
* apps/examples/udpblaster: Add a test to stress the network by
sending UDP packets at a very high rate. (2015-09-30).
* apps/examples/uavcan: libuavcan example from Paul Alexander
Patience (2015-10-01).
7.13 2015-xx-xx Gregory Nutt <gnutt@nuttx.org>
* apps/examples/fstest: Add a generic file system test. This is
essentially the same as examples/smart, but has all of the SmartFS
specific logic ripped out. This was created for testing the new
tmpfs (2015-10-10).
* apps/examples/zerocross: Add a Zero Cross application example.
From Alan Carvalho de Assis (2015-10-13).

68
Directory.mk Normal file
View file

@ -0,0 +1,68 @@
############################################################################
# apps/Directory.mk
#
# Copyright (C) 2011-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.
#
############################################################################
-include $(TOPDIR)/.config # Current configuration
# Sub-directories
SUBDIRS = $(dir $(wildcard */Makefile))
all: nothing
.PHONY: nothing context depend clean distclean
define SDIR_template
$(1)_$(2):
$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
endef
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),context)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),depend)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
nothing:
install:
context: $(foreach SDIR, $(SUBDIRS), $(SDIR)_context)
depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend)
clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean)
distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean)
-include Make.dep

44
Kconfig
View file

@ -1,44 +0,0 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menu "Built-In Applications"
source "$APPSDIR/builtin/Kconfig"
endmenu
menu "Examples"
source "$APPSDIR/examples/Kconfig"
endmenu
menu "Graphics Support"
source "$APPSDIR/graphics/Kconfig"
endmenu
menu "Interpreters"
source "$APPSDIR/interpreters/Kconfig"
endmenu
menu "Network Utilities"
source "$APPSDIR/netutils/Kconfig"
endmenu
menu "FreeModBus"
source "$APPSDIR/modbus/Kconfig"
endmenu
menu "NSH Library"
source "$APPSDIR/nshlib/Kconfig"
endmenu
menu "NxWidgets/NxWM"
source "$APPSDIR/NxWidgets/Kconfig"
endmenu
menu "Platform-specific Support"
source "$APPSDIR/platform/Kconfig"
endmenu
menu "System Libraries and NSH Add-Ons"
source "$APPSDIR/system/Kconfig"
endmenu

108
Makefile
View file

@ -40,64 +40,33 @@ TOPDIR ?= $(APPDIR)/import
-include $(TOPDIR)/Make.defs
# Tools
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
MKKCONFIG = ${shell $(APPDIR)\tools\mkkconfig.bat}
else
MKKCONFIG = ${shell $(APPDIR)/tools/mkkconfig.sh}
endif
# Application Directories
# CONFIGURED_APPS is the list of all configured built-in directories/built
# action.
# SUBDIRS is the list of all directories containing Makefiles. It is used
# only for cleaning.
# BUILDIRS is the list of top-level directories containing Make.defs files
# CLEANDIRS is the list of all top-level directories containing Makefiles.
# It is used only for cleaning.
BUILDIRS := $(dir $(filter-out import/Make.defs,$(wildcard */Make.defs)))
CLEANDIRS := $(dir $(wildcard */Makefile))
# CONFIGURED_APPS is the application directories that should be built in
# the current configuration.
CONFIGURED_APPS =
SUBDIRS = examples graphics interpreters modbus builtin import nshlib
SUBDIRS += netutils platform system
# The list of configured directories is derived from NuttX configuration
# file: The selected applications are enabled settings in the configuration
# file. For example,
#
# CONFIG_EXAMPLES_HELLO=y
#
# Will cause the "Hello, World!" example at apps/examples/hello to be
# built and added int libapps.a.
# out.
# builtin/Make.defs must be included first
include builtin/Make.defs
include examples/Make.defs
include graphics/Make.defs
include interpreters/Make.defs
include modbus/Make.defs
include netutils/Make.defs
include nshlib/Make.defs
include platform/Make.defs
include system/Make.defs
-include external/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
# application directory. builtin is always in the list of applications to be
# built.
INSTALLED_APPS =
# Create the list of available applications (INSTALLED_APPS)
define ADD_BUILTIN
INSTALLED_APPS += $(if $(wildcard $1$(DELIM)Makefile),$1,)
define Add_Application
include $(1)Make.defs
endef
$(foreach BUILTIN, $(CONFIGURED_APPS), $(eval $(call ADD_BUILTIN,$(BUILTIN))))
# The external/ directory may also be added to the INSTALLED_APPS. But there
# is no external/ directory in the repository. Rather, this directory may be
# provided by the user (possibly as a symbolic link) to add libraries and
# applications to the standard build from the repository.
EXTERNAL_DIR := $(dir $(wildcard external$(DELIM)Makefile))
INSTALLED_APPS += $(EXTERNAL_DIR)
SUBDIRS += $(EXTERNAL_DIR)
$(foreach BDIR, $(BUILDIRS), $(eval $(call Add_Application,$(BDIR))))
# Library path
@ -114,23 +83,23 @@ BIN = libapps$(LIBEXT)
# Build targets
all: $(BIN)
.PHONY: import install context context_serialize context_rest .depdirs depend clean distclean
.PHONY: import install context context_serialize context_rest .depdirs preconfig depend clean distclean
define SDIR_template
$(1)_$(2):
$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)" BIN_DIR="$(BIN_DIR)"
endef
$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),all)))
$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),install)))
$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),context)))
$(foreach SDIR, $(INSTALLED_APPS), $(eval $(call SDIR_template,$(SDIR),depend)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),all)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),install)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),context)))
$(foreach SDIR, $(CONFIGURED_APPS), $(eval $(call SDIR_template,$(SDIR),depend)))
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
$(foreach SDIR, $(CLEANDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
$(BIN): $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_all)
$(BIN): $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_all)
.install: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_install)
.install: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_install)
$(BIN_DIR):
mkdir -p $(BIN_DIR)
@ -142,7 +111,7 @@ install: $(BIN_DIR) .install
import:
$(Q) $(MAKE) .import TOPDIR="$(APPDIR)$(DELIM)import"
context_rest: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_context)
context_rest: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_context)
context_serialize:
$(Q) $(MAKE) -C builtin context TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
@ -150,19 +119,25 @@ context_serialize:
context: context_serialize
.depdirs: $(foreach SDIR, $(INSTALLED_APPS), $(SDIR)_depend)
Kconfig: $(MKKCONFIG)
$(MKKCONFIG)
preconfig: Kconfig
.depdirs: $(foreach SDIR, $(CONFIGURED_APPS), $(SDIR)_depend)
.depend: context Makefile .depdirs
$(Q) touch $@
depend: .depend
clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean)
clean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_clean)
$(call DELFILE, $(BIN))
$(call DELFILE, Kconfig)
$(call DELDIR, $(BIN_DIR))
$(call CLEAN)
distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean)
distclean: $(foreach SDIR, $(CLEANDIRS), $(SDIR)_distclean)
ifeq ($(CONFIG_WINDOWS_NATIVE),y)
$(Q) ( if exist external ( \
echo ********************************************************" \
@ -178,6 +153,7 @@ else
)
endif
$(call DELFILE, .depend)
$(call DELFILE, $(BIN))
$(call DELFILE, Kconfig)
$(call DELDIR, $(BIN_DIR))
$(call CLEAN)

View file

@ -3,6 +3,8 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
menu "NxWidgets/NxWM"
config NXWIDGETS
bool "Enable NxWidgets"
default n
@ -1281,3 +1283,4 @@ endif # NXWM_MEDIAPLAYER
endmenu # NxWM Media Player Display Settings
endif # NXWM
endmenu # NxWidgets/NxWM

View file

@ -83,7 +83,7 @@ asynchronously with NSH. If you want to force NSH to execute commands
then wait for the command to execute, you can enable that feature by
adding the following to the NuttX configuration file:
CONFIG_SCHED_WAITPID=y
CONFIG_SCHED_WAITPID=y
The configuration option enables support for the waitpid() RTOS interface.
When that interface is enabled, NSH will use it to wait, sleeping until
@ -150,7 +150,7 @@ Building NuttX with Board-Specific Pieces Outside the Source Tree
Q: Has anyone come up with a tidy way to build NuttX with board-
specific pieces outside the source tree?
A: Here are four:
A: Here are three:
1) There is a make target called 'make export'. It will build
NuttX, then bundle all of the header files, libaries, startup
@ -176,38 +176,48 @@ A: Here are four:
3) If you like the random collection of stuff in the apps/ directory
but just want to expand the existing components with your own,
external sub-directory then there is an easy way to that too:
You just create the sympolic link at apps/external that
redirects to your application sub-directory. The apps/Makefile
will always automatically check for the existence of an
apps/external directory and if it exists, it will automatically
incorporate it into the build.
You just create a sympolic link in the apps/ directory that
redirects to your application sub-directory.
This feature of the apps/Makefile is documented only here.
In order to be incorporated into the build, the directory that
you link under the apps/ directory should contain (1) a Makefile
that supports the clean and distclean targets (see other Makefiles
for examples), and (2) a tiny Make.defs file that simply adds the
custon build directories to the variable CONFIGURED_APPS like:
You can, for example, create a script called install.sh that
CONFIGURED_APPS += my_directory1 my_directory2
The apps/Makefile will always automatically check for the
existence of subdirectories containing a Makefile and a Make.defs
file. The Makefile will be used only to support cleaning operations.
The Make.defs file provides the set of directories to be built; these
directories must also contain a Makefile. That Makefile must be able
to build the sources and add the objects to the apps/libapps.a archive.
(see other Makefiles for examples). It should support the all,
install, context, and depend targets.
apps/Makefile does not depend on any hardcoded lists of directories.
Instead, it does a wildcard search to find all appropriate
directories. This means that to install a new application, you
simply have to copy the directory (or link it) into the apps/
directory. If the new directory includes a Makefile and Make.defs
file, then it will automatically be included in the build.
If the directory that you add also includes a Kconfig file, then it
will automatically be included in the NuttX configuration system as
well. apps/Makefile uses a tool at apps/tools/mkkconfig.sh that
dynamically builds the apps/Kconfig file at pre-configuration time.
You could, for example, create a script called install.sh that
installs a custom application, configuration, and board specific
directory:
a) Copy 'MyBoard' directory to configs/MyBoard.
b) Add a symbolic link to MyApplication at apps/external
c) Configure NuttX (usually by:
a) Copy 'MyBoard' directory to configs/MyBoard.
b) Add a symbolic link to MyApplication at apps/external
c) Configure NuttX (usually by:
tools/configure.sh MyBoard/MyConfiguration
tools/configure.sh MyBoard/MyConfiguration
or simply by copying defconfig->nuttx/.config,
setenv.sh->nuttx/setenv.sh, and Make.defs->nuttx/Make.defs.
Using the 'external' link makes it especially easy to add a
'built-in' application an existing configuration.
4) Add any link to apps/
a) Add symbolic links apps/ to as many other directories as you
want,
b) Add the symbolic link to the list of candidate paths in the
top level apps/Makefile, and
b) Add the (relative) paths to the CONFIGURED_APPS list
in the Make.defs file in your new directory.
That is basically the same as my option #3 but doesn't use the
magic 'external' link.
Use of the name ''apps/external'' is suggested because that name
is included in the .gitignore file and will save you some nuisance
when working with GIT.

View file

@ -3,7 +3,8 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
if BUILTIN
menu "Built-In Applications"
depends on BUILTIN
config BUILTIN_PROXY_STACKSIZE
int "Builtin Proxy Stack Size"
@ -14,4 +15,4 @@ config BUILTIN_PROXY_STACKSIZE
configuration item specifies the stack size used for the proxy. Default:
1024 bytes.
endif
endmenu # Built-In Applications

10
canutils/Kconfig Normal file
View file

@ -0,0 +1,10 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
menu "CAN Utilities"
source "$APPSDIR/canutils/uavcan/Kconfig"
endmenu # CAN Utilities

37
canutils/Make.defs Normal file
View file

@ -0,0 +1,37 @@
############################################################################
# apps/canutils/Make.defs
# Adds selected applications to apps/ build
#
# 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.
#
############################################################################
include $(wildcard canutils/*/Make.defs)

36
canutils/Makefile Normal file
View file

@ -0,0 +1,36 @@
############################################################################
# apps/canutils/Makefile
#
# Copyright (C) 2011-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.
#
############################################################################
include $(APPDIR)/Directory.mk

6
canutils/uavcan/.gitignore vendored Normal file
View file

@ -0,0 +1,6 @@
/.built
/dsdlc_generated
/libuavcan
/libuavcan-*
/dsdl-*
/pyuavcan-*

232
canutils/uavcan/Kconfig Normal file
View file

@ -0,0 +1,232 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config CANUTILS_UAVCAN
bool "UAVCAN Library"
default n
depends on STM32_HAVE_CAN1
depends on !STM32_CAN1
depends on !STM32_CAN2
depends on !STM32_TIM2 || (STM32_HAVE_TIM3 && !STM32_TIM3) || (STM32_HAVE_TIM4 && !STM32_TIM4) || (STM32_HAVE_TIM5 && !STM32_TIM5) || (STM32_HAVE_TIM6 && !STM32_TIM6) || (STM32_HAVE_TIM7 && !STM32_TIM7)
depends on C99_BOOL8
depends on HAVE_CXX
depends on !DISABLE_POLL
---help---
Enables support for the UAVCAN library.
if CANUTILS_UAVCAN
config UAVCAN_LIBUAVCAN_URL
string "UAVCAN URL"
default "https://github.com/UAVCAN/libuavcan/archive"
---help---
UAVCAN URL.
config UAVCAN_LIBUAVCAN_VERSION
string "UAVCAN Version"
default "531433a3261ff1568e824c240d0f1c6ecef73be1"
---help---
UAVCAN version.
config UAVCAN_DSDL_URL
string "DSDL URL"
default "https://github.com/UAVCAN/dsdl/archive"
---help---
DSDL URL.
config UAVCAN_DSDL_VERSION
string "DSDL Version"
default "9804a3e6972825586be252ce08dd899f44994b14"
---help---
DSDL version.
config UAVCAN_PYUAVCAN_URL
string "Python UAVCAN URL"
default "https://github.com/UAVCAN/pyuavcan/archive"
---help---
Python UAVCAN URL.
config UAVCAN_PYUAVCAN_VERSION
string "Python UAVCAN Version"
default "4e2798ec3da8e8493b769da514f3b96eea5773e2"
---help---
Python UAVCAN version.
config UAVCAN_STM32_NUM_IFACES
int "Number of CAN Interfaces"
default 1
range 1 1 if !STM32_HAVE_CAN2
range 1 2 if STM32_HAVE_CAN2
choice
prompt "Timer"
default UAVCAN_STM32_TIM2 if !STM32_TIM2
default UAVCAN_STM32_TIM3 if STM32_HAVE_TIM3 && !STM32_TIM3
default UAVCAN_STM32_TIM4 if STM32_HAVE_TIM4 && !STM32_TIM4
default UAVCAN_STM32_TIM5 if STM32_HAVE_TIM5 && !STM32_TIM5
default UAVCAN_STM32_TIM6 if STM32_HAVE_TIM6 && !STM32_TIM6
default UAVCAN_STM32_TIM7 if STM32_HAVE_TIM7 && !STM32_TIM7
config UAVCAN_STM32_TIM2
bool "TIM2"
depends on !STM32_TIM2
---help---
The library will use TIM2.
config UAVCAN_STM32_TIM3
bool "TIM3"
depends on STM32_HAVE_TIM3 && !STM32_TIM3
---help---
The library will use TIM3.
config UAVCAN_STM32_TIM4
bool "TIM4"
depends on STM32_HAVE_TIM4 && !STM32_TIM4
---help---
The library will use TIM4.
config UAVCAN_STM32_TIM5
bool "TIM5"
depends on STM32_HAVE_TIM5 && !STM32_TIM5
---help---
The library will use TIM5.
config UAVCAN_STM32_TIM6
bool "TIM6"
depends on STM32_HAVE_TIM6 && !STM32_TIM6
---help---
The library will use TIM6.
config UAVCAN_STM32_TIM7
bool "TIM7"
depends on STM32_HAVE_TIM7 && !STM32_TIM7
---help---
The library will use TIM7.
endchoice
choice
prompt "C++ Version"
default UAVCAN_CPP03
config UAVCAN_CPP03
bool "C++03"
---help---
The library will use C++03.
config UAVCAN_CPP11
bool "C++11"
---help---
The library will use C++11.
endchoice
config UAVCAN_DEBUG
bool "Debug"
default n
---help---
Enables debug.
config UAVCAN_EXCEPTIONS
bool "Exceptions"
default n
---help---
Enables exceptions.
config UAVCAN_TINY
bool "Tiny"
default n
---help---
Removes some features to save memory.
config UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY
bool "No Global Data Type Registry"
default n
---help---
Removes the global data type registry.
config UAVCAN_TOSTRING
bool "Implement toString"
default n
depends on UAVCAN_EXCEPTIONS
---help---
The library will add a toString method to most of its classes.
config UAVCAN_IMPLEMENT_PLACEMENT_NEW
bool "Implement Placement new"
default n
---help---
The library will implement placement new.
config UAVCAN_USE_EXTERNAL_SNPRINTF
bool "Use External snprintf"
default n
---help---
The library will use an external snprintf.
config UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION
bool "Use External float16 Conversion"
default n
---help---
The library will use an external float16 conversion.
config UAVCAN_NO_ASSERTIONS
bool "No Assertions"
default n
---help---
Disables assertions.
config UAVCAN_MEM_POOL_BLOCK_SIZE
int "Memory Pool Block Size"
default 0
---help---
Specifies the memory pool block size. If the value is 0, the
library will use a default value.
config UAVCAN_FLOAT_COMPARISON_EPSILON_MULT
int "Float Comparion Epsilon Mult"
default 0
---help---
Specifies the float comparison epsilon mult. If the value is
0, the library will use a default value.
config UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS
int "Max CAN Acceptance Filters"
default 0
---help---
Specifies the maximum number of CAN acceptance filters. If
the value is 0, the library will use a default value.
config UAVCAN_MAX_NETWORK_SIZE_HINT
int "Max Network Size Hint"
default 0
---help---
Specifies the maximum network size. If the value is 0, the
library will use a default value.
config UAVCAN_RX_QUEUE_CAPACITY
int "Rx Queue Capacity"
default 0
---help---
Specifies the rx queue capacity. If the value is 0, the
library will use a default value.
config UAVCAN_BIT_RATE
int "Bit Rate"
default 0
range 0 1000000
---help---
Specifies the CAN bit rate. If the value is 0, the library
will automatically detect the bit rate.
config UAVCAN_INIT_RETRIES
int "Initialization Retries"
default 0
---help---
Specifies the number of times to try initializing the CAN
peripherals before panicking. A value of 0 means to try
forever.
endif

38
canutils/uavcan/Make.defs Normal file
View file

@ -0,0 +1,38 @@
############################################################################
# apps/canutils/uavcan/Make.defs
#
# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
# Author: Paul Alexander Patience <paul-a.patience@polymtl.ca>
#
# 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_CANUTILS_UAVCAN),y)
CONFIGURED_APPS += canutils/uavcan
endif

254
canutils/uavcan/Makefile Normal file
View file

@ -0,0 +1,254 @@
############################################################################
# apps/canutils/uavcan/Makefile
#
# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
# Author: Paul Alexander Patience <paul-a.patience@polymtl.ca>
#
# 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
WGET = wget
UNPACK = unzip
PACKEXT = .zip
LIBUAVCAN_URL = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_LIBUAVCAN_URL)))
LIBUAVCAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_LIBUAVCAN_VERSION)))
LIBUAVCAN_UNPACKNAME = libuavcan-$(LIBUAVCAN_VERSION)
LIBUAVCAN_PACKNAME = $(LIBUAVCAN_UNPACKNAME)$(PACKEXT)
LIBUAVCAN_DSDL_PATH = libuavcan$(DELIM)dsdl
LIBUAVCAN_PYUAVCAN_PATH = libuavcan$(DELIM)libuavcan$(DELIM)dsdl_compiler$(DELIM)pyuavcan
DSDL_URL = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_DSDL_URL)))
DSDL_VERSION = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_DSDL_VERSION)))
DSDL_UNPACKNAME = dsdl-$(DSDL_VERSION)
DSDL_PACKNAME = $(DSDL_UNPACKNAME)$(PACKEXT)
PYUAVCAN_URL = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_PYUAVCAN_URL)))
PYUAVCAN_VERSION = $(patsubst "%",%,$(strip $(CONFIG_UAVCAN_PYUAVCAN_VERSION)))
PYUAVCAN_UNPACKNAME = pyuavcan-$(PYUAVCAN_VERSION)
PYUAVCAN_PACKNAME = $(PYUAVCAN_UNPACKNAME)$(PACKEXT)
-include libuavcan/libuavcan/include.mk
-include libuavcan/libuavcan_drivers/stm32/driver/include.mk
CXXSRCS = platform_stm32.cpp $(LIBUAVCAN_SRC) $(LIBUAVCAN_STM32_SRC)
CXXFLAGS += -I$(LIBUAVCAN_INC) -I$(LIBUAVCAN_STM32_INC) -Idsdlc_generated
CXXFLAGS += -I$(TOPDIR)$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)common
CXXFLAGS += -I$(TOPDIR)$(DELIM)arch$(DELIM)arm$(DELIM)src$(DELIM)stm32
CXXFLAGS += -D__KERNEL__
CXXFLAGS += -DUAVCAN_STM32_NUTTX=1
CXXFLAGS += -DUAVCAN_STM32_NUM_IFACES=$(CONFIG_UAVCAN_STM32_NUM_IFACES)
ifeq ($(CONFIG_UAVCAN_STM32_TIM2),y)
CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=2
else
ifeq ($(CONFIG_UAVCAN_STM32_TIM3),y)
CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=3
else
ifeq ($(CONFIG_UAVCAN_STM32_TIM4),y)
CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=4
else
ifeq ($(CONFIG_UAVCAN_STM32_TIM5),y)
CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=5
else
ifeq ($(CONFIG_UAVCAN_STM32_TIM6),y)
CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=6
else
ifeq ($(CONFIG_UAVCAN_STM32_TIM7),y)
CXXFLAGS += -DUAVCAN_STM32_TIMER_NUMBER=7
endif
endif
endif
endif
endif
endif
ifeq ($(CONFIG_UAVCAN_CPP03),y)
CXXFLAGS += -std=c++03 -DUAVCAN_CPP_VERSION=UAVCAN_CPP03
else
ifeq ($(CONFIG_UAVCAN_CPP11),y)
CXXFLAGS += -std=c++11 -DUAVCAN_CPP_VERSION=UAVCAN_CPP11
endif
endif
ifeq ($(CONFIG_UAVCAN_DEBUG),y)
CXXFLAGS += -DUAVCAN_DEBUG=1
endif
ifeq ($(CONFIG_UAVCAN_EXCEPTIONS),y)
CXXFLAGS += -DUAVCAN_EXCEPTIONS=1
else
CXXFLAGS += -DUAVCAN_EXCEPTIONS=0
endif
ifeq ($(CONFIG_UAVCAN_TINY),y)
CXXFLAGS += -DUAVCAN_TINY=1
endif
ifeq ($(CONFIG_UAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY),y)
CXXFLAGS += -DUAVCAN_NO_GLOBAL_DATA_TYPE_REGISTRY=1
endif
ifeq ($(CONFIG_UAVCAN_TOSTRING),y)
CXXFLAGS += -DUAVCAN_TOSTRING=1
else
CXXFLAGS += -DUAVCAN_TOSTRING=0
endif
ifeq ($(CONFIG_UAVCAN_IMPLEMENT_PLACEMENT_NEW),y)
CXXFLAGS += -DUAVCAN_IMPLEMENT_PLACEMENT_NEW=1
endif
ifeq ($(CONFIG_UAVCAN_USE_EXTERNAL_SNPRINTF),y)
CXXFLAGS += -DUAVCAN_USE_EXTERNAL_SNPRINTF=1
endif
ifeq ($(CONFIG_UAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION),y)
CXXFLAGS += -DUAVCAN_USE_EXTERNAL_FLOAT16_CONVERSION=1
endif
ifeq ($(CONFIG_UAVCAN_NO_ASSERTIONS),y)
CXXFLAGS += -DUAVCAN_NO_ASSERTIONS=1
endif
ifneq ($(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE),0)
CXXFLAGS += -DUAVCAN_MEM_POOL_BLOCK_SIZE=$(CONFIG_UAVCAN_MEM_POOL_BLOCK_SIZE)
endif
ifneq ($(CONFIG_UAVCAN_FLOAT_COMPARISON_EPSILON_MULT),0)
CXXFLAGS += -DUAVCAN_FLOAT_COMPARISON_EPSILON_MULT=$(CONFIG_UAVCAN_FLOAT_COMPARISON_EPSILON_MULT)
endif
ifneq ($(CONFIG_UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS),0)
CXXFLAGS += -DUAVCAN_MAX_CAN_ACCEPTANCE_FILTERS=$(CONFIG_UAVCAN_MAX_CAN_ACCEPTANCE_FILTERS)
endif
ifneq ($(CONFIG_UAVCAN_MAX_NETWORK_SIZE_HINT),0)
CXXFLAGS += -DUAVCAN_MAX_NETWORK_SIZE_HINT=$(CONFIG_UAVCAN_MAX_NETWORK_SIZE_HINT)
endif
CXXEXT = .cpp
CXXOBJS = $(CXXSRCS:$(CXXEXT)=$(OBJEXT))
ifeq ($(WINTOOL),y)
BIN = "${shell cygpath -w $(APPDIR)$(DELIM)libapps$(LIBEXT)}"
else
BIN = $(APPDIR)$(DELIM)libapps$(LIBEXT)
endif
ROOTDEPPATH = --dep-path .
VPATH =
all: .built
.PHONY: clean depend distclean
$(LIBUAVCAN_PACKNAME):
@echo "Downloading: $(LIBUAVCAN_PACKNAME)"
$(Q) $(WGET) -O $(LIBUAVCAN_PACKNAME) $(LIBUAVCAN_URL)$(DELIM)$(LIBUAVCAN_VERSION)$(PACKEXT)
$(LIBUAVCAN_UNPACKNAME): $(LIBUAVCAN_PACKNAME)
@echo "Unpacking: $(LIBUAVCAN_PACKNAME) -> $(LIBUAVCAN_UNPACKNAME)"
$(Q) $(UNPACK) $(LIBUAVCAN_PACKNAME)
$(Q) touch $(LIBUAVCAN_UNPACKNAME)
$(DSDL_PACKNAME):
@echo "Downloading: $(DSDL_PACKNAME)"
$(Q) $(WGET) -O $(DSDL_PACKNAME) $(DSDL_URL)$(DELIM)$(DSDL_VERSION)$(PACKEXT)
$(DSDL_UNPACKNAME): $(DSDL_PACKNAME)
@echo "Unpacking: $(DSDL_PACKNAME) -> $(DSDL_UNPACKNAME)"
$(Q) $(UNPACK) $(DSDL_PACKNAME)
$(Q) touch $(DSDL_UNPACKNAME)
$(PYUAVCAN_PACKNAME):
@echo "Downloading: $(PYUAVCAN_PACKNAME)"
$(Q) $(WGET) -O $(PYUAVCAN_PACKNAME) $(PYUAVCAN_URL)$(DELIM)$(PYUAVCAN_VERSION)$(PACKEXT)
$(PYUAVCAN_UNPACKNAME): $(PYUAVCAN_PACKNAME)
@echo "Unpacking: $(PYUAVCAN_PACKNAME) -> $(PYUAVCAN_UNPACKNAME)"
$(Q) $(UNPACK) $(PYUAVCAN_PACKNAME)
$(Q) touch $(PYUAVCAN_UNPACKNAME)
libuavcan: $(LIBUAVCAN_UNPACKNAME) $(DSDL_UNPACKNAME) $(PYUAVCAN_UNPACKNAME)
$(Q) cp -R $(LIBUAVCAN_UNPACKNAME) libuavcan
$(call DELDIR, $(LIBUAVCAN_DSDL_PATH))
$(Q) cp -R $(DSDL_UNPACKNAME) $(LIBUAVCAN_DSDL_PATH)
$(call DELDIR, $(LIBUAVCAN_PYUAVCAN_PATH))
$(Q) cp -R $(PYUAVCAN_UNPACKNAME) $(LIBUAVCAN_PYUAVCAN_PATH)
dsdlc_generated: libuavcan
$(info $(shell $(LIBUAVCAN_DSDLC) $(UAVCAN_DSDL_DIR)))
$(APPDIR)$(DELIM)include$(DELIM)uavcan: dsdlc_generated
$(Q) mkdir -p $(APPDIR)$(DELIM)include$(DELIM)uavcan
$(Q) cp -R libuavcan$(DELIM)libuavcan$(DELIM)include$(DELIM)uavcan$(DELIM)* $(APPDIR)$(DELIM)include$(DELIM)uavcan
$(Q) cp -R dsdlc_generated$(DELIM)uavcan$(DELIM)* $(APPDIR)$(DELIM)include$(DELIM)uavcan
$(CXXOBJS): %$(OBJEXT): %$(CXXEXT)
$(call COMPILEXX, $<, $@)
.built: $(CXXOBJS)
$(call ARCHIVE, $(BIN), $(CXXOBJS))
$(Q) touch .built
install:
context: libuavcan
$(Q) $(MAKE) $(APPDIR)$(DELIM)include$(DELIM)uavcan TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
.depend: Makefile $(CXXSRCS)
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CXX)" -- $(CXXFLAGS) -- $(CXXSRCS) >Make.dep
$(Q) touch $@
depend: .depend
clean:
$(call DELFILE, .built)
$(foreach CXXOBJ, $(CXXOBJS), $(call DELFILE, $(CXXOBJ)))
$(call DELDIR, dsdlc_generated)
$(call DELDIR, $(APPDIR)$(DELIM)include$(DELIM)uavcan)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
$(call DELDIR, $(LIBUAVCAN_UNPACKNAME))
$(call DELFILE, $(LIBUAVCAN_PACKNAME))
$(call DELDIR, $(DSDL_UNPACKNAME))
$(call DELFILE, $(DSDL_PACKNAME))
$(call DELDIR, $(PYUAVCAN_UNPACKNAME))
$(call DELFILE, $(PYUAVCAN_PACKNAME))
-include Make.dep

View file

@ -0,0 +1,101 @@
/****************************************************************************
* canutils/uavcan/uavcan_platform.cpp
*
* Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved.
* Author: Paul Alexander Patience <paul-a.patience@polymtl.ca>
*
* 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 <cunistd>
#include <uavcan_stm32/uavcan_stm32.hpp>
/****************************************************************************
* Private Data
****************************************************************************/
#if CONFIG_UAVCAN_RX_QUEUE_CAPACITY > 0
static uavcan_stm32::CanInitHelper<CONFIG_UAVCAN_RX_QUEUE_CAPACITY> can;
#else
static uavcan_stm32::CanInitHelper<> can;
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
static void delay_callable()
{
std::usleep(can.getRecommendedListeningDelay().toUSec());
}
/****************************************************************************
* Public Functions
****************************************************************************/
uavcan::ICanDriver& getCanDriver()
{
static bool initialized = false;
if (!initialized)
{
uavcan::uint32_t bitrate = CONFIG_UAVCAN_BIT_RATE;
#if CONFIG_UAVCAN_INIT_RETRIES > 0
int retries = 0;
#endif
while (can.init(delay_callable, bitrate) < 0)
{
#if CONFIG_UAVCAN_INIT_RETRIES > 0
retries++;
if (retries >= CONFIG_UAVCAN_INIT_RETRIES)
{
PANIC();
}
#endif
}
initialized = true;
}
return can.driver;
}
uavcan::ISystemClock& getSystemClock()
{
return uavcan_stm32::SystemClock::instance();
}

View file

@ -3,6 +3,8 @@
# see the file kconfig-language.txt in the NuttX tools repository.
#
menu "Examples"
source "$APPSDIR/examples/adc/Kconfig"
source "$APPSDIR/examples/ajoystick/Kconfig"
source "$APPSDIR/examples/bastest/Kconfig"
@ -16,6 +18,7 @@ source "$APPSDIR/examples/cxxtest/Kconfig"
source "$APPSDIR/examples/dhcpd/Kconfig"
source "$APPSDIR/examples/djoystick/Kconfig"
source "$APPSDIR/examples/elf/Kconfig"
source "$APPSDIR/examples/fstest/Kconfig"
source "$APPSDIR/examples/ftpc/Kconfig"
source "$APPSDIR/examples/ftpd/Kconfig"
source "$APPSDIR/examples/hello/Kconfig"
@ -32,6 +35,7 @@ source "$APPSDIR/examples/modbus/Kconfig"
source "$APPSDIR/examples/mount/Kconfig"
source "$APPSDIR/examples/mtdpart/Kconfig"
source "$APPSDIR/examples/mtdrwb/Kconfig"
source "$APPSDIR/examples/netloop/Kconfig"
source "$APPSDIR/examples/netpkt/Kconfig"
source "$APPSDIR/examples/nettest/Kconfig"
source "$APPSDIR/examples/nrf24l01_term/Kconfig"
@ -71,7 +75,9 @@ source "$APPSDIR/examples/thttpd/Kconfig"
source "$APPSDIR/examples/timer/Kconfig"
source "$APPSDIR/examples/tiff/Kconfig"
source "$APPSDIR/examples/touchscreen/Kconfig"
source "$APPSDIR/examples/uavcan/Kconfig"
source "$APPSDIR/examples/udp/Kconfig"
source "$APPSDIR/examples/udpblaster/Kconfig"
source "$APPSDIR/examples/discover/Kconfig"
source "$APPSDIR/examples/webserver/Kconfig"
source "$APPSDIR/examples/unionfs/Kconfig"
@ -83,3 +89,6 @@ source "$APPSDIR/examples/watchdog/Kconfig"
source "$APPSDIR/examples/wget/Kconfig"
source "$APPSDIR/examples/wgetjson/Kconfig"
source "$APPSDIR/examples/xmlrpc/Kconfig"
source "$APPSDIR/examples/zerocross/Kconfig"
endmenu # Examples

View file

@ -33,36 +33,4 @@
#
############################################################################
-include $(TOPDIR)/.config # Current configuration
# Sub-directories
SUBDIRS = $(dir $(wildcard */Makefile))
all: nothing
.PHONY: nothing context depend clean distclean
define SDIR_template
$(1)_$(2):
$(Q) $(MAKE) -C $(1) $(2) TOPDIR="$(TOPDIR)" APPDIR="$(APPDIR)"
endef
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),context)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),depend)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),clean)))
$(foreach SDIR, $(SUBDIRS), $(eval $(call SDIR_template,$(SDIR),distclean)))
nothing:
install:
context: $(foreach SDIR, $(SUBDIRS), $(SDIR)_context)
depend: $(foreach SDIR, $(SUBDIRS), $(SDIR)_depend)
clean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_clean)
distclean: $(foreach SDIR, $(SUBDIRS), $(SDIR)_distclean)
-include Make.dep
include $(APPDIR)/Directory.mk

View file

@ -389,6 +389,24 @@ examples/flash_test
internal OS interfaces and so is not available in the NUTTX kernel
builds
examples/fstest
^^^^^^^^^^^^^^
This is a generic file system test that derives from examples/nxffs. It
was created to test the tmpfs file system, but should work with any file
system provided that all initialization has already been performed prior
to starting the test.
* CONFIG_EXAMPLES_FSTEST: Enable the file system example
* CONFIG_EXAMPLES_FSTEST_MAXNAME: Determines the maximum size of names used
in the filesystem
* CONFIG_EXAMPLES_FSTEST_MAXFILE: Determines the maximum size of a file
* CONFIG_EXAMPLES_FSTEST_MAXIO: Max I/O, default 347.
* CONFIG_EXAMPLES_FSTEST_MAXOPEN: Max open files.
* CONFIG_EXAMPLES_FSTEST_MOUNTPT: Path where the file system is mounted.
* CONFIG_EXAMPLES_FSTEST_NLOOPS: Number of test loops. default 100
* CONFIG_EXAMPLES_FSTEST_VERBOSE: Verbose output
examples/ftpc
^^^^^^^^^^^^^
@ -794,6 +812,26 @@ examples/netpkt
A test of AF_PACKET, "raw" sockets. Contributed by Lazlo Sitzer.
examples/netloop
^^^^^^^^^^^^^^^^
This is a simple test of the netwok loopback device. examples/nettest can
also be configured to provide (better) test of local loopback transfers.
This version derives from examples/poll and is focused on testing poll()
with loopback devices.
CONFIG_EXAMPLES_NETLOOP=y - Enables the nettest example
Dependencies:
CONFIG_NSH_BUILTIN_APPS=n - Does NOT work as an NSH built-in command
CONFIG_NET_LOOPBACK - Requires local loopback supprt
CONFIG_NET_TCP - Requires TCP support with the following:
CONFIG_NET_TCPBACKLOG
CONFIG_NET_TCP_READAHEAD
CONFIG_NET_TCP_WRITE_BUFFERS
CONFIG_NET_IPv4 - Currently supports only IPv4
examples/nettest
^^^^^^^^^^^^^^^^
@ -1643,7 +1681,7 @@ examples/slcd
examples/smart
^^^^^^^^^^^^^^
This is a test of the SMART file systemt that derives from
This is a test of the SMART file system that derives from
examples/nxffs.
* CONFIG_EXAMPLES_SMART: - Enable the SMART file system example
@ -1666,8 +1704,6 @@ examples/smart
* CONFIG_EXAMPLES_SMART_NLOOPS: Number of test loops. default 100
* CONFIG_EXAMPLES_SMART_VERBOSE: Verbose output
endif
examples/smart_test
^^^^^^^^^^^^^^^^^^^
@ -1841,6 +1877,12 @@ examples/touchscreen
int board_tsc_setup(int minor);
void board_tsc_teardown(void);
examples/uavcan
^^^^^^^^^^^^^^^
Illustrates use of canutils/uavcan. Contributed by Paul Alexander
Patience.
examples/udp
^^^^^^^^^^^^
@ -1852,6 +1894,14 @@ examples/udp
CONFIG_NETUTILS_NETLIB=y
examples/udpblaster
^^^^^^^^^^^^^^^^^^^
This is a simple network test for stressing UDP transfers. It simply
sends UDP packets from both the host and the target and the highest ratei
possible.
examples/unionfs
^^^^^^^^^^^^^^^^
@ -2200,3 +2250,8 @@ examples/xmlrpc
Default 0x0a000001. Ignored if CONFIG_NSH_BUILTIN_APPS is selected.
CONFIG_EXAMPLES_XMLRPC_NETMASK - Network Mask. Default 0xffffff00
Ignored if CONFIG_NSH_BUILTIN_APPS is selected.
examples/zerocross
^^^^^^^^^^^^^^^^^^
A simple test of the Zero Crossing device driver.

View file

@ -6,7 +6,7 @@
config EXAMPLES_ADC
bool "ADC example"
default n
depends on ADC && LIB_BOARDCTL
depends on ADC && BOARDCTL_ADCTEST
---help---
Enable the ADC example

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# NuttX NX Graphics Example.
@ -43,95 +41,13 @@ ASRCS =
CSRCS =
MAINSRC = adc_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
CONFIG_XYZ_PROGNAME ?= adc$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Touchscreen built-in application info
APPNAME = adc
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Common build
VPATH =
all: .built
.PHONY: context 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
include $(APPDIR)/Application.mk

View file

@ -43,7 +43,7 @@
#include <nuttx/config.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* CONFIG_NSH_BUILTIN_APPS - Build the ADC test as an NSH built-in function.

View file

@ -288,7 +288,7 @@ int adc_main(int argc, char *argv[])
/* Open the ADC device for reading */
printf("adc_main: Hardware initialized. Opening the ADC device: %s\n",
g_adcstate.devpath);
g_adcstate.devpath);
fd = open(g_adcstate.devpath, O_RDONLY);
if (fd < 0)
@ -305,7 +305,9 @@ int adc_main(int argc, char *argv[])
#if defined(CONFIG_NSH_BUILTIN_APPS)
for (; g_adcstate.count > 0; g_adcstate.count--)
#elif CONFIG_EXAMPLES_ADC_NSAMPLES > 0
for (g_adcstate.count = 0; g_adcstate.count < CONFIG_EXAMPLES_ADC_NSAMPLES; g_adcstate.count++)
for (g_adcstate.count = 0;
g_adcstate.count < CONFIG_EXAMPLES_ADC_NSAMPLES;
g_adcstate.count++)
#else
for (;;)
#endif
@ -340,7 +342,7 @@ int adc_main(int argc, char *argv[])
if (errval != EINTR)
{
printf("adc_main: read %s failed: %d\n",
g_adcstate.devpath, errval);
g_adcstate.devpath, errval);
errval = 3;
goto errout_with_dev;
}
@ -365,10 +367,10 @@ int adc_main(int argc, char *argv[])
else
{
printf("Sample:\n");
for (i = 0; i < nsamples ; i++)
for (i = 0; i < nsamples; i++)
{
printf("%d: channel: %d value: %d\n",
i+1, sample[i].am_channel, sample[i].am_data);
i+1, sample[i].am_channel, sample[i].am_data);
}
}
}

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Hello, World! Example
@ -43,95 +41,14 @@ ASRCS =
CSRCS =
MAINSRC = ajoy_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
CONFIG_AJOY_PROGNAME ?= ajoy$(EXEEXT)
PROGNAME = $(CONFIG_AJOY_PROGNAME)
ROOTDEPPATH = --dep-path .
# Buttons built-in application info
APPNAME = ajoy
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Common build
include $(APPDIR)/Application.mk
VPATH =
all: .built
.PHONY: context 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

View file

@ -1,7 +1,7 @@
/****************************************************************************
* examplex/ajoystick/ajoy_main.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -114,8 +114,8 @@ static b16_t g_ybslope;
static const char *g_ajoynames[AJOY_NBUTTONS] =
{
"SELECT", "FIRE", "JUMP", "BUTTON 4",
"BUTTON 5", "BUTTON 6", "BUTTON 7", "BUTTON 8",
"SELECT", "FIRE", "JUMP", "BUTTON 4",
"BUTTON 5", "BUTTON 6", "BUTTON 7", "BUTTON 8",
};
/****************************************************************************
@ -196,16 +196,16 @@ static void show_joystick(FAR const struct ajoy_sample_s *sample)
static int ajoy_wait(int fd, FAR const struct timespec *timeout)
{
sigset_t sigset;
sigset_t set;
struct siginfo value;
ajoy_buttonset_t newset;
int ret;
/* Wait for a signal */
(void)sigemptyset(&sigset);
(void)sigaddset(&sigset, CONFIG_EXAMPLES_AJOYSTICK_SIGNO);
ret = sigtimedwait(&sigset, &value, timeout);
(void)sigemptyset(&set);
(void)sigaddset(&set, CONFIG_EXAMPLES_AJOYSTICK_SIGNO);
ret = sigtimedwait(&set, &value, timeout);
if (ret < 0)
{
int errcode = errno;

View file

@ -47,7 +47,7 @@ config EXAMPLES_BRIDGE_NET1_DHCPC
bool "DHCP Client"
default n
select NETUTILS_DHCPC
select NETUTILS_DNSCLIENT
select NETDB_DNSCLIENT
config EXAMPLES_BRIDGE_NET1_NOMAC
bool "Use Canned MAC Address"
@ -129,7 +129,7 @@ config EXAMPLES_BRIDGE_NET2_DHCPC
bool "DHCP Client"
default n
select NETUTILS_DHCPC
select NETUTILS_DNSCLIENT
select NETDB_DNSCLIENT
config EXAMPLES_BRIDGE_NET2_NOMAC
bool "Use Canned MAC Address"

View file

@ -6,6 +6,7 @@
config EXAMPLES_BUTTONS
bool "Buttons example"
default n
depends on ARCH_BUTTONS && BUILD_FLAT
---help---
Enable the buttons example. May require ARCH_BUTTONS on some boards.

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Hello, World! Example
@ -43,95 +41,13 @@ ASRCS =
CSRCS =
MAINSRC = buttons_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
CONFIG_XYZ_PROGNAME ?= buttons$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Buttons built-in application info
APPNAME = buttons
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Common build
VPATH =
all: .built
.PHONY: context 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
include $(APPDIR)/Application.mk

View file

@ -183,7 +183,7 @@ static int button7_handler(int irq, FAR void *context);
* Private Data
****************************************************************************/
/* Button Names */
/* Button Names */
static const struct button_info_s g_buttoninfo[NUM_BUTTONS] =
{

View file

@ -6,9 +6,18 @@
config EXAMPLES_CAN
bool "CAN example"
default n
depends on CAN && LIB_BOARDCTL
select BOARDCTL_CANINIT
---help---
Enable the CAN example
if EXAMPLES_CAN
config EXAMPLES_CAN_NMSGS
int "Number of Messages"
default 32
---help---
The number of CAN messages to send before returning
endif

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# NuttX NX Graphics Example.
@ -43,95 +41,13 @@ ASRCS =
CSRCS =
MAINSRC = can_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
CONFIG_XYZ_PROGNAME ?= can$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Touchscreen built-in application info
APPNAME = can
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Common build
VPATH =
all: .built
.PHONY: context 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
include $(APPDIR)/Application.mk

View file

@ -43,7 +43,7 @@
#include <nuttx/config.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* This test depends on these specific CAN configurations settings (your
@ -97,15 +97,4 @@
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: can_devinit()
*
* Description:
* Perform architecuture-specific initialization of the CAN hardware. This
* interface must be provided by all configurations using apps/examples/can
*
****************************************************************************/
int can_devinit(void);
#endif /* __APPS_EXAMPLES_CAN_CAN_H */

View file

@ -40,6 +40,8 @@
#include <nuttx/config.h>
#include <sys/types.h>
#include <sys/ioctl.h>
#include <sys/boardctl.h>
#include <stdio.h>
#include <stdlib.h>
@ -70,10 +72,17 @@
# define CAN_OFLAGS O_RDWR
#endif
#ifndef CONFIG_EXAMPLES_CAN_NMSGS
# define CONFIG_EXAMPLES_CAN_NMSGS 32
#endif
#define MAX_EXTID (1 << 29)
#define MAX_STDID (1 << 11)
#ifdef CONFIG_CAN_EXTID
# define MAX_ID (1 << 29)
# define MAX_ID MAX_EXTID
#else
# define MAX_ID (1 << 11)
# define MAX_ID MAX_STDID
#endif
/****************************************************************************
@ -96,6 +105,27 @@
* Private Functions
****************************************************************************/
static void show_usage(FAR const char *progname)
{
#ifdef CONFIG_CAN_EXTID
fprintf(stderr, "USAGE: %s [-s] [-n <nmsgs] [-a <min-id>] [b <max-id>]\n",
progname);
#else
fprintf(stderr, "USAGE: %s [-n <nmsgs] [-a <min-id>] [b <max-id>]\n",
progname);
#endif
fprintf(stderr, "USAGE: %s -h\n",
progname);
fprintf(stderr, "\nWhere:\n");
#ifdef CONFIG_CAN_EXTID
fprintf(stderr, "-s: Use standard IDs. Default: Extended ID\n");
#endif
fprintf(stderr, "-n <nmsgs>: The number of messages to send. Default: 32\n");
fprintf(stderr, "-a <min-id>: The start message id. Default 1\n");
fprintf(stderr, "-b <max-id>: The start message id. Default %d\n", MAX_ID - 1);
fprintf(stderr, "-h: Show this message and exit\n");
}
/****************************************************************************
* Public Functions
****************************************************************************/
@ -110,13 +140,17 @@ int main(int argc, FAR char *argv[])
int can_main(int argc, char *argv[])
#endif
{
struct canioc_bittiming_s bt;
#ifndef CONFIG_EXAMPLES_CAN_READONLY
struct can_msg_s txmsg;
#ifdef CONFIG_CAN_EXTID
bool extended;
uint32_t msgid;
#else
uint16_t msgid;
#endif
long minid;
long maxid;
int msgdlc;
uint8_t msgdata;
#endif
@ -127,174 +161,341 @@ int can_main(int argc, char *argv[])
size_t msgsize;
ssize_t nbytes;
#if defined(CONFIG_NSH_BUILTIN_APPS) || defined(CONFIG_EXAMPLES_CAN_NMSGS)
bool badarg;
bool help;
long nmsgs;
#endif
int option;
int fd;
int errval = 0;
int msgno;
int ret;
int i;
/* If this example is configured as an NX add-on, then limit the number of
* samples that we collect before returning. Otherwise, we never return
*/
/* Parse command line parameters */
#if defined(CONFIG_NSH_BUILTIN_APPS)
nmsgs = CONFIG_EXAMPLES_CAN_NMSGS;
if (argc > 1)
nmsgs = CONFIG_EXAMPLES_CAN_NMSGS;
minid = 1;
maxid = MAX_ID - 1;
#ifdef CONFIG_CAN_EXTID
extended = true;
#endif
badarg = false;
help = false;
#ifdef CONFIG_CAN_EXTID
while ((option = getopt(argc, argv, ":n:a:b:hs")) != ERROR)
#else
while ((option = getopt(argc, argv, ":n:a:b:h")) != ERROR)
#endif
{
nmsgs = strtol(argv[1], NULL, 10);
switch (option)
{
case 'a':
minid = strtol(optarg, NULL, 10);
if (minid < 1 || minid > maxid)
{
fprintf(stderr, "<min-id> out of range\n");
badarg = true;
}
break;
case 'b':
maxid = strtol(optarg, NULL, 10);
if (maxid < minid || maxid >= MAX_ID)
{
fprintf(stderr, "ERROR: <max-id> out of range\n");
badarg = true;
}
break;
case 'h':
help = true;
break;
#ifdef CONFIG_CAN_EXTID
case 's':
extended = false;
break;
#endif
case 'n':
nmsgs = strtol(optarg, NULL, 10);
if (nmsgs < 1)
{
fprintf(stderr, "ERROR: <nmsgs> out of range\n");
badarg = true;
}
break;
case ':':
fprintf(stderr, "ERROR: Bad option argument\n");
badarg = true;
break;
case '?':
default:
fprintf(stderr, "ERROR: Unrecognized option\n");
badarg = true;
break;
}
}
printf("can_main: nmsgs: %ld\n", nmsgs);
#elif defined(CONFIG_EXAMPLES_CAN_NMSGS)
printf("can_main: nmsgs: %d\n", CONFIG_EXAMPLES_CAN_NMSGS);
if (badarg)
{
show_usage(argv[0]);
return EXIT_FAILURE;
}
if (help)
{
show_usage(argv[0]);
return EXIT_SUCCESS;
}
#ifdef CONFIG_CAN_EXTID
if (!extended && maxid >= MAX_STDID)
{
maxid = MAX_STDID - 1;
if (minid > maxid)
{
minid = maxid;
}
}
#endif
if (optind != argc)
{
fprintf(stderr, "ERROR: Garbage on command line\n");
show_usage(argv[0]);
return EXIT_FAILURE;
}
printf("nmsgs: %d min ID: %d max ID: %d\n", nmsgs, minid, maxid);
/* Initialization of the CAN hardware is performed by logic external to
* this test.
*/
printf("can_main: Initializing external CAN device\n");
ret = can_devinit();
ret = boardctl(BOARDIOC_CAN_INITIALIZE, 0);
if (ret != OK)
{
printf("can_main: can_devinit failed: %d\n", ret);
printf("ERROR: BOARDIOC_CAN_INITIALIZE failed: %d\n", ret);
errval = 1;
goto errout;
}
/* Open the CAN device for reading */
printf("can_main: Hardware initialized. Opening the CAN device\n");
fd = open(CONFIG_EXAMPLES_CAN_DEVPATH, CAN_OFLAGS);
if (fd < 0)
{
printf("can_main: open %s failed: %d\n",
printf("ERROR: open %s failed: %d\n",
CONFIG_EXAMPLES_CAN_DEVPATH, errno);
errval = 2;
goto errout_with_dev;
}
/* Show bit timing information .. if provided by the driver. Not all CAN
* drivers will support this IOCTL.
*/
ret = ioctl(fd, CANIOC_GET_BITTIMING, (unsigned long)((uintptr_t)&bt));
if (ret < 0)
{
printf("Bit timing not available: %d\n", errno);
}
else
{
printf("Bit timing:\n");
printf(" Baud: %lu\n", (unsigned long)bt.bt_baud);
printf(" TSEG1: %u\n", bt.bt_tseg1);
printf(" TSEG2: %u\n", bt.bt_tseg2);
printf(" SJW: %u\n", bt.bt_sjw);
}
/* Now loop the appropriate number of times, performing one loopback test
* on each pass.
*/
#ifndef CONFIG_EXAMPLES_CAN_READONLY
msgdlc = 1;
msgid = 1;
msgid = minid;
msgdata = 0;
#endif
#if defined(CONFIG_NSH_BUILTIN_APPS)
for (; nmsgs > 0; nmsgs--)
#elif defined(CONFIG_EXAMPLES_CAN_NMSGS)
for (nmsgs = 0; nmsgs < CONFIG_EXAMPLES_CAN_NMSGS; nmsgs++)
#else
for (;;)
#endif
{
/* Flush any output before the loop entered or from the previous pass
* through the loop.
*/
for (msgno = 0; msgno < nmsgs; msgno++)
{
/* Flush any output before the loop entered or from the previous pass
* through the loop.
*/
fflush(stdout);
fflush(stdout);
/* Construct the next TX message */
/* Construct the next TX message */
#ifndef CONFIG_EXAMPLES_CAN_READONLY
txmsg.cm_hdr.ch_id = msgid;
txmsg.cm_hdr.ch_rtr = false;
txmsg.cm_hdr.ch_dlc = msgdlc;
txmsg.cm_hdr.ch_id = msgid;
txmsg.cm_hdr.ch_rtr = false;
txmsg.cm_hdr.ch_dlc = msgdlc;
txmsg.cm_hdr.ch_error = 0;
#ifdef CONFIG_CAN_EXTID
txmsg.cm_hdr.ch_extid = true;
txmsg.cm_hdr.ch_extid = extended;
#endif
txmsg.cm_hdr.ch_unused = 0;
for (i = 0; i < msgdlc; i++)
{
txmsg.cm_data[i] = msgdata + i;
}
for (i = 0; i < msgdlc; i++)
{
txmsg.cm_data[i] = msgdata + i;
}
/* Send the TX message */
/* Send the TX message */
msgsize = CAN_MSGLEN(msgdlc);
nbytes = write(fd, &txmsg, msgsize);
if (nbytes != msgsize)
{
printf("ERROR: write(%ld) returned %ld\n", (long)msgsize, (long)nbytes);
errval = 3;
goto errout_with_dev;
}
msgsize = CAN_MSGLEN(msgdlc);
nbytes = write(fd, &txmsg, msgsize);
if (nbytes != msgsize)
{
printf("ERROR: write(%ld) returned %ld\n",
(long)msgsize, (long)nbytes);
errval = 3;
goto errout_with_dev;
}
#endif
#ifdef CONFIG_EXAMPLES_CAN_WRITEONLY
printf(" ID: %4u DLC: %d\n", msgid, msgdlc);
printf(" ID: %4u DLC: %d\n", msgid, msgdlc);
#endif
/* Read the RX message */
/* Read the RX message */
#ifndef CONFIG_EXAMPLES_CAN_WRITEONLY
msgsize = sizeof(struct can_msg_s);
nbytes = read(fd, &rxmsg, msgsize);
if (nbytes < CAN_MSGLEN(0) || nbytes > msgsize)
{
printf("ERROR: read(%ld) returned %ld\n", (long)msgsize, (long)nbytes);
errval = 4;
goto errout_with_dev;
}
msgsize = sizeof(struct can_msg_s);
nbytes = read(fd, &rxmsg, msgsize);
if (nbytes < CAN_MSGLEN(0) || nbytes > msgsize)
{
printf("ERROR: read(%ld) returned %ld\n",
(long)msgsize, (long)nbytes);
errval = 4;
goto errout_with_dev;
}
#endif
#ifndef CONFIG_EXAMPLES_CAN_READONLY
printf(" ID: %4u DLC: %u\n", rxmsg.cm_hdr.ch_id, rxmsg.cm_hdr.ch_dlc);
printf(" ID: %4u DLC: %u\n",
rxmsg.cm_hdr.ch_id, rxmsg.cm_hdr.ch_dlc);
#endif
/* Verify that the received messages are the same */
/* Check for error reports */
#ifndef CONFIG_EXAMPLES_CAN_WRITEONLY
if (rxmsg.cm_hdr.ch_error != 0)
{
printf("ERROR: CAN error report: [%04x]\n", rxmsg.cm_hdr.ch_id);
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_SYSTEM) != 0)
{
printf(" Driver internal error\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_RXLOST) != 0)
{
printf(" RX Message Lost\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_TXLOST) != 0)
{
printf(" TX Message Lost\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_ACCESS) != 0)
{
printf(" RAM Access Failure\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_TIMEOUT) != 0)
{
printf(" Timeout Occurred\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_PASSIVE) != 0)
{
printf(" Error Passive\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_CRC) != 0)
{
printf(" RX CRC Error\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_BIT) != 0)
{
printf(" Bit Error\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_ACK) != 0)
{
printf(" Acknowledge Error\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_FORMAT) != 0)
{
printf(" Format Error\n");
}
if ((rxmsg.cm_hdr.ch_id & CAN_ERROR_STUFF) != 0)
{
printf(" Stuff Error\n");
}
}
else
{
/* Verify that the received messages are the same */
#ifdef CONFIG_EXAMPLES_CAN_READWRITE
if (memcmp(&txmsg.cm_hdr, &rxmsg.cm_hdr, sizeof(struct can_hdr_s)) != 0)
{
printf("ERROR: Sent header does not match received header:\n");
lib_dumpbuffer("Sent header", (FAR const uint8_t*)&txmsg.cm_hdr,
sizeof(struct can_hdr_s));
lib_dumpbuffer("Received header", (FAR const uint8_t*)&rxmsg.cm_hdr,
sizeof(struct can_hdr_s));
errval = 4;
goto errout_with_dev;
}
if (memcmp(&txmsg.cm_hdr, &rxmsg.cm_hdr, sizeof(struct can_hdr_s)) != 0)
{
printf("ERROR: Sent header does not match received header:\n");
lib_dumpbuffer("Sent header", (FAR const uint8_t*)&txmsg.cm_hdr,
sizeof(struct can_hdr_s));
lib_dumpbuffer("Received header", (FAR const uint8_t*)&rxmsg.cm_hdr,
sizeof(struct can_hdr_s));
errval = 4;
goto errout_with_dev;
}
if (memcmp(txmsg.cm_data, rxmsg.cm_data, msgdlc) != 0)
{
printf("ERROR: Data does not match. DLC=%d\n", msgdlc);
for (i = 0; i < msgdlc; i++)
{
printf(" %d: TX %02x RX %02x\n", i, txmsg.cm_data[i], rxmsg.cm_data[i]);
errval = 5;
goto errout_with_dev;
}
}
/* Report success */
printf(" ID: %4u DLC: %d -- OK\n", msgid, msgdlc);
if (memcmp(txmsg.cm_data, rxmsg.cm_data, msgdlc) != 0)
{
printf("ERROR: Data does not match. DLC=%d\n", msgdlc);
for (i = 0; i < msgdlc; i++)
{
printf(" %d: TX %02x RX %02x\n",
i, txmsg.cm_data[i], rxmsg.cm_data[i]);
errval = 5;
goto errout_with_dev;
}
}
}
#endif
/* Set up for the next pass */
/* Report success */
printf(" ID: %4u DLC: %d -- OK\n", msgid, msgdlc);
#endif
/* Set up for the next pass */
#ifndef CONFIG_EXAMPLES_CAN_READONLY
msgdata += msgdlc;
msgdata += msgdlc;
if (++msgid >= MAX_ID)
{
msgid = 1;
}
if (++msgid > maxid)
{
msgid = minid;
}
if (++msgdlc > CAN_MAXDATALEN)
{
msgdlc = 1;
}
if (++msgdlc > CAN_MAXDATALEN)
{
msgdlc = 1;
}
#endif
}
}
errout_with_dev:
close(fd);

View file

@ -1,31 +1,36 @@
/**************************************************************************
*
* This file is part of the ArduinoCC3000 library.
/****************************************************************************
* This file is part of the ArduinoCC3000 library.
* Version 1.0.1b
*
* Copyright (C) 2013 Chris Magagna - cmagagna@yahoo.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Don't sue me if my code blows up your board and burns down your house
*
* This file is the main module for the Arduino CC3000 library.
* Your program must call CC3000_Init() before any other API calls.
*
****************************************************************************/
* Version 1.0.1b
*
* Copyright (C) 2013 Chris Magagna - cmagagna@yahoo.com
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
*
* Don't sue me if my code blows up your board and burns down your house
*
* This file is the main module for the Arduino CC3000 library.
* Your program must call CC3000_Init() before any other API calls.
*
****************************************************************************/
/*
Some things are different for the Teensy 3.0, so set a flag if we're using
that hardware.
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Some things are different for the Teensy 3.0, so set a flag if we're using
* that hardware.
*/
#if defined(__arm__) && defined(CORE_TEENSY) && defined(__MK20DX128__)
#define TEENSY3 1
# define TEENSY3 1
#endif
/* I used the Teensy 3.0 to get the Arduino CC3000 library working but the
@ -35,9 +40,9 @@
your wiring is OK then try changing this. */
#ifdef TEENSY3
#define USE_HARDWARE_SPI false
#define USE_HARDWARE_SPI false
#else
#define USE_HARDWARE_SPI true
#define USE_HARDWARE_SPI true
#endif
// These are the Arduino pins that connect to the CC3000
@ -48,102 +53,114 @@
#ifndef TEENSY3
#define WLAN_CS 10 // Arduino pin connected to CC3000 WLAN_SPI_CS
#define WLAN_EN 9 // Arduino pin connected to CC3000 VBAT_SW_EN
#define WLAN_IRQ 3 // Arduino pin connected to CC3000 WLAN_SPI_IRQ
#define WLAN_IRQ_INTNUM 1 // The attachInterrupt() number that corresponds
// to WLAN_IRQ
#define WLAN_MOSI MOSI
#define WLAN_MISO MISO
#define WLAN_SCK SCK
#define WLAN_CS 10 // Arduino pin connected to CC3000 WLAN_SPI_CS
#define WLAN_EN 9 // Arduino pin connected to CC3000 VBAT_SW_EN
#define WLAN_IRQ 3 // Arduino pin connected to CC3000 WLAN_SPI_IRQ
#define WLAN_IRQ_INTNUM 1 // The attachInterrupt() number that corresponds
// to WLAN_IRQ
#define WLAN_MOSI MOSI
#define WLAN_MISO MISO
#define WLAN_SCK SCK
#else
#define WLAN_CS 25
#define WLAN_MISO 26
#define WLAN_IRQ 27
#define WLAN_IRQ_INTNUM 27 // On the Teensy 3.0 the interrupt # is the same as the pin #
#define WLAN_MOSI 28
#define WLAN_SCK 29
#define WLAN_EN 30
#define WLAN_CS 25
#define WLAN_MISO 26
#define WLAN_IRQ 27
#define WLAN_IRQ_INTNUM 27 // On the Teensy 3.0 the interrupt # is the same as the pin #
#define WLAN_MOSI 28
#define WLAN_SCK 29
#define WLAN_EN 30
#endif
/*
The timing between setting the CS pin and reading the IRQ pin is very
tight on the CC3000, and sometimes the default Arduino digitalRead()
and digitalWrite() functions are just too slow.
For many of the CC3000 library functions this isn't a big deal because the
IRQ pin is tied to an interrupt routine but some of them of them disable
the interrupt routine and read the pins directly. Because digitalRead()
/ Write() are so slow once in a while the Arduino will be in the middle of
its pin code and the CC3000 will flip another pin's state and it will be
missed, and everything locks up.
The upshot of all of this is we need to read & write the pin states
directly, which is very fast compared to the built in Arduino functions.
The Teensy 3.0's library has built in macros called digitalReadFast()
& digitalWriteFast() that compile down to direct port manipulations but
are still readable, so use those if possible.
There's a digitalReadFast() / digitalWriteFast() library for Arduino but
it looks like it hasn't been updated since 2010 so I think it's best to
just use the direct port manipulations.
*/
/* The timing between setting the CS pin and reading the IRQ pin is very
* tight on the CC3000, and sometimes the default Arduino digitalRead()
* and digitalWrite() functions are just too slow.
*
* For many of the CC3000 library functions this isn't a big deal because the
* IRQ pin is tied to an interrupt routine but some of them of them disable
* the interrupt routine and read the pins directly. Because digitalRead()
* / Write() are so slow once in a while the Arduino will be in the middle of
* its pin code and the CC3000 will flip another pin's state and it will be
* missed, and everything locks up.
*
* The upshot of all of this is we need to read & write the pin states
* directly, which is very fast compared to the built in Arduino functions.
*
* The Teensy 3.0's library has built in macros called digitalReadFast()
* & digitalWriteFast() that compile down to direct port manipulations but
* are still readable, so use those if possible.
*
* There's a digitalReadFast() / digitalWriteFast() library for Arduino but
* it looks like it hasn't been updated since 2010 so I think it's best to
* just use the direct port manipulations.
*/
#ifdef TEENSY3
#define Read_CC3000_IRQ_Pin() digitalReadFast(WLAN_IRQ)
#define Set_CC3000_CS_NotActive() digitalWriteFast(WLAN_CS, HIGH)
#define Set_CC3000_CS_Active() digitalWriteFast(WLAN_CS, LOW)
#define Read_CC3000_IRQ_Pin() digitalReadFast(WLAN_IRQ)
#define Set_CC3000_CS_NotActive() digitalWriteFast(WLAN_CS, HIGH)
#define Set_CC3000_CS_Active() digitalWriteFast(WLAN_CS, LOW)
#else
// This is hardcoded for an ATMega328 and pin 3. You will need to change this
// for other MCUs or pins
#define Read_CC3000_IRQ_Pin() ((PIND & B00001000) ? 1 : 0)
#define Read_CC3000_IRQ_Pin() ((PIND & B00001000) ? 1 : 0)
// This is hardcoded for an ATMega328 and pin 10. You will need to change this
// for other MCUs or pins
#define Set_CC3000_CS_NotActive() PORTB |= B00000100
#define Set_CC3000_CS_Active() PORTB &= B11111011
#define Set_CC3000_CS_NotActive() PORTB |= B00000100
#define Set_CC3000_CS_Active() PORTB &= B11111011
#endif
#define MAC_ADDR_LEN 6
#define DISABLE (0)
#define ENABLE (1)
#define MAC_ADDR_LEN 6
#define DISABLE (0)
#define ENABLE (1)
//AES key "smartconfigAES16"
//const uint8_t smartconfigkey[] = {0x73,0x6d,0x61,0x72,0x74,0x63,0x6f,0x6e,0x66,0x69,0x67,0x41,0x45,0x53,0x31,0x36};
/****************************************************************************
* Public Data
****************************************************************************/
#if 0
/* AES key "smartconfigAES16" */
const uint8_t smartconfigkey[] =
{
0x73, 0x6d, 0x61, 0x72, 0x74, 0x63, 0x6f, 0x6e,
0x66, 0x69, 0x67, 0x41, 0x45, 0x53, 0x31, 0x36
};
#endif
/* If you uncomment the line below the library will leave out a lot of the
higher level functions but use a lot less memory. From:
* higher level functions but use a lot less memory. From:
*
* http://processors.wiki.ti.com/index.php/Tiny_Driver_Support
*
* CC3000's new driver has flexible memory compile options.
*
* This feature comes in handy when we want to use a limited RAM size MCU.
*
* Using The Tiny Driver Compilation option will create a tiny version of our
* host driver with lower data, stack and code consumption.
*
* By enabling this feature, host driver's RAM consumption can be reduced to
* minimum of 251 bytes.
*
* The Tiny host driver version will limit the host driver API to the most
* essential ones.
*
* Code size depends on actual APIs used.
*
* RAM size depends on the largest packet sent and received.
*
* CC3000 can now be used with ultra low cost MCUs, consuming 251 byte of RAM
* and 2K to 6K byte of code size, depending on the API usage.
*/
http://processors.wiki.ti.com/index.php/Tiny_Driver_Support
CC3000's new driver has flexible memory compile options.
This feature comes in handy when we want to use a limited RAM size MCU.
Using The Tiny Driver Compilation option will create a tiny version of our
host driver with lower data, stack and code consumption.
By enabling this feature, host driver's RAM consumption can be reduced to
minimum of 251 bytes.
The Tiny host driver version will limit the host driver API to the most
essential ones.
Code size depends on actual APIs used.
RAM size depends on the largest packet sent and received.
CC3000 can now be used with ultra low cost MCUs, consuming 251 byte of RAM
and 2K to 6K byte of code size, depending on the API usage. */
//#define CC3000_TINY_DRIVER 1
//#define CC3000_TINY_DRIVER 1
extern uint8_t asyncNotificationWaiting;
extern long lastAsyncEvent;
@ -155,4 +172,8 @@ extern volatile unsigned long OkToDoShutDown;
extern volatile unsigned long ulCC3000DHCP_configured;
extern volatile uint8_t ucStopSmartConfig;
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
void CC3000_Init(void);

View file

@ -1,4 +1,4 @@
/***************************************************************************
/****************************************************************************
* apps/examples/cc3000basic.c
*
* Derives from an application to demo an Arduino connected to the TI CC3000
@ -102,7 +102,7 @@
* 11 860 844 Telnet sd
*/
#include <nuttx/config.h>
#include <nuttx/config.h>
#include "board.h"
#include <stdio.h>

View file

@ -54,7 +54,7 @@
#include <apps/nsh.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# CONFIGDATA Unit Test
@ -43,82 +41,7 @@ ASRCS =
CSRCS =
MAINSRC = configdata_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
CONFIG_XYZ_PROGNAME ?= configdata$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
context:
.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
include $(APPDIR)/Application.mk

View file

@ -55,7 +55,7 @@
#include <sys/ioctl.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# do nothing loop to use up cpu time
@ -43,38 +41,9 @@ ASRCS =
CSRCS =
MAINSRC = cpuhog_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
CONFIG_XYZ_PROGNAME ?= cpuhog$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Built-in application info
CONFIG_EXAMPLES_CPUHOG_PRIORITY ?= 50
@ -84,57 +53,4 @@ APPNAME = cpuhog
PRIORITY = $(CONFIG_EXAMPLES_CPUHOG_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_CPUHOG_STACKSIZE)
# 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
include $(APPDIR)/Application.mk

View file

@ -20,6 +20,6 @@ config EXAMPLES_CXXTEST_CXXINITIALIZE
By default, if CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE are
defined, then this example will call the NuttX function to
initialize static C++ constructors. This option may be disabled,
however, if that static initialization was preformed elsewhere.
however, if that static initialization was performed elsewhere.
endif

View file

@ -33,117 +33,22 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# CXX test program
ASRCS =
CSRCS =
CXXSRCS =
CXXSRCS =
MAINSRC = cxxtest_main.cxx
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
MAINOBJ = $(MAINSRC:.cxx=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS)
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
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
CONFIG_XYZ_PROGNAME ?= cxxtest$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
ROOTDEPPATH = --dep-path .
# cxxtest built-in application info
APPNAME = cxxtest
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 4096
# Common build
VPATH =
all: .built
.PHONY: clean depend distclean chkcxx
chkcxx:
ifneq ($(CONFIG_HAVE_CXX),y)
@echo ""
@echo "In order to use this example, you toolchain must support must"
@echo ""
@echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
@echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
@echo " of the configuration that you are using."
@echo ""
@exit 1
endif
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
$(CXXOBJS) $(MAINOBJ): %$(OBJEXT): %.cxx
$(call COMPILEXX, $<, $@)
.built: chkcxx $(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) "$(CXX)" -- $(CXXFLAGS) -- $(SRCS) >Make.dep
@touch $@
depend: .depend
clean:
$(call DELFILE, .built)
$(call CLEAN)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep
include $(APPDIR)/Application.mk

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# DHCP Daemon Example
@ -43,96 +41,13 @@ ASRCS =
CSRCS =
MAINSRC = target.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
CONFIG_XYZ_PROGNAME ?= dhcpd$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# DHCPD built-in application info
APPNAME = dhcpd
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# 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
include $(APPDIR)/Application.mk

View file

@ -22,7 +22,7 @@ config EXAMPLES_DISCOVER_DHCPC
default n
depends on EXAMPLES_DISCOVER && !NSH_BUILTIN_APPS
select NETUTILS_DHCPC
select NETUTILS_DNSCLIENT
select NETDB_DNSCLIENT
config EXAMPLES_DISCOVER_NOMAC
bool "Use Canned MAC Address"

View file

@ -36,9 +36,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Discover built-in application info
@ -50,89 +48,7 @@ ASRCS =
CSRCS =
MAINSRC = discover_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
CONFIG_XYZ_PROGNAME ?= discover$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Hello, World! Example
@ -43,95 +41,13 @@ ASRCS =
CSRCS =
MAINSRC = djoy_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
CONFIG_DJOY_PROGNAME ?= djoy$(EXEEXT)
PROGNAME = $(CONFIG_DJOY_PROGNAME)
ROOTDEPPATH = --dep-path .
# Buttons built-in application info
APPNAME = djoy
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Common build
VPATH =
all: .built
.PHONY: context 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
include $(APPDIR)/Application.mk

View file

@ -1,7 +1,7 @@
/****************************************************************************
* examplex/djoystick/djoy_main.c
*
* Copyright (C) 2014 Gregory Nutt. All rights reserved.
* Copyright (C) 2014-2015 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
@ -95,7 +95,7 @@ static djoy_buttonset_t g_djoylast;
static const char *g_djoynames[DJOY_NDISCRETES] =
{
"UP", "DOWN", "LEFT", "RIGHT", "SELECT", "FIRE", "JUMP", "RUN"
"UP", "DOWN", "LEFT", "RIGHT", "SELECT", "FIRE", "JUMP", "RUN"
};
/****************************************************************************
@ -204,15 +204,15 @@ int djoy_main(int argc, char *argv[])
#endif
{
struct siginfo value;
sigset_t sigset;
sigset_t set;
djoy_buttonset_t newset;
ssize_t nread;
/* Wait for a signal */
(void)sigemptyset(&sigset);
(void)sigaddset(&sigset, CONFIG_EXAMPLES_DJOYSTICK_SIGNO);
ret = sigwaitinfo(&sigset, &value);
(void)sigemptyset(&set);
(void)sigaddset(&set, CONFIG_EXAMPLES_DJOYSTICK_SIGNO);
ret = sigwaitinfo(&set, &value);
if (ret < 0)
{
fprintf(stderr, "ERROR: sigwaitinfo() failed: %d\n", errno);
@ -240,7 +240,7 @@ int djoy_main(int argc, char *argv[])
(long)nread, sizeof(djoy_buttonset_t));
goto errout_with_fd;
}
/* Show the set of joystick discretes that we just read */
printf("Read set\n");

View file

@ -59,7 +59,7 @@
#include "tests/dirlist.h"
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Check configuration. This is not all of the configuration settings that

View file

@ -68,7 +68,7 @@ int main(int argc, char **argv)
if (test_stream)
{
fprintf(stderr, "Hmm... Delete \"%s\" and try this again\n",
g_nonexistent);
g_nonexistent);
exit(1);
}
@ -77,7 +77,7 @@ int main(int argc, char **argv)
*/
fprintf(stderr, "We failed to open \"%s!\" errno is %d\n",
g_nonexistent, errno);
g_nonexistent, errno);
return 0;
}

View file

@ -1,7 +1,7 @@
/****************************************************************************
* examples/elf/tests/signal/signal.c
*
* Copyright (C) 2012 Gregory Nutt. All rights reserved.
* 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
@ -47,7 +47,7 @@
#include <errno.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
#define USEC_PER_MSEC 1000
@ -68,7 +68,7 @@ static int sigusr2_rcvd = 0;
/****************************************************************************
* Name: siguser_action
***************************************************************************/
****************************************************************************/
/* NOTE: it is necessary for functions that are referred to by function pointers
* pointer to be declared with global scope (at least for ARM). Otherwise,
@ -100,6 +100,7 @@ void siguser_action(int signo, siginfo_t *siginfo, void *arg)
printf("siginfo:\n");
printf(" si_signo = %d\n", siginfo->si_signo);
printf(" si_code = %d\n", siginfo->si_code);
printf(" si_errno = %d\n", siginfo->si_errno);
printf(" si_value = %d\n", siginfo->si_value.sival_int);
}
}

View file

@ -67,7 +67,7 @@ static char no_name[] = "<noname>";
* a relocation type that is not supported by ELF is generated by GCC.
*/
int child_task(int argc, char **argv)
int child_task(int argc, char **argv)
{
printf("Child: execv was successful!\n");
printf("Child: argc=%d\n", argc);

View file

@ -34,9 +34,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
ifeq ($(WINTOOL),y)
INCDIROPT = -w
@ -52,93 +50,7 @@ ASRCS =
CSRCS =
MAINSRC = flash_test.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
CONFIG_XYZ_PROGNAME ?= flash_test$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Common build
VPATH =
all: .built
.PHONY: context depend clean distclean
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
.built: $(OBJS)
$(call ARCHIVE, $(BIN), $(OBJS))
$(Q) 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
# Register application
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
# Create dependencies
.depend: Makefile $(SRCS)
$(Q) $(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(SRCS) >Make.dep
$(Q) touch $@
depend: .depend
clean:
$(call DELFILE, .built)
$(call CLEAN)
distclean: clean
$(call DELFILE, Make.dep)
$(call DELFILE, .depend)
-include Make.dep
include $(APPDIR)/Application.mk

11
examples/fstest/.gitignore vendored Normal file
View file

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

47
examples/fstest/Kconfig Normal file
View file

@ -0,0 +1,47 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
config EXAMPLES_FSTEST
bool "Generic file system test"
default n
depends on FS_READABLE && FS_WRITABLE
---help---
Enable the generic file system test
if EXAMPLES_FSTEST
config EXAMPLES_FSTEST_MAXNAME
int "Max name size"
default 32
range 1 255
---help---
Determines the maximum size of names used in the filesystem
config EXAMPLES_FSTEST_MAXFILE
int "Max file size"
default 8192
---help---
Determines the maximum size of a file
config EXAMPLES_FSTEST_MAXIO
int "Max I/O"
default 347
config EXAMPLES_FSTEST_MAXOPEN
int "Max open files"
default 512
config EXAMPLES_FSTEST_MOUNTPT
string "FSTEST mountpoint"
config EXAMPLES_FSTEST_NLOOPS
int "Number of test loops"
default 100
config EXAMPLES_FSTEST_VERBOSE
bool "Verbose output"
default n
endif

39
examples/fstest/Make.defs Normal file
View file

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

53
examples/fstest/Makefile Normal file
View file

@ -0,0 +1,53 @@
############################################################################
# apps/examples/fstest/Makefile
#
# Copyright (C) 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.
#
############################################################################
-include $(TOPDIR)/Make.defs
# Generic file system stress test appliation info
APPNAME = fstest
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Generic file system stress test
ASRCS =
CSRCS =
MAINSRC = fstest_main.c
CONFIG_XYZ_PROGNAME ?= fstest$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,873 @@
/****************************************************************************
* examples/fstest/fstest_main.c
*
* Copyright (C) 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 <sys/mount.h>
#include <stdint.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <fcntl.h>
#include <dirent.h>
#include <string.h>
#include <errno.h>
#include <crc32.h>
#include <debug.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
#ifndef CONFIG_EXAMPLES_FSTEST_MAXNAME
# define CONFIG_EXAMPLES_FSTEST_MAXNAME 128
#endif
#if CONFIG_EXAMPLES_FSTEST_MAXNAME > 255
# undef CONFIG_EXAMPLES_FSTEST_MAXNAME
# define CONFIG_EXAMPLES_FSTEST_MAXNAME 255
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MAXFILE
# define CONFIG_EXAMPLES_FSTEST_MAXFILE 8192
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MAXIO
# define CONFIG_EXAMPLES_FSTEST_MAXIO 347
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MAXOPEN
# define CONFIG_EXAMPLES_FSTEST_MAXOPEN 512
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_MOUNTPT
# error CONFIG_EXAMPLES_FSTEST_MOUNTPT must be provided
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_NLOOPS
# define CONFIG_EXAMPLES_FSTEST_NLOOPS 100
#endif
#ifndef CONFIG_EXAMPLES_FSTEST_VERBOSE
# define CONFIG_EXAMPLES_FSTEST_VERBOSE 0
#endif
/****************************************************************************
* Private Types
****************************************************************************/
struct fstest_filedesc_s
{
FAR char *name;
bool deleted;
size_t len;
uint32_t crc;
};
/****************************************************************************
* Private Data
****************************************************************************/
/* Pre-allocated simulated flash */
static uint8_t g_fileimage[CONFIG_EXAMPLES_FSTEST_MAXFILE];
static struct fstest_filedesc_s g_files[CONFIG_EXAMPLES_FSTEST_MAXOPEN];
static const char g_mountdir[] = CONFIG_EXAMPLES_FSTEST_MOUNTPT "/";
static int g_nfiles;
static int g_ndeleted;
static struct mallinfo g_mmbefore;
static struct mallinfo g_mmprevious;
static struct mallinfo g_mmafter;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: fstest_memusage
****************************************************************************/
static void fstest_showmemusage(struct mallinfo *mmbefore,
struct mallinfo *mmafter)
{
printf("VARIABLE BEFORE AFTER\n");
printf("======== ======== ========\n");
printf("arena %8x %8x\n", mmbefore->arena, mmafter->arena);
printf("ordblks %8d %8d\n", mmbefore->ordblks, mmafter->ordblks);
printf("mxordblk %8x %8x\n", mmbefore->mxordblk, mmafter->mxordblk);
printf("uordblks %8x %8x\n", mmbefore->uordblks, mmafter->uordblks);
printf("fordblks %8x %8x\n", mmbefore->fordblks, mmafter->fordblks);
}
/****************************************************************************
* Name: fstest_loopmemusage
****************************************************************************/
static void fstest_loopmemusage(void)
{
/* Get the current memory usage */
#ifdef CONFIG_CAN_PASS_STRUCTS
g_mmafter = mallinfo();
#else
(void)mallinfo(&g_mmafter);
#endif
/* Show the change from the previous loop */
printf("\nEnd of loop memory usage:\n");
fstest_showmemusage(&g_mmprevious, &g_mmafter);
/* Set up for the next test */
#ifdef CONFIG_CAN_PASS_STRUCTS
g_mmprevious = g_mmafter;
#else
memcpy(&g_mmprevious, &g_mmafter, sizeof(struct mallinfo));
#endif
}
/****************************************************************************
* Name: fstest_endmemusage
****************************************************************************/
static void fstest_endmemusage(void)
{
#ifdef CONFIG_CAN_PASS_STRUCTS
g_mmafter = mallinfo();
#else
(void)mallinfo(&g_mmafter);
#endif
printf("\nFinal memory usage:\n");
fstest_showmemusage(&g_mmbefore, &g_mmafter);
}
/****************************************************************************
* Name: fstest_randchar
****************************************************************************/
static inline char fstest_randchar(void)
{
int value = rand() % 63;
if (value == 0)
{
return '0';
}
else if (value <= 10)
{
return value + '0' - 1;
}
else if (value <= 36)
{
return value + 'a' - 11;
}
else /* if (value <= 62) */
{
return value + 'A' - 37;
}
}
/****************************************************************************
* Name: fstest_randname
****************************************************************************/
static inline void fstest_randname(FAR struct fstest_filedesc_s *file)
{
int dirlen;
int maxname;
int namelen;
int alloclen;
int i;
dirlen = strlen(g_mountdir);
maxname = CONFIG_EXAMPLES_FSTEST_MAXNAME - dirlen;
namelen = (rand() % maxname) + 1;
alloclen = namelen + dirlen;
file->name = (FAR char*)malloc(alloclen + 1);
if (!file->name)
{
printf("ERROR: Failed to allocate name, length=%d\n", namelen);
fflush(stdout);
exit(5);
}
memcpy(file->name, g_mountdir, dirlen);
for (i = dirlen; i < alloclen; i++)
{
file->name[i] = fstest_randchar();
}
file->name[alloclen] = '\0';
}
/****************************************************************************
* Name: fstest_randfile
****************************************************************************/
static inline void fstest_randfile(FAR struct fstest_filedesc_s *file)
{
int i;
file->len = (rand() % CONFIG_EXAMPLES_FSTEST_MAXFILE) + 1;
for (i = 0; i < file->len; i++)
{
g_fileimage[i] = fstest_randchar();
}
file->crc = crc32(g_fileimage, file->len);
}
/****************************************************************************
* Name: fstest_freefile
****************************************************************************/
static void fstest_freefile(FAR struct fstest_filedesc_s *file)
{
if (file->name)
{
free(file->name);
}
memset(file, 0, sizeof(struct fstest_filedesc_s));
}
/****************************************************************************
* Name: fstest_wrfile
****************************************************************************/
static inline int fstest_wrfile(FAR struct fstest_filedesc_s *file)
{
size_t offset;
int fd;
int ret;
/* Create a random file */
fstest_randname(file);
fstest_randfile(file);
fd = open(file->name, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (fd < 0)
{
/* If it failed because there is no space on the device, then don't
* complain.
*/
if (errno != ENOSPC)
{
printf("ERROR: Failed to open file for writing: %d\n", errno);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
}
fstest_freefile(file);
return ERROR;
}
/* Write a random amount of data to the file */
for (offset = 0; offset < file->len; )
{
size_t maxio = (rand() % CONFIG_EXAMPLES_FSTEST_MAXIO) + 1;
size_t nbytestowrite = file->len - offset;
ssize_t nbyteswritten;
if (nbytestowrite > maxio)
{
nbytestowrite = maxio;
}
nbyteswritten = write(fd, &g_fileimage[offset], nbytestowrite);
if (nbyteswritten < 0)
{
int err = errno;
/* If the write failed because there is no space on the device,
* then don't complain.
*/
if (err != ENOSPC)
{
printf("ERROR: Failed to write file: %d\n", err);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" Write offset: %ld\n", (long)offset);
printf(" Write size: %ld\n", (long)nbytestowrite);
ret = ERROR;
}
close(fd);
/* Remove any garbage file that might have been left behind */
ret = unlink(file->name);
if (ret < 0)
{
printf(" Failed to remove partial file\n");
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf(" Successfully removed partial file\n");
#endif
}
fstest_freefile(file);
return ERROR;
}
else if (nbyteswritten != nbytestowrite)
{
printf("ERROR: Partial write:\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" Write offset: %ld\n", (long)offset);
printf(" Write size: %ld\n", (long)nbytestowrite);
printf(" Written: %ld\n", (long)nbyteswritten);
}
offset += nbyteswritten;
}
close(fd);
return OK;
}
/****************************************************************************
* Name: fstest_fillfs
****************************************************************************/
static int fstest_fillfs(void)
{
FAR struct fstest_filedesc_s *file;
int ret;
int i;
/* Create a file for each unused file structure */
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name == NULL)
{
ret = fstest_wrfile(file);
if (ret < 0)
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf("ERROR: Failed to write file %d\n", i);
#endif
return ERROR;
}
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf(" Created file %s\n", file->name);
#endif
g_nfiles++;
}
}
return OK;
}
/****************************************************************************
* Name: fstest_rdblock
****************************************************************************/
static ssize_t fstest_rdblock(int fd, FAR struct fstest_filedesc_s *file,
size_t offset, size_t len)
{
size_t maxio = (rand() % CONFIG_EXAMPLES_FSTEST_MAXIO) + 1;
ssize_t nbytesread;
if (len > maxio)
{
len = maxio;
}
nbytesread = read(fd, &g_fileimage[offset], len);
if (nbytesread < 0)
{
printf("ERROR: Failed to read file: %d\n", errno);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" Read offset: %ld\n", (long)offset);
printf(" Read size: %ld\n", (long)len);
return ERROR;
}
else if (nbytesread == 0)
{
#if 0 /* No... we do this on purpose sometimes */
printf("ERROR: Unexpected end-of-file:\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" Read offset: %ld\n", (long)offset);
printf(" Read size: %ld\n", (long)len);
#endif
return ERROR;
}
else if (nbytesread != len)
{
printf("ERROR: Partial read:\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" Read offset: %ld\n", (long)offset);
printf(" Read size: %ld\n", (long)len);
printf(" Bytes read: %ld\n", (long)nbytesread);
}
return nbytesread;
}
/****************************************************************************
* Name: fstest_rdfile
****************************************************************************/
static inline int fstest_rdfile(FAR struct fstest_filedesc_s *file)
{
size_t ntotalread;
ssize_t nbytesread;
uint32_t crc;
int fd;
/* Open the file for reading */
fd = open(file->name, O_RDONLY);
if (fd < 0)
{
if (!file->deleted)
{
printf("ERROR: Failed to open file for reading: %d\n", errno);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
}
return ERROR;
}
/* Read all of the data info the fileimage buffer using random read sizes */
for (ntotalread = 0; ntotalread < file->len; )
{
nbytesread = fstest_rdblock(fd, file, ntotalread, file->len - ntotalread);
if (nbytesread < 0)
{
close(fd);
return ERROR;
}
ntotalread += nbytesread;
}
/* Verify the file image CRC */
crc = crc32(g_fileimage, file->len);
if (crc != file->crc)
{
printf("ERROR: Bad CRC: %d vs %d\n", crc, file->crc);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
close(fd);
return ERROR;
}
/* Try reading past the end of the file */
nbytesread = fstest_rdblock(fd, file, ntotalread, 1024) ;
if (nbytesread > 0)
{
printf("ERROR: Read past the end of file\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" Bytes read: %ld\n", (long)nbytesread);
close(fd);
return ERROR;
}
close(fd);
return OK;
}
/****************************************************************************
* Name: fstest_verifyfs
****************************************************************************/
static int fstest_verifyfs(void)
{
FAR struct fstest_filedesc_s *file;
int ret;
int i;
/* Create a file for each unused file structure */
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name != NULL)
{
ret = fstest_rdfile(file);
if (ret < 0)
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf("Deleted file %d OK\n", i);
#endif
fstest_freefile(file);
g_ndeleted--;
g_nfiles--;
}
else
{
printf("ERROR: Failed to read a file: %d\n", i);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
return ERROR;
}
}
else
{
if (file->deleted)
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf("Succesffully read a deleted file\n");
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
#endif
fstest_freefile(file);
g_ndeleted--;
g_nfiles--;
return ERROR;
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf(" Verifed file %s\n", file->name);
#endif
}
}
}
}
return OK;
}
/****************************************************************************
* Name: fstest_delfiles
****************************************************************************/
static int fstest_delfiles(void)
{
FAR struct fstest_filedesc_s *file;
int ndel;
int ret;
int i;
int j;
/* Are there any files to be deleted? */
int nfiles = g_nfiles - g_ndeleted;
if (nfiles < 1)
{
return 0;
}
/* Yes... How many files should we delete? */
ndel = (rand() % nfiles) + 1;
/* Now pick which files to delete */
for (i = 0; i < ndel; i++)
{
/* Guess a file index */
int ndx = (rand() % (g_nfiles - g_ndeleted));
/* And delete the next undeleted file after that random index. NOTE
* that the entry at ndx is not checked.
*/
for (j = ndx + 1; j != ndx; j++)
{
/* Test for wrap-around */
if (j >= CONFIG_EXAMPLES_FSTEST_MAXOPEN)
{
j = 0;
}
file = &g_files[j];
if (file->name && !file->deleted)
{
ret = unlink(file->name);
if (ret < 0)
{
printf("ERROR: Unlink %d failed: %d\n", i+1, errno);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" File index: %d\n", j);
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
file->deleted = true;
g_ndeleted++;
break;
}
}
}
}
return OK;
}
/****************************************************************************
* Name: fstest_delallfiles
****************************************************************************/
static int fstest_delallfiles(void)
{
FAR struct fstest_filedesc_s *file;
int ret;
int i;
for (i = 0; i < CONFIG_EXAMPLES_FSTEST_MAXOPEN; i++)
{
file = &g_files[i];
if (file->name)
{
ret = unlink(file->name);
if (ret < 0)
{
printf("ERROR: Unlink %d failed: %d\n", i+1, errno);
printf(" File name: %s\n", file->name);
printf(" File size: %d\n", file->len);
printf(" File index: %d\n", i);
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf(" Deleted file %s\n", file->name);
#endif
fstest_freefile(file);
}
}
}
g_nfiles = 0;
g_ndeleted = 0;
return OK;
}
/****************************************************************************
* Name: fstest_directory
****************************************************************************/
static int fstest_directory(void)
{
DIR *dirp;
FAR struct dirent *entryp;
int number;
/* Open the directory */
dirp = opendir(CONFIG_EXAMPLES_FSTEST_MOUNTPT);
if (!dirp)
{
/* Failed to open the directory */
printf("ERROR: Failed to open directory '%s': %d\n",
CONFIG_EXAMPLES_FSTEST_MOUNTPT, errno);
return ERROR;
}
/* Read each directory entry */
printf("Directory:\n");
number = 1;
do
{
entryp = readdir(dirp);
if (entryp)
{
printf("%2d. Type[%d]: %s Name: %s\n",
number, entryp->d_type,
entryp->d_type == DTYPE_FILE ? "File " : "Error",
entryp->d_name);
}
number++;
}
while (entryp != NULL);
closedir(dirp);
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: fstest_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int fstest_main(int argc, char *argv[])
#endif
{
unsigned int i;
int ret;
/* Seed the random number generated */
srand(0x93846);
/* Set up memory monitoring */
#ifdef CONFIG_CAN_PASS_STRUCTS
g_mmbefore = mallinfo();
g_mmprevious = g_mmbefore;
#else
(void)mallinfo(&g_mmbefore);
memcpy(&g_mmprevious, &g_mmbefore, sizeof(struct mallinfo));
#endif
/* Loop a few times ... file the file system with some random, files,
* delete some files randomly, fill the file system with more random file,
* delete, etc. This beats the FLASH very hard!
*/
#if CONFIG_EXAMPLES_FSTEST_NLOOPS == 0
for (i = 0; ; i++)
#else
for (i = 1; i <= CONFIG_EXAMPLES_FSTEST_NLOOPS; i++)
#endif
{
/* Write a files to the file system until either (1) all of the open
* file structures are utilized or until (2) the file system reports an
* error (hopefully meaning that the file system is full)
*/
printf("\n=== FILLING %u =============================\n", i);
(void)fstest_fillfs();
printf("Filled file system\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
/* Directory listing */
fstest_directory();
/* Verify all files written to FLASH */
ret = fstest_verifyfs();
if (ret < 0)
{
printf("ERROR: Failed to verify files\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
#endif
}
/* Delete some files */
printf("\n=== DELETING %u ============================\n", i);
ret = fstest_delfiles();
if (ret < 0)
{
printf("ERROR: Failed to delete files\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
}
else
{
printf("Deleted some files\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
}
/* Directory listing */
fstest_directory();
/* Verify all files written to FLASH */
ret = fstest_verifyfs();
if (ret < 0)
{
printf("ERROR: Failed to verify files\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
}
else
{
#if CONFIG_EXAMPLES_FSTEST_VERBOSE != 0
printf("Verified!\n");
printf(" Number of files: %d\n", g_nfiles);
printf(" Number deleted: %d\n", g_ndeleted);
#endif
}
/* Show memory usage */
fstest_loopmemusage();
fflush(stdout);
}
/* Delete all files then show memory usage again */
fstest_delallfiles();
fstest_endmemusage();
fflush(stdout);
return 0;
}

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# FTPC Client Application
@ -47,93 +45,7 @@ ASRCS =
CSRCS = ftpc_cmds.c
MAINSRC = ftpc_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
CONFIG_XYZ_PROGNAME ?= ftpc$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Common build
VPATH =
all: .built
.PHONY: context depend clean 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
# Register application
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
# Create dependencies
.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
include $(APPDIR)/Application.mk

View file

@ -52,7 +52,7 @@
#include <apps/ftpc.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Maximum size of one command line */

View file

@ -243,7 +243,7 @@ int cmd_rhelp(SESSION handle, int argc, char **argv)
free(msg);
}
return ret;
return ret;
}
/****************************************************************************

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Hello, World! built-in application info
@ -49,89 +47,7 @@ ASRCS =
CSRCS =
MAINSRC = hello_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
CONFIG_EXAMPLES_HELLO_PROGNAME ?= hello$(EXEEXT)
PROGNAME = $(CONFIG_EXAMPLES_HELLO_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -41,7 +41,7 @@
#include <stdio.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************

View file

@ -6,6 +6,7 @@
config EXAMPLES_HELLOXX
bool "\"Hello, World!\" C++ example"
default n
depends on HAVE_CXX
---help---
Enable the \"Hello, World!\" C++ example
@ -19,6 +20,6 @@ config EXAMPLES_HELLOXX_CXXINITIALIZE
By default, if CONFIG_HAVE_CXX and CONFIG_HAVE_CXXINITIALIZE are
defined, then this example will call the NuttX function to
initialize static C++ constructors. This option may be disabled,
however, if that static initialization was preformed elsewhere.
however, if that static initialization was performed elsewhere.
endif

View file

@ -33,116 +33,22 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Hello, World! C++ Example
ASRCS =
CSRCS =
CXXSRCS =
MAINSRC = helloxx_main.cxx
AOBJS = $(ASRCS:.S=$(OBJEXT))
COBJS = $(CSRCS:.c=$(OBJEXT))
CXXOBJS = $(CXXSRCS:.cxx=$(OBJEXT))
MAINOBJ = $(MAINSRC:.cxx=$(OBJEXT))
SRCS = $(ASRCS) $(CSRCS) $(CXXSRCS) $(MAINSRC)
OBJS = $(AOBJS) $(COBJS) $(CXXOBJS)
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
ASRCS =
CSRCS =
CXXSRCS =
MAINSRC = helloxx_main.cxx
CONFIG_EXAMPLES_HELLOXX_PROGNAME ?= helloxx$(EXEEXT)
PROGNAME = $(CONFIG_EXAMPLES_HELLOXX_PROGNAME)
ROOTDEPPATH = --dep-path .
PROGNAME = $(CONFIG_EXAMPLES_HELLOXX_PROGNAME)
# helloxx built-in application info
APPNAME = helloxx
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
APPNAME = helloxx
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Common build
VPATH =
all: .built
.PHONY: clean depend distclean chkcxx
chkcxx:
ifneq ($(CONFIG_HAVE_CXX),y)
@echo ""
@echo "In order to use this example, you toolchain must support must"
@echo ""
@echo " (1) Explicitly select CONFIG_HAVE_CXX to build in C++ support"
@echo " (2) Define CXX, CXXFLAGS, and COMPILEXX in the Make.defs file"
@echo " of the configuration that you are using."
@echo ""
@exit 1
endif
$(AOBJS): %$(OBJEXT): %.S
$(call ASSEMBLE, $<, $@)
$(COBJS): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
$(CXXOBJS) $(MAINOBJ): %$(OBJEXT): %.cxx
$(call COMPILEXX, $<, $@)
.built: chkcxx $(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
include $(APPDIR)/Application.mk

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# USB Host HID keyboard Example
@ -43,82 +41,7 @@ ASRCS =
CSRCS =
MAINSRC = hidkbd_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
CONFIG_XYZ_PROGNAME ?= hidkbd$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
context:
.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
include $(APPDIR)/Application.mk

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# I2S character driver test
@ -49,95 +47,13 @@ CSRCS += i2schar_receiver.c
endif
MAINSRC = i2schar_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
CONFIG_XYZ_PROGNAME ?= i2schar$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# Touchscreen built-in application info
APPNAME = i2schar
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# Common build
VPATH =
all: .built
.PHONY: context 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
include $(APPDIR)/Application.mk

View file

@ -44,7 +44,7 @@
#include <pthread.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* CONFIG_NSH_BUILTIN_APPS - Build the I2SCHAR test as an NSH built-in

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
APPNAME = igmp
PRIORITY = SCHED_PRIORITY_DEFAULT
@ -47,89 +45,7 @@ ASRCS =
CSRCS =
MAINSRC = igmp.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
CONFIG_XYZ_PROGNAME ?= igmp$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -54,7 +54,7 @@
#include "igmp.h"
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Check if the destination address is a multicast address

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# cJSON built-in application info
@ -47,89 +45,7 @@ ASRCS =
CSRCS =
MAINSRC = json_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
CONFIG_XYZ_PROGNAME ?= json$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Keypad Test Example
@ -43,95 +41,13 @@ ASRCS =
CSRCS =
MAINSRC = keypadtest_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
# helloxx built-in application info
APPNAME = keypadtest
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
ifeq ($(WINTOOL),y)
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
else
INSTALL_DIR = $(BIN_DIR)
endif
CONFIG_XYZ_PROGNAME ?= keypadtest$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -58,7 +58,7 @@
#endif
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# LCD Read/Write Test
@ -43,95 +41,13 @@ ASRCS =
CSRCS =
MAINSRC = lcdrw_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
CONFIG_XYZ_PROGNAME ?= lcdrw$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
ROOTDEPPATH = --dep-path .
# LCD R/W built-in application info
APPNAME = lcdrw
PRIORITY = SCHED_PRIORITY_DEFAULT
STACKSIZE = 2048
# 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
include $(APPDIR)/Application.mk

View file

@ -47,7 +47,7 @@
#include <nuttx/nx/nxglib.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Most of the NX configuration settings are probably *not* needed by this

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# ltdc framebuffer example
@ -50,89 +48,7 @@ CSRCS += dma2d.c
endif
MAINSRC = ltdc_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
CONFIG_XYZ_PROGNAME ?= slcd$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -58,7 +58,7 @@
* Description:
* Remove the surface of the dma2dlayer
*
***************************************************************************/
****************************************************************************/
static void ltdc_remove_dma2d_surface(FAR struct dma2d_surface *sur)
{
@ -76,7 +76,7 @@ static void ltdc_remove_dma2d_surface(FAR struct dma2d_surface *sur)
* Description:
* Create a surface for the dma2dlayer
*
***************************************************************************/
****************************************************************************/
static FAR struct dma2d_surface *ltdc_create_dma2d_surface(uint16_t xres,
uint16_t yres,
@ -143,7 +143,7 @@ static FAR struct dma2d_surface *ltdc_create_dma2d_surface(uint16_t xres,
* Description:
* Clear the whole ltdc layer with a specific color
*
***************************************************************************/
****************************************************************************/
static void ltdc_clearlayer(FAR struct surface *sur, uint8_t color)
{
@ -165,7 +165,7 @@ static void ltdc_clearlayer(FAR struct surface *sur, uint8_t color)
* Description:
* Clear the whole dma2d layer with a specific color
*
***************************************************************************/
****************************************************************************/
static void dma2d_clearlayer(FAR struct dma2d_surface *sur, uint8_t color)
{
@ -193,7 +193,7 @@ static void dma2d_clearlayer(FAR struct dma2d_surface *sur, uint8_t color)
* layer dest must be larger or equal to the size of the layer back and
* fore.
*
***************************************************************************/
****************************************************************************/
static void ltdc_blendshadow(FAR struct surface *dest,
FAR struct dma2d_surface *fore,
@ -267,7 +267,7 @@ static void ltdc_blendshadow(FAR struct surface *dest,
* Helper: Blend a rectangle to the a specific pixel position.
* Note! This is only useful for the blitflipositioning test.
*
***************************************************************************/
****************************************************************************/
static void ltdc_blendrect(FAR struct dma2d_surface *fore,
FAR struct dma2d_surface *back,
@ -301,7 +301,7 @@ static void ltdc_blendrect(FAR struct dma2d_surface *fore,
* Note! This is done by performing sequential blend operations.
* It does not claim to have a good speed performance.
*
***************************************************************************/
****************************************************************************/
static void ltdc_blendoutline(FAR struct dma2d_surface *fore,
FAR struct dma2d_surface *back)
@ -368,7 +368,7 @@ static void ltdc_blendoutline(FAR struct dma2d_surface *fore,
* Calculates the next pixel position.
* This is based on the Breseham algorithmus.
*
***************************************************************************/
****************************************************************************/
static void ltdc_calcpos(int32_t *x0, int32_t *y0, int32_t x1, int32_t y1)
{
@ -397,7 +397,7 @@ static void ltdc_calcpos(int32_t *x0, int32_t *y0, int32_t x1, int32_t y1)
* Description:
* Test: Error handling of dma2d interface
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_interface(void)
{
@ -661,7 +661,7 @@ static void ltdc_dma2d_interface(void)
* Description:
* Test: Drawing color to specific area.
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_fillarea(void)
{
@ -821,7 +821,7 @@ static void ltdc_dma2d_fillarea(void)
* Description:
* Test: Perform simple blit operation to check source area positioning
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_blitsimple(void)
{
@ -951,7 +951,7 @@ static void ltdc_dma2d_blitsimple(void)
* Test: Perform simple blit operation to check source and destination
* positioning
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_blitpositioning(void)
{
@ -1215,7 +1215,7 @@ static void ltdc_dma2d_blitpositioning(void)
* Description:
* Test: Perform simple blend operation to check source area positioning
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_blendsimple(void)
{
@ -1376,7 +1376,7 @@ static void ltdc_dma2d_blendsimple(void)
* Test: Perform simple blit operation with allocated dma2d layer using the
* dma2d interface.
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_blitdynamiclayer(void)
{
@ -1648,7 +1648,7 @@ static void ltdc_dma2d_blitdynamiclayer(void)
* Test: Perform simple blend operation with allocated dma2d layer using the
* dma2d interface.
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_blenddynamiclayer(void)
{
@ -1972,7 +1972,7 @@ static void ltdc_dma2d_blenddynamiclayer(void)
* Description:
* Perform simple blit and flip operation with both interfaces
*
***************************************************************************/
****************************************************************************/
static void ltdc_dma2d_blitflippositioning(void)
{
@ -2273,7 +2273,7 @@ static void ltdc_dma2d_blitflippositioning(void)
* Perform the screensaver test.
* Note! This test runs in an endless loop.
*
***************************************************************************/
****************************************************************************/
static void ltdc_screensaver(void)
{
@ -2448,7 +2448,7 @@ static void ltdc_screensaver(void)
* Description:
* Triggers the dma2d tests
*
***************************************************************************/
****************************************************************************/
void ltdc_dma2d_main(void)
{

View file

@ -112,7 +112,7 @@ static const uint32_t g_rgb16[LTDC_EXAMPLE_NCOLORS] =
/****************************************************************************
* Public Functions
****************************************************************************/
****************************************************************************/
void ltdc_clrcolor(uint8_t *color, uint8_t value, size_t size);
int ltdc_cmpcolor(uint8_t *color1, uint8_t *color2, size_t size);

View file

@ -80,13 +80,13 @@ static struct fb_cmap_s g_cmap =
****************************************************************************/
#ifdef CONFIG_STM32_LTDC_INTERFACE
/******************************************************************************
/****************************************************************************
* Name: ltdc_init_surface
*
* Description:
* Initialize layer and the layers videoinfo and planeinfo
*
*****************************************************************************/
****************************************************************************/
static int ltdc_init_surface(int lid, uint32_t mode)
{
@ -149,13 +149,13 @@ static int ltdc_init_surface(int lid, uint32_t mode)
return OK;
}
/******************************************************************************
/****************************************************************************
* Name: ltdc_setget_test
*
* Description:
* Perform layer area positioning test
*
*****************************************************************************/
****************************************************************************/
static void ltdc_setget_test(void)
{
@ -338,13 +338,13 @@ static void ltdc_setget_test(void)
sur->layer->update(sur->layer, 0);
}
/******************************************************************************
/****************************************************************************
* Name: ltdc_color_test
*
* Description:
* Perform layer color test
*
*****************************************************************************/
****************************************************************************/
static void ltdc_color_test(void)
{
@ -445,13 +445,13 @@ static void ltdc_color_test(void)
usleep(1000000);
}
/******************************************************************************
/****************************************************************************
* Name: ltdc_colorkey_test
*
* Description:
* Perform layer colorkey test
*
*****************************************************************************/
****************************************************************************/
static void ltdc_colorkey_test(void)
{
@ -552,13 +552,13 @@ static void ltdc_colorkey_test(void)
usleep(1000000);
}
/******************************************************************************
/****************************************************************************
* Name: ltdc_area_test
*
* Description:
* Perform layer area positioning test
*
*****************************************************************************/
****************************************************************************/
static void ltdc_area_test(void)
{
@ -874,14 +874,14 @@ static void ltdc_area_test(void)
usleep(1000000);
}
/******************************************************************************
/****************************************************************************
* Name: ltdc_common_test
*
* Description:
* Perform test with all layer operations at once
* Todo: add alpha blending and default color
*
*****************************************************************************/
****************************************************************************/
static void ltdc_common_test(void)
{
@ -1289,13 +1289,13 @@ static void ltdc_common_test(void)
}
#ifdef CONFIG_STM32_LTDC_L2
/******************************************************************************
/****************************************************************************
* Name: ltdc_alpha_blend_test
*
* Description:
* Perform layer blend test
*
*****************************************************************************/
****************************************************************************/
static void ltdc_alpha_blend_test(void)
{
@ -1422,13 +1422,13 @@ static void ltdc_alpha_blend_test(void)
top->layer->update(top->layer, LTDC_UPDATE_SIM|LTDC_SYNC_VBLANK);
}
/******************************************************************************
/****************************************************************************
* Name: ltdc_flip_test
*
* Description:
* Perform layer flip test
*
*****************************************************************************/
****************************************************************************/
static void ltdc_flip_test(void)
{
@ -1629,7 +1629,7 @@ static void ltdc_flip_test(void)
* value - The color to set
* size - the size of the color value table
*
***************************************************************************/
****************************************************************************/
void ltdc_clrcolor(uint8_t *color, uint8_t value, size_t size)
{
@ -1653,7 +1653,7 @@ void ltdc_clrcolor(uint8_t *color, uint8_t value, size_t size)
* Return:
* 0 - if equal otherwise unequal to 0
*
***************************************************************************/
****************************************************************************/
int ltdc_cmpcolor(uint8_t *color1, uint8_t *color2, size_t size)
{
@ -1673,7 +1673,7 @@ int ltdc_cmpcolor(uint8_t *color1, uint8_t *color2, size_t size)
* Description:
* Initialize the color lookup table
*
***************************************************************************/
****************************************************************************/
#ifdef CONFIG_FB_CMAP
void ltdc_init_cmap(void)
@ -1712,7 +1712,7 @@ void ltdc_init_cmap(void)
* Description:
* Initialize
*
***************************************************************************/
****************************************************************************/
FAR struct fb_cmap_s * ltdc_createcmap(uint16_t ncolors)
{
@ -1758,7 +1758,7 @@ FAR struct fb_cmap_s * ltdc_createcmap(uint16_t ncolors)
* Description:
* Initialize
*
***************************************************************************/
****************************************************************************/
void ltdc_deletecmap(FAR struct fb_cmap_s *cmap)
{
@ -1780,7 +1780,7 @@ void ltdc_deletecmap(FAR struct fb_cmap_s *cmap)
* Description:
* Get the correct color value to the pixel format
*
***************************************************************************/
****************************************************************************/
uint32_t ltdc_color(FAR struct fb_videoinfo_s *vinfo, uint8_t color)
{
@ -1813,13 +1813,13 @@ uint32_t ltdc_color(FAR struct fb_videoinfo_s *vinfo, uint8_t color)
return value;
}
/***************************************************************************
/****************************************************************************
* Name: ltdc_simple_draw
*
* Description:
* Draw four different colored rectangles on the whole screen
*
***************************************************************************/
****************************************************************************/
void ltdc_simple_draw(FAR struct fb_videoinfo_s *vinfo,
FAR struct fb_planeinfo_s *pinfo)
@ -1967,13 +1967,13 @@ void ltdc_simple_draw(FAR struct fb_videoinfo_s *vinfo,
}
#ifdef CONFIG_STM32_LTDC_L2
/******************************************************************************
/****************************************************************************
* Name: ltdc_drawcolor
*
* Description:
* Draw a specific color to the framebuffer
*
*****************************************************************************/
****************************************************************************/
void ltdc_drawcolor(FAR struct fb_videoinfo_s *vinfo, void *buffer,
uint16_t xres, uint16_t yres, uint32_t color)
@ -2041,13 +2041,13 @@ void ltdc_drawcolor(FAR struct fb_videoinfo_s *vinfo, void *buffer,
#endif
#ifdef CONFIG_STM32_LTDC_INTERFACE
/******************************************************************************
/****************************************************************************
* Name: ltdc_get_surface
*
* Description:
* Get a reference to a specific layer
*
*****************************************************************************/
****************************************************************************/
struct surface * ltdc_get_surface(uint32_t mode)
{

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Memory Management Test
@ -43,82 +41,7 @@ ASRCS =
CSRCS =
MAINSRC = mm_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
CONFIG_XYZ_PROGNAME ?= mm$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
context:
.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
include $(APPDIR)/Application.mk

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# FreeModBus demo built-in application info
@ -49,89 +47,7 @@ ASRCS =
CSRCS =
MAINSRC = modbus_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
CONFIG_XYZ_PROGNAME ?= modbus$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -72,7 +72,7 @@
#include <apps/modbus/mbport.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# mount() test
@ -43,82 +41,7 @@ ASRCS =
CSRCS = ramdisk.c
MAINSRC = mount_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
CONFIG_XYZ_PROGNAME ?= mount$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
context:
.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
include $(APPDIR)/Application.mk

View file

@ -43,7 +43,7 @@
#include <nuttx/config.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configure the test */

View file

@ -52,7 +52,7 @@
#include "mount.h"
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
#define TEST_USE_STAT 1

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Hello, World! Example
@ -43,82 +41,7 @@ ASRCS =
CSRCS =
MAINSRC = mtdpart_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
CONFIG_XYZ_PROGNAME ?= mtdpart$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
context:
.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
include $(APPDIR)/Application.mk

View file

@ -51,7 +51,7 @@
#include <nuttx/fs/ioctl.h>
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Make sure that support for MTD partitions is enabled */

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Hello, World! Example
@ -43,82 +41,7 @@ ASRCS =
CSRCS =
MAINSRC = mtdrwb_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
CONFIG_EXAMPLES_MTDRWB_PROGNAME ?= mtdrwb$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
context:
.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
include $(APPDIR)/Application.mk

14
examples/netloop/.gitignore vendored Normal file
View file

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

25
examples/netloop/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 EXAMPLES_NETLOOP
bool "Local loopback example"
default n
depends on NET_LOOPBACK && NET_TCP && NET_TCPBACKLOG && NET_TCP_READAHEAD && NET_TCP_WRITE_BUFFERS && NET_IPv4
---help---
Enable the local loopback example
if EXAMPLES_NETLOOP
if NSH_BUILTIN_APPS
config EXAMPLES_NETLOOP_STACKSIZE
int "Loopback test stack size"
default 2048
config EXAMPLES_NETLOOP_PRIORITY
int "Loopback test task priority"
default 100
endif # NSH_BUILTIN_APPS
endif # EXAMPLES_NETLOOP

View file

@ -0,0 +1,38 @@
############################################################################
# apps/examples/netloop/Make.defs
#
# Copyright (C) 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.
#
############################################################################
ifeq ($(CONFIG_EXAMPLES_NETLOOP),y)
CONFIGURED_APPS += examples/netloop
endif

54
examples/netloop/Makefile Normal file
View file

@ -0,0 +1,54 @@
############################################################################
# apps/examples/netloop/Makefile
#
# Copyright (C) 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.
#
############################################################################
-include $(TOPDIR)/Make.defs
# Device Driver poll()/select() Example
ASRCS =
CSRCS = lo_listener.c
MAINSRC = lo_main.c
CONFIG_EXAMPLES_NETLOOP_STACKSIZE ?= 2048
CONFIG_EXAMPLES_NETLOOP_PRIORITY ?= 100
APPNAME = netloop
PRIORITY = $(CONFIG_EXAMPLES_NETLOOP_PRIORITY)
STACKSIZE = $(CONFIG_EXAMPLES_NETLOOP_STACKSIZE)
CONFIG_XYZ_PROGNAME ?= poll$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
include $(APPDIR)/Application.mk

View file

@ -0,0 +1,392 @@
/****************************************************************************
* examples/netloop/lo_listener.c
*
* Copyright (C) 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 <sys/stat.h>
#include <sys/select.h>
#include <sys/socket.h>
#include <sys/ioctl.h>
#include <sys/time.h>
#include <stdint.h>
#include <stdbool.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <errno.h>
#include <debug.h>
#include <net/if.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <apps/netutils/netlib.h>
#include "netloop.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define IOBUFFER_SIZE 80
/****************************************************************************
* Private Types
****************************************************************************/
struct net_listener_s
{
struct sockaddr_in addr;
fd_set master;
fd_set working;
char buffer[IOBUFFER_SIZE];
int listensd;
int mxsd;
};
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: net_closeclient
****************************************************************************/
static bool net_closeclient(struct net_listener_s *nls, int sd)
{
printf("lo_listener: Closing host side connection sd=%d\n", sd);
close(sd);
FD_CLR(sd, &nls->master);
/* If we just closed the max SD, then search downward for the next biggest SD. */
while (FD_ISSET(nls->mxsd, &nls->master) == false)
{
nls->mxsd -= 1;
}
return true;
}
/****************************************************************************
* Name: net_incomingdata
****************************************************************************/
static inline bool net_incomingdata(struct net_listener_s *nls, int sd)
{
char *ptr;
int nbytes;
int ret;
/* Read data from the socket */
#ifdef FIONBIO
for (;;)
#endif
{
printf("lo_listener: Read data from sd=%d\n", sd);
ret = recv(sd, nls->buffer, IOBUFFER_SIZE, 0);
if (ret < 0)
{
if (errno != EINTR)
{
printf("lo_listener: recv failed sd=%d: %d\n", sd, errno);
if (errno != EAGAIN)
{
net_closeclient(nls, sd);
return false;
}
}
}
else if (ret == 0)
{
printf("lo_listener: Client connection lost sd=%d\n", sd);
net_closeclient(nls, sd);
return false;
}
else
{
nls->buffer[ret]='\0';
printf("lo_listener: Read '%s' (%d bytes)\n", nls->buffer, ret);
/* Echo the data back to the client */
for (nbytes = ret, ptr = nls->buffer; nbytes > 0; )
{
ret = send(sd, ptr, nbytes, 0);
if (ret < 0)
{
if (errno != EINTR)
{
printf("lo_listener: Send failed sd=%d: %d\n", sd, errno);
net_closeclient(nls, sd);
return false;
}
}
else
{
nbytes -= ret;
ptr += ret;
}
}
}
}
return 0;
}
/****************************************************************************
* Name: net_connection
****************************************************************************/
static inline bool net_connection(struct net_listener_s *nls)
{
int sd;
/* Loop until all connections have been processed */
#ifdef FIONBIO
for (;;)
#endif
{
printf("lo_listener: Accepting new connection on sd=%d\n", nls->listensd);
sd = accept(nls->listensd, NULL, NULL);
if (sd < 0)
{
printf("lo_listener: accept failed: %d\n", errno);
if (errno != EINTR)
{
return false;
}
}
else
{
/* Add the new connection to the master set */
printf("lo_listener: Connection accepted for sd=%d\n", sd);
FD_SET(sd, &nls->master);
if (sd > nls->mxsd)
{
nls->mxsd = sd;
}
return true;
}
}
return false;
}
/****************************************************************************
* Name: net_mksocket
****************************************************************************/
static inline bool net_mksocket(struct net_listener_s *nls)
{
int value;
int ret;
/* Create a listening socket */
printf("lo_listener: Initializing listener socket\n");
nls->listensd = socket(AF_INET, SOCK_STREAM, 0);
if (nls->listensd < 0)
{
printf("lo_listener: socket failed: %d\n", errno);
return false;
}
/* Configure the socket */
value = 1;
ret = setsockopt(nls->listensd, SOL_SOCKET, SO_REUSEADDR, (char*)&value, sizeof(int));
if (ret < 0)
{
printf("lo_listener: setsockopt failed: %d\n", errno);
close(nls->listensd);
return false;
}
/* Set the socket to non-blocking */
#ifdef FIONBIO
ret = ioctl(nls->listensd, FIONBIO, (char *)&value);
if (ret < 0)
{
printf("lo_listener: ioctl failed: %d\n", errno);
close(nls->listensd);
return false;
}
#endif
/* Bind the socket */
memset(&nls->addr, 0, sizeof(struct sockaddr_in));
nls->addr.sin_family = AF_INET;
nls->addr.sin_port = htons(LISTENER_PORT);
nls->addr.sin_addr.s_addr = htonl(LO_ADDRESS);
ret = bind(nls->listensd, (struct sockaddr *)&nls->addr, sizeof(struct sockaddr_in));
if (ret < 0)
{
printf("lo_listener: bind failed: %d\n", errno);
close(nls->listensd);
return false;
}
/* Mark the socket as a listener */
ret = listen(nls->listensd, 32);
if (ret < 0)
{
printf("lo_listener: bind failed: %d\n", errno);
close(nls->listensd);
return false;
}
return true;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: lo_listener
****************************************************************************/
void *lo_listener(pthread_addr_t pvarg)
{
struct net_listener_s nls;
struct timeval timeout;
int nsds;
int ret;
int i;
/* Set up a listening socket */
memset(&nls, 0, sizeof(struct net_listener_s));
if (!net_mksocket(&nls))
{
return (void*)1;
}
/* Initialize the 'master' file descriptor set */
FD_ZERO(&nls.master);
nls.mxsd = nls.listensd;
FD_SET(nls.listensd, &nls.master);
/* Set up a 3 second timeout */
timeout.tv_sec = LISTENER_DELAY;
timeout.tv_usec = 0;
/* Loop waiting for incoming connections or for incoming data
* on any of the connect sockets.
*/
for (;;)
{
/* Wait on select */
printf("lo_listener: Calling select(), listener sd=%d\n", nls.listensd);
memcpy(&nls.working, &nls.master, sizeof(fd_set));
ret = select(nls.mxsd + 1, (FAR fd_set*)&nls.working, (FAR fd_set*)NULL, (FAR fd_set*)NULL, &timeout);
if (ret < 0)
{
printf("lo_listener: select failed: %d\n", errno);
break;
}
/* Check for timeout */
if (ret == 0)
{
printf("lo_listener: Timeout\n");
continue;
}
/* Find which descriptors caused the wakeup */
nsds = ret;
for (i = 0; i <= nls.mxsd && nsds > 0; i++)
{
/* Is this descriptor ready? */
if (FD_ISSET(i, &nls.working))
{
/* Yes, is it our listener? */
printf("lo_listener: Activity on sd=%d\n", i);
nsds--;
if (i == nls.listensd)
{
(void)net_connection(&nls);
}
else
{
net_incomingdata(&nls, i);
}
}
}
}
/* Cleanup */
#if 0 /* Don't get here */
for (i = 0; i <= nls.mxsd; +i++)
{
if (FD_ISSET(i, &nls.master))
{
close(i);
}
}
#endif
return NULL; /* Keeps some compilers from complaining */
}

209
examples/netloop/lo_main.c Normal file
View file

@ -0,0 +1,209 @@
/****************************************************************************
* examples/netloop/lo_main.c
*
* Copyright (C) 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 <sys/types.h>
#include <sys/stat.h>
#include <stdio.h>
#include <unistd.h>
#include <string.h>
#include <pthread.h>
#include <fcntl.h>
#include <poll.h>
#include <errno.h>
#include <debug.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include "netloop.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define IOBUFFER_SIZE 80
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: lo_client
****************************************************************************/
static int lo_client(void)
{
struct sockaddr_in myaddr;
char outbuf[IOBUFFER_SIZE];
char inbuf[IOBUFFER_SIZE];
int sockfd;
int len;
int nbytessent;
int nbytesrecvd;
int ret;
int i;
/* Create a new TCP socket */
sockfd = socket(PF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
{
ret = -errno;
printf("lo_client: socket failure %d\n", ret);
return ret;
}
/* Connect the socket to the server */
myaddr.sin_family = AF_INET;
myaddr.sin_port = htons(LISTENER_PORT);
myaddr.sin_addr.s_addr = htonl(LO_ADDRESS);
printf("lo_client: Connecting to %08x:%d...\n", LO_ADDRESS, LISTENER_PORT);
if (connect( sockfd, (struct sockaddr*)&myaddr, sizeof(struct sockaddr_in)) < 0)
{
ret = -errno;
printf("lo_client: connect failure: %d\n", ret);
goto errout_with_socket;
}
printf("lo_client: Connected\n");
/* Then send and receive messages */
for (i = 0; ; i++)
{
sprintf(outbuf, "Loopback message %d", i);
len = strlen(outbuf);
printf("lo_client: Sending '%s' (%d bytes)\n", outbuf, len);
nbytessent = send(sockfd, outbuf, len, 0);
printf("lo_client: Sent %d bytes\n", nbytessent);
if (nbytessent < 0)
{
ret = -errno;
printf("lo_client: send failed: %d\n", ret);
goto errout_with_socket;
}
else if (nbytessent != len)
{
ret = -EINVAL;
printf("lo_client: Bad send length: %d Expected: %d\n", nbytessent, len);
goto errout_with_socket;
}
printf("lo_client: Receiving...\n");
nbytesrecvd = recv(sockfd, inbuf, IOBUFFER_SIZE, 0);
if (nbytesrecvd < 0)
{
ret = -errno;
printf("lo_client: recv failed: %d\n", ret);
goto errout_with_socket;
}
else if (nbytesrecvd == 0)
{
ret = -ENOTCONN;
printf("lo_client: The server broke the connections\n");
goto errout_with_socket;
}
inbuf[nbytesrecvd] = '\0';
printf("lo_client: Received '%s' (%d bytes)\n", inbuf, nbytesrecvd);
if (nbytesrecvd != len)
{
ret = -EINVAL;
printf("lo_client: Bad recv length: %d Expected: %d\n", nbytesrecvd, len);
goto errout_with_socket;
}
else if (memcmp(inbuf, outbuf, len) != 0)
{
ret = -EINVAL;
printf("lo_client: Received outbuf does not match sent outbuf\n");
goto errout_with_socket;
}
printf("lo_client: Sleeping\n");
sleep(8);
}
close(sockfd);
return 0;
errout_with_socket:
close(sockfd);
return ret;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: netloop_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int netloop_main(int argc, char *argv[])
#endif
{
pthread_t tid;
int ret;
/* Start the listeners */
printf("netloop_main: Starting lo_listener thread\n");
ret = pthread_create(&tid, NULL, lo_listener, NULL);
if (ret != 0)
{
printf("netloop_main: Failed to create lo_listener thread: %d\n", ret);
}
/* Run the client */
ret = lo_client();
return 0;
}

View file

@ -0,0 +1,99 @@
/****************************************************************************
* examples/netloop/netloop.h
*
* Copyright (C) 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.
*
****************************************************************************/
#ifndef __APPS_EXAMPLES_NETLOOP_NETLOOP_H
#define __APPS_EXAMPLES_NETLOOP_NETLOOP_H
/****************************************************************************
* Compilation Switches
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <pthread.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifdef CONFIG_DISABLE_POLL
# error "The polling API is disabled"
#endif
/* Here are all of the configuration settings that must be met to have TCP/IP
* poll/select support. This kind of looks like overkill.
*
* CONFIG_NET - Network support must be enabled
* CONFIG_NSOCKET_DESCRIPTORS - Socket descriptors must be allocated
* CONFIG_NET_TCP - Only support on TCP (because read-ahead
* buffering s not yet support for UDP)
* CONFIG_NET_TCP_READAHEAD - TCP/IP read-ahead buffering must be enabled
*/
#if !defined(CONFIG_NET) || CONFIG_NSOCKET_DESCRIPTORS <= 0
# error Network socket support not enabled
#endif
#if !defined(CONFIG_NET_TCP) && !defined(CONFIG_NET_TCP_READAHEAD) || \
!defined(CONFIG_NET_TCPBACKLOG) || !defined(CONFIG_NET_TCP_WRITE_BUFFERS)
# error TCP not configured correctly
#endif
#if !defined(CONFIG_NET_IPv4)
# error This test only works with IPv4
#endif
#define LISTENER_DELAY 3 /* 3 seconds */
#define LISTENER_PORT 5471
#define LO_ADDRESS 0x7f000001
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Variables
****************************************************************************/
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
void *lo_listener(pthread_addr_t pvarg);
#endif /* __APPS_EXAMPLES_NETLOOP_NETLOOP_H */

View file

@ -33,9 +33,7 @@
#
############################################################################
-include $(TOPDIR)/.config
-include $(TOPDIR)/Make.defs
include $(APPDIR)/Make.defs
# Network packet socket example
@ -49,89 +47,7 @@ ASRCS =
CSRCS =
MAINSRC = netpkt_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
CONFIG_XYZ_PROGNAME ?= netpkt$(EXEEXT)
PROGNAME = $(CONFIG_XYZ_PROGNAME)
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
include $(APPDIR)/Application.mk

View file

@ -12,23 +12,40 @@ config EXAMPLES_NETTEST
if EXAMPLES_NETTEST
config EXAMPLES_NETTEST_LOOPBACK
bool "Loopback test"
default n
depends on NET_LOOPBACK
---help---
Perform the test using the local loopback device. In this case,
both the client and the server reside on the target.
if EXAMPLES_NETTEST_LOOPBACK
config EXAMPLES_NETTEST_STACKSIZE
int "Server stack size"
default 2048
config EXAMPLES_NETTEST_PRIORITY
int "Server priority"
default 100
endif # EXAMPLES_NETTEST_LOOPBACK
config EXAMPLES_NETTEST_SERVER
bool "Target is server"
default n
depends on !EXAMPLES_NETTEST_LOOPBACK
---help---
Select to use the host as the client side of the test. Default: The
target is the client side of the test
Select to use the host as the client side of the test. Default: The
target is the client side of the test
config EXAMPLES_NETTEST_PERFORMANCE
bool "Test for Performance"
default n
---help---
Configure the example to test for network performance. Default: Test
is for network functionality.
config EXAMPLES_NETTEST_NOMAC
bool "Use Canned MAC Address"
default n
Configure the example to test for network performance. Default: Test
is for network functionality.
choice
prompt "IP Domain"
@ -45,10 +62,28 @@ config EXAMPLES_NETTEST_IPv6
endchoice # IP Domain
config EXAMPLES_NETTEST_INIT
bool "Initialize network"
default n if NSH_BUILTIN_APPS
default y if !NSH_BUILTIN_APPS
depends on !BUILD_KERNEL && !EXAMPLES_NETTEST_LOOPBACK
---help---
Include logic to initialize the network. This should not be done if
the network is already initialized when nettest runs. This is
usually the case, for example, when nettest is run as an NSH built-
in task.
config EXAMPLES_NETTEST_NOMAC
bool "Use Canned MAC Address"
default n
depends on EXAMPLES_NETTEST_INIT
if EXAMPLES_NETTEST_IPv4
comment "IPv4 addresses"
if EXAMPLES_NETTEST_INIT
config EXAMPLES_NETTEST_IPADDR
hex "Target IP address"
default 0x0a000002
@ -61,6 +96,10 @@ config EXAMPLES_NETTEST_NETMASK
hex "Network Mask"
default 0xffffff00
endif # EXAMPLES_NETTEST_INIT
if !EXAMPLES_NETTEST_LOOPBACK
config EXAMPLES_NETTEST_CLIENTIP
hex "Client IP Address"
default 0x0a000001 if !EXAMPLES_NETTEST_SERVER
@ -73,6 +112,7 @@ config EXAMPLES_NETTEST_CLIENTIP
host PC IP address (possibly the gateway address,
EXAMPLES_NETTEST_DRIPADDR?).
endif # !EXAMPLES_NETTEST_LOOPBACK
endif # EXAMPLES_NETTEST_IPv4
if EXAMPLES_NETTEST_IPv6
@ -80,6 +120,8 @@ if !NET_ICMPv6_AUTOCONF
comment "Target IPv6 address"
if EXAMPLES_NETTEST_INIT
config EXAMPLES_NETTEST_IPv6ADDR_1
hex "[0]"
default 0xfc00
@ -325,6 +367,9 @@ config EXAMPLES_NETTEST_IPv6NETMASK_8
all eight values is fe00::0.
endif # NET_ICMPv6_AUTOCONF
endif # EXAMPLES_NETTEST_INIT
if !EXAMPLES_NETTEST_LOOPBACK
comment "Client IPv6 address"
@ -457,5 +502,6 @@ config EXAMPLES_NETTEST_CLIENTIPv6ADDR_8
values forming the full IP address must be specified individually.
This is the last of the 8-values.
endif # !EXAMPLES_NETTEST_LOOPBACK
endif # EXAMPLES_NETTEST_IPv6
endif # EXAMPLES_NETTEST

View file

@ -43,7 +43,9 @@ TARG_ASRCS =
TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT))
TARG_CSRCS =
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
ifeq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
TARG_CSRCS += nettest_server.c nettest_client.c
else ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
TARG_CSRCS += nettest_server.c
else
TARG_CSRCS += nettest_client.c
@ -70,24 +72,26 @@ else
endif
endif
HOSTCFLAGS += -DNETTEST_HOST=1
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_CLIENTIP="$(CONFIG_EXAMPLES_NETTEST_CLIENTIP)"
endif
ifeq ($(CONFIG_EXAMPLES_NETTEST_PERFORMANCE),y)
HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_PERFORMANCE=1
endif
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
HOSTCFLAGS += -DNETTEST_HOST=1
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_SERVER=1 -DCONFIG_EXAMPLES_NETTEST_CLIENTIP="$(CONFIG_EXAMPLES_NETTEST_CLIENTIP)"
endif
ifeq ($(CONFIG_EXAMPLES_NETTEST_PERFORMANCE),y)
HOSTCFLAGS += -DCONFIG_EXAMPLES_NETTEST_PERFORMANCE=1
endif
HOST_SRCS = host.c
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
HOST_SRCS += nettest_client.c
else
HOST_SRCS += nettest_server.c
endif
HOST_SRCS = host.c
ifeq ($(CONFIG_EXAMPLES_NETTEST_SERVER),y)
HOST_SRCS += nettest_client.c
else
HOST_SRCS += nettest_server.c
endif
HOSTOBJEXT ?= .hobj
HOST_OBJS = $(HOST_SRCS:.c=$(HOSTOBJEXT))
HOST_BIN = host
HOSTOBJEXT ?= .hobj
HOST_OBJS = $(HOST_SRCS:.c=$(HOSTOBJEXT))
HOST_BIN = host
endif
ifeq ($(WINTOOL),y)
INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}"
@ -119,17 +123,21 @@ $(TARG_AOBJS): %$(OBJEXT): %.S
$(TARG_COBJS) $(TARG_MAINOBJ): %$(OBJEXT): %.c
$(call COMPILE, $<, $@)
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
$(HOST_OBJS): %$(HOSTOBJEXT): %.c
@echo "CC: $<"
$(Q) $(HOSTCC) -c $(HOSTCFLAGS) $< -o $@
endif
config.h: $(TOPDIR)/include/nuttx/config.h
@echo "CP: $<"
$(Q) cp $< $@
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
$(HOST_BIN): config.h $(HOST_OBJS)
@echo "LD: $@"
$(Q) $(HOSTCC) $(HOSTLDFLAGS) $(HOST_OBJS) -o $@
endif
.built: config.h $(TARG_OBJS)
$(call ARCHIVE, $(TARG_BIN), $(TARG_OBJS))
@ -164,8 +172,10 @@ endif
depend: .depend
clean:
ifneq ($(CONFIG_EXAMPLES_NETTEST_LOOPBACK),y)
$(call DELFILE, *$(HOSTOBJEXT))
$(call DELFILE, $(HOST_BIN))
endif
$(call DELFILE, .built)
$(call DELFILE, *.dSYM)
$(call DELFILE, config.h)

View file

@ -40,8 +40,12 @@
#include "config.h"
//#include <nuttx/config.h>
#include <sys/wait.h>
#include <stdint.h>
#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <sched.h>
#include <debug.h>
#include <net/if.h>
@ -53,14 +57,16 @@
#include "nettest.h"
/****************************************************************************
* Definitions
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
#if defined(CONFIG_EXAMPLES_NETTEST_IPv6) && !defined(CONFIG_NET_ICMPv6_AUTOCONF)
#if defined(CONFIG_EXAMPLES_NETTEST_INIT) && \
defined(CONFIG_EXAMPLES_NETTEST_IPv6) && \
!defined(CONFIG_NET_ICMPv6_AUTOCONF)
/* Our host IPv6 address */
static const uint16_t g_ipv6_hostaddr[8] =
@ -102,21 +108,14 @@ static const uint16_t g_ipv6_netmask[8] =
HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_7),
HTONS(CONFIG_EXAMPLES_NETTEST_IPv6NETMASK_8),
};
#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */
#endif /* CONFIG_EXAMPLES_NETTEST_INIT && CONFIG_EXAMPLES_NETTEST_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */
/****************************************************************************
* Public Functions
* Private Functions
****************************************************************************/
/****************************************************************************
* nettest_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int nettest_main(int argc, char *argv[])
#endif
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
static void netest_initialize(void)
{
#ifndef CONFIG_EXAMPLES_NETTEST_IPv6
struct in_addr addr;
@ -179,12 +178,75 @@ int nettest_main(int argc, char *argv[])
netlib_set_ipv4netmask("eth0", &addr);
#endif /* CONFIG_EXAMPLES_NETTEST_IPv6 */
}
#endif /*CONFIG_EXAMPLES_NETTEST_INIT */
#ifdef CONFIG_EXAMPLES_NETTEST_SERVER
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
static int server_child(int argc, char *argv[])
{
recv_server();
return EXIT_SUCCESS;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* nettest_main
****************************************************************************/
#ifdef CONFIG_BUILD_KERNEL
int main(int argc, FAR char *argv[])
#else
int nettest_main(int argc, char *argv[])
#endif
{
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
pid_t child;
#ifdef CONFIG_SCHED_WAITPID
int statloc;
#endif
#endif
#ifdef CONFIG_EXAMPLES_NETTEST_INIT
/* Initialize the network */
netest_initialize();
#endif
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK)
/* Then perform the server side of the test on a child task */
child = task_create("Nettest Child", CONFIG_EXAMPLES_NETTEST_PRIORITY,
CONFIG_EXAMPLES_NETTEST_STACKSIZE, server_child,
NULL);
if (child < 0)
{
fprintf(stderr, "ERROR: Failed to server daemon\n");
return EXIT_FAILURE;
}
usleep(500*1000);
#elif defined(CONFIG_EXAMPLES_NETTEST_SERVER)
/* Then perform the server side of the test on this thread */
recv_server();
#endif
#if !defined(CONFIG_EXAMPLES_NETTEST_SERVER) || \
defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK)
/* Then perform the client side of the test on this thread */
send_client();
#endif
return 0;
#if defined(CONFIG_EXAMPLES_NETTEST_LOOPBACK) && defined(CONFIG_SCHED_WAITPID)
printf("main: Waiting for the server to exit\n");
(void)waitpid(child, &statloc, 0);
#endif
return EXIT_SUCCESS;
}

View file

@ -106,6 +106,16 @@ void send_client(void)
myaddr.sin6_family = AF_INET6;
myaddr.sin6_port = HTONS(PORTNO);
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
myaddr.sin6_addr.s6_addr16[0] = 0;
myaddr.sin6_addr.s6_addr16[1] = 0;
myaddr.sin6_addr.s6_addr16[2] = 0;
myaddr.sin6_addr.s6_addr16[3] = 0;
myaddr.sin6_addr.s6_addr16[4] = 0;
myaddr.sin6_addr.s6_addr16[5] = 0;
myaddr.sin6_addr.s6_addr16[6] = 0;
myaddr.sin6_addr.s6_addr16[7] = HTONS(1);
#else
myaddr.sin6_addr.s6_addr16[0] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_1);
myaddr.sin6_addr.s6_addr16[1] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_2);
myaddr.sin6_addr.s6_addr16[2] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_3);
@ -114,12 +124,18 @@ void send_client(void)
myaddr.sin6_addr.s6_addr16[5] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_6);
myaddr.sin6_addr.s6_addr16[6] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_7);
myaddr.sin6_addr.s6_addr16[7] = HTONS(CONFIG_EXAMPLES_NETTEST_CLIENTIPv6ADDR_8);
#endif
addrlen = sizeof(struct sockaddr_in6);
#else
myaddr.sin_family = AF_INET;
myaddr.sin_port = HTONS(PORTNO);
#ifdef CONFIG_EXAMPLES_NETTEST_LOOPBACK
myaddr.sin_addr.s_addr = HTONL(0x7f000001);
#else
myaddr.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_NETTEST_CLIENTIP);
#endif
addrlen = sizeof(struct sockaddr_in);
#endif

View file

@ -178,6 +178,7 @@ void recv_server(void)
printf("server: The client broke the connection\n");
goto errout_with_acceptsd;
}
printf("Received %d bytes\n", nbytesread);
}
#else
@ -245,9 +246,10 @@ void recv_server(void)
#if 1 /* Do it for all platforms */
printf("server: Wait before closing\n");
sleep(60);
sleep(2);
#endif
printf("server: Terminating\n");
close(listensd);
close(acceptsd);
free(buffer);

Some files were not shown because too many files have changed in this diff Show more