diff --git a/.gitignore b/.gitignore index 7a658a38b..64741c525 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ Make.dep core .gdbinit cscope.out +/Kconfig /bin /external /.context diff --git a/Application.mk b/Application.mk new file mode 100644 index 000000000..cd9d247c2 --- /dev/null +++ b/Application.mk @@ -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 +# Paul Alexander Patience +# +# 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 diff --git a/ChangeLog.txt b/ChangeLog.txt index 5c59eec58..386ed441f 100644 --- a/ChangeLog.txt +++ b/ChangeLog.txt @@ -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 +7.11 2015-08-13 Gregory Nutt * 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 + + * 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 + + * 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). diff --git a/Directory.mk b/Directory.mk new file mode 100644 index 000000000..9c233fe9c --- /dev/null +++ b/Directory.mk @@ -0,0 +1,68 @@ +############################################################################ +# apps/Directory.mk +# +# Copyright (C) 2011-2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config # 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 diff --git a/Kconfig b/Kconfig deleted file mode 100644 index 7b21c6387..000000000 --- a/Kconfig +++ /dev/null @@ -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 diff --git a/Makefile b/Makefile index d580d2f10..76b23eddd 100644 --- a/Makefile +++ b/Makefile @@ -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) diff --git a/NxWidgets/Kconfig b/NxWidgets/Kconfig index 018e5f9b6..d0026e492 100644 --- a/NxWidgets/Kconfig +++ b/NxWidgets/Kconfig @@ -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 diff --git a/README.txt b/README.txt index 909499378..4f481cefb 100644 --- a/README.txt +++ b/README.txt @@ -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. diff --git a/builtin/Kconfig b/builtin/Kconfig index 8ea51b38a..e8384234a 100644 --- a/builtin/Kconfig +++ b/builtin/Kconfig @@ -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 diff --git a/canutils/Kconfig b/canutils/Kconfig new file mode 100644 index 000000000..59830cba2 --- /dev/null +++ b/canutils/Kconfig @@ -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 diff --git a/canutils/Make.defs b/canutils/Make.defs new file mode 100644 index 000000000..92373732f --- /dev/null +++ b/canutils/Make.defs @@ -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 +# +# 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) diff --git a/canutils/Makefile b/canutils/Makefile new file mode 100644 index 000000000..abe102db3 --- /dev/null +++ b/canutils/Makefile @@ -0,0 +1,36 @@ +############################################################################ +# apps/canutils/Makefile +# +# Copyright (C) 2011-2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +include $(APPDIR)/Directory.mk diff --git a/canutils/uavcan/.gitignore b/canutils/uavcan/.gitignore new file mode 100644 index 000000000..bb6550f3b --- /dev/null +++ b/canutils/uavcan/.gitignore @@ -0,0 +1,6 @@ +/.built +/dsdlc_generated +/libuavcan +/libuavcan-* +/dsdl-* +/pyuavcan-* diff --git a/canutils/uavcan/Kconfig b/canutils/uavcan/Kconfig new file mode 100644 index 000000000..3103be4ca --- /dev/null +++ b/canutils/uavcan/Kconfig @@ -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 diff --git a/canutils/uavcan/Make.defs b/canutils/uavcan/Make.defs new file mode 100644 index 000000000..fa3c9c602 --- /dev/null +++ b/canutils/uavcan/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# apps/canutils/uavcan/Make.defs +# +# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience +# +# 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 diff --git a/canutils/uavcan/Makefile b/canutils/uavcan/Makefile new file mode 100644 index 000000000..90551ef95 --- /dev/null +++ b/canutils/uavcan/Makefile @@ -0,0 +1,254 @@ +############################################################################ +# apps/canutils/uavcan/Makefile +# +# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience +# +# 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 diff --git a/canutils/uavcan/platform_stm32.cpp b/canutils/uavcan/platform_stm32.cpp new file mode 100644 index 000000000..596b3eb69 --- /dev/null +++ b/canutils/uavcan/platform_stm32.cpp @@ -0,0 +1,101 @@ +/**************************************************************************** + * canutils/uavcan/uavcan_platform.cpp + * + * Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. + * Author: Paul Alexander Patience + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if CONFIG_UAVCAN_RX_QUEUE_CAPACITY > 0 +static uavcan_stm32::CanInitHelper 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(); +} diff --git a/examples/Kconfig b/examples/Kconfig index bd90ae004..04a2a39bc 100644 --- a/examples/Kconfig +++ b/examples/Kconfig @@ -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 diff --git a/examples/Makefile b/examples/Makefile index e3e67d6aa..70315d06c 100644 --- a/examples/Makefile +++ b/examples/Makefile @@ -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 diff --git a/examples/README.txt b/examples/README.txt index fac72092d..562000fc0 100644 --- a/examples/README.txt +++ b/examples/README.txt @@ -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. diff --git a/examples/adc/Kconfig b/examples/adc/Kconfig index 237562e4d..418bd7a15 100644 --- a/examples/adc/Kconfig +++ b/examples/adc/Kconfig @@ -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 diff --git a/examples/adc/Makefile b/examples/adc/Makefile index 1cd406a80..14dcaa648 100644 --- a/examples/adc/Makefile +++ b/examples/adc/Makefile @@ -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 diff --git a/examples/adc/adc.h b/examples/adc/adc.h index 84583ca8f..693301687 100644 --- a/examples/adc/adc.h +++ b/examples/adc/adc.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* CONFIG_NSH_BUILTIN_APPS - Build the ADC test as an NSH built-in function. diff --git a/examples/adc/adc_main.c b/examples/adc/adc_main.c index c64281385..8bbc469dc 100644 --- a/examples/adc/adc_main.c +++ b/examples/adc/adc_main.c @@ -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); } } } diff --git a/examples/ajoystick/Makefile b/examples/ajoystick/Makefile index b294c36dd..9e736c859 100644 --- a/examples/ajoystick/Makefile +++ b/examples/ajoystick/Makefile @@ -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 diff --git a/examples/ajoystick/ajoy_main.c b/examples/ajoystick/ajoy_main.c index 3fb4a2b23..c047d2555 100644 --- a/examples/ajoystick/ajoy_main.c +++ b/examples/ajoystick/ajoy_main.c @@ -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 * * 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; diff --git a/examples/bridge/Kconfig b/examples/bridge/Kconfig index 4ae08ecb6..c275fc331 100644 --- a/examples/bridge/Kconfig +++ b/examples/bridge/Kconfig @@ -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" diff --git a/examples/buttons/Kconfig b/examples/buttons/Kconfig index 924e27902..b84eb08eb 100644 --- a/examples/buttons/Kconfig +++ b/examples/buttons/Kconfig @@ -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. diff --git a/examples/buttons/Makefile b/examples/buttons/Makefile index ed1361922..1e59ef2d0 100644 --- a/examples/buttons/Makefile +++ b/examples/buttons/Makefile @@ -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 diff --git a/examples/buttons/buttons_main.c b/examples/buttons/buttons_main.c index 9cb9e588d..71fc54ec0 100644 --- a/examples/buttons/buttons_main.c +++ b/examples/buttons/buttons_main.c @@ -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] = { diff --git a/examples/can/Kconfig b/examples/can/Kconfig index 70092c5e2..b0afb0dad 100644 --- a/examples/can/Kconfig +++ b/examples/can/Kconfig @@ -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 diff --git a/examples/can/Makefile b/examples/can/Makefile index 44d43ace8..fa024eaa9 100644 --- a/examples/can/Makefile +++ b/examples/can/Makefile @@ -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 diff --git a/examples/can/can.h b/examples/can/can.h index 794a84b33..8b6e55c7e 100644 --- a/examples/can/can.h +++ b/examples/can/can.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * 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 */ diff --git a/examples/can/can_main.c b/examples/can/can_main.c index 9daafc56a..e2c67546e 100644 --- a/examples/can/can_main.c +++ b/examples/can/can_main.c @@ -40,6 +40,8 @@ #include #include +#include +#include #include #include @@ -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 ] [b ]\n", + progname); +#else + fprintf(stderr, "USAGE: %s [-n ] [b ]\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 : The number of messages to send. Default: 32\n"); + fprintf(stderr, "-a : The start message id. Default 1\n"); + fprintf(stderr, "-b : 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, " out of range\n"); + badarg = true; + } + break; + + case 'b': + maxid = strtol(optarg, NULL, 10); + if (maxid < minid || maxid >= MAX_ID) + { + fprintf(stderr, "ERROR: 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: 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); diff --git a/examples/cc3000/board.h b/examples/cc3000/board.h index 75caab003..df1d87085 100644 --- a/examples/cc3000/board.h +++ b/examples/cc3000/board.h @@ -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 +/**************************************************************************** + * 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); diff --git a/examples/cc3000/cc3000basic.c b/examples/cc3000/cc3000basic.c index a3747a4bc..8117bac14 100644 --- a/examples/cc3000/cc3000basic.c +++ b/examples/cc3000/cc3000basic.c @@ -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 +#include #include "board.h" #include diff --git a/examples/cc3000/shell.c b/examples/cc3000/shell.c index 2eecd2afa..9df6814fd 100644 --- a/examples/cc3000/shell.c +++ b/examples/cc3000/shell.c @@ -54,7 +54,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/configdata/Makefile b/examples/configdata/Makefile index c5b7dbe2d..d3a23e212 100644 --- a/examples/configdata/Makefile +++ b/examples/configdata/Makefile @@ -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 diff --git a/examples/configdata/configdata_main.c b/examples/configdata/configdata_main.c index 09e8303d2..1f3047aff 100644 --- a/examples/configdata/configdata_main.c +++ b/examples/configdata/configdata_main.c @@ -55,7 +55,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But diff --git a/examples/cpuhog/Makefile b/examples/cpuhog/Makefile index b21f143c0..29f46d3c9 100644 --- a/examples/cpuhog/Makefile +++ b/examples/cpuhog/Makefile @@ -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 diff --git a/examples/cxxtest/Kconfig b/examples/cxxtest/Kconfig index 55d2cf762..6c9c4c51a 100644 --- a/examples/cxxtest/Kconfig +++ b/examples/cxxtest/Kconfig @@ -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 diff --git a/examples/cxxtest/Makefile b/examples/cxxtest/Makefile index 2e75f5bf9..0f5638ef0 100644 --- a/examples/cxxtest/Makefile +++ b/examples/cxxtest/Makefile @@ -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 diff --git a/examples/dhcpd/Makefile b/examples/dhcpd/Makefile index 7ca4bed09..f8de0d6bd 100644 --- a/examples/dhcpd/Makefile +++ b/examples/dhcpd/Makefile @@ -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 diff --git a/examples/discover/Kconfig b/examples/discover/Kconfig index 4955be359..3f847d044 100644 --- a/examples/discover/Kconfig +++ b/examples/discover/Kconfig @@ -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" diff --git a/examples/discover/Makefile b/examples/discover/Makefile index 51abaf5dc..214f03d9f 100644 --- a/examples/discover/Makefile +++ b/examples/discover/Makefile @@ -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 diff --git a/examples/djoystick/Makefile b/examples/djoystick/Makefile index c1897b3e7..dccb826a7 100644 --- a/examples/djoystick/Makefile +++ b/examples/djoystick/Makefile @@ -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 diff --git a/examples/djoystick/djoy_main.c b/examples/djoystick/djoy_main.c index 7a7a74d51..bf4139228 100644 --- a/examples/djoystick/djoy_main.c +++ b/examples/djoystick/djoy_main.c @@ -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 * * 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"); diff --git a/examples/elf/elf_main.c b/examples/elf/elf_main.c index 9d0ef64aa..322ba83c9 100644 --- a/examples/elf/elf_main.c +++ b/examples/elf/elf_main.c @@ -59,7 +59,7 @@ #include "tests/dirlist.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Check configuration. This is not all of the configuration settings that diff --git a/examples/elf/tests/errno/errno.c b/examples/elf/tests/errno/errno.c index adc88ddd3..f02dab7d5 100644 --- a/examples/elf/tests/errno/errno.c +++ b/examples/elf/tests/errno/errno.c @@ -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; } diff --git a/examples/elf/tests/signal/signal.c b/examples/elf/tests/signal/signal.c index d43f012cb..1ee0e360a 100644 --- a/examples/elf/tests/signal/signal.c +++ b/examples/elf/tests/signal/signal.c @@ -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 * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ #include /**************************************************************************** - * 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); } } diff --git a/examples/elf/tests/task/task.c b/examples/elf/tests/task/task.c index a947aac73..b26e71e4d 100644 --- a/examples/elf/tests/task/task.c +++ b/examples/elf/tests/task/task.c @@ -67,7 +67,7 @@ static char no_name[] = ""; * 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); diff --git a/examples/flash_test/Makefile b/examples/flash_test/Makefile index ad91bed84..08ad8dc05 100644 --- a/examples/flash_test/Makefile +++ b/examples/flash_test/Makefile @@ -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 diff --git a/examples/fstest/.gitignore b/examples/fstest/.gitignore new file mode 100644 index 000000000..fa1ec7579 --- /dev/null +++ b/examples/fstest/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.depend +/.built +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src diff --git a/examples/fstest/Kconfig b/examples/fstest/Kconfig new file mode 100644 index 000000000..ee4708131 --- /dev/null +++ b/examples/fstest/Kconfig @@ -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 diff --git a/examples/fstest/Make.defs b/examples/fstest/Make.defs new file mode 100644 index 000000000..e935a6b4a --- /dev/null +++ b/examples/fstest/Make.defs @@ -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 +# +# 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 diff --git a/examples/fstest/Makefile b/examples/fstest/Makefile new file mode 100644 index 000000000..9fb9c9434 --- /dev/null +++ b/examples/fstest/Makefile @@ -0,0 +1,53 @@ +############################################################################ +# apps/examples/fstest/Makefile +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/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 diff --git a/examples/fstest/fstest_main.c b/examples/fstest/fstest_main.c new file mode 100644 index 000000000..8cc31b69d --- /dev/null +++ b/examples/fstest/fstest_main.c @@ -0,0 +1,873 @@ +/**************************************************************************** + * examples/fstest/fstest_main.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +/**************************************************************************** + * 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; +} + diff --git a/examples/ftpc/Makefile b/examples/ftpc/Makefile index 950677c9e..a12654b98 100644 --- a/examples/ftpc/Makefile +++ b/examples/ftpc/Makefile @@ -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 diff --git a/examples/ftpc/ftpc.h b/examples/ftpc/ftpc.h index 429976ad0..e4f729b08 100644 --- a/examples/ftpc/ftpc.h +++ b/examples/ftpc/ftpc.h @@ -52,7 +52,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Maximum size of one command line */ diff --git a/examples/ftpc/ftpc_cmds.c b/examples/ftpc/ftpc_cmds.c index 15e8ffd19..1a51867d3 100644 --- a/examples/ftpc/ftpc_cmds.c +++ b/examples/ftpc/ftpc_cmds.c @@ -243,7 +243,7 @@ int cmd_rhelp(SESSION handle, int argc, char **argv) free(msg); } - return ret; + return ret; } /**************************************************************************** diff --git a/examples/hello/Makefile b/examples/hello/Makefile index ce7c5fea2..986b68a8e 100644 --- a/examples/hello/Makefile +++ b/examples/hello/Makefile @@ -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 diff --git a/examples/hello/hello_main.c b/examples/hello/hello_main.c index 93a964ba0..94b9b5fa6 100644 --- a/examples/hello/hello_main.c +++ b/examples/hello/hello_main.c @@ -41,7 +41,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/helloxx/Kconfig b/examples/helloxx/Kconfig index f585578ce..1a8bcd738 100644 --- a/examples/helloxx/Kconfig +++ b/examples/helloxx/Kconfig @@ -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 diff --git a/examples/helloxx/Makefile b/examples/helloxx/Makefile index 285dd1d88..64b9b32d7 100644 --- a/examples/helloxx/Makefile +++ b/examples/helloxx/Makefile @@ -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 diff --git a/examples/hidkbd/Makefile b/examples/hidkbd/Makefile index acb4d4e24..32fd923a6 100644 --- a/examples/hidkbd/Makefile +++ b/examples/hidkbd/Makefile @@ -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 diff --git a/examples/i2schar/Makefile b/examples/i2schar/Makefile index 3347fb66d..91230f749 100644 --- a/examples/i2schar/Makefile +++ b/examples/i2schar/Makefile @@ -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 diff --git a/examples/i2schar/i2schar.h b/examples/i2schar/i2schar.h index 53ba1d9c5..4fe24a282 100644 --- a/examples/i2schar/i2schar.h +++ b/examples/i2schar/i2schar.h @@ -44,7 +44,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* CONFIG_NSH_BUILTIN_APPS - Build the I2SCHAR test as an NSH built-in diff --git a/examples/igmp/Makefile b/examples/igmp/Makefile index 1c58629b5..9a94d11db 100644 --- a/examples/igmp/Makefile +++ b/examples/igmp/Makefile @@ -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 diff --git a/examples/igmp/igmp.c b/examples/igmp/igmp.c index 26b82478c..59ee0c5cf 100644 --- a/examples/igmp/igmp.c +++ b/examples/igmp/igmp.c @@ -54,7 +54,7 @@ #include "igmp.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Check if the destination address is a multicast address diff --git a/examples/json/Makefile b/examples/json/Makefile index 3a19041c7..c89c7d5c3 100644 --- a/examples/json/Makefile +++ b/examples/json/Makefile @@ -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 diff --git a/examples/keypadtest/Makefile b/examples/keypadtest/Makefile index 6aefb4a8c..8faaf7341 100644 --- a/examples/keypadtest/Makefile +++ b/examples/keypadtest/Makefile @@ -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 diff --git a/examples/keypadtest/keypadtest_main.c b/examples/keypadtest/keypadtest_main.c index 9d0343b9a..bd2254d79 100644 --- a/examples/keypadtest/keypadtest_main.c +++ b/examples/keypadtest/keypadtest_main.c @@ -58,7 +58,7 @@ #endif /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ diff --git a/examples/lcdrw/Makefile b/examples/lcdrw/Makefile index 35b2064f3..2166b97cd 100644 --- a/examples/lcdrw/Makefile +++ b/examples/lcdrw/Makefile @@ -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 diff --git a/examples/lcdrw/lcdrw_main.c b/examples/lcdrw/lcdrw_main.c index 1599e0f17..1fbe4de51 100644 --- a/examples/lcdrw/lcdrw_main.c +++ b/examples/lcdrw/lcdrw_main.c @@ -47,7 +47,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* Most of the NX configuration settings are probably *not* needed by this diff --git a/examples/ltdc/Makefile b/examples/ltdc/Makefile index 97f16a657..547e5ca0d 100644 --- a/examples/ltdc/Makefile +++ b/examples/ltdc/Makefile @@ -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 diff --git a/examples/ltdc/dma2d.c b/examples/ltdc/dma2d.c index d3e34d26c..1970f1c73 100644 --- a/examples/ltdc/dma2d.c +++ b/examples/ltdc/dma2d.c @@ -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) { diff --git a/examples/ltdc/ltdc.h b/examples/ltdc/ltdc.h index 582583bff..04684f797 100644 --- a/examples/ltdc/ltdc.h +++ b/examples/ltdc/ltdc.h @@ -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); diff --git a/examples/ltdc/ltdc_main.c b/examples/ltdc/ltdc_main.c index 671ea5d74..aab6f84f3 100644 --- a/examples/ltdc/ltdc_main.c +++ b/examples/ltdc/ltdc_main.c @@ -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) { diff --git a/examples/mm/Makefile b/examples/mm/Makefile index 155f811c9..3f86b95f7 100644 --- a/examples/mm/Makefile +++ b/examples/mm/Makefile @@ -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 diff --git a/examples/modbus/Makefile b/examples/modbus/Makefile index b8bbce88c..b793d882c 100644 --- a/examples/modbus/Makefile +++ b/examples/modbus/Makefile @@ -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 diff --git a/examples/modbus/modbus_main.c b/examples/modbus/modbus_main.c index 6466f410d..926ddf519 100644 --- a/examples/modbus/modbus_main.c +++ b/examples/modbus/modbus_main.c @@ -72,7 +72,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ diff --git a/examples/mount/Makefile b/examples/mount/Makefile index f54edbb82..295389c60 100644 --- a/examples/mount/Makefile +++ b/examples/mount/Makefile @@ -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 diff --git a/examples/mount/mount.h b/examples/mount/mount.h index c75686086..f1db3c305 100644 --- a/examples/mount/mount.h +++ b/examples/mount/mount.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configure the test */ diff --git a/examples/mount/mount_main.c b/examples/mount/mount_main.c index e475306ea..e0e2520a2 100644 --- a/examples/mount/mount_main.c +++ b/examples/mount/mount_main.c @@ -52,7 +52,7 @@ #include "mount.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define TEST_USE_STAT 1 diff --git a/examples/mtdpart/Makefile b/examples/mtdpart/Makefile index 8b418327c..3a5a2f2af 100755 --- a/examples/mtdpart/Makefile +++ b/examples/mtdpart/Makefile @@ -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 diff --git a/examples/mtdpart/mtdpart_main.c b/examples/mtdpart/mtdpart_main.c index 620b3608b..66edadb5c 100644 --- a/examples/mtdpart/mtdpart_main.c +++ b/examples/mtdpart/mtdpart_main.c @@ -51,7 +51,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* Make sure that support for MTD partitions is enabled */ diff --git a/examples/mtdrwb/Makefile b/examples/mtdrwb/Makefile index 48a292296..c284910b8 100755 --- a/examples/mtdrwb/Makefile +++ b/examples/mtdrwb/Makefile @@ -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 diff --git a/examples/netloop/.gitignore b/examples/netloop/.gitignore new file mode 100644 index 000000000..cfcfc3a67 --- /dev/null +++ b/examples/netloop/.gitignore @@ -0,0 +1,14 @@ +/Make.dep +/.depend +/.built +/host +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src +/*.exe +/*.dSYM diff --git a/examples/netloop/Kconfig b/examples/netloop/Kconfig new file mode 100644 index 000000000..0cf60041e --- /dev/null +++ b/examples/netloop/Kconfig @@ -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 diff --git a/examples/netloop/Make.defs b/examples/netloop/Make.defs new file mode 100644 index 000000000..14b6c56e1 --- /dev/null +++ b/examples/netloop/Make.defs @@ -0,0 +1,38 @@ +############################################################################ +# apps/examples/netloop/Make.defs +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_EXAMPLES_NETLOOP),y) +CONFIGURED_APPS += examples/netloop +endif diff --git a/examples/netloop/Makefile b/examples/netloop/Makefile new file mode 100644 index 000000000..2ca76e7a2 --- /dev/null +++ b/examples/netloop/Makefile @@ -0,0 +1,54 @@ +############################################################################ +# apps/examples/netloop/Makefile +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/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 diff --git a/examples/netloop/lo_listener.c b/examples/netloop/lo_listener.c new file mode 100644 index 000000000..3397ad364 --- /dev/null +++ b/examples/netloop/lo_listener.c @@ -0,0 +1,392 @@ +/**************************************************************************** + * examples/netloop/lo_listener.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include + +#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 */ +} diff --git a/examples/netloop/lo_main.c b/examples/netloop/lo_main.c new file mode 100644 index 000000000..1c7b5e866 --- /dev/null +++ b/examples/netloop/lo_main.c @@ -0,0 +1,209 @@ +/**************************************************************************** + * examples/netloop/lo_main.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include + +#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; +} diff --git a/examples/netloop/netloop.h b/examples/netloop/netloop.h new file mode 100644 index 000000000..05d3348d4 --- /dev/null +++ b/examples/netloop/netloop.h @@ -0,0 +1,99 @@ +/**************************************************************************** + * examples/netloop/netloop.h + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __APPS_EXAMPLES_NETLOOP_NETLOOP_H +#define __APPS_EXAMPLES_NETLOOP_NETLOOP_H + +/**************************************************************************** + * Compilation Switches + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * 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 */ diff --git a/examples/netpkt/Makefile b/examples/netpkt/Makefile index 2f6d2eee5..b492d98ea 100644 --- a/examples/netpkt/Makefile +++ b/examples/netpkt/Makefile @@ -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 diff --git a/examples/nettest/Kconfig b/examples/nettest/Kconfig index 4ccc04052..7f5d8d8b0 100644 --- a/examples/nettest/Kconfig +++ b/examples/nettest/Kconfig @@ -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 diff --git a/examples/nettest/Makefile b/examples/nettest/Makefile index b41eeccf9..fbefe3701 100644 --- a/examples/nettest/Makefile +++ b/examples/nettest/Makefile @@ -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) diff --git a/examples/nettest/nettest.c b/examples/nettest/nettest.c index b03b288c1..13605bec3 100644 --- a/examples/nettest/nettest.c +++ b/examples/nettest/nettest.c @@ -40,8 +40,12 @@ #include "config.h" //#include +#include #include +#include #include +#include +#include #include #include @@ -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; } diff --git a/examples/nettest/nettest_client.c b/examples/nettest/nettest_client.c index 42699b177..d377a9b3a 100644 --- a/examples/nettest/nettest_client.c +++ b/examples/nettest/nettest_client.c @@ -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 diff --git a/examples/nettest/nettest_server.c b/examples/nettest/nettest_server.c index d2087a7ef..990168a5b 100644 --- a/examples/nettest/nettest_server.c +++ b/examples/nettest/nettest_server.c @@ -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); diff --git a/examples/nrf24l01_term/Makefile b/examples/nrf24l01_term/Makefile index db267b59e..e080cba9f 100644 --- a/examples/nrf24l01_term/Makefile +++ b/examples/nrf24l01_term/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Basic nRF24L01+ terminal demonstration @@ -43,95 +41,13 @@ ASRCS = CSRCS = MAINSRC = nrf24l01_term.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 ?= nrf24l01_term$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # built-in application info APPNAME = nrf24l01_term 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 diff --git a/examples/nsh/Makefile b/examples/nsh/Makefile index bcfb1fb6c..bfb6958a7 100644 --- a/examples/nsh/Makefile +++ b/examples/nsh/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # NuttShell (NSH) Example @@ -43,82 +41,7 @@ ASRCS = CSRCS = MAINSRC = nsh_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_NSH_PROGNAME ?= nsh$(EXEEXT) PROGNAME = $(CONFIG_EXAMPLES_NSH_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 diff --git a/examples/null/Makefile b/examples/null/Makefile index 3a63cb748..4b8e714f0 100644 --- a/examples/null/Makefile +++ b/examples/null/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # The smallest thing you can build -- the NULL example. @@ -43,82 +41,7 @@ ASRCS = CSRCS = MAINSRC = null_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 ?= null$(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 diff --git a/examples/null/null_main.c b/examples/null/null_main.c index 4ed4f8aca..60e44af09 100644 --- a/examples/null/null_main.c +++ b/examples/null/null_main.c @@ -40,7 +40,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/nx/Makefile b/examples/nx/Makefile index 6c5d15063..c6ceb0a4b 100644 --- a/examples/nx/Makefile +++ b/examples/nx/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # NuttX NX Graphics Example. @@ -46,95 +44,13 @@ CSRCS += nx_server.c endif MAINSRC = nx_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 ?= nx$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # NX built-in application info APPNAME = nx 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 diff --git a/examples/nx/nx_events.c b/examples/nx/nx_events.c index 7d2213f32..fb389003a 100644 --- a/examples/nx/nx_events.c +++ b/examples/nx/nx_events.c @@ -52,7 +52,7 @@ #include "nx_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/nx/nx_internal.h b/examples/nx/nx_internal.h index ff1c3b63a..1358d5885 100644 --- a/examples/nx/nx_internal.h +++ b/examples/nx/nx_internal.h @@ -51,7 +51,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ diff --git a/examples/nx/nx_kbdin.c b/examples/nx/nx_kbdin.c index 67a90d03a..8e35f6130 100644 --- a/examples/nx/nx_kbdin.c +++ b/examples/nx/nx_kbdin.c @@ -56,7 +56,7 @@ #ifdef CONFIG_NX_KBD /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Select renderer -- Some additional logic would be required to support diff --git a/examples/nxffs/Makefile b/examples/nxffs/Makefile index 0d92dc146..045d3a55b 100644 --- a/examples/nxffs/Makefile +++ b/examples/nxffs/Makefile @@ -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 = nxffs_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 ?= nxffs$(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 diff --git a/examples/nxffs/nxffs_main.c b/examples/nxffs/nxffs_main.c index 1c369937f..ddc15ee88 100644 --- a/examples/nxffs/nxffs_main.c +++ b/examples/nxffs/nxffs_main.c @@ -56,7 +56,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But @@ -652,10 +652,19 @@ static int nxffs_delfiles(void) int ndx = (rand() % (g_nfiles - g_ndeleted)); - /* And delete the next undeleted file after that random index */ + /* 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;) + 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) { @@ -677,14 +686,6 @@ static int nxffs_delfiles(void) break; } } - - /* Increment the index and test for wrap-around */ - - if (++j >= CONFIG_EXAMPLES_NXFFS_MAXOPEN) - { - j = 0; - } - } } diff --git a/examples/nxflat/nxflat_main.c b/examples/nxflat/nxflat_main.c index 3871ef600..a584a675a 100644 --- a/examples/nxflat/nxflat_main.c +++ b/examples/nxflat/nxflat_main.c @@ -58,7 +58,7 @@ #include "tests/symtab.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Check configuration. This is not all of the configuration settings that diff --git a/examples/nxflat/tests/errno/errno.c b/examples/nxflat/tests/errno/errno.c index 08a15808a..dcadb1993 100644 --- a/examples/nxflat/tests/errno/errno.c +++ b/examples/nxflat/tests/errno/errno.c @@ -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; } diff --git a/examples/nxflat/tests/hello/hello.c b/examples/nxflat/tests/hello/hello.c index 8ec4e019a..284f268df 100644 --- a/examples/nxflat/tests/hello/hello.c +++ b/examples/nxflat/tests/hello/hello.c @@ -63,13 +63,13 @@ int main(int argc, char **argv) { printf("argv[%d]\t= ", i); if (argv[i]) - { - printf("(0x%p) \"%s\"\n", argv[i], argv[i]); - } + { + printf("(0x%p) \"%s\"\n", argv[i], argv[i]); + } else - { - printf("NULL?\n"); - } + { + printf("NULL?\n"); + } } printf("argv[%d]\t= 0x%p\n", argc, argv[argc]); diff --git a/examples/nxflat/tests/signal/signal.c b/examples/nxflat/tests/signal/signal.c index ac03f6d33..a6f7b1cb0 100644 --- a/examples/nxflat/tests/signal/signal.c +++ b/examples/nxflat/tests/signal/signal.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/nxflat/tests/signal/signal.c * - * Copyright (C) 2009, 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2009, 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -47,7 +47,7 @@ #include /**************************************************************************** - * 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); } } diff --git a/examples/nxflat/tests/task/task.c b/examples/nxflat/tests/task/task.c index 2ffc1565a..b30626028 100644 --- a/examples/nxflat/tests/task/task.c +++ b/examples/nxflat/tests/task/task.c @@ -67,7 +67,7 @@ static char no_name[] = ""; * a relocation type that is not supported by NXFLAT 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); diff --git a/examples/nxhello/Makefile b/examples/nxhello/Makefile index bd41344c1..16f834737 100644 --- a/examples/nxhello/Makefile +++ b/examples/nxhello/Makefile @@ -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 = nxhello_bkgd.c MAINSRC = nxhello_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 ?= nxhello$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # NXHELLO built-in application info APPNAME = nxhello 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 diff --git a/examples/nxhello/nxhello.h b/examples/nxhello/nxhello.h index 4dde63a16..78b5f9edb 100644 --- a/examples/nxhello/nxhello.h +++ b/examples/nxhello/nxhello.h @@ -51,7 +51,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ diff --git a/examples/nxhello/nxhello_bkgd.c b/examples/nxhello/nxhello_bkgd.c index 64d66b9cb..4be77d61b 100644 --- a/examples/nxhello/nxhello_bkgd.c +++ b/examples/nxhello/nxhello_bkgd.c @@ -55,7 +55,7 @@ #include "nxhello.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Select renderer -- Some additional logic would be required to support @@ -327,7 +327,7 @@ static void nxhello_initglyph(FAR uint8_t *glyph, uint8_t height, #endif } - /**************************************************************************** +/**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/examples/nximage/Makefile b/examples/nximage/Makefile index ec8a96709..8f1aaf998 100644 --- a/examples/nximage/Makefile +++ b/examples/nximage/Makefile @@ -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 = nximage_bkgd.c nximage_bitmap.c MAINSRC = nximage_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 ?= nximage$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # NXIMAGE built-in application info APPNAME = nximage 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 diff --git a/examples/nximage/nximage.h b/examples/nximage/nximage.h index 94ca8297c..141b657ef 100644 --- a/examples/nximage/nximage.h +++ b/examples/nximage/nximage.h @@ -50,7 +50,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ diff --git a/examples/nximage/nximage_bitmap.c b/examples/nximage/nximage_bitmap.c index c750aab29..208b02cea 100644 --- a/examples/nximage/nximage_bitmap.c +++ b/examples/nximage/nximage_bitmap.c @@ -1074,7 +1074,7 @@ static const struct pix_run_s g_nuttx[] = { 75, 0}, { 1, 5}, { 2, 4}, { 1, 3}, { 1, 163}, { 1, 6}, { 1, 4}, { 1, 5}, /* Row 158 */ { 77, 0}, { 76, 0}, { 1, 5}, { 4, 4}, { 1, 5}, { 78, 0} /* Row 159 */ - }; +}; #elif CONFIG_EXAMPLES_NXIMAGE_BPP == 16 diff --git a/examples/nximage/nximage_bkgd.c b/examples/nximage/nximage_bkgd.c index c90e7c559..9ea5e3ace 100644 --- a/examples/nximage/nximage_bkgd.c +++ b/examples/nximage/nximage_bkgd.c @@ -55,7 +55,7 @@ #include "nximage.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Select renderer -- Some additional logic would be required to support diff --git a/examples/nxlines/Makefile b/examples/nxlines/Makefile index fae42e1c3..c0d8adec7 100644 --- a/examples/nxlines/Makefile +++ b/examples/nxlines/Makefile @@ -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 = nxlines_bkgd.c MAINSRC = nxlines_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 ?= nxlines$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # NXLINES built-in application info APPNAME = nxlines 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 diff --git a/examples/nxlines/nxlines.h b/examples/nxlines/nxlines.h index 65f983245..fc8cfa74c 100644 --- a/examples/nxlines/nxlines.h +++ b/examples/nxlines/nxlines.h @@ -51,7 +51,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ diff --git a/examples/nxlines/nxlines_bkgd.c b/examples/nxlines/nxlines_bkgd.c index f377be89f..4cfe94b1a 100644 --- a/examples/nxlines/nxlines_bkgd.c +++ b/examples/nxlines/nxlines_bkgd.c @@ -197,7 +197,7 @@ static void nxlines_kbdin(NXWINDOW hwnd, uint8_t nch, FAR const uint8_t *ch, } #endif - /**************************************************************************** +/**************************************************************************** * Public Functions ****************************************************************************/ diff --git a/examples/nxterm/Makefile b/examples/nxterm/Makefile index f8add33dc..ca374bc75 100644 --- a/examples/nxterm/Makefile +++ b/examples/nxterm/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # NuttX NX Console Example. @@ -43,95 +41,13 @@ ASRCS = CSRCS = nxterm_toolbar.c nxterm_wndo.c nxterm_server.c MAINSRC = nxterm_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 ?= nxterm$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # NX built-in application info APPNAME = nxterm 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 diff --git a/examples/nxterm/nxterm_internal.h b/examples/nxterm/nxterm_internal.h index 5d1df732e..43bbd945a 100644 --- a/examples/nxterm/nxterm_internal.h +++ b/examples/nxterm/nxterm_internal.h @@ -33,8 +33,8 @@ * ****************************************************************************/ -#ifndef __EXAMPLES_NXTERM_NXCON_INTERNAL_H -#define __EXAMPLES_NXTERM_NXCON_INTERNAL_H +#ifndef __EXAMPLES_NXTERM_NXTERM_INTERNAL_H +#define __EXAMPLES_NXTERM_NXTERM_INTERNAL_H /**************************************************************************** * Included Files @@ -54,7 +54,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* Need NX graphics support */ @@ -93,27 +93,27 @@ # error "Only CONFIG_NX_NPLANES==1 supported" #endif -#ifndef CONFIG_EXAMPLES_NXCON_VPLANE -# define CONFIG_EXAMPLES_NXCON_VPLANE 0 +#ifndef CONFIG_EXAMPLES_NXTERM_VPLANE +# define CONFIG_EXAMPLES_NXTERM_VPLANE 0 #endif /* Pixel depth. If none provided, pick the smallest enabled pixel depth */ -#ifndef CONFIG_EXAMPLES_NXCON_BPP +#ifndef CONFIG_EXAMPLES_NXTERM_BPP # if !defined(CONFIG_NX_DISABLE_1BPP) -# define CONFIG_EXAMPLES_NXCON_BPP 1 +# define CONFIG_EXAMPLES_NXTERM_BPP 1 # elif !defined(CONFIG_NX_DISABLE_2BPP) -# define CONFIG_EXAMPLES_NXCON_BPP 2 +# define CONFIG_EXAMPLES_NXTERM_BPP 2 # elif !defined(CONFIG_NX_DISABLE_4BPP) -# define CONFIG_EXAMPLES_NXCON_BPP 4 +# define CONFIG_EXAMPLES_NXTERM_BPP 4 # elif !defined(CONFIG_NX_DISABLE_8BPP) -# define CONFIG_EXAMPLES_NXCON_BPP 8 +# define CONFIG_EXAMPLES_NXTERM_BPP 8 # elif !defined(CONFIG_NX_DISABLE_16BPP) -# define CONFIG_EXAMPLES_NXCON_BPP 16 +# define CONFIG_EXAMPLES_NXTERM_BPP 16 //#elif !defined(CONFIG_NX_DISABLE_24BPP) //# define CONFIG_NXTERM_BPP 24 # elif !defined(CONFIG_NX_DISABLE_32BPP) -# define CONFIG_EXAMPLES_NXCON_BPP 32 +# define CONFIG_EXAMPLES_NXTERM_BPP 32 # else # error "No pixel depth provided" # endif @@ -121,62 +121,62 @@ /* Background color (default is darker royal blue) */ -#ifndef CONFIG_EXAMPLES_NXCON_BGCOLOR -# if CONFIG_EXAMPLES_NXCON_BPP == 24 || CONFIG_EXAMPLES_NXCON_BPP == 32 -# define CONFIG_EXAMPLES_NXCON_BGCOLOR RGBTO24(39, 64, 139) -# elif CONFIG_EXAMPLES_NXCON_BPP == 16 -# define CONFIG_EXAMPLES_NXCON_BGCOLOR RGBTO16(39, 64, 139) +#ifndef CONFIG_EXAMPLES_NXTERM_BGCOLOR +# if CONFIG_EXAMPLES_NXTERM_BPP == 24 || CONFIG_EXAMPLES_NXTERM_BPP == 32 +# define CONFIG_EXAMPLES_NXTERM_BGCOLOR RGBTO24(39, 64, 139) +# elif CONFIG_EXAMPLES_NXTERM_BPP == 16 +# define CONFIG_EXAMPLES_NXTERM_BGCOLOR RGBTO16(39, 64, 139) # else -# define CONFIG_EXAMPLES_NXCON_BGCOLOR RGBTO8(39, 64, 139) +# define CONFIG_EXAMPLES_NXTERM_BGCOLOR RGBTO8(39, 64, 139) # endif #endif /* Window color (lighter steel blue) */ -#ifndef CONFIG_EXAMPLES_NXCON_WCOLOR -# if CONFIG_EXAMPLES_NXCON_BPP == 24 || CONFIG_EXAMPLES_NXCON_BPP == 32 -# define CONFIG_EXAMPLES_NXCON_WCOLOR RGBTO24(202, 225, 255) -# elif CONFIG_EXAMPLES_NXCON_BPP == 16 -# define CONFIG_EXAMPLES_NXCON_WCOLOR RGBTO16(202, 225, 255) +#ifndef CONFIG_EXAMPLES_NXTERM_WCOLOR +# if CONFIG_EXAMPLES_NXTERM_BPP == 24 || CONFIG_EXAMPLES_NXTERM_BPP == 32 +# define CONFIG_EXAMPLES_NXTERM_WCOLOR RGBTO24(202, 225, 255) +# elif CONFIG_EXAMPLES_NXTERM_BPP == 16 +# define CONFIG_EXAMPLES_NXTERM_WCOLOR RGBTO16(202, 225, 255) # else -# define CONFIG_EXAMPLES_NXCON_WCOLOR RGBTO8(202, 225, 255) +# define CONFIG_EXAMPLES_NXTERM_WCOLOR RGBTO8(202, 225, 255) # endif #endif /* Toolbar color (medium grey) */ -#ifndef CONFIG_EXAMPLES_NXCON_TBCOLOR -# if CONFIG_EXAMPLES_NX_BPP == 24 || CONFIG_EXAMPLES_NX_BPP == 32 -# define CONFIG_EXAMPLES_NXCON_TBCOLOR RGBTO24(188, 188, 188) -# elif CONFIG_EXAMPLES_NX_BPP == 16 -# define CONFIG_EXAMPLES_NXCON_TBCOLOR RGBTO16(188, 188, 188) +#ifndef CONFIG_EXAMPLES_NXTERM_TBCOLOR +# if CONFIG_EXAMPLES_NXTERM_BPP == 24 || CONFIG_EXAMPLES_NXTERM_BPP == 32 +# define CONFIG_EXAMPLES_NXTERM_TBCOLOR RGBTO24(188, 188, 188) +# elif CONFIG_EXAMPLES_NXTERM_BPP == 16 +# define CONFIG_EXAMPLES_NXTERM_TBCOLOR RGBTO16(188, 188, 188) # else -# define CONFIG_EXAMPLES_NXCON_TBCOLOR RGBTO8(188, 188, 188) +# define CONFIG_EXAMPLES_NXTERM_TBCOLOR RGBTO8(188, 188, 188) # endif #endif /* Font ID */ -#ifndef CONFIG_EXAMPLES_NXCON_FONTID -# define CONFIG_EXAMPLES_NXCON_FONTID NXFONT_DEFAULT +#ifndef CONFIG_EXAMPLES_NXTERM_FONTID +# define CONFIG_EXAMPLES_NXTERM_FONTID NXFONT_DEFAULT #endif /* Font color */ -#ifndef CONFIG_EXAMPLES_NXCON_FONTCOLOR -# if CONFIG_EXAMPLES_NXCON_BPP == 24 || CONFIG_EXAMPLES_NXCON_BPP == 32 -# define CONFIG_EXAMPLES_NXCON_FONTCOLOR RGBTO24(0, 0, 0) -# elif CONFIG_EXAMPLES_NXCON_BPP == 16 -# define CONFIG_EXAMPLES_NXCON_FONTCOLOR RGBTO16(0, 0, 0) +#ifndef CONFIG_EXAMPLES_NXTERM_FONTCOLOR +# if CONFIG_EXAMPLES_NXTERM_BPP == 24 || CONFIG_EXAMPLES_NXTERM_BPP == 32 +# define CONFIG_EXAMPLES_NXTERM_FONTCOLOR RGBTO24(0, 0, 0) +# elif CONFIG_EXAMPLES_NXTERM_BPP == 16 +# define CONFIG_EXAMPLES_NXTERM_FONTCOLOR RGBTO16(0, 0, 0) # else -# define CONFIG_EXAMPLES_NXCON_FONTCOLOR RGBTO8(0, 0, 0) +# define CONFIG_EXAMPLES_NXTERM_FONTCOLOR RGBTO8(0, 0, 0) # endif #endif /* Height of the toolbar */ -#ifndef CONFIG_EXAMPLES_NXCON_TOOLBAR_HEIGHT -# define CONFIG_EXAMPLES_NXCON_TOOLBAR_HEIGHT 16 +#ifndef CONFIG_EXAMPLES_NXTERM_TOOLBAR_HEIGHT +# define CONFIG_EXAMPLES_NXTERM_TOOLBAR_HEIGHT 16 #endif /* Multi-user NX support */ @@ -193,36 +193,36 @@ #ifndef CONFIG_NX_BLOCKING # error "This example depends on CONFIG_NX_BLOCKING" #endif -#ifndef CONFIG_EXAMPLES_NXCON_STACKSIZE -# define CONFIG_EXAMPLES_NXCON_STACKSIZE 2048 +#ifndef CONFIG_EXAMPLES_NXTERM_STACKSIZE +# define CONFIG_EXAMPLES_NXTERM_STACKSIZE 2048 #endif -#ifndef CONFIG_EXAMPLES_NXCON_LISTENERPRIO -# define CONFIG_EXAMPLES_NXCON_LISTENERPRIO 100 +#ifndef CONFIG_EXAMPLES_NXTERM_LISTENERPRIO +# define CONFIG_EXAMPLES_NXTERM_LISTENERPRIO 100 #endif -#ifndef CONFIG_EXAMPLES_NXCON_CLIENTPRIO -# define CONFIG_EXAMPLES_NXCON_CLIENTPRIO 100 +#ifndef CONFIG_EXAMPLES_NXTERM_CLIENTPRIO +# define CONFIG_EXAMPLES_NXTERM_CLIENTPRIO 100 #endif -#ifndef CONFIG_EXAMPLES_NXCON_SERVERPRIO -# define CONFIG_EXAMPLES_NXCON_SERVERPRIO 120 +#ifndef CONFIG_EXAMPLES_NXTERM_SERVERPRIO +# define CONFIG_EXAMPLES_NXTERM_SERVERPRIO 120 #endif -#ifndef CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO -# define CONFIG_EXAMPLES_NXCON_NOTIFYSIGNO 4 +#ifndef CONFIG_EXAMPLES_NXTERM_NOTIFYSIGNO +# define CONFIG_EXAMPLES_NXTERM_NOTIFYSIGNO 4 #endif /* Graphics Device */ -#ifndef CONFIG_EXAMPLES_NXCON_DEVNO -# define CONFIG_EXAMPLES_NXCON_DEVNO 0 +#ifndef CONFIG_EXAMPLES_NXTERM_DEVNO +# define CONFIG_EXAMPLES_NXTERM_DEVNO 0 #endif /* NX Console Device */ -#ifndef CONFIG_EXAMPLES_NXCON_MINOR -# define CONFIG_EXAMPLES_NXCON_MINOR 0 +#ifndef CONFIG_EXAMPLES_NXTERM_MINOR +# define CONFIG_EXAMPLES_NXTERM_MINOR 0 #endif -#ifndef CONFIG_EXAMPLES_NXCON_DEVNAME -# define CONFIG_EXAMPLES_NXCON_DEVNAME "/dev/nxterm0" +#ifndef CONFIG_EXAMPLES_NXTERM_DEVNAME +# define CONFIG_EXAMPLES_NXTERM_DEVNAME "/dev/nxterm0" #endif /* NxTerm task */ @@ -282,4 +282,4 @@ extern const struct nx_callback_s g_nxtoolcb; int nxterm_server(int argc, char *argv[]); FAR void *nxterm_listener(FAR void *arg); -#endif /* __EXAMPLES_NXTERM_NXCON_INTERNAL_H */ +#endif /* __EXAMPLES_NXTERM_NXTERM_INTERNAL_H */ diff --git a/examples/nxterm/nxterm_main.c b/examples/nxterm/nxterm_main.c index c44f5fd9a..7db53e801 100644 --- a/examples/nxterm/nxterm_main.c +++ b/examples/nxterm/nxterm_main.c @@ -110,7 +110,7 @@ static int nxterm_initialize(void) /* Set the client task priority */ - param.sched_priority = CONFIG_EXAMPLES_NXCON_CLIENTPRIO; + param.sched_priority = CONFIG_EXAMPLES_NXTERM_CLIENTPRIO; ret = sched_setparam(0, ¶m); if (ret < 0) { @@ -121,8 +121,8 @@ static int nxterm_initialize(void) /* Start the server task */ printf("nxterm_initialize: Starting nxterm_server task\n"); - servrid = task_create("NX Server", CONFIG_EXAMPLES_NXCON_SERVERPRIO, - CONFIG_EXAMPLES_NXCON_STACKSIZE, nxterm_server, NULL); + servrid = task_create("NX Server", CONFIG_EXAMPLES_NXTERM_SERVERPRIO, + CONFIG_EXAMPLES_NXTERM_STACKSIZE, nxterm_server, NULL); if (servrid < 0) { printf("nxterm_initialize: Failed to create nxterm_server task: %d\n", errno); @@ -146,9 +146,9 @@ static int nxterm_initialize(void) */ (void)pthread_attr_init(&attr); - param.sched_priority = CONFIG_EXAMPLES_NXCON_LISTENERPRIO; + param.sched_priority = CONFIG_EXAMPLES_NXTERM_LISTENERPRIO; (void)pthread_attr_setschedparam(&attr, ¶m); - (void)pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXCON_STACKSIZE); + (void)pthread_attr_setstacksize(&attr, CONFIG_EXAMPLES_NXTERM_STACKSIZE); ret = pthread_create(&thread, &attr, nxterm_listener, NULL); if (ret != 0) @@ -267,8 +267,8 @@ int nxterm_main(int argc, char **argv) /* Set the background to the configured background color */ - printf("nxterm_main: Set background color=%d\n", CONFIG_EXAMPLES_NXCON_BGCOLOR); - color = CONFIG_EXAMPLES_NXCON_BGCOLOR; + printf("nxterm_main: Set background color=%d\n", CONFIG_EXAMPLES_NXTERM_BGCOLOR); + color = CONFIG_EXAMPLES_NXTERM_BGCOLOR; ret = nx_setbgcolor(g_nxterm_vars.hnx, &color); if (ret < 0) { @@ -333,7 +333,7 @@ int nxterm_main(int argc, char **argv) /* Open the toolbar */ printf("nxterm_main: Add toolbar to window\n"); - ret = nxtk_opentoolbar(g_nxterm_vars.hwnd, CONFIG_EXAMPLES_NXCON_TOOLBAR_HEIGHT, &g_nxtoolcb, NULL); + ret = nxtk_opentoolbar(g_nxterm_vars.hwnd, CONFIG_EXAMPLES_NXTERM_TOOLBAR_HEIGHT, &g_nxtoolcb, NULL); if (ret < 0) { printf("nxterm_main: nxtk_opentoolbar failed: %d\n", errno); @@ -347,11 +347,11 @@ int nxterm_main(int argc, char **argv) /* NxTerm Configuration ************************************************/ /* Use the window to create an NX console */ - g_nxterm_vars.wndo.wcolor[0] = CONFIG_EXAMPLES_NXCON_WCOLOR; - g_nxterm_vars.wndo.fcolor[0] = CONFIG_EXAMPLES_NXCON_FONTCOLOR; - g_nxterm_vars.wndo.fontid = CONFIG_EXAMPLES_NXCON_FONTID; + g_nxterm_vars.wndo.wcolor[0] = CONFIG_EXAMPLES_NXTERM_WCOLOR; + g_nxterm_vars.wndo.fcolor[0] = CONFIG_EXAMPLES_NXTERM_FONTCOLOR; + g_nxterm_vars.wndo.fontid = CONFIG_EXAMPLES_NXTERM_FONTID; - g_nxterm_vars.hdrvr = nxtk_register(g_nxterm_vars.hwnd, &g_nxterm_vars.wndo, CONFIG_EXAMPLES_NXCON_MINOR); + g_nxterm_vars.hdrvr = nxtk_register(g_nxterm_vars.hwnd, &g_nxterm_vars.wndo, CONFIG_EXAMPLES_NXTERM_MINOR); if (!g_nxterm_vars.hdrvr) { printf("nxterm_main: nxtk_register failed: %d\n", errno); @@ -360,11 +360,11 @@ int nxterm_main(int argc, char **argv) /* Open the NxTerm driver */ - fd = open(CONFIG_EXAMPLES_NXCON_DEVNAME, O_WRONLY); + fd = open(CONFIG_EXAMPLES_NXTERM_DEVNAME, O_WRONLY); if (fd < 0) { printf("nxterm_main: open %s read-only failed: %d\n", - CONFIG_EXAMPLES_NXCON_DEVNAME, errno); + CONFIG_EXAMPLES_NXTERM_DEVNAME, errno); goto errout_with_driver; } diff --git a/examples/nxterm/nxterm_server.c b/examples/nxterm/nxterm_server.c index 1be10e17b..50867a29c 100644 --- a/examples/nxterm/nxterm_server.c +++ b/examples/nxterm/nxterm_server.c @@ -88,7 +88,7 @@ int nxterm_server(int argc, char *argv[]) FAR NX_DRIVERTYPE *dev; int ret; -#if defined(CONFIG_EXAMPLES_NXCON_EXTERNINIT) +#if defined(CONFIG_EXAMPLES_NXTERM_EXTERNINIT) struct boardioc_graphics_s devinfo; int ret; @@ -96,14 +96,14 @@ int nxterm_server(int argc, char *argv[]) printf("nxterm_server: Initializing external graphics device\n"); - devinfo.devno = CONFIG_EXAMPLES_NXCON_DEVNO; + devinfo.devno = CONFIG_EXAMPLES_NXTERM_DEVNO; devinfo.dev = NULL; ret = boardctl(BOARDIOC_GRAPHICS_SETUP, (uintptr_t)&devinfo); if (ret < 0) { printf("nxterm_server: boardctl failed, devno=%d: %d\n", - CONFIG_EXAMPLES_NXCON_DEVNO, errno); + CONFIG_EXAMPLES_NXTERM_DEVNO, errno); return ERROR; } @@ -122,11 +122,11 @@ int nxterm_server(int argc, char *argv[]) /* Get the device instance */ - dev = board_lcd_getdev(CONFIG_EXAMPLES_NXCON_DEVNO); + dev = board_lcd_getdev(CONFIG_EXAMPLES_NXTERM_DEVNO); if (!dev) { printf("nxterm_server: board_lcd_getdev failed, devno=%d\n", - CONFIG_EXAMPLES_NXCON_DEVNO); + CONFIG_EXAMPLES_NXTERM_DEVNO); return 2; } @@ -144,10 +144,10 @@ int nxterm_server(int argc, char *argv[]) return 1; } - dev = up_fbgetvplane(CONFIG_EXAMPLES_NXCON_VPLANE); + dev = up_fbgetvplane(CONFIG_EXAMPLES_NXTERM_VPLANE); if (!dev) { - printf("nxterm_server: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXCON_VPLANE); + printf("nxterm_server: up_fbgetvplane failed, vplane=%d\n", CONFIG_EXAMPLES_NXTERM_VPLANE); return 2; } #endif diff --git a/examples/nxterm/nxterm_toolbar.c b/examples/nxterm/nxterm_toolbar.c index a34e7cebd..2182fa98c 100644 --- a/examples/nxterm/nxterm_toolbar.c +++ b/examples/nxterm/nxterm_toolbar.c @@ -54,7 +54,7 @@ #include "nxterm_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -121,7 +121,7 @@ static void nxtool_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, hwnd, rect->pt1.x, rect->pt1.y, rect->pt2.x, rect->pt2.y, more ? "true" : "false"); - color[0] = CONFIG_EXAMPLES_NXCON_TBCOLOR; + color[0] = CONFIG_EXAMPLES_NXTERM_TBCOLOR; ret = nxtk_filltoolbar(hwnd, rect, color); if (ret < 0) { diff --git a/examples/nxterm/nxterm_wndo.c b/examples/nxterm/nxterm_wndo.c index 9b9edff77..8f5b09cf7 100644 --- a/examples/nxterm/nxterm_wndo.c +++ b/examples/nxterm/nxterm_wndo.c @@ -55,7 +55,7 @@ #include "nxterm_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -133,7 +133,7 @@ static void nxwndo_redraw(NXWINDOW hwnd, FAR const struct nxgl_rect_s *rect, { /* If the driver has not been opened, then just redraw the window color */ - wcolor[0] = CONFIG_EXAMPLES_NXCON_WCOLOR; + wcolor[0] = CONFIG_EXAMPLES_NXTERM_WCOLOR; (void)nxtk_fillwindow(hwnd, rect, wcolor); } } diff --git a/examples/nxtext/Makefile b/examples/nxtext/Makefile index 5734b5554..b38a9a91c 100644 --- a/examples/nxtext/Makefile +++ b/examples/nxtext/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # NuttX NX Graphics Example. @@ -47,95 +45,13 @@ ifeq ($(CONFIG_NX_MULTIUSER),y) CSRCS += nxtext_server.c endif -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 ?= nxtext$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # NXTEXT built-in application info APPNAME = nxtext 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 diff --git a/examples/nxtext/nxtext_bkgd.c b/examples/nxtext/nxtext_bkgd.c index 1dc74d075..df0f70d6e 100644 --- a/examples/nxtext/nxtext_bkgd.c +++ b/examples/nxtext/nxtext_bkgd.c @@ -54,7 +54,7 @@ #include "nxtext_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/nxtext/nxtext_internal.h b/examples/nxtext/nxtext_internal.h index 3e4b27b8d..a94aafec9 100644 --- a/examples/nxtext/nxtext_internal.h +++ b/examples/nxtext/nxtext_internal.h @@ -51,7 +51,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ diff --git a/examples/nxtext/nxtext_popup.c b/examples/nxtext/nxtext_popup.c index 6d4719e19..78e331089 100644 --- a/examples/nxtext/nxtext_popup.c +++ b/examples/nxtext/nxtext_popup.c @@ -53,7 +53,7 @@ #include "nxtext_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define NBM_CACHE 8 diff --git a/examples/nxtext/nxtext_putc.c b/examples/nxtext/nxtext_putc.c index fddd98a80..01031ad5f 100644 --- a/examples/nxtext/nxtext_putc.c +++ b/examples/nxtext/nxtext_putc.c @@ -54,7 +54,7 @@ #include "nxtext_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Select renderer -- Some additional logic would be required to support diff --git a/examples/ostest/Makefile b/examples/ostest/Makefile index d591ce3f2..32befbb71 100644 --- a/examples/ostest/Makefile +++ b/examples/ostest/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # ostest built-in application info @@ -112,89 +110,7 @@ endif # CONFIG_PRIORITY_INHERITANCE endif # CONFIG_DISABLE_PTHREAD endif # CONFIG_DISABLE_SIGNALS -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 ?= ostest$(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 diff --git a/examples/ostest/barrier.c b/examples/ostest/barrier.c index 9de96ceaf..494502ce4 100644 --- a/examples/ostest/barrier.c +++ b/examples/ostest/barrier.c @@ -44,7 +44,7 @@ #include "ostest.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define HALF_SECOND 500000L diff --git a/examples/ostest/cancel.c b/examples/ostest/cancel.c index 25564c00f..5bd395020 100644 --- a/examples/ostest/cancel.c +++ b/examples/ostest/cancel.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * examples/ostest/cancel.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ #include #include diff --git a/examples/ostest/cond.c b/examples/ostest/cond.c index ed95473de..5c0108577 100644 --- a/examples/ostest/cond.c +++ b/examples/ostest/cond.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * cond.c * * Copyright (C) 2007, 2008, 2013 Gregory Nutt. All rights reserved. @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ #include #include diff --git a/examples/ostest/fpu.c b/examples/ostest/fpu.c index c0a60c086..81c4790c6 100644 --- a/examples/ostest/fpu.c +++ b/examples/ostest/fpu.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * apps/examples/ostest/fpu.c * * Copyright (C) 2012 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ -/*********************************************************************** +/**************************************************************************** * Included Files - ***********************************************************************/ + ****************************************************************************/ #include #include @@ -48,9 +48,9 @@ #include "ostest.h" -/*********************************************************************** +/**************************************************************************** * Pre-processor definitions - ***********************************************************************/ + ****************************************************************************/ /* Configuration *******************************************************/ #undef HAVE_FPU @@ -106,9 +106,9 @@ # define NULL (void*)0 #endif -/*********************************************************************** +/**************************************************************************** * External Dependencies - ***********************************************************************/ + ****************************************************************************/ /* This test is very dependent on support provided by the chip/board- * layer logic. In particular, it expects the following functions * to be provided: @@ -127,9 +127,9 @@ extern void arch_getfpu(FAR uint32_t *fpusave); extern bool arch_cmpfpu(FAR const uint32_t *fpusave1, FAR const uint32_t *fpusave2); -/*********************************************************************** +/**************************************************************************** * Private Types - ***********************************************************************/ + ****************************************************************************/ struct fpu_threaddata_s { @@ -152,16 +152,16 @@ struct fpu_threaddata_s volatile float dp4; }; -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ static uint8_t g_fpuno; /* static */ struct fpu_threaddata_s g_fputhread[FPU_NTHREADS]; -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ static void fpu_dump(FAR uint32_t *buffer, FAR const char *msg) { @@ -299,9 +299,9 @@ static int fpu_task(int argc, char *argv[]) } #endif /* HAVE_FPU */ -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ void fpu_test(void) { diff --git a/examples/ostest/mqueue.c b/examples/ostest/mqueue.c index 4f1c48807..3def67cbb 100644 --- a/examples/ostest/mqueue.c +++ b/examples/ostest/mqueue.c @@ -1,4 +1,4 @@ -/************************************************************************** +/**************************************************************************** * apps/examples/ostest/mqueue.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************/ + ****************************************************************************/ #include @@ -51,9 +51,9 @@ #include "ostest.h" -/************************************************************************** +/**************************************************************************** * Private Definitions - **************************************************************************/ + ****************************************************************************/ #define TEST_MESSAGE "This is a test and only a test" #if defined(SDCC) || defined(__ZILOG__) @@ -75,32 +75,32 @@ #define HALF_SECOND_USEC_USEC 500000L -/************************************************************************** +/**************************************************************************** * Private Types - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Private Function Prototypes - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** - * Global Variables - **************************************************************************/ +/**************************************************************************** + * Public Data + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Private Variables - **************************************************************************/ + ****************************************************************************/ static mqd_t g_send_mqfd; static mqd_t g_recv_mqfd; -/************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************/ + ****************************************************************************/ static void *sender_thread(void *arg) { diff --git a/examples/ostest/mutex.c b/examples/ostest/mutex.c index 1951a4039..a99ee7f69 100644 --- a/examples/ostest/mutex.c +++ b/examples/ostest/mutex.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * mutex.c * * Copyright (C) 2007, 2008 Gregory Nutt. All rights reserved. @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ #include #include diff --git a/examples/ostest/nsem.c b/examples/ostest/nsem.c index cef2282fb..50d10e7bc 100644 --- a/examples/ostest/nsem.c +++ b/examples/ostest/nsem.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * apps/examples/nsem.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ -/*********************************************************************** +/**************************************************************************** * Included Files - ***********************************************************************/ + ****************************************************************************/ #include #include @@ -48,9 +48,9 @@ #ifdef CONFIG_FS_NAMED_SEMAPHORES -/*********************************************************************** +/**************************************************************************** * Pre-processor Definitions - ***********************************************************************/ + ****************************************************************************/ #define SEM1_NAME "foo" #define SEM2_NAME "bar" @@ -59,13 +59,13 @@ # define NULL (void*)0 #endif -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ static FAR void *nsem_peer(void *parameter) { @@ -111,9 +111,9 @@ static FAR void *nsem_peer(void *parameter) return NULL; } -/*********************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************/ + ****************************************************************************/ void nsem_test(void) { diff --git a/examples/ostest/ostest.h b/examples/ostest/ostest.h index 6512c7547..c97dd8a70 100644 --- a/examples/ostest/ostest.h +++ b/examples/ostest/ostest.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* The task_create task size can be specified in the defconfig file */ diff --git a/examples/ostest/ostest_main.c b/examples/ostest/ostest_main.c index b972a6544..1450373dc 100644 --- a/examples/ostest/ostest_main.c +++ b/examples/ostest/ostest_main.c @@ -58,7 +58,7 @@ #include "ostest.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define PRIORITY 100 diff --git a/examples/ostest/posixtimer.c b/examples/ostest/posixtimer.c index ebb1ab79e..9f95536d3 100644 --- a/examples/ostest/posixtimer.c +++ b/examples/ostest/posixtimer.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * examples/ostest/posixtimer.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************/ + ****************************************************************************/ #include #include @@ -45,9 +45,9 @@ #include #include "ostest.h" -/************************************************************************** +/**************************************************************************** * Private Definitions - **************************************************************************/ + ****************************************************************************/ #ifndef NULL # define NULL (void*)0 @@ -56,16 +56,16 @@ #define MY_TIMER_SIGNAL 17 #define SIGVALUE_INT 42 -/************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************/ + ****************************************************************************/ static sem_t sem; static int g_nsigreceived = 0; -/************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************/ + ****************************************************************************/ static void timer_expiration(int signo, siginfo_t *info, void *ucontext) { @@ -134,13 +134,13 @@ static void timer_expiration(int signo, siginfo_t *info, void *ucontext) } -/************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************/ + ****************************************************************************/ void timer_test(void) { - sigset_t sigset; + sigset_t set; struct sigaction act; struct sigaction oact; struct sigevent notify; @@ -156,9 +156,9 @@ void timer_test(void) printf("timer_test: Unmasking signal %d\n" , MY_TIMER_SIGNAL); - (void)sigemptyset(&sigset); - (void)sigaddset(&sigset, MY_TIMER_SIGNAL); - status = sigprocmask(SIG_UNBLOCK, &sigset, NULL); + (void)sigemptyset(&set); + (void)sigaddset(&set, MY_TIMER_SIGNAL); + status = sigprocmask(SIG_UNBLOCK, &set, NULL); if (status != OK) { printf("timer_test: ERROR sigprocmask failed, status=%d\n", diff --git a/examples/ostest/prioinherit.c b/examples/ostest/prioinherit.c index 70ad430ba..a9a926c50 100644 --- a/examples/ostest/prioinherit.c +++ b/examples/ostest/prioinherit.c @@ -52,7 +52,7 @@ #if defined(CONFIG_PRIORITY_INHERITANCE) && !defined(CONFIG_DISABLE_SIGNALS) && !defined(CONFIG_DISABLE_PTHREAD) /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #ifndef CONFIG_SEM_PREALLOCHOLDERS diff --git a/examples/ostest/rmutex.c b/examples/ostest/rmutex.c index f7c0b8bc0..4cd61d6c0 100644 --- a/examples/ostest/rmutex.c +++ b/examples/ostest/rmutex.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * rmutex.c * * Copyright (C) 2008 Gregory Nutt. All rights reserved. @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ #include #include diff --git a/examples/ostest/sem.c b/examples/ostest/sem.c index 14d0c0725..6b22c7f03 100644 --- a/examples/ostest/sem.c +++ b/examples/ostest/sem.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * sem.c * * Copyright (C) 2007-2009 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ -/*********************************************************************** +/**************************************************************************** * Included Files - ***********************************************************************/ + ****************************************************************************/ #include #include @@ -43,23 +43,23 @@ #include #include "ostest.h" -/*********************************************************************** +/**************************************************************************** * Pre-processor Definitions - ***********************************************************************/ + ****************************************************************************/ #ifndef NULL # define NULL (void*)0 #endif -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ static sem_t sem; -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ static void *waiter_func(void *parameter) { @@ -154,9 +154,9 @@ static void *poster_func(void *parameter) } -/*********************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************/ + ****************************************************************************/ void sem_test(void) { diff --git a/examples/ostest/semtimed.c b/examples/ostest/semtimed.c index 55f8bf774..83b73731e 100644 --- a/examples/ostest/semtimed.c +++ b/examples/ostest/semtimed.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * apps/examples/ostest/semtimed.c * * Copyright (C) 2014-2015 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ -/*********************************************************************** +/**************************************************************************** * Included Files - ***********************************************************************/ + ****************************************************************************/ #include #include @@ -46,23 +46,23 @@ #include "ostest.h" -/*********************************************************************** +/**************************************************************************** * Preprocessor Definitions - ***********************************************************************/ + ****************************************************************************/ #ifndef NULL # error Broken toolchain does not have NULL #endif -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ static sem_t sem; -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ static void *poster_func(void *parameter) { @@ -98,9 +98,9 @@ static void ostest_gettime(struct timespec *tp) } } -/*********************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************/ + ****************************************************************************/ void semtimed_test(void) { diff --git a/examples/ostest/sighand.c b/examples/ostest/sighand.c index e4e5bf639..138c54e73 100644 --- a/examples/ostest/sighand.c +++ b/examples/ostest/sighand.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * apps/examples/ostest/sighand.c * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ #include #include @@ -43,9 +43,9 @@ #include #include "ostest.h" -/*********************************************************************** +/**************************************************************************** * Pre-processor Definitions - ***********************************************************************/ + ****************************************************************************/ #ifndef NULL # define NULL (void*)0 @@ -54,17 +54,17 @@ #define WAKEUP_SIGNAL 17 #define SIGVALUE_INT 42 -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ static sem_t sem; static bool sigreceived = false; static bool threadexited = false; -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ #ifdef CONFIG_SCHED_HAVE_PARENT static void death_of_child(int signo, siginfo_t *info, void *ucontext) @@ -78,8 +78,10 @@ static void death_of_child(int signo, siginfo_t *info, void *ucontext) if (info) { - printf("death_of_child: PID %d received signal=%d code=%d pid=%d status=%d\n", - getpid(), signo, info->si_code, info->si_pid, info->si_status); + printf("death_of_child: PID %d received signal=%d code=%d " + "errno=%d pid=%d status=%d\n", + getpid(), signo, info->si_code, info->si_errno, + info->si_pid, info->si_status); } else { @@ -151,7 +153,7 @@ static void wakeup_action(int signo, siginfo_t *info, void *ucontext) static int waiter_main(int argc, char *argv[]) { - sigset_t sigset; + sigset_t set; struct sigaction act; struct sigaction oact; int status; @@ -159,9 +161,9 @@ static int waiter_main(int argc, char *argv[]) printf("waiter_main: Waiter started\n" ); printf("waiter_main: Unmasking signal %d\n" , WAKEUP_SIGNAL); - (void)sigemptyset(&sigset); - (void)sigaddset(&sigset, WAKEUP_SIGNAL); - status = sigprocmask(SIG_UNBLOCK, &sigset, NULL); + (void)sigemptyset(&set); + (void)sigaddset(&set, WAKEUP_SIGNAL); + status = sigprocmask(SIG_UNBLOCK, &set, NULL); if (status != OK) { printf("waiter_main: ERROR sigprocmask failed, status=%d\n", @@ -221,16 +223,16 @@ static int waiter_main(int argc, char *argv[]) return 0; } -/*********************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************/ + ****************************************************************************/ void sighand_test(void) { #ifdef CONFIG_SCHED_HAVE_PARENT struct sigaction act; struct sigaction oact; - sigset_t sigset; + sigset_t set; #endif struct sched_param param; union sigval sigvalue; @@ -243,9 +245,9 @@ void sighand_test(void) #ifdef CONFIG_SCHED_HAVE_PARENT printf("sighand_test: Unmasking SIGCHLD\n"); - (void)sigemptyset(&sigset); - (void)sigaddset(&sigset, SIGCHLD); - status = sigprocmask(SIG_UNBLOCK, &sigset, NULL); + (void)sigemptyset(&set); + (void)sigaddset(&set, SIGCHLD); + status = sigprocmask(SIG_UNBLOCK, &set, NULL); if (status != OK) { printf("sighand_test: ERROR sigprocmask failed, status=%d\n", diff --git a/examples/ostest/signest.c b/examples/ostest/signest.c index 61792fdab..afb44a8d5 100644 --- a/examples/ostest/signest.c +++ b/examples/ostest/signest.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * apps/examples/ostest/signest.c * * Copyright (C) 2015 Gregory Nutt. All rights reserved. @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ #include #include @@ -44,9 +44,9 @@ #include #include "ostest.h" -/*********************************************************************** +/**************************************************************************** * Pre-processor Definitions - ***********************************************************************/ + ****************************************************************************/ #ifndef NULL # define NULL (void*)0 @@ -55,9 +55,9 @@ #define WAKEUP_SIGNAL 17 #define SIGVALUE_INT 42 -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ static sem_t g_waiter_sem; static sem_t g_interferer_sem; @@ -73,9 +73,9 @@ static volatile int g_odd_nested; static volatile int g_nest_level; -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ static void waiter_action(int signo) { @@ -107,7 +107,7 @@ static void waiter_action(int signo) static int waiter_main(int argc, char *argv[]) { - sigset_t sigset; + sigset_t set; struct sigaction act; int ret; int i; @@ -115,8 +115,8 @@ static int waiter_main(int argc, char *argv[]) printf("waiter_main: Waiter started\n" ); printf("waiter_main: Setting signal mask\n" ); - (void)sigemptyset(&sigset); - ret = sigprocmask(SIG_SETMASK, &sigset, NULL); + (void)sigemptyset(&set); + ret = sigprocmask(SIG_SETMASK, &set, NULL); if (ret < 0) { printf("waiter_main: ERROR sigprocmask failed: %d\n", errno); @@ -179,9 +179,9 @@ static int interfere_main(int argc, char *argv[]) g_interferer_running = false; return EXIT_SUCCESS; } -/*********************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************/ + ****************************************************************************/ void signest_test(void) { diff --git a/examples/ostest/sigprocmask.c b/examples/ostest/sigprocmask.c index 8e8791501..4e752d12e 100644 --- a/examples/ostest/sigprocmask.c +++ b/examples/ostest/sigprocmask.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * apps/examples/ostest/sigprocmask.c * * Copyright (C) 2015 Gregory Nutt. All rights reserved. @@ -31,7 +31,7 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ #include #include @@ -42,21 +42,21 @@ #include "ostest.h" -/*********************************************************************** +/**************************************************************************** * Pre-processor Definitions - ***********************************************************************/ + ****************************************************************************/ #define NSIGNALS 5 -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ static int g_some_signals[NSIGNALS] = {1, 3, 5, 7, 9}; -/*********************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************/ + ****************************************************************************/ void sigprocmask_test(void) { @@ -126,7 +126,7 @@ void sigprocmask_test(void) printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); goto errout_with_mask; } - + /* It should be the same as newmask */ if (memcmp(&currmask, &newmask, sizeof(sigset_t)) != 0) @@ -185,7 +185,7 @@ void sigprocmask_test(void) printf("sigprocmask_test: ERROR sigprocmask failed: %d\n", errcode); goto errout_with_mask; } - + /* It should be the same as newmask */ if (memcmp(&currmask, &newmask, sizeof(sigset_t)) != 0) @@ -193,7 +193,7 @@ void sigprocmask_test(void) printf("sigprocmask_test: ERROR unexpected sigprocmask\n"); goto errout_with_mask; } - + ret = sigprocmask(SIG_SETMASK, &saved, NULL); if (ret != OK) { diff --git a/examples/ostest/sporadic.c b/examples/ostest/sporadic.c index 48677afc9..b830f8235 100644 --- a/examples/ostest/sporadic.c +++ b/examples/ostest/sporadic.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * apps/examples/ostest/sporadic.c * * Copyright (C) 2015 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ -/*********************************************************************** +/**************************************************************************** * Included Files - ***********************************************************************/ + ****************************************************************************/ #include @@ -50,9 +50,18 @@ #ifdef CONFIG_SCHED_SPORADIC -/*********************************************************************** +/**************************************************************************** * Pre-processor Definitions - ***********************************************************************/ + ****************************************************************************/ + +/* It is actually a better test without schedule locking because that + * forces the scheduler into an uninteresting fallback mode. + */ + +#undef sched_lock +#undef sched_unlock +#define sched_lock() +#define sched_unlock() #ifndef NULL # define NULL (void*)0 @@ -62,16 +71,16 @@ # define MIN(a,b) (((a) < (b)) ? (a) : (b)) #endif -/*********************************************************************** +/**************************************************************************** * Private Data - ***********************************************************************/ + ****************************************************************************/ static sem_t g_sporadic_sem; static time_t g_start_time; -/*********************************************************************** +/**************************************************************************** * Private Functions - ***********************************************************************/ + ****************************************************************************/ void my_mdelay(unsigned int milliseconds) { @@ -181,9 +190,9 @@ static void *sporadic_func(void *parameter) } } -/*********************************************************************** +/**************************************************************************** * Public Functions - ***********************************************************************/ + ****************************************************************************/ void sporadic_test(void) { @@ -304,7 +313,7 @@ void sporadic_test(void) sparam.sched_priority = prio_high; sparam.sched_ss_low_priority = prio_low; - sparam.sched_ss_repl_period.tv_sec = 4; + sparam.sched_ss_repl_period.tv_sec = 5; sparam.sched_ss_repl_period.tv_nsec = 0; sparam.sched_ss_init_budget.tv_sec = 2; sparam.sched_ss_init_budget.tv_nsec = 0; @@ -332,19 +341,19 @@ void sporadic_test(void) /* Wait a while then kill the FIFO thread */ - sleep(12); + sleep(15); ret = pthread_cancel(fifo_thread); pthread_join(fifo_thread, &result); /* Wait a bit longer then kill the nuisance thread */ - sleep(8); + sleep(10); ret = pthread_cancel(nuisance_thread); pthread_join(nuisance_thread, &result); /* Wait a bit longer then kill the sporadic thread */ - sleep(8); + sleep(10); ret = pthread_cancel(sporadic_thread); pthread_join(sporadic_thread, &result); sched_unlock(); diff --git a/examples/ostest/timedmqueue.c b/examples/ostest/timedmqueue.c index 5792b426e..f67ee7ea3 100644 --- a/examples/ostest/timedmqueue.c +++ b/examples/ostest/timedmqueue.c @@ -1,4 +1,4 @@ -/************************************************************************** +/**************************************************************************** * apps/examples/ostest/mqueue.c * * Copyright (C) 2007-2009, 2011 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************/ + ****************************************************************************/ #include @@ -51,9 +51,9 @@ #include "ostest.h" -/************************************************************************** +/**************************************************************************** * Private Definitions - **************************************************************************/ + ****************************************************************************/ #define TEST_MESSAGE "This is a test and only a test" #if defined(SDCC) || defined(__ZILOG__) @@ -69,32 +69,32 @@ #define TEST_SEND_NMSGS (10) #define TEST_RECEIVE_NMSGS (10) -/************************************************************************** +/**************************************************************************** * Private Types - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Private Function Prototypes - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** - * Global Variables - **************************************************************************/ +/**************************************************************************** + * Public Data + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Private Variables - **************************************************************************/ + ****************************************************************************/ static mqd_t g_send_mqfd; static mqd_t g_recv_mqfd; -/************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Public Functions - **************************************************************************/ + ****************************************************************************/ static void *sender_thread(void *arg) { diff --git a/examples/ostest/timedwait.c b/examples/ostest/timedwait.c index 7cf875fb6..b878fa4b1 100644 --- a/examples/ostest/timedwait.c +++ b/examples/ostest/timedwait.c @@ -1,4 +1,4 @@ -/*********************************************************************** +/**************************************************************************** * examples/ostest/timedwait.c * * Copyright (C) 2007, 2008, 2011 Gregory Nutt. All rights reserved. @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - ***********************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Included Files - **************************************************************************/ + ****************************************************************************/ #include #include @@ -45,20 +45,20 @@ #include "ostest.h" -/************************************************************************** +/**************************************************************************** * Private Definitions - **************************************************************************/ + ****************************************************************************/ -/************************************************************************** +/**************************************************************************** * Private Data - **************************************************************************/ + ****************************************************************************/ static pthread_mutex_t mutex; static pthread_cond_t cond; -/************************************************************************** +/**************************************************************************** * Private Functions - **************************************************************************/ + ****************************************************************************/ static void *thread_waiter(void *parameter) { @@ -116,9 +116,9 @@ static void *thread_waiter(void *parameter) return NULL; } -/************************************************************************** +/**************************************************************************** * Public Definitions - **************************************************************************/ + ****************************************************************************/ void timedwait_test(void) { diff --git a/examples/pashello/Makefile b/examples/pashello/Makefile index 9db97eace..403173867 100644 --- a/examples/pashello/Makefile +++ b/examples/pashello/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Pascal Add-On Example @@ -51,82 +49,7 @@ ASRCS = CSRCS = device.c MAINSRC = pashello.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 ?= pashello$(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 diff --git a/examples/pashello/hello.h b/examples/pashello/hello.h index 818e5e4a5..b2a5e64a8 100644 --- a/examples/pashello/hello.h +++ b/examples/pashello/hello.h @@ -1,4 +1,5 @@ -unsigned char hello_pex[] = { +unsigned char hello_pex[] = +{ 0x50, 0x4f, 0x46, 0x46, 0x01, 0x01, 0x00, 0x00, 0x00, 0x14, 0x00, 0x05, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x18, 0x01, 0x06, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x00, @@ -20,4 +21,5 @@ unsigned char hello_pex[] = { 0x2e, 0x6c, 0x69, 0x6e, 0x65, 0x6e, 0x6f, 0x00, 0x2e, 0x73, 0x74, 0x72, 0x74, 0x61, 0x62, 0x00 }; + unsigned int hello_pex_len = 232; diff --git a/examples/pashello/pashello.c b/examples/pashello/pashello.c index 94ddf2e65..fa65465fe 100644 --- a/examples/pashello/pashello.c +++ b/examples/pashello/pashello.c @@ -48,7 +48,7 @@ #include "pashello.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #ifndef CONFIG_EXAMPLES_PASHELLO_VARSTACKSIZE diff --git a/examples/pashello/pashello.h b/examples/pashello/pashello.h index 6a550764c..f366557fc 100644 --- a/examples/pashello/pashello.h +++ b/examples/pashello/pashello.h @@ -41,7 +41,7 @@ ****************************************************************************/ /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/pipe/Makefile b/examples/pipe/Makefile index 45a76c19e..62d1ac584 100644 --- a/examples/pipe/Makefile +++ b/examples/pipe/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Pipe Example @@ -43,82 +41,7 @@ ASRCS = CSRCS = transfer_test.c interlock_test.c redirect_test.c MAINSRC = pipe_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 ?= pipe$(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 diff --git a/examples/pipe/interlock_test.c b/examples/pipe/interlock_test.c index d06442950..3b72ef0f3 100644 --- a/examples/pipe/interlock_test.c +++ b/examples/pipe/interlock_test.c @@ -50,7 +50,7 @@ #include "pipe.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/pipe/pipe.h b/examples/pipe/pipe.h index 38143e492..75eff1a21 100644 --- a/examples/pipe/pipe.h +++ b/examples/pipe/pipe.h @@ -45,7 +45,7 @@ ****************************************************************************/ /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define FIFO_PATH1 "/tmp/testfifo-1" diff --git a/examples/pipe/pipe_main.c b/examples/pipe/pipe_main.c index 2efcb41ea..8d04f3543 100644 --- a/examples/pipe/pipe_main.c +++ b/examples/pipe/pipe_main.c @@ -49,7 +49,7 @@ #include "pipe.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/pipe/redirect_test.c b/examples/pipe/redirect_test.c index ddce093f1..d364650ef 100644 --- a/examples/pipe/redirect_test.c +++ b/examples/pipe/redirect_test.c @@ -49,7 +49,7 @@ #include "pipe.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define READ_SIZE 37 diff --git a/examples/poll/Kconfig b/examples/poll/Kconfig index 0b4b1d296..5d26f9bb6 100644 --- a/examples/poll/Kconfig +++ b/examples/poll/Kconfig @@ -28,4 +28,4 @@ config EXAMPLES_POLL_NETMASK hex "Network Mask" default 0xffffff00 -endif +endif # EXAMPLES_POLL diff --git a/examples/poll/net_listener.c b/examples/poll/net_listener.c index 2164c112c..f1bda2e72 100644 --- a/examples/poll/net_listener.c +++ b/examples/poll/net_listener.c @@ -63,7 +63,7 @@ #include "poll_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define IOBUFFER_SIZE 80 @@ -298,7 +298,7 @@ static void net_configure(void) uint8_t mac[IFHWADDRLEN]; #endif - /* Configure uIP */ + /* Configure the network */ /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_POLL_NOMAC @@ -343,7 +343,7 @@ void *net_listener(pthread_addr_t pvarg) int ret; int i; - /* Configure uIP */ + /* Configure the network */ net_configure(); diff --git a/examples/poll/net_reader.c b/examples/poll/net_reader.c index 082ce1b41..dedba5634 100644 --- a/examples/poll/net_reader.c +++ b/examples/poll/net_reader.c @@ -63,7 +63,7 @@ #include "poll_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define IOBUFFER_SIZE 80 @@ -91,7 +91,7 @@ static void net_configure(void) uint8_t mac[IFHWADDRLEN]; #endif - /* Configure uIP */ + /* Configure the network */ /* Many embedded network interfaces must have a software assigned MAC */ #ifdef CONFIG_EXAMPLES_POLL_NOMAC @@ -232,7 +232,7 @@ void *net_reader(pthread_addr_t pvarg) socklen_t addrlen; int optval; - /* Configure uIP */ + /* Configure the network */ net_configure(); @@ -288,6 +288,7 @@ void *net_reader(pthread_addr_t pvarg) printf("net_reader: accept failure: %d\n", errno); continue; } + printf("net_reader: Connection accepted on sd=%d\n", acceptsd); /* Configure to "linger" until all data is sent when the socket is closed */ @@ -295,11 +296,12 @@ void *net_reader(pthread_addr_t pvarg) #ifdef POLL_HAVE_SOLINGER ling.l_onoff = 1; ling.l_linger = 30; /* timeout is seconds */ + if (setsockopt(acceptsd, SOL_SOCKET, SO_LINGER, &ling, sizeof(struct linger)) < 0) { - printf("net_reader: setsockopt SO_LINGER failure: %d\n", errno); - goto errout_with_acceptsd; - } + printf("net_reader: setsockopt SO_LINGER failure: %d\n", errno); + goto errout_with_acceptsd; + } #endif /* Handle incoming messsages on the connection. */ diff --git a/examples/poll/poll_internal.h b/examples/poll/poll_internal.h index 534a6e2ec..7d8c3ecee 100644 --- a/examples/poll/poll_internal.h +++ b/examples/poll/poll_internal.h @@ -47,7 +47,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #ifdef CONFIG_DISABLE_POLL diff --git a/examples/poll/poll_listener.c b/examples/poll/poll_listener.c index ca1b1542d..901a017c4 100644 --- a/examples/poll/poll_listener.c +++ b/examples/poll/poll_listener.c @@ -56,7 +56,7 @@ #include "poll_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #if defined(CONFIG_DEV_CONSOLE) && !defined(CONFIG_DEV_LOWCONSOLE) @@ -105,6 +105,7 @@ void *poll_listener(pthread_addr_t pvarg) /* Open the FIFO for non-blocking read */ printf("poll_listener: Opening %s for non-blocking read\n", FIFO_PATH1); + fd = open(FIFO_PATH1, O_RDONLY|O_NONBLOCK); if (fd < 0) { diff --git a/examples/poll/poll_main.c b/examples/poll/poll_main.c index 0f61f2f25..6fb166afd 100644 --- a/examples/poll/poll_main.c +++ b/examples/poll/poll_main.c @@ -54,7 +54,7 @@ #include "poll_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/poll/select_listener.c b/examples/poll/select_listener.c index 8a8023f9f..d3933bbeb 100644 --- a/examples/poll/select_listener.c +++ b/examples/poll/select_listener.c @@ -55,7 +55,7 @@ #include "poll_internal.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/posix_spawn/spawn_main.c b/examples/posix_spawn/spawn_main.c index 5c6dd6210..fbd9dc65e 100644 --- a/examples/posix_spawn/spawn_main.c +++ b/examples/posix_spawn/spawn_main.c @@ -58,7 +58,7 @@ #include "filesystem/romfs.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Check configuration. This is not all of the configuration settings that diff --git a/examples/pppd/Makefile b/examples/pppd/Makefile index 924c57ed4..9f75a710e 100644 --- a/examples/pppd/Makefile +++ b/examples/pppd/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # pppd Example @@ -43,95 +41,13 @@ ASRCS = CSRCS = MAINSRC = pppd_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_PPPD_PROGNAME ?= pppd$(EXEEXT) PROGNAME = $(CONFIG_EXAMPLES_PPPD_PROGNAME) -ROOTDEPPATH = --dep-path . - # PPPD built-in application info APPNAME = pppd 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 diff --git a/examples/pppd/pppd_main.c b/examples/pppd/pppd_main.c index 43993f6fd..19dffc26e 100644 --- a/examples/pppd/pppd_main.c +++ b/examples/pppd/pppd_main.c @@ -87,6 +87,11 @@ int pppd_main(int argc, char *argv[]) .disconnect_script = &disconnect_script, .connect_script = &connect_script, .ttyname = "/dev/ttyS2", +#ifdef CONFIG_NETUTILS_PPPD_PAP + .pap_username = "username", + .pap_password = "password", +#endif }; + return pppd(&pppd_settings); } diff --git a/examples/pwm/Kconfig b/examples/pwm/Kconfig index 2c2725c5e..1d2e9f02a 100644 --- a/examples/pwm/Kconfig +++ b/examples/pwm/Kconfig @@ -17,27 +17,102 @@ config EXAMPLES_PWM_DEVPATH string "PWM device path" default "/dev/pwm0" ---help--- - The path to the PWM device. Default: /dev/pwm0 + The path to the PWM device. Default: /dev/pwm0 config EXAMPLES_PWM_FREQUENCY - int "Default PWM freququency" + int "Default PWM frequency" default 100 ---help--- The default PWM frequency. Default: 100 Hz -config EXAMPLES_PWM_DUTYPCT - int "Default PWM duty percentage" - default 50 - ---help--- - The default PWM duty as a percentage. Default: 50% - config EXAMPLES_PWM_DURATION int "Default PWM duration" default 5 ---help--- The default PWM pulse train duration in seconds. Used only if the current pulse count is zero (pulse count is only supported if PWM_PULSECOUNT - is not defined). Default: 5 seconds + is not defined). Default: 5 seconds + +if PWM_MULTICHAN + +config EXAMPLES_PWM_DUTYPCT1 + int "First PWM duty percentage" + default 50 + range 1 99 + ---help--- + The first PWM duty as a percentage. Default: 50% + +config EXAMPLES_PWM_CHANNEL1 + int "First PWM channel number" + default 1 + range 1 4 + ---help--- + The first PWM channel number. Default: 1 + +if PWM_NCHANNELS = 2 || PWM_NCHANNELS = 3 || PWM_NCHANNELS = 4 + +config EXAMPLES_PWM_DUTYPCT2 + int "Second PWM duty percentage" + default 50 + range 1 99 + ---help--- + The second PWM duty as a percentage. Default: 50% + +config EXAMPLES_PWM_CHANNEL2 + int "Second PWM channel number" + default 2 + range 1 4 + ---help--- + The second PWM channel number. Default: 2 + +endif + +if PWM_NCHANNELS = 3 || PWM_NCHANNELS = 4 + +config EXAMPLES_PWM_DUTYPCT3 + int "Third PWM duty percentage" + default 50 + range 1 99 + ---help--- + The third PWM duty as a percentage. Default: 50% + +config EXAMPLES_PWM_CHANNEL3 + int "Third PWM channel number" + default 3 + range 1 4 + ---help--- + The third PWM channel number. Default: 3 + +endif + +if PWM_NCHANNELS = 4 + +config EXAMPLES_PWM_DUTYPCT4 + int "Fourth PWM duty percentage" + default 50 + range 1 99 + ---help--- + The fourth PWM duty as a percentage. Default: 50% + +config EXAMPLES_PWM_CHANNEL4 + int "Fourth PWM channel number" + default 4 + range 1 4 + ---help--- + The fourth PWM channel number. Default: 4 + +endif + +endif + +if !PWM_MULTICHAN + +config EXAMPLES_PWM_DUTYPCT + int "Default PWM duty percentage" + default 50 + range 1 99 + ---help--- + The default PWM duty as a percentage. Default: 50% config EXAMPLES_PWM_PULSECOUNT int "Default pulse count" @@ -45,7 +120,9 @@ config EXAMPLES_PWM_PULSECOUNT depends on PWM_PULSECOUNT ---help--- The initial PWM pulse count. This option is only available if - PWM_PULSECOUNT is defined. Default: 0 (i.e., use the duration, not + PWM_PULSECOUNT is defined. Default: 0 (i.e., use the duration, not the count). endif + +endif diff --git a/examples/pwm/Makefile b/examples/pwm/Makefile index c836d129e..25ec0b9e7 100644 --- a/examples/pwm/Makefile +++ b/examples/pwm/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # PWM Example. @@ -43,95 +41,13 @@ ASRCS = CSRCS = MAINSRC = pwm_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 ?= pwm$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # PWM built-in application info APPNAME = pwm 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 diff --git a/examples/pwm/pwm.h b/examples/pwm/pwm.h index e6703991a..9be2dc0be 100644 --- a/examples/pwm/pwm.h +++ b/examples/pwm/pwm.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* CONFIG_NSH_BUILTIN_APPS - Build the PWM test as an NSH built-in function. diff --git a/examples/pwm/pwm_main.c b/examples/pwm/pwm_main.c index 84c78c329..229c049e1 100644 --- a/examples/pwm/pwm_main.c +++ b/examples/pwm/pwm_main.c @@ -59,6 +59,29 @@ * Pre-processor Definitions ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifdef CONFIG_PWM_MULTICHAN +# if CONFIG_PWM_NCHANNELS > 1 +# if CONFIG_EXAMPLES_PWM_CHANNEL1 == CONFIG_EXAMPLES_PWM_CHANNEL2 +# error "Channel numbers must be unique" +# endif +# endif +# if CONFIG_PWM_NCHANNELS > 2 +# if CONFIG_EXAMPLES_PWM_CHANNEL1 == CONFIG_EXAMPLES_PWM_CHANNEL3 || \ + CONFIG_EXAMPLES_PWM_CHANNEL2 == CONFIG_EXAMPLES_PWM_CHANNEL3 +# error "Channel numbers must be unique" +# endif +# endif +# if CONFIG_PWM_NCHANNELS > 3 +# if CONFIG_EXAMPLES_PWM_CHANNEL1 == CONFIG_EXAMPLES_PWM_CHANNEL4 || \ + CONFIG_EXAMPLES_PWM_CHANNEL2 == CONFIG_EXAMPLES_PWM_CHANNEL4 || \ + CONFIG_EXAMPLES_PWM_CHANNEL3 == CONFIG_EXAMPLES_PWM_CHANNEL4 +# error "Channel numbers must be unique" +# endif +# endif +#endif + /**************************************************************************** * Private Types ****************************************************************************/ @@ -67,7 +90,12 @@ struct pwm_state_s { bool initialized; FAR char *devpath; +#ifdef CONFIG_PWM_MULTICHAN + uint8_t channels[CONFIG_PWM_NCHANNELS]; + uint8_t duties[CONFIG_PWM_NCHANNELS]; +#else uint8_t duty; +#endif uint32_t freq; #ifdef CONFIG_PWM_PULSECOUNT uint32_t count; @@ -117,27 +145,82 @@ static void pwm_devpath(FAR struct pwm_state_s *pwm, FAR const char *devpath) static void pwm_help(FAR struct pwm_state_s *pwm) { +#ifdef CONFIG_PWM_MULTICHAN + uint8_t channels[CONFIG_PWM_NCHANNELS] = + { + CONFIG_EXAMPLES_PWM_CHANNEL1, +#if CONFIG_PWM_NCHANNELS > 1 + CONFIG_EXAMPLES_PWM_CHANNEL2, +#endif +#if CONFIG_PWM_NCHANNELS > 2 + CONFIG_EXAMPLES_PWM_CHANNEL3, +#endif +#if CONFIG_PWM_NCHANNELS > 3 + CONFIG_EXAMPLES_PWM_CHANNEL4, +#endif + }; + uint8_t duties[CONFIG_PWM_NCHANNELS] = + { + CONFIG_EXAMPLES_PWM_DUTYPCT1, +#if CONFIG_PWM_NCHANNELS > 1 + CONFIG_EXAMPLES_PWM_DUTYPCT2, +#endif +#if CONFIG_PWM_NCHANNELS > 2 + CONFIG_EXAMPLES_PWM_DUTYPCT3, +#endif +#if CONFIG_PWM_NCHANNELS > 3 + CONFIG_EXAMPLES_PWM_DUTYPCT4, +#endif + }; + int i; +#endif + printf("Usage: pwm [OPTIONS]\n"); printf("\nArguments are \"sticky\". For example, once the PWM frequency is\n"); printf("specified, that frequency will be re-used until it is changed.\n"); printf("\n\"sticky\" OPTIONS include:\n"); printf(" [-p devpath] selects the PWM device. " - "Default: %s Current: %s\n", - CONFIG_EXAMPLES_PWM_DEVPATH, pwm->devpath ? pwm->devpath : "NONE"); + "Default: %s Current: %s\n", + CONFIG_EXAMPLES_PWM_DEVPATH, pwm->devpath ? pwm->devpath : "NONE"); printf(" [-f frequency] selects the pulse frequency. " - "Default: %d Hz Current: %u Hz\n", - CONFIG_EXAMPLES_PWM_FREQUENCY, pwm->freq); + "Default: %d Hz Current: %u Hz\n", + CONFIG_EXAMPLES_PWM_FREQUENCY, pwm->freq); +#ifdef CONFIG_PWM_MULTICHAN + printf(" [[-c channel1] [[-c channel2] ...]] selects the channel number for each channel. "); + printf("Default:"); + for (i = 0; i < CONFIG_PWM_MULTICHAN; i++) + { + printf(" %d", channels[i]); + } + printf("Current:"); + for (i = 0; i < CONFIG_PWM_MULTICHAN; i++) + { + printf(" %d", pwm->channels[i]); + } + printf(" [[-d duty1] [[-d duty2] ...]] selects the pulse duty as a percentage. "); + printf("Default:"); + for (i = 0; i < CONFIG_PWM_MULTICHAN; i++) + { + printf(" %d %%", duties[i]); + } + printf("Current:"); + for (i = 0; i < CONFIG_PWM_MULTICHAN; i++) + { + printf(" %d %%", pwm->duties[i]); + } +#else printf(" [-d duty] selects the pulse duty as a percentage. " "Default: %d %% Current: %d %%\n", CONFIG_EXAMPLES_PWM_DUTYPCT, pwm->duty); +#endif #ifdef CONFIG_PWM_PULSECOUNT printf(" [-n count] selects the pulse count. " - "Default: %d Current: %u\n", - CONFIG_EXAMPLES_PWM_PULSECOUNT, pwm->count); + "Default: %d Current: %u\n", + CONFIG_EXAMPLES_PWM_PULSECOUNT, pwm->count); #endif printf(" [-t duration] is the duration of the pulse train in seconds. " "Default: %d Current: %d\n", - CONFIG_EXAMPLES_PWM_DURATION, pwm->duration); + CONFIG_EXAMPLES_PWM_DURATION, pwm->duration); printf(" [-h] shows this message and exits\n"); } @@ -186,6 +269,10 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) long value; int index; int nargs; +#ifdef CONFIG_PWM_MULTICHAN + int nchannels = 0; + int nduties = 0; +#endif for (index = 1; index < argc; ) { @@ -210,6 +297,29 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) index += nargs; break; +#ifdef CONFIG_PWM_MULTICHAN + case 'c': + nargs = arg_decimal(&argv[index], &value); + if (value < 1 || value > 4) + { + printf("Channel out of range: %ld\n", value); + exit(1); + } + + if (nchannels < CONFIG_PWM_NCHANNELS) + { + nchannels++; + } + else + { + memmove(pwm->channels, pwm->channels+1, CONFIG_PWM_NCHANNELS-1); + } + + pwm->channels[nchannels-1] = (uint8_t)value; + index += nargs; + break; +#endif + case 'd': nargs = arg_decimal(&argv[index], &value); if (value < 1 || value > 99) @@ -218,7 +328,20 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) exit(1); } +#ifdef CONFIG_PWM_MULTICHAN + if (nduties < CONFIG_PWM_NCHANNELS) + { + nduties++; + } + else + { + memmove(pwm->duties, pwm->duties+1, CONFIG_PWM_NCHANNELS-1); + } + + pwm->duties[nduties-1] = (uint8_t)value; +#else pwm->duty = (uint8_t)value; +#endif index += nargs; break; @@ -234,8 +357,8 @@ static void parse_args(FAR struct pwm_state_s *pwm, int argc, FAR char **argv) pwm->count = (uint32_t)value; index += nargs; break; - #endif + case 'p': nargs = arg_string(&argv[index], &str); pwm_devpath(pwm, str); @@ -283,12 +406,33 @@ int pwm_main(int argc, char *argv[]) struct pwm_info_s info; int fd; int ret; +#ifdef CONFIG_PWM_MULTICHAN + int i; + int j; +#endif /* Initialize the state data */ if (!g_pwmstate.initialized) { +#ifdef CONFIG_PWM_MULTICHAN + g_pwmstate.channels[0] = CONFIG_EXAMPLES_PWM_CHANNEL1; + g_pwmstate.duties[0] = CONFIG_EXAMPLES_PWM_DUTYPCT1; +#if CONFIG_PWM_NCHANNELS > 1 + g_pwmstate.channels[1] = CONFIG_EXAMPLES_PWM_CHANNEL2; + g_pwmstate.duties[1] = CONFIG_EXAMPLES_PWM_DUTYPCT2; +#endif +#if CONFIG_PWM_NCHANNELS > 2 + g_pwmstate.channels[2] = CONFIG_EXAMPLES_PWM_CHANNEL3; + g_pwmstate.duties[2] = CONFIG_EXAMPLES_PWM_DUTYPCT3; +#endif +#if CONFIG_PWM_NCHANNELS > 3 + g_pwmstate.channels[3] = CONFIG_EXAMPLES_PWM_CHANNEL4; + g_pwmstate.duties[3] = CONFIG_EXAMPLES_PWM_DUTYPCT4; +#endif +#else g_pwmstate.duty = CONFIG_EXAMPLES_PWM_DUTYPCT; +#endif g_pwmstate.freq = CONFIG_EXAMPLES_PWM_FREQUENCY; g_pwmstate.duration = CONFIG_EXAMPLES_PWM_DURATION; #ifdef CONFIG_PWM_PULSECOUNT @@ -301,6 +445,20 @@ int pwm_main(int argc, char *argv[]) parse_args(&g_pwmstate, argc, argv); +#ifdef CONFIG_PWM_MULTICHAN + for (i = 0; i < CONFIG_PWM_MULTICHAN; i++) + { + for (j = i + 1; j < CONFIG_PWM_MULTICHAN; j++) + { + if (g_pwmstate.channels[j] == g_pwmstate.channels[i]) + { + printf("pwm_main: channel numbers must be unique\n"); + goto errout; + } + } + } +#endif + /* Has a device been assigned? */ if (!g_pwmstate.devpath) @@ -333,17 +491,33 @@ int pwm_main(int argc, char *argv[]) /* Configure the characteristics of the pulse train */ info.frequency = g_pwmstate.freq; +#ifdef CONFIG_PWM_MULTICHAN + printf("pwm_main: starting output with frequency: %u", + info.frequency); + + for (i = 0; i < CONFIG_PWM_NCHANNELS; i++) + { + info.channels[i].channel = g_pwmstate.channels[i]; + info.channels[i].duty = ((uint32_t)g_pwmstate.duties[i] << 16) / 100; + printf(" channel: %d duty: %08x", + info.channels[i].channel, info.channels[i].duty); + } + + printf("\n"); + +#else info.duty = ((uint32_t)g_pwmstate.duty << 16) / 100; -#ifdef CONFIG_PWM_PULSECOUNT +# ifdef CONFIG_PWM_PULSECOUNT info.count = g_pwmstate.count; printf("pwm_main: starting output with frequency: %u duty: %08x count: %u\n", info.frequency, info.duty, info.count); -#else +# else printf("pwm_main: starting output with frequency: %u duty: %08x\n", info.frequency, info.duty); +# endif #endif ret = ioctl(fd, PWMIOC_SETCHARACTERISTICS, (unsigned long)((uintptr_t)&info)); @@ -376,7 +550,7 @@ int pwm_main(int argc, char *argv[]) sleep(g_pwmstate.duration); - /* Then stop the pulse train */ + /* Then stop the pulse train */ printf("pwm_main: stopping output\n"); @@ -388,9 +562,9 @@ int pwm_main(int argc, char *argv[]) } } - close(fd); - fflush(stdout); - return OK; + close(fd); + fflush(stdout); + return OK; errout_with_dev: close(fd); diff --git a/examples/qencoder/Makefile b/examples/qencoder/Makefile index b0d0ef9f9..70c316272 100644 --- a/examples/qencoder/Makefile +++ b/examples/qencoder/Makefile @@ -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 = qe_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 ?= qencoder$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Quadrature Encoder built-in application info APPNAME = qe 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 diff --git a/examples/qencoder/qe.h b/examples/qencoder/qe.h index 1fd09d2ea..b4802a886 100644 --- a/examples/qencoder/qe.h +++ b/examples/qencoder/qe.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* CONFIG_NSH_BUILTIN_APPS - Build the QE test as an NSH built-in function. diff --git a/examples/random/Makefile b/examples/random/Makefile index 06c3056ca..5e4231259 100644 --- a/examples/random/Makefile +++ b/examples/random/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # /dev/random test @@ -47,89 +45,7 @@ ASRCS = CSRCS = MAINSRC = random_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 ?= random$(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 diff --git a/examples/relays/Makefile b/examples/relays/Makefile index 3cfbaa6e7..691b0ed14 100644 --- a/examples/relays/Makefile +++ b/examples/relays/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # relays Example @@ -43,95 +41,13 @@ ASRCS = CSRCS = MAINSRC = relays_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 ?= relays$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Buttons built-in application info APPNAME = relays PRIORITY = SCHED_PRIORITY_DEFAULT STACKSIZE = 512 -# 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 diff --git a/examples/relays/relays_main.c b/examples/relays/relays_main.c index 92fc02c17..af1f7bf41 100644 --- a/examples/relays/relays_main.c +++ b/examples/relays/relays_main.c @@ -54,14 +54,14 @@ #ifdef CONFIG_ARCH_RELAYS /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #ifndef CONFIG_EXAMPLES_RELAYS_NRELAYS # define CONFIG_EXAMPLES_RELAYS_NRELAYS 2 #endif - /**************************************************************************** +/**************************************************************************** * Private Types ****************************************************************************/ diff --git a/examples/rgmp/Makefile b/examples/rgmp/Makefile index c59e92a1e..2cc19a0cf 100644 --- a/examples/rgmp/Makefile +++ b/examples/rgmp/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # The smallest thing you can build -- the NULL example. @@ -43,82 +41,7 @@ ASRCS = CSRCS = MAINSRC = rgmp_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 ?= rgmp$(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 diff --git a/examples/rgmp/rgmp_main.c b/examples/rgmp/rgmp_main.c index 6af9f9d4b..01c8f6a49 100644 --- a/examples/rgmp/rgmp_main.c +++ b/examples/rgmp/rgmp_main.c @@ -42,7 +42,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/romfs/romfs_testdir.h b/examples/romfs/romfs_testdir.h index 53f93105c..b0d10de66 100644 --- a/examples/romfs/romfs_testdir.h +++ b/examples/romfs/romfs_testdir.h @@ -1,4 +1,5 @@ -unsigned char testdir_img[] = { +unsigned char testdir_img[] = +{ 0x2d, 0x72, 0x6f, 0x6d, 0x31, 0x66, 0x73, 0x2d, 0x00, 0x00, 0x02, 0x60, 0x27, 0x43, 0x4a, 0x8a, 0x52, 0x4f, 0x4d, 0x46, 0x53, 0x5f, 0x54, 0x65, 0x73, 0x74, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x49, @@ -86,4 +87,5 @@ unsigned char testdir_img[] = { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }; + unsigned int testdir_img_len = 1024; diff --git a/examples/sendmail/Makefile b/examples/sendmail/Makefile index c2f3ecda0..3a0430744 100644 --- a/examples/sendmail/Makefile +++ b/examples/sendmail/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Sendmail SMTP Example @@ -43,84 +41,7 @@ ASRCS = CSRCS = MAINSRC = sendmail_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 ?= sendmail$(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 $@ - -# Register application -depend: .depend - -clean: - $(call DELFILE, .built) - $(call CLEAN) - -distclean: clean - $(call DELFILE, Make.dep) - $(call DELFILE, .depend) - --include Make.dep - +include $(APPDIR)/Application.mk diff --git a/examples/serialblaster/Makefile b/examples/serialblaster/Makefile index 44b5c92f4..8d35eeef0 100644 --- a/examples/serialblaster/Makefile +++ b/examples/serialblaster/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # For testing: Blast canned characters at a designated serial port @@ -43,38 +41,9 @@ ASRCS = CSRCS = MAINSRC = serialblaster_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 ?= serialblaster$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Built-in application info CONFIG_EXAMPLES_SERIALBLASTER_PRIORITY ?= 50 @@ -84,57 +53,4 @@ APPNAME = serialblaster PRIORITY = $(CONFIG_EXAMPLES_SERIALBLASTER_PRIORITY) STACKSIZE = $(CONFIG_EXAMPLES_SERIALBLASTER_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 diff --git a/examples/serialrx/Makefile b/examples/serialrx/Makefile index 2558dd979..b95087bee 100644 --- a/examples/serialrx/Makefile +++ b/examples/serialrx/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # For testing: Blast canned characters at a designated serial port @@ -43,38 +41,9 @@ ASRCS = CSRCS = MAINSRC = serialrx_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 ?= serialrx$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Built-in application info CONFIG_EXAMPLES_SERIALRX_PRIORITY ?= 50 @@ -84,57 +53,4 @@ APPNAME = serialrx PRIORITY = $(CONFIG_EXAMPLES_SERIALRX_PRIORITY) STACKSIZE = $(CONFIG_EXAMPLES_SERIALRX_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 diff --git a/examples/serloop/Makefile b/examples/serloop/Makefile index 850d2e1b0..716e2622b 100644 --- a/examples/serloop/Makefile +++ b/examples/serloop/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Mindlessly simple console loopack test @@ -43,84 +41,7 @@ ASRCS = CSRCS = MAINSRC = serloop_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 ?= serloop$(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 $@ - -# Register application -depend: .depend - -clean: - $(call DELFILE, .built) - $(call CLEAN) - -distclean: clean - $(call DELFILE, Make.dep) - $(call DELFILE, .depend) - --include Make.dep - +include $(APPDIR)/Application.mk diff --git a/examples/serloop/serloop_main.c b/examples/serloop/serloop_main.c index f573a4c7c..b8d11dd42 100644 --- a/examples/serloop/serloop_main.c +++ b/examples/serloop/serloop_main.c @@ -44,7 +44,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/slcd/Makefile b/examples/slcd/Makefile index 4f15d6fad..d22a55517 100644 --- a/examples/slcd/Makefile +++ b/examples/slcd/Makefile @@ -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 = slcd_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 diff --git a/examples/smart/Makefile b/examples/smart/Makefile index 9248f5eeb..e612c8e5a 100644 --- a/examples/smart/Makefile +++ b/examples/smart/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # SMART file system stress test @@ -43,82 +41,7 @@ ASRCS = CSRCS = MAINSRC = smart_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 ?= smart$(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 diff --git a/examples/smart/smart_main.c b/examples/smart/smart_main.c index d9e1819b5..b189205b3 100644 --- a/examples/smart/smart_main.c +++ b/examples/smart/smart_main.c @@ -58,7 +58,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* The default is to use the RAM MTD device at drivers/mtd/rammtd.c. But @@ -657,10 +657,19 @@ static int smart_delfiles(void) int ndx = (rand() % (g_nfiles - g_ndeleted)); - /* And delete the next undeleted file after that random index */ + /* 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;) + 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) { @@ -682,14 +691,6 @@ static int smart_delfiles(void) break; } } - - /* Increment the index and test for wrap-around */ - - if (++j >= CONFIG_EXAMPLES_SMART_MAXOPEN) - { - j = 0; - } - } } diff --git a/examples/smart_test/Makefile b/examples/smart_test/Makefile index c9160d629..a7449252d 100644 --- a/examples/smart_test/Makefile +++ b/examples/smart_test/Makefile @@ -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 = smart_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 ?= smart_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 diff --git a/examples/tcpecho/Kconfig b/examples/tcpecho/Kconfig index c3760b744..b39e6abd8 100644 --- a/examples/tcpecho/Kconfig +++ b/examples/tcpecho/Kconfig @@ -31,7 +31,7 @@ config EXAMPLES_TCPECHO_DHCPC default n depends on EXAMPLES_TCPECHO && !NSH_BUILTIN_APPS select NETUTILS_DHCPC - select NETUTILS_DNSCLIENT + select NETDB_DNSCLIENT config EXAMPLES_TCPECHO_NOMAC bool "Use Canned MAC Address" diff --git a/examples/tcpecho/Makefile b/examples/tcpecho/Makefile index d0a21e0b7..fb28fda28 100644 --- a/examples/tcpecho/Makefile +++ b/examples/tcpecho/Makefile @@ -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 = tcpecho_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 ?= tcpecho$(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 diff --git a/examples/telnetd/Makefile b/examples/telnetd/Makefile index 1713a9645..f0f0dcec5 100644 --- a/examples/telnetd/Makefile +++ b/examples/telnetd/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Telnetd Example @@ -43,95 +41,13 @@ ASRCS = CSRCS = MAINSRC = telnetd.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 ?= telnetd$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Buttons built-in application info APPNAME = telnetd 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 diff --git a/examples/telnetd/telnetd.c b/examples/telnetd/telnetd.c index 19ad35413..815fac882 100644 --- a/examples/telnetd/telnetd.c +++ b/examples/telnetd/telnetd.c @@ -54,7 +54,7 @@ #include "telnetd.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/examples/thttpd/thttpd_main.c b/examples/thttpd/thttpd_main.c index 48ab2f238..07a1a9b66 100644 --- a/examples/thttpd/thttpd_main.c +++ b/examples/thttpd/thttpd_main.c @@ -80,7 +80,7 @@ #endif /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Check configuration. This is not all of the configuration settings that diff --git a/examples/timer/Kconfig b/examples/timer/Kconfig index 6170f0556..3df21dd0f 100644 --- a/examples/timer/Kconfig +++ b/examples/timer/Kconfig @@ -6,7 +6,7 @@ config EXAMPLES_TIMER bool "Timer example" default n - depends on TIMER + depends on TIMER && BUILD_FLAT ---help--- Enable the \"Timer, World!\" example diff --git a/examples/timer/Makefile b/examples/timer/Makefile index dfbca4635..02390b68d 100644 --- a/examples/timer/Makefile +++ b/examples/timer/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Timer built-in application info @@ -55,86 +53,4 @@ ASRCS = CSRCS = MAINSRC = timer_main.c -AOBJS = $(ASRCS:.S=$(OBJEXT)) -COBJS = $(CSRCS:.c=$(OBJEXT)) -MAINOBJ = $(MAINSRC:.c=$(OBJEXT)) - -SRCS = $(ASRCS) $(CSRCS) $(MAINSRC) -OBJS = $(AOBJS) $(COBJS) - -ifneq ($(CONFIG_BUILD_KERNEL),y) - OBJS += $(MAINOBJ) -endif - -ifeq ($(CONFIG_WINDOWS_NATIVE),y) - BIN = ..\..\libapps$(LIBEXT) -else -ifeq ($(WINTOOL),y) - BIN = ..\\..\\libapps$(LIBEXT) -else - BIN = ../../libapps$(LIBEXT) -endif -endif - -ifeq ($(WINTOOL),y) - INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" -else - INSTALL_DIR = $(BIN_DIR) -endif - -ROOTDEPPATH = --dep-path . - -# Common build - -VPATH = - -all: .built -.PHONY: clean depend distclean - -$(AOBJS): %$(OBJEXT): %.S - $(call ASSEMBLE, $<, $@) - -$(COBJS) $(MAINOBJ): %$(OBJEXT): %.c - $(call COMPILE, $<, $@) - -.built: $(OBJS) - $(call ARCHIVE, $(BIN), $(OBJS)) - @touch .built - -ifeq ($(CONFIG_BUILD_KERNEL),y) -$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(MAINOBJ) - @echo "LD: $(PROGNAME)" - $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(MAINOBJ) $(LDLIBS) - $(Q) $(NM) -u $(INSTALL_DIR)$(DELIM)$(PROGNAME) - -install: $(BIN_DIR)$(DELIM)$(PROGNAME) - -else -install: - -endif - -ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) -$(BUILTIN_REGISTRY)$(DELIM)timer_main.bdat: $(DEPCONFIG) Makefile - $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),timer_main) - -context: $(BUILTIN_REGISTRY)$(DELIM)timer_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 diff --git a/examples/touchscreen/Makefile b/examples/touchscreen/Makefile index 69e2549ce..9fa44f4cf 100644 --- a/examples/touchscreen/Makefile +++ b/examples/touchscreen/Makefile @@ -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 = tc_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 ?= touchscreen$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Touchscreen built-in application info APPNAME = tc 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 diff --git a/examples/touchscreen/tc.h b/examples/touchscreen/tc.h index a196d2d9b..f597bd548 100644 --- a/examples/touchscreen/tc.h +++ b/examples/touchscreen/tc.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* CONFIG_NSH_BUILTIN_APPS - Build the touchscreen test as diff --git a/examples/uavcan/Kconfig b/examples/uavcan/Kconfig new file mode 100644 index 000000000..6d47c3b57 --- /dev/null +++ b/examples/uavcan/Kconfig @@ -0,0 +1,34 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config EXAMPLES_UAVCAN + bool "UAVCAN example" + default n + depends on CANUTILS_UAVCAN + ---help--- + Enable the UAVCAN example + +if EXAMPLES_UAVCAN + +config EXAMPLES_UAVCAN_NODE_MEM_POOL_SIZE + int "Node Memory Pool Size" + default 4096 + ---help--- + Specifies the node's memory pool size + +config EXAMPLES_UAVCAN_NODE_ID + int "Node ID" + default 1 + range 1 127 + ---help--- + Specifies the node's ID + +config EXAMPLES_UAVCAN_NODE_NAME + string "Node Name" + default "org.nuttx.apps.examples.uavcan" + ---help--- + Specifies the node's name + +endif diff --git a/examples/uavcan/Make.defs b/examples/uavcan/Make.defs new file mode 100644 index 000000000..e72f62ca2 --- /dev/null +++ b/examples/uavcan/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# apps/examples/uavcan/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience +# +# 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_UAVCAN),y) +CONFIGURED_APPS += examples/uavcan +endif diff --git a/examples/uavcan/Makefile b/examples/uavcan/Makefile new file mode 100644 index 000000000..8d5df1888 --- /dev/null +++ b/examples/uavcan/Makefile @@ -0,0 +1,42 @@ +############################################################################ +# apps/examples/uavcan/Makefile +# +# Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. +# Author: Paul Alexander Patience +# +# 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 + +MAINSRC = uavcan_main.cxx + +CXXFLAGS += -I$(TOPDIR)/include/apps + +include $(APPDIR)/Application.mk diff --git a/examples/uavcan/uavcan_main.cxx b/examples/uavcan/uavcan_main.cxx new file mode 100644 index 000000000..7181356a0 --- /dev/null +++ b/examples/uavcan/uavcan_main.cxx @@ -0,0 +1,94 @@ +/**************************************************************************** + * examples/uavcan/uavcan_main.cxx + * + * Copyright (C) 2015 Omni Hoverboards Inc. All rights reserved. + * Author: Paul Alexander Patience + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include + +#include + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +uavcan::ICanDriver& getCanDriver(); +uavcan::ISystemClock& getSystemClock(); + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: uavcan_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +extern "C" int uavcan_main(int argc, FAR char *argv[]) +#endif +{ + uavcan::Node + node(getCanDriver(), getSystemClock()); + int ret; + + node.setNodeID(CONFIG_EXAMPLES_UAVCAN_NODE_ID); + node.setName(CONFIG_EXAMPLES_UAVCAN_NODE_NAME); + + ret = node.start(); + if (ret < 0) + { + std::fprintf(stderr, "ERROR: node.start failed: %d\n", ret); + return EXIT_FAILURE; + } + + node.setModeOperational(); + + for (;;) + { + ret = node.spin(uavcan::MonotonicDuration::fromMSec(100)); + if (ret < 0) + { + std::fprintf(stderr, "ERROR: node.spin failed: %d\n", ret); + } + } + + return EXIT_SUCCESS; +} diff --git a/examples/udp/udp-internal.h b/examples/udp/udp-internal.h index 909d5091c..8bd6fbe58 100644 --- a/examples/udp/udp-internal.h +++ b/examples/udp/udp-internal.h @@ -48,7 +48,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #ifdef EXAMPLES_UDP_HOST diff --git a/examples/udpblaster/.gitignore b/examples/udpblaster/.gitignore new file mode 100644 index 000000000..8598f0ee9 --- /dev/null +++ b/examples/udpblaster/.gitignore @@ -0,0 +1,16 @@ +/Make.dep +/.depend +/.built +/host +/config.h +/*.asm +/*.obj +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src +/*.hobj +/*.exe +/*.dSYM diff --git a/examples/udpblaster/Kconfig b/examples/udpblaster/Kconfig new file mode 100644 index 000000000..a65b41d81 --- /dev/null +++ b/examples/udpblaster/Kconfig @@ -0,0 +1,325 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config EXAMPLES_UDPBLASTER + bool "UDP blaster example" + default n + depends on NET_UDP + ---help--- + Enable the network test example + +if EXAMPLES_UDPBLASTER + +config EXAMPLES_UDPBLASTER_HOSTRATE + int "Host send rate (bits/second)" + default 800000 + +choice + prompt "IP Domain" + default EXAMPLES_UDPBLASTER_IPv4 if NET_IPv4 + default EXAMPLES_UDPBLASTER_IPv6 if NET_IPv6 && !NET_IPv4 + +config EXAMPLES_UDPBLASTER_IPv4 + bool "IPv4" + depends on NET_IPv4 + +config EXAMPLES_UDPBLASTER_IPv6 + bool "IPv6" + depends on NET_IPv6 + +endchoice # IP Domain + +config EXAMPLES_UDPBLASTER_INIT + bool "Initialize network" + default n if NSH_BUILTIN_APPS + default y if !NSH_BUILTIN_APPS + depends on !BUILD_KERNEL && !EXAMPLES_UDPBLASTER_LOOPBACK + ---help--- + Include logic to initialize the network. This should not be done if + the network is already initialized when udpblaster runs. This is + usually the case, for example, when udpblaster is run as an NSH built- + in task. + +config EXAMPLES_UDPBLASTER_NOMAC + bool "Use Canned MAC Address" + default n + depends on EXAMPLES_UDPBLASTER_INIT + +if EXAMPLES_UDPBLASTER_IPv4 + +comment "IPv4 addresses" + +config EXAMPLES_UDPBLASTER_TARGETIP + hex "Target IP address" + default 0x0a000002 + +config EXAMPLES_UDPBLASTER_HOSTIP + hex "Host IP address)" + default 0x0a000001 + +if EXAMPLES_UDPBLASTER_INIT + +config EXAMPLES_UDPBLASTER_NETMASK + hex "Network Mask" + default 0xffffff00 + +endif # EXAMPLES_UDPBLASTER_INIT +endif # EXAMPLES_UDPBLASTER_IPv4 + +if EXAMPLES_UDPBLASTER_IPv6 +if !NET_ICMPv6_AUTOCONF + +comment "Target IPv6 address" + +config EXAMPLES_UDPBLASTER_TARGETIPv6_1 + hex "[0]" + default 0xfc00 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the first of the 8-values. The + default for all eight values is fc00::2. + +config EXAMPLES_UDPBLASTER_TARGETIPv6_2 + hex "[1]" + default 0x0000 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the second of the 8-values. The + default for all eight values is fc00::2. + +config EXAMPLES_UDPBLASTER_TARGETIPv6_3 + hex "[2]" + default 0x0000 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the third of the 8-values. The + default for all eight values is fc00::2. + +config EXAMPLES_UDPBLASTER_TARGETIPv6_4 + hex "[3]" + default 0x0000 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the fourth of the 8-values. The + default for all eight values is fc00::2. + +config EXAMPLES_UDPBLASTER_TARGETIPv6_5 + hex "[4]" + default 0x0000 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the fifth of the 8-values. The + default for all eight values is fc00::2. + +config EXAMPLES_UDPBLASTER_TARGETIPv6_6 + hex "[5]" + default 0x0000 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the sixth of the 8-values. The + default for all eight values is fc00::2. + +config EXAMPLES_UDPBLASTER_TARGETIPv6_7 + hex "[6]" + default 0x0000 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the seventh of the 8-values. The + default for all eight values is fc00::2. + +config EXAMPLES_UDPBLASTER_TARGETIPv6_8 + hex "[7]" + default 0x0002 + range 0x0 0xffff + ---help--- + Target IPv6 address. This is a 16-bit integer value in host order. + Each of the eight values forming the full IP address must be + specified individually. This is the last of the 8-values. The + default for all eight values is fc00::2. + +comment "Router IPv6 address" + +config EXAMPLES_UDPBLASTER_HOSTIPv6_1 + hex "[0]" + default 0xfc00 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the first of the + 8-values. The default for all eight values is fc00::1. + +config EXAMPLES_UDPBLASTER_HOSTIPv6_2 + hex "[1]" + default 0x0000 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the second of the + 8-values. The default for all eight values is fc00::1. + +config EXAMPLES_UDPBLASTER_HOSTIPv6_3 + hex "[2]" + default 0x0000 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the third of the + 8-values. The default for all eight values is fc00::1. + +config EXAMPLES_UDPBLASTER_HOSTIPv6_4 + hex "[3]" + default 0x0000 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the fourth of the + 8-values. The default for all eight values is fc00::1. + +config EXAMPLES_UDPBLASTER_HOSTIPv6_5 + hex "[4]" + default 0x0000 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the fifth of the + 8-values. The default for all eight values is fc00::1. + +config EXAMPLES_UDPBLASTER_HOSTIPv6_6 + hex "[5]" + default 0x0000 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the sixth of the + 8-values. The default for all eight values is fc00::1. + +config EXAMPLES_UDPBLASTER_HOSTIPv6_7 + hex "[6]" + default 0x0000 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the seventh of the + 8-values. The default for all eight values is fc00::1. + +config EXAMPLES_UDPBLASTER_HOSTIPv6_8 + hex "[7]" + default 0x0001 + range 0x0 0xffff + ---help--- + Default router IP address (aka, Gateway). This is a 16-bit integer + value in host order. Each of the eight values forming the full IP + address must be specified individually. This is the last of the + 8-values. The default for all eight values is fc00::1. + +if EXAMPLES_UDPBLASTER_INIT + +comment "IPv6 Network mask" + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_1 + hex "[0]" + default 0xffff + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the first of the 8-values. The default for + all eight values is fe00::0. + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_2 + hex "[1]" + default 0xffff + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the second of the 8-values. The default for + all eight values is fe00::0. + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_3 + hex "[2]" + default 0xffff + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the third of the 8-values. The default for + all eight values is fe00::0. + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_4 + hex "[3]" + default 0xffff + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the fourth of the 8-values. The default for + all eight values is fe00::0. + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_5 + hex "[4]" + default 0xffff + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the fifth of the 8-values. The default for + all eight values is fe00::0. + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_6 + hex "[5]" + default 0xffff + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the sixth of the 8-values. The default for + all eight values is fe00::0. + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_7 + hex "[6]" + default 0xffff + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the seventh of the 8-values. The default for + all eight values is fe00::0. + +config EXAMPLES_UDPBLASTER_IPv6NETMASK_8 + hex "[7]" + default 0xff80 + range 0x0 0xffff + ---help--- + Network mask. This is a 16-bit integer value in host order. Each + of the eight values forming the full IP address must be specified + individually. This is the eighth of the 8-values. The default for + all eight values is fe00::0. + +endif # NET_ICMPv6_AUTOCONF +endif # EXAMPLES_UDPBLASTER_INIT +endif # EXAMPLES_UDPBLASTER_IPv6 +endif # EXAMPLES_UDPBLASTER diff --git a/examples/udpblaster/Make.defs b/examples/udpblaster/Make.defs new file mode 100644 index 000000000..c5c7208bf --- /dev/null +++ b/examples/udpblaster/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# apps/examples/udpblaster/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_EXAMPLES_UDPBLASTER),y) +CONFIGURED_APPS += examples/udpblaster +endif diff --git a/examples/udpblaster/Makefile b/examples/udpblaster/Makefile new file mode 100644 index 000000000..654a914a9 --- /dev/null +++ b/examples/udpblaster/Makefile @@ -0,0 +1,169 @@ +############################################################################ +# examples/udpblaster/Makefile +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +# Basic TCP networking test + +TARG_ASRCS = +TARG_AOBJS = $(TARG_ASRCS:.S=$(OBJEXT)) + +TARG_CSRCS = udpblaster_text.c +TARG_MAINSRC = udpblaster_target.c + +TARG_COBJS = $(TARG_CSRCS:.c=$(OBJEXT)) +TARG_MAINOBJ = $(TARG_MAINSRC:.c=$(OBJEXT)) + +TARG_SRCS = $(TARG_ASRCS) $(TARG_CSRCS) $(TARG_CSRCS) +TARG_OBJS = $(TARG_AOBJS) $(TARG_COBJS) + +ifneq ($(CONFIG_BUILD_KERNEL),y) + TARG_OBJS += $(TARG_MAINOBJ) +endif + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + TARG_BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + TARG_BIN = ..\\..\\libapps$(LIBEXT) +else + TARG_BIN = ../../libapps$(LIBEXT) +endif +endif + +HOSTCFLAGS += -DUDPBLASTER_HOST=1 + +HOST_SRCS = udpblaster_host.c udpblaster_text.c + +HOSTOBJEXT ?= .hobj +HOST_OBJS = $(HOST_SRCS:.c=$(HOSTOBJEXT)) +HOST_BIN = host + +ifeq ($(WINTOOL),y) + INSTALL_DIR = "${shell cygpath -w $(BIN_DIR)}" +else + INSTALL_DIR = $(BIN_DIR) +endif + +CONFIG_XYZ_PROGNAME ?= udpblaster$(EXEEXT) +PROGNAME = $(CONFIG_XYZ_PROGNAME) + +ROOTDEPPATH = --dep-path . + +# NET test built-in application info + +APPNAME = udpblaster +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + +# Common build + +VPATH = + +all: .built $(HOST_BIN) +.PHONY: clean depend distclean + +$(TARG_AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(TARG_COBJS) $(TARG_MAINOBJ): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +ifneq ($(CONFIG_EXAMPLES_UDPBLASTER_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_UDPBLASTER_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)) + $(Q) touch .built + +ifeq ($(CONFIG_BUILD_KERNEL),y) +$(BIN_DIR)$(DELIM)$(PROGNAME): $(OBJS) $(TARG_MAINOBJ) + @echo "LD: $(PROGNAME)" + $(Q) $(LD) $(LDELFFLAGS) $(LDLIBPATH) -o $(INSTALL_DIR)$(DELIM)$(PROGNAME) $(ARCHCRT0OBJ) $(TARG_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 config.h $(TARG_SRCS) + @$(MKDEP) $(ROOTDEPPATH) "$(CC)" -- $(CFLAGS) -- $(TARG_SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: +ifneq ($(CONFIG_EXAMPLES_UDPBLASTER_LOOPBACK),y) + $(call DELFILE, *$(HOSTOBJEXT)) + $(call DELFILE, $(HOST_BIN)) +endif + $(call DELFILE, .built) + $(call DELFILE, *.dSYM) + $(call DELFILE, config.h) + $(call CLEAN) + +distclean: clean + $(call DELFILE, Make.dep) + $(call DELFILE, .depend) + +-include Make.dep + diff --git a/examples/udpblaster/udpblaster.h b/examples/udpblaster/udpblaster.h new file mode 100644 index 000000000..6e2a21db3 --- /dev/null +++ b/examples/udpblaster/udpblaster.h @@ -0,0 +1,127 @@ +/**************************************************************************** + * examples/udpblaster/udpblaster.h + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __EXAMPLES_UDPBLASTER_UDPBLASTER_H +#define __EXAMPLES_UDPBLASTER_UDPBLASTER_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "config.h" + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#ifdef UDPBLASTER_HOST + /* HTONS/L macros are unique to uIP */ + +# define HTONS(a) htons(a) +# define HTONL(a) htonl(a) + + /* Have SO_LINGER */ + +# define UDPBLASTER_HAVE_SOLINGER 1 + +#else +# ifdef CONFIG_NET_SOLINGER +# define UDPBLASTER_HAVE_SOLINGER 1 +# else +# undef UDPBLASTER_HAVE_SOLINGER +# endif +#endif /* UDPBLASTER_HOST */ + +#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6 +# define AF_INETX AF_INET6 +# define PF_INETX PF_INET6 +#else +# define AF_INETX AF_INET +# define PF_INETX PF_INET +#endif + +#define UDPBLASTER_PORTNO 5471 + +#define ETH_HDRLEN 14 /* Size of the Ethernet header */ +#define IPv4_HDRLEN 20 /* Size of IPv4 header */ +#define IPv6_HDRLEN 40 /* Size of IPv6 header */ +#define UDP_HDRLEN 8 /* Size of UDP header */ + +#if defined(CONFIG_NET_ETHERNET) +# define UDPBLASTER_MTU CONFIG_NET_ETH_MTU +# ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6 +# define UDPBLASTER_MSS (UDPBLASTER_MTU - ETH_HDRLEN - IPv6_HDRLEN - UDP_HDRLEN) +# else +# define UDPBLASTER_MSS (UDPBLASTER_MTU - ETH_HDRLEN - IPv4_HDRLEN - UDP_HDRLEN) +# endif +# +#elif defined(CONFIG_NET_LOOPBACK) +# define UDPBLASTER_MTU 1518 +# ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6 +# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv6_HDRLEN - UDP_HDRLEN) +# else +# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv4_HDRLEN - UDP_HDRLEN) +# endif +#elif defined(CONFIG_NET_SLIP) +# define UDPBLASTER_MTU CONFIG_NET_SLIP_MTU +# ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6 +# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv6_HDRLEN - UDP_HDRLEN) +# else +# define UDPBLASTER_MSS (UDPBLASTER_MTU - IPv4_HDRLEN - UDP_HDRLEN) +# endif +#else +# error "Additional link layer definitions needed" +#endif + +#ifndef MIN +# define MIN(a,b) ((a)<(b)?(a):(b)) +#endif + +#define UDPBLASTER_SENDSIZE MIN(UDPBLASTER_MSS, g_udpblaster_strlen) + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +extern const char g_udpblaster_text[]; +extern const int g_udpblaster_strlen; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +#endif /* __EXAMPLES_UDPBLASTER_UDPBLASTER_H */ diff --git a/examples/udpblaster/udpblaster_host.c b/examples/udpblaster/udpblaster_host.c new file mode 100644 index 000000000..c2dfcd201 --- /dev/null +++ b/examples/udpblaster/udpblaster_host.c @@ -0,0 +1,154 @@ +/**************************************************************************** + * examples/udpblaster/udpblaster_host.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name Gregory Nutt 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 "config.h" + +#include +#include +#include + +#include +#include + +#include "udpblaster.h" + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * main + ****************************************************************************/ + +int main(int argc, char **argv, char **envp) +{ +#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4 + struct sockaddr_in target; +#else + struct sockaddr_in6 target; +#endif + socklen_t addrlen; + size_t sendsize; + unsigned long delay; + int npackets; + int ndots; + int sockfd; + int ret; + +#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4 + target.sin_family = AF_INET; + target.sin_port = HTONS(UDPBLASTER_PORTNO); + target.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_TARGETIP); + + addrlen = sizeof(struct sockaddr_in); + sockfd = socket(PF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) + { + fprintf(stderr, "ERROR: socket() failed: %d\n", errno); + return 1; + } + +#else + target.sin6_family = AF_INET6; + target.sin6_port = HTONS(UDPBLASTER_PORTNO); + target.sin6_addr.s6_addr16[0] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_1); + target.sin6_addr.s6_addr16[1] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_2); + target.sin6_addr.s6_addr16[2] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_3); + target.sin6_addr.s6_addr16[3] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_4); + target.sin6_addr.s6_addr16[4] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_5); + target.sin6_addr.s6_addr16[5] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_6); + target.sin6_addr.s6_addr16[6] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_7); + target.sin6_addr.s6_addr16[7] = HTONL(EXAMPLES_UDPBLASTER_TARGETIPv6_8); + + addrlen = sizeof(struct sockaddr_in6); + sockfd = socket(PF_INET6, SOCK_DGRAM, 0); + if (sockfd < 0) + { + fprintf(stderr, "ERROR: socket() failed: %d\n", errno); + return 1; + } +#endif + + /* bytes/packet = UDPBLASTER_SENDSIZE + * bits/sec = CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE + * bytes/sec = CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE / 8 + * packets/sec = (bytes/sec) / (bytes/packet) + * = CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE / UDPBLASTER_SENDSIZE / 8 + * delay = microseconds/packet + * = (1000000 * UDPBLASTER_SENDSIZE) / CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE / 8 + * = (125000 * UDPBLASTER_SENDSIZE) / CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE + */ + + sendsize = UDPBLASTER_SENDSIZE; + delay = (125000 * sendsize) / CONFIG_EXAMPLES_UDPBLASTER_HOSTRATE; + + npackets = 0; + ndots = 0; + + for (;;) + { + ret = sendto(sockfd, g_udpblaster_text, sendsize, 0, + (struct sockaddr *)&target, addrlen); + if (ret < 0) + { + fprintf(stderr, "ERROR: sendto() failed: %d\n", errno); + return 1; + } + + if (++npackets >= 10) + { + putchar('.'); + npackets = 0; + + if (++ndots >= 50) + { + putchar('\n'); + ndots = 0; + } + } + + usleep(delay); + } + + return 0; /* Won't get here */ +} diff --git a/examples/udpblaster/udpblaster_target.c b/examples/udpblaster/udpblaster_target.c new file mode 100644 index 000000000..e9c6ec48e --- /dev/null +++ b/examples/udpblaster/udpblaster_target.c @@ -0,0 +1,271 @@ +/**************************************************************************** + * examples/udpblaster/udpblaster_target.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "config.h" + +#include +#include +#include + +#include +#include +#include + +#include + +#include "udpblaster.h" + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +#if defined(CONFIG_EXAMPLES_UDPBLASTER_INIT) && \ + defined(CONFIG_EXAMPLES_UDPBLASTER_IPv6) && \ + !defined(CONFIG_NET_ICMPv6_AUTOCONF) +/* Our host IPv6 address */ + +static const uint16_t g_ipv6_hostaddr[8] = +{ + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_1), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_2), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_3), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_4), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_5), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_6), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_7), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_TARGETIPv6_8), +}; + +/* Default routine IPv6 address */ + +static const uint16_t g_ipv6_draddr[8] = +{ + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_1), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_2), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_3), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_4), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_5), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_6), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_7), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_HOSTIPv6_8), +}; + +/* IPv6 netmask */ + +static const uint16_t g_ipv6_netmask[8] = +{ + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_1), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_2), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_3), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_4), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_5), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_6), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_7), + HTONS(CONFIG_EXAMPLES_UDPBLASTER_IPv6NETMASK_8), +}; +#endif /* CONFIG_EXAMPLES_UDPBLASTER_INIT && CONFIG_EXAMPLES_UDPBLASTER_IPv6 && !CONFIG_NET_ICMPv6_AUTOCONF */ + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +#ifdef CONFIG_EXAMPLES_UDPBLASTER_INIT +static void netest_initialize(void) +{ +#ifndef CONFIG_EXAMPLES_UDPBLASTER_IPv6 + struct in_addr addr; +#endif +#ifdef CONFIG_EXAMPLES_UDPBLASTER_NOMAC + uint8_t mac[IFHWADDRLEN]; +#endif + +/* Many embedded network interfaces must have a software assigned MAC */ + +#ifdef CONFIG_EXAMPLES_UDPBLASTER_NOMAC + mac[0] = 0x00; + mac[1] = 0xe0; + mac[2] = 0xde; + mac[3] = 0xad; + mac[4] = 0xbe; + mac[5] = 0xef; + netlib_setmacaddr("eth0", mac); +#endif + +#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv6 +#ifdef CONFIG_NET_ICMPv6_AUTOCONF + /* Perform ICMPv6 auto-configuration */ + + netlib_icmpv6_autoconfiguration("eth0"); + +#else /* CONFIG_NET_ICMPv6_AUTOCONF */ + + /* Set up our fixed host address */ + + netlib_set_ipv6addr("eth0", + (FAR const struct in6_addr *)g_ipv6_hostaddr); + + /* Set up the default router address */ + + netlib_set_dripv6addr("eth0", + (FAR const struct in6_addr *)g_ipv6_draddr); + + /* Setup the subnet mask */ + + netlib_set_ipv6netmask("eth0", + (FAR const struct in6_addr *)g_ipv6_netmask); + +#endif /* CONFIG_NET_ICMPv6_AUTOCONF */ +#else /* CONFIG_EXAMPLES_UDPBLASTER_IPv6 */ + + /* Set up our host address */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_TARGETIP); + netlib_set_ipv4addr("eth0", &addr); + + /* Set up the default router address */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_HOSTIP); + netlib_set_dripv4addr("eth0", &addr); + + /* Setup the subnet mask */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_NETMASK); + netlib_set_ipv4netmask("eth0", &addr); + +#endif /* CONFIG_EXAMPLES_UDPBLASTER_IPv6 */ +} +#endif /*CONFIG_EXAMPLES_UDPBLASTER_INIT */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * udpblaster_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int udpblaster_main(int argc, char *argv[]) +#endif +{ +#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4 + struct sockaddr_in host; +#else + struct sockaddr_in6 host; +#endif + socklen_t addrlen; + int npackets; + int ndots; + int sockfd; + int ret; + +#ifdef CONFIG_EXAMPLES_UDPBLASTER_INIT + /* Initialize the network */ + + netest_initialize(); +#endif + +#ifdef CONFIG_EXAMPLES_UDPBLASTER_IPv4 + host.sin_family = AF_INET; + host.sin_port = HTONS(UDPBLASTER_PORTNO); + host.sin_addr.s_addr = HTONL(CONFIG_EXAMPLES_UDPBLASTER_HOSTIP); + + addrlen = sizeof(struct sockaddr_in); + sockfd = socket(PF_INET, SOCK_DGRAM, 0); + if (sockfd < 0) + { + fprintf(stderr, "ERROR: socket() failed: %d\n", errno); + return 1; + } + +#else + host.sin6_family = AF_INET6; + host.sin6_port = HTONS(UDPBLASTER_PORTNO); + host.sin6_addr.s6_addr16[0] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_1); + host.sin6_addr.s6_addr16[1] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_2); + host.sin6_addr.s6_addr16[2] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_3); + host.sin6_addr.s6_addr16[3] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_4); + host.sin6_addr.s6_addr16[4] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_5); + host.sin6_addr.s6_addr16[5] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_6); + host.sin6_addr.s6_addr16[6] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_7); + host.sin6_addr.s6_addr16[7] = HTONL(EXAMPLES_UDPBLASTER_HOSTIPv6_8); + + addrlen = sizeof(struct sockaddr_in6); + sockfd = socket(PF_INET6, SOCK_DGRAM, 0); + if (sockfd < 0) + { + fprintf(stderr, "ERROR: socket() failed: %d\n", errno) + return 1; + } +#endif + + npackets = 0; + ndots = 0; + + for (;;) + { + ret = sendto(sockfd, g_udpblaster_text, UDPBLASTER_SENDSIZE, 0, + (struct sockaddr *)&host, addrlen); + if (ret < 0) + { + fprintf(stderr, "ERROR: sendto() failed: %d\n", errno); + return 1; + } + + if (++npackets >= 10) + { + putchar('.'); + npackets = 0; + + if (++ndots >= 50) + { + putchar('\n'); + ndots = 0; + } + } + } + + return 0; /* Won't get here */ +} diff --git a/examples/udpblaster/udpblaster_text.c b/examples/udpblaster/udpblaster_text.c new file mode 100644 index 000000000..ad057da4b --- /dev/null +++ b/examples/udpblaster/udpblaster_text.c @@ -0,0 +1,121 @@ +/**************************************************************************** + * examples/udpblaster/udpblaster_text.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include "config.h" +#include "udpblaster.h" + +/**************************************************************************** + * Public Data + ****************************************************************************/ + +const char g_udpblaster_text[] = + "ONE day Henny-penny was picking up corn in the cornyard when--whack!--" + "something hit her upon the head. 'Goodness gracious me!' said Henny-" + "penny; 'the sky's a-going to fall; I must go and tell the king.'\n\n" + + "So she went along and she went along and she went along till she met " + "Cocky-locky. 'Where are you going, Hennypenny?' says Cocky-locky. 'Oh! " + "I'm going to tell the king the sky's a-falling,' says Henny-penny. 'May " + "I come with you?' says Cocky-locky. 'Certainly,' says Henny-penny. So " + "Hennypenny and Cocky-locky went to tell the king the sky was falling.\n\n" + + "They went along, and they went along, and they went along, till they " + "met Ducky-daddles. 'Where are you going to, Hennypenny and Cocky-locky?' " + "says Ducky-daddles. 'Oh! we're going to tell the king the sky's a-falling,' " + "said Henny-penny and Cocky-locky. 'May I come with you?' said Ducky-daddles. " + "'Certainly,' said Henny-penny and Cocky-locky. So Hennypenny, Cocky-locky, " + "and Ducky-daddles went to tell the king the sky was a-falling.\n\n" + + "So they went along and they went along, and they went along, till they met " + "Goosey-poosey. 'Where are you going to, Henny-penny, Cocky-locky, and " + "Ducky-daddles?' said Gooseypoosey. 'Oh! we're going to tell the king the " + "sky's a-falling,' said Henny-penny and Cocky-locky and Ducky-daddles. 'May " + "I come with you?' said Goosey-poosey. 'Certainly,' said Hennypenny, " + "Cocky-locky, and Ducky-daddles. So Henny-penny, Cocky-locky, Ducky-daddles, " + "and Goosey-poosey went to tell the king the sky was a-falling.\n\n" + + "So they went along, and they went along, and they went along, till they met " + "Turkey-lurkey. 'Where are you going, Henny-penny, Cocky-locky, Ducky-daddles, " + "and Gooseypoosey?' says Turkey-turkey. 'Oh! we're going to tell the king the " + "sky's a-falling,' said Henny-penny, Cocky-locky, Duckydaddies, and Goosey-poosey. " + "'May I come with you, Hennypenny, Cocky-locky, Ducky-daddles, and Goosey-poosey?' " + "said Turkey-lurkey. 'Oh, certainly, Turkey-turkey,' said Henny-penny, Cocky-locky, " + "Ducky-daddles, and Gooseypoosey. So Henny-penny, Cocky-locky, Ducky-daddles, " + "Goosey-poosey, and Turkey-lurkey all went to tell the king the sky was a-" + "falling.\n\n" + + "So they went along, and they went along, and they went along, till they met " + "Foxy-woxy, and Foxy-woxy said to Hennypenny, Cocky-locky, Ducky-daddles, " + "Goosey-poosey, and Turkey-lurkey: 'Where are you going, Henny-penny, " + "Cockylocky, Ducky-daddles, Goosey-poosey, and Turkey-lurkey?' And Henny-penny, " + "Cocky-locky, Ducky-daddles, Goosey poosey, and Turkey-lurkey said to " + "Foxy-woxy: 'We' re going to tell the king the sky's a-falling.' 'Oh! but " + "this is not the way to the king, Henny-penny, Cocky-locky, Ducky-daddles, " + "Goosey-poosey, and Turkey-lurkey,' says Foxy-woxy; 'I know the proper way; " + "shall I show it you?' 'Oh, certainly, Foxywoxy,' said Henny-penny, Cocky-locky, " + "Ducky-daddles, Goosey-poosey, and Turkey-lurkey. So Henny-penny, Cockylocky, " + "Ducky-daddles, Goosey-poosey, Turkey-lurkey, and Foxy-woxy all went to tell " + "the king the sky was a-falling. So they went along, and they went along, and " + "they went along, till they came to a narrow and dark hole. Now this was the " + "door of Foxy-woxy's cave. But Foxy-woxy said to Henny-penny, Cocky-locky, " + "Ducky-daddles, Goosey-poosey, and Turkeyturkey: 'This is the short way to the " + "king's palace: you'll soon get there if you follow me. I will go first and you " + "come after, Henny-penny, Cocky-locky, Ducky-daddles, Goosey-poosey, and " + "Turkey-turkey.' 'Why, of course, certainly, without doubt, why not?' said " + "Henny-penny, Cocky-locky, Ducky-daddles, Goosey-poosey, and Turkey-lurkey.\n\n" + + "So Foxy-woxy went into his cave, and he didn't go very far, but turned round " + "to wait for Henny-penny, Cocky-locky, Ducky-daddles, Goosey-poosey, and " + "Turkey-lurkey. So at last at first Turkey-lurkey went through the dark hole " + "into the cave. He hadn't got far when 'Hrumph', Foxy-woxy snapped off Turkey-" + "lurkey's head and threw his body over his left shoulder. Then Goosey-poosey " + "went in, and 'Hrumph', off went her head and Goosey-poosey was thrown beside " + "Turkey-lurkey. Then Ducky-daddles waddled down, and 'Hrumph', snapped " + "Foxy-woxy, and Ducky-daddles's head was off and Duckydaddies was thrown " + "alongside Turkey-turkey and Gooseypoosey. Then Cocky-locky strutted down " + "into the cave, and he hadn't gone far when 'Snap, Hrumph!' went Foxy-woxy, " + "and Cocky-locky was thrown alongside of Turkey-lurkey, Gooseypoosey, and " + "Ducky-daddles.\n\n" + + "But Foxy-woxy had made two bites at Cocky-locky, and when the first snap " + "only hurt Cocky-locky, but didn't kill him, he called out to Henny-penny. " + "But she turned tail and off she ran home, so she never told the king the " + "sky was a-falling.\n\n"; + +const int g_udpblaster_strlen = sizeof(g_udpblaster_text) - 1; diff --git a/examples/usbserial/Kconfig b/examples/usbserial/Kconfig index 1fd4e9b18..0ceea5d75 100644 --- a/examples/usbserial/Kconfig +++ b/examples/usbserial/Kconfig @@ -11,6 +11,13 @@ config EXAMPLES_USBSERIAL if EXAMPLES_USBSERIAL +config EXAMPLES_USBSERIAL_BUFSIZE + int "Target I/O Buffer Size" + default 512 + ---help--- + The size of the array that is used as an I/O buffer for USB serial + data transfers. + config EXAMPLES_USBSERIAL_TRACEINIT bool "USB Trace Initialization" default n diff --git a/examples/usbserial/Makefile b/examples/usbserial/Makefile index 78dd4b1c7..f7d0b9602 100644 --- a/examples/usbserial/Makefile +++ b/examples/usbserial/Makefile @@ -37,6 +37,11 @@ include $(APPDIR)/Make.defs # USB serial device example +# Built-in application info + +APPNAME = usbserial +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 ASRCS = CSRCS = @@ -104,7 +109,14 @@ 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 diff --git a/examples/usbserial/Makefile.host b/examples/usbserial/Makefile.host index 2dbaa7e92..c6ebf54e5 100644 --- a/examples/usbserial/Makefile.host +++ b/examples/usbserial/Makefile.host @@ -1,7 +1,7 @@ ############################################################################ # apps/examples/usbserial/Makefile.host # -# Copyright (C) 2008, 2011 Gregory Nutt. All rights reserved. +# Copyright (C) 2008, 2011, 2015 Gregory Nutt. All rights reserved. # Author: Gregory Nutt # # Redistribution and use in source and binary forms, with or without @@ -53,6 +53,9 @@ endif ifeq ($(CONFIG_EXAMPLES_USBSERIAL_ONLYBIG),y) DEFINES += -DCONFIG_EXAMPLES_USBSERIAL_ONLYBIG=1 endif +ifeq ($(CONFIG_CDCACM),y) +DEFINES += -DCONFIG_CDCACM=1 +endif all: $(BIN) diff --git a/examples/usbserial/host.c b/examples/usbserial/host.c index 37ff9efa8..1ccfce124 100644 --- a/examples/usbserial/host.c +++ b/examples/usbserial/host.c @@ -50,7 +50,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #if defined(CONFIG_EXAMPLES_USBSERIAL_INONLY) && defined(CONFIG_EXAMPLES_USBSERIAL_OUTONLY) @@ -181,6 +181,7 @@ int main(int argc, char **argv, char **envp) fprintf(stderr, "Too many arguments on command line\n"); show_usage(argv[0], 1); } + g_ttydev = argv[1]; } @@ -192,13 +193,15 @@ int main(int argc, char **argv, char **envp) fd = open(g_ttydev, O_RDWR); if (fd < 0) { - printf("main: ERROR: Failed to open %s: %s\n", g_ttydev, strerror(errno)); + printf("main: ERROR: Failed to open %s: %s\n", + g_ttydev, strerror(errno)); printf("main: Assume not connected. Wait and try again.\n"); printf("main: (Control-C to terminate).\n"); sleep(5); } } while (fd < 0); + printf("main: Successfully opened the serial driver\n"); /* Configure the serial port in raw mode (at least turn off echo) */ @@ -206,7 +209,8 @@ int main(int argc, char **argv, char **envp) ret = tcgetattr(fd, &tty); if (ret < 0) { - printf("main: ERROR: Failed to get termios for %s: %s\n", g_ttydev, strerror(errno)); + printf("main: ERROR: Failed to get termios for %s: %s\n", + g_ttydev, strerror(errno)); close(fd); return 1; } @@ -220,7 +224,8 @@ int main(int argc, char **argv, char **envp) ret = tcsetattr(fd, TCSANOW, &tty); if (ret < 0) { - printf("main: ERROR: Failed to set termios for %s: %s\n", g_ttydev, strerror(errno)); + printf("main: ERROR: Failed to set termios for %s: %s\n", + g_ttydev, strerror(errno)); close(fd); return 1; } @@ -237,7 +242,8 @@ int main(int argc, char **argv, char **envp) nbytes = read(fd, g_iobuffer, BUFFER_SIZE-1); if (nbytes < 0) { - printf("main: ERROR: Failed to read from %s: %s\n", g_ttydev, strerror(errno)); + printf("main: ERROR: Failed to read from %s: %s\n", + g_ttydev, strerror(errno)); close(fd); return 2; } @@ -271,9 +277,11 @@ int main(int argc, char **argv, char **envp) nbytes = write(fd, g_longmsg, sizeof(g_longmsg)); count = 0; } + #elif !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL) printf("main: Sending %d bytes..\n", sizeof(g_longmsg)); nbytes = write(fd, g_longmsg, sizeof(g_longmsg)); + #else /* !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYBIG) */ printf("main: Sending %d bytes..\n", sizeof(g_shortmsg)); nbytes = write(fd, g_shortmsg, sizeof(g_shortmsg)); @@ -287,6 +295,7 @@ int main(int argc, char **argv, char **envp) close(fd); return 2; } + printf("main: %ld bytes sent\n", (long)nbytes); #endif /* CONFIG_EXAMPLES_USBSERIAL_INONLY */ } diff --git a/examples/usbserial/usbserial_main.c b/examples/usbserial/usbserial_main.c index 13c4bdb5c..04af142de 100644 --- a/examples/usbserial/usbserial_main.c +++ b/examples/usbserial/usbserial_main.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/usbserial/usbserial_main.c * - * Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2008, 2010-2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -56,7 +56,7 @@ #endif /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #if defined(CONFIG_EXAMPLES_USBSERIAL_INONLY) && defined(CONFIG_EXAMPLES_USBSERIAL_OUTONLY) @@ -72,6 +72,10 @@ # endif #endif +#ifndef CONFIG_USBDEV_TRACE_INITIALIDSET +# define CONFIG_USBDEV_TRACE_INITIALIDSET 0 +#endif + #ifdef CONFIG_EXAMPLES_USBSERIAL_TRACEINIT # define TRACE_INIT_BITS (TRACE_INIT_BIT) #else @@ -113,7 +117,9 @@ # define USBSER_DEVNAME "/dev/ttyUSB0" #endif -#define IOBUFFER_SIZE 256 +#ifndef CONFIG_EXAMPLES_USBSERIAL_BUFSIZE +# define CONFIG_EXAMPLES_USBSERIAL_BUFSIZE 256 +#endif /**************************************************************************** * Private Data @@ -153,7 +159,7 @@ static const char g_longmsg[] = #endif #ifndef CONFIG_EXAMPLES_USBSERIAL_INONLY -static char g_iobuffer[IOBUFFER_SIZE]; +static char g_iobuffer[CONFIG_EXAMPLES_USBSERIAL_BUFSIZE]; #endif /**************************************************************************** @@ -214,12 +220,14 @@ int usbserial_main(int argc, char *argv[]) #endif if (ret < 0) { - printf("usbserial_main: ERROR: Failed to create the USB serial device: %d\n", -ret); + printf("usbserial_main: ERROR: Failed to create the USB serial device: %d\n", + -ret); return 1; } + printf("usbserial_main: Successfully registered the serial driver\n"); -#if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 +#if defined(CONFIG_USBDEV_TRACE) && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 /* If USB tracing is enabled and tracing of initial USB events is specified, * then dump all collected trace data to stdout */ @@ -242,7 +250,8 @@ int usbserial_main(int argc, char *argv[]) if (outfd < 0) { int errcode = errno; - printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for writing: %d\n", errcode); + printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME + " for writing: %d\n", errcode); /* ENOTCONN means that the USB device is not yet connected */ @@ -274,7 +283,8 @@ int usbserial_main(int argc, char *argv[]) infd = open(USBSER_DEVNAME, O_RDONLY|O_NONBLOCK); if (infd < 0) { - printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for reading: %d\n", errno); + printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME + " for reading: %d\n", errno); close(outfd); return 3; } @@ -285,7 +295,8 @@ int usbserial_main(int argc, char *argv[]) if (infd < 0) { int errcode = errno; - printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME " for reading: %d\n", errno); + printf("usbserial_main: ERROR: Failed to open " USBSER_DEVNAME + " for reading: %d\n", errno); /* ENOTCONN means that the USB device is not yet connected */ @@ -333,9 +344,11 @@ int usbserial_main(int argc, char *argv[]) nbytes = write(outfd, g_longmsg, sizeof(g_longmsg)); count = 0; } + #elif !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYSMALL) printf("usbserial_main: Reciting QEI's speech of 1588\n"); nbytes = write(outfd, g_longmsg, sizeof(g_longmsg)); + #else /* !defined(CONFIG_EXAMPLES_USBSERIAL_ONLYBIG) */ printf("usbserial_main: Saying hello\n"); nbytes = write(outfd, g_shortmsg, sizeof(g_shortmsg)); @@ -352,6 +365,7 @@ int usbserial_main(int argc, char *argv[]) close(outfd); return 4; } + printf("usbserial_main: %ld bytes sent\n", (long)nbytes); #endif /* CONFIG_EXAMPLES_USBSERIAL_OUTONLY */ @@ -363,8 +377,8 @@ int usbserial_main(int argc, char *argv[]) printf("usbserial_main: Polling for OUT messages\n"); for (i = 0; i < 5; i++) { - memset(g_iobuffer, 'X', IOBUFFER_SIZE); - nbytes = read(infd, g_iobuffer, IOBUFFER_SIZE); + memset(g_iobuffer, 'X', CONFIG_EXAMPLES_USBSERIAL_BUFSIZE); + nbytes = read(infd, g_iobuffer, CONFIG_EXAMPLES_USBSERIAL_BUFSIZE); if (nbytes < 0) { int errorcode = errno; @@ -380,7 +394,7 @@ int usbserial_main(int argc, char *argv[]) } else { - printf("usbserial_main: Received l%d bytes:\n", (long)nbytes); + printf("usbserial_main: Received %ld bytes:\n", (long)nbytes); if (nbytes > 0) { for (j = 0; j < nbytes; j += 16) @@ -392,6 +406,7 @@ int usbserial_main(int argc, char *argv[]) { printf(" "); } + if (j+k < nbytes) { printf("%02x", g_iobuffer[j+k]); @@ -401,6 +416,7 @@ int usbserial_main(int argc, char *argv[]) printf(" "); } } + printf(" "); for (k = 0; k < 16; k++) { @@ -408,6 +424,7 @@ int usbserial_main(int argc, char *argv[]) { printf(" "); } + if (j+k < nbytes) { if (g_iobuffer[j+k] >= 0x20 && g_iobuffer[j+k] < 0x7f) @@ -424,12 +441,15 @@ int usbserial_main(int argc, char *argv[]) printf(" "); } } + printf("\n"); } } } + sleep(1); } + #else /* CONFIG_EXAMPLES_USBSERIAL_INONLY */ printf("usbserial_main: Waiting\n"); sleep(5); @@ -450,4 +470,3 @@ int usbserial_main(int argc, char *argv[]) #endif return 0; } - diff --git a/examples/usbterm/Makefile b/examples/usbterm/Makefile index 3b55f0990..98e7d8128 100644 --- a/examples/usbterm/Makefile +++ b/examples/usbterm/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # USB terminal example @@ -43,96 +41,13 @@ ASRCS = CSRCS = MAINSRC = usbterm_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 ?= usbterm$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Built-in application info APPNAME = usbterm 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 diff --git a/examples/usbterm/usbterm.h b/examples/usbterm/usbterm.h index 303d1b9f1..755c28046 100644 --- a/examples/usbterm/usbterm.h +++ b/examples/usbterm/usbterm.h @@ -47,7 +47,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ @@ -55,6 +55,10 @@ # define CONFIG_EXAMPLES_USBTERM_BUFLEN 256 #endif +#ifndef CONFIG_USBDEV_TRACE_INITIALIDSET +# define CONFIG_USBDEV_TRACE_INITIALIDSET 0 +#endif + #ifdef CONFIG_EXAMPLES_USBTERM_TRACEINIT # define TRACE_INIT_BITS (TRACE_INIT_BIT) #else diff --git a/examples/usbterm/usbterm_main.c b/examples/usbterm/usbterm_main.c index 3ec2a4a2b..ed1c56833 100644 --- a/examples/usbterm/usbterm_main.c +++ b/examples/usbterm/usbterm_main.c @@ -1,7 +1,7 @@ /**************************************************************************** * examples/usbterm/usbterm_main.c * - * Copyright (C) 2011-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2011-2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -66,7 +66,7 @@ #include "usbterm.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -226,7 +226,7 @@ int usbterm_main(int argc, char *argv[]) } printf("usbterm_main: Successfully registered the serial driver\n"); -#if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 +#if defined(CONFIG_USBDEV_TRACE) && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 /* If USB tracing is enabled and tracing of initial USB events is specified, * then dump all collected trace data to stdout */ diff --git a/examples/watchdog/Makefile b/examples/watchdog/Makefile index 2354894f4..b710c7e23 100644 --- a/examples/watchdog/Makefile +++ b/examples/watchdog/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # Watchdog Timer Example. @@ -43,95 +41,13 @@ ASRCS = CSRCS = MAINSRC = watchdog_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 ?= watchdog$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Touchscreen built-in application info APPNAME = wdog 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 diff --git a/examples/watchdog/watchdog.h b/examples/watchdog/watchdog.h index c7ba9919b..69ee16e97 100644 --- a/examples/watchdog/watchdog.h +++ b/examples/watchdog/watchdog.h @@ -43,7 +43,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* CONFIG_NSH_BUILTIN_APPS - Build the WATCHDOG test as an NSH built-in diff --git a/examples/watchdog/watchdog_main.c b/examples/watchdog/watchdog_main.c index 9390279bf..95ff07b83 100644 --- a/examples/watchdog/watchdog_main.c +++ b/examples/watchdog/watchdog_main.c @@ -354,9 +354,9 @@ int wdog_main(int argc, char *argv[]) goto errout_with_dev; } - close(fd); - fflush(stdout); - return OK; + close(fd); + fflush(stdout); + return OK; errout_with_dev: close(fd); diff --git a/examples/webserver/Makefile b/examples/webserver/Makefile index 384bf0910..3f4b1c1bb 100644 --- a/examples/webserver/Makefile +++ b/examples/webserver/Makefile @@ -75,6 +75,12 @@ PROGNAME = $(CONFIG_XYZ_PROGNAME) ROOTDEPPATH = --dep-path . +# Webserver built-in application info + +APPNAME = webserver +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + # Common build VPATH = @@ -108,7 +114,14 @@ 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 diff --git a/examples/wget/Makefile b/examples/wget/Makefile index b30c062b5..9fa488e41 100644 --- a/examples/wget/Makefile +++ b/examples/wget/Makefile @@ -33,9 +33,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # wget webclient example @@ -43,83 +41,7 @@ ASRCS = CSRCS = MAINSRC = wget_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 ?= wget$(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 diff --git a/examples/wgetjson/Makefile b/examples/wgetjson/Makefile index f4ddd234d..9ce0e3c60 100644 --- a/examples/wgetjson/Makefile +++ b/examples/wgetjson/Makefile @@ -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 = wgetjson_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 ?= wgetjson$(EXEEXT) PROGNAME = $(CONFIG_XYZ_PROGNAME) -ROOTDEPPATH = --dep-path . - # Buttons built-in application info APPNAME = wgetjson 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 diff --git a/examples/wgetjson/wgetjson_main.c b/examples/wgetjson/wgetjson_main.c index 7dafbcb44..ac363e21c 100644 --- a/examples/wgetjson/wgetjson_main.c +++ b/examples/wgetjson/wgetjson_main.c @@ -54,7 +54,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #ifndef CONFIG_EXAMPLES_WGETJSON_MAXSIZE diff --git a/examples/xmlrpc/Kconfig b/examples/xmlrpc/Kconfig index fd1f41dfc..6014b1a6b 100644 --- a/examples/xmlrpc/Kconfig +++ b/examples/xmlrpc/Kconfig @@ -23,7 +23,7 @@ config EXAMPLES_XMLRPC_DHCPC default n depends on EXAMPLES_XMLRPC && !NSH_BUILTIN_APPS select NETUTILS_DHCPC - select NETUTILS_DNSCLIENT + select NETDB_DNSCLIENT config EXAMPLES_XMLRPC_NOMAC bool "Use Canned MAC Address" diff --git a/examples/xmlrpc/Makefile b/examples/xmlrpc/Makefile index 5b8356db3..99a575868 100644 --- a/examples/xmlrpc/Makefile +++ b/examples/xmlrpc/Makefile @@ -36,9 +36,7 @@ # ############################################################################ --include $(TOPDIR)/.config -include $(TOPDIR)/Make.defs -include $(APPDIR)/Make.defs # XML RPC built-in application info @@ -50,89 +48,7 @@ ASRCS = CSRCS = calls.c MAINSRC = xmlrpc_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 ?= xmlrpc$(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 diff --git a/examples/zerocross/.gitignore b/examples/zerocross/.gitignore new file mode 100644 index 000000000..105259c49 --- /dev/null +++ b/examples/zerocross/.gitignore @@ -0,0 +1,11 @@ +/Make.dep +/.context +/.depend +/.built +/*.asm +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src diff --git a/examples/zerocross/Kconfig b/examples/zerocross/Kconfig new file mode 100644 index 000000000..541da9fa8 --- /dev/null +++ b/examples/zerocross/Kconfig @@ -0,0 +1,23 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config EXAMPLES_ZEROCROSS + bool "Zero Cross Detection example" + default n + depends on ZEROCROSS && !DISABLE_SIGNALS + ---help--- + Enable the zero cross detection example + +if EXAMPLES_ZEROCROSS + +config EXAMPLES_ZEROCROSS_DEVNAME + string "Zero Cross device name" + default "/dev/zc0" + +config EXAMPLES_ZEROCROSS_SIGNO + int "Zero Cross signal" + default 13 + +endif diff --git a/examples/zerocross/Make.defs b/examples/zerocross/Make.defs new file mode 100644 index 000000000..e3f15f592 --- /dev/null +++ b/examples/zerocross/Make.defs @@ -0,0 +1,39 @@ +############################################################################ +# apps/examples/zerocross/Make.defs +# Adds selected applications to apps/ build +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +ifeq ($(CONFIG_EXAMPLES_ZEROCROSS),y) +CONFIGURED_APPS += examples/zerocross +endif diff --git a/examples/zerocross/Makefile b/examples/zerocross/Makefile new file mode 100644 index 000000000..6d79faa05 --- /dev/null +++ b/examples/zerocross/Makefile @@ -0,0 +1,53 @@ +############################################################################ +# apps/examples/zerocross/Makefile +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/Make.defs + +# Zero Cross Example + +ASRCS = +CSRCS = +MAINSRC = zerocross_main.c + +CONFIG_ZEROCROSS_PROGNAME ?= zerocross$(EXEEXT) +PROGNAME = $(CONFIG_ZEROCROSS_PROGNAME) + +# Buttons built-in application info + +APPNAME = zerocross +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + +include $(APPDIR)/Application.mk diff --git a/examples/zerocross/zerocross_main.c b/examples/zerocross/zerocross_main.c new file mode 100644 index 000000000..89d66aee6 --- /dev/null +++ b/examples/zerocross/zerocross_main.c @@ -0,0 +1,148 @@ +/**************************************************************************** + * examplex/zerocross/zerocross_main.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ +/* Configuration ************************************************************/ + +#ifndef CONFIG_ZEROCROSS +# error "CONFIG_ZEROCROSS is not defined in the configuration" +#endif + +#ifndef CONFIG_EXAMPLES_ZEROCROSS_DEVNAME +# define CONFIG_EXAMPLES_ZEROCROSS_DEVNAME "/dev/zc0" +#endif + +#ifndef CONFIG_EXAMPLES_ZEROCROSS_SIGNO +# define CONFIG_EXAMPLES_ZEROCROSS_SIGNO 13 +#endif + +/* Helpers ******************************************************************/ + +#ifndef MIN +# define MIN(a,b) (a < b ? a : b) +#endif +#ifndef MAX +# define MAX(a,b) (a > b ? a : b) +#endif + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * zerocross_main + ****************************************************************************/ + +#ifdef CONFIG_BUILD_KERNEL +int main(int argc, FAR char *argv[]) +#else +int zerocross_main(int argc, char *argv[]) +#endif +{ + struct zc_notify_s notify; + int fd; + int tmp; + int ret; + int err = EXIT_FAILURE; + + /* Open the zerocross device */ + + fd = open(CONFIG_EXAMPLES_ZEROCROSS_DEVNAME, O_RDONLY); + if (fd < 0) + { + fprintf(stderr, "ERROR: Failed to open %s: %d\n", + CONFIG_EXAMPLES_ZEROCROSS_DEVNAME, errno); + return EXIT_FAILURE; + } + + /* Register to receive a signal on every zero cross event */ + + notify.zc_signo = CONFIG_EXAMPLES_ZEROCROSS_SIGNO; + + ret = ioctl(fd, ZCIOC_REGISTER, (unsigned long)((uintptr_t)¬ify)); + if (ret < 0) + { + fprintf(stderr, "ERROR: ioctl(ZCIOC_REGISTER) failed: %d\n", errno); + goto errout_with_fd; + } + + /* Then loop, receiving signals indicating zero cross events. */ + + for (; ; ) + { + struct siginfo value; + sigset_t set; + ssize_t nread; + + /* Wait for a signal */ + + (void)sigemptyset(&set); + (void)sigaddset(&set, CONFIG_EXAMPLES_ZEROCROSS_SIGNO); + ret = sigwaitinfo(&set, &value); + if (ret < 0) + { + fprintf(stderr, "ERROR: sigwaitinfo() failed: %d\n", errno); + goto errout_with_fd; + } + + /* Show the value accompanying the signal */ + + printf("Signal received!\n"); + printf("Sample = %d\n", value.si_value.sival_int); + } + + err = EXIT_SUCCESS; + +errout_with_fd: + close(fd); + return err; +} diff --git a/graphics/Kconfig b/graphics/Kconfig index 4e8b40809..8bfad9e8d 100644 --- a/graphics/Kconfig +++ b/graphics/Kconfig @@ -3,6 +3,8 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +menu "Graphics Support" + config TIFF bool "TIFF file generation library" default n @@ -31,4 +33,4 @@ source "$APPSDIR/graphics/traveler/Kconfig" endmenu endif # GRAPHICS_TRAVELER - +endmenu # Graphics Support diff --git a/graphics/tiff/tiff_initialize.c b/graphics/tiff/tiff_initialize.c index 2d6f66a50..645743164 100644 --- a/graphics/tiff/tiff_initialize.c +++ b/graphics/tiff/tiff_initialize.c @@ -321,10 +321,10 @@ static inline int tiff_putheader(FAR struct tiff_info_s *info) return ret; } - /* Two pad bytes following the header */ + /* Two pad bytes following the header */ - ret = tiff_putint16(info->outfd, 0); - return ret; + ret = tiff_putint16(info->outfd, 0); + return ret; } /**************************************************************************** @@ -450,7 +450,7 @@ static int tiff_datetime(FAR char *timbuf, unsigned int buflen) int tiff_initialize(FAR struct tiff_info_s *info) { uint16_t val16; -#if CONFIG_DEBUG_TIFFOFFSETS +#ifdef CONFIG_DEBUG_TIFFOFFSETS off_t offset = 0; #endif char timbuf[TIFF_DATETIME_STRLEN + 8]; diff --git a/graphics/tiff/tiff_internal.h b/graphics/tiff/tiff_internal.h index ac7f91381..f03ba5aae 100644 --- a/graphics/tiff/tiff_internal.h +++ b/graphics/tiff/tiff_internal.h @@ -114,7 +114,7 @@ extern "C" * ****************************************************************************/ -EXTERN ssize_t tiff_read(int fd, FAR void *buffer, size_t count); +ssize_t tiff_read(int fd, FAR void *buffer, size_t count); /**************************************************************************** * Name: tiff_write @@ -132,7 +132,7 @@ EXTERN ssize_t tiff_read(int fd, FAR void *buffer, size_t count); * ****************************************************************************/ -EXTERN int tiff_write(int fd, FAR const void *buffer, size_t count); +int tiff_write(int fd, FAR const void *buffer, size_t count); /**************************************************************************** * Name: tiff_putint16 @@ -149,7 +149,7 @@ EXTERN int tiff_write(int fd, FAR const void *buffer, size_t count); * ****************************************************************************/ -EXTERN int tiff_putint16(int fd, uint16_t value); +int tiff_putint16(int fd, uint16_t value); /**************************************************************************** * Name: tiff_putint32 @@ -166,7 +166,7 @@ EXTERN int tiff_putint16(int fd, uint16_t value); * ****************************************************************************/ -EXTERN int tiff_putint32(int fd, uint32_t value); +int tiff_putint32(int fd, uint32_t value); /**************************************************************************** * Name: tiff_putstring @@ -184,7 +184,7 @@ EXTERN int tiff_putint32(int fd, uint32_t value); * ****************************************************************************/ -EXTERN int tiff_putstring(int fd, FAR const char *string, int len); +int tiff_putstring(int fd, FAR const char *string, int len); /**************************************************************************** * Name: tiff_wordalign @@ -201,7 +201,7 @@ EXTERN int tiff_putstring(int fd, FAR const char *string, int len); * ****************************************************************************/ -EXTERN ssize_t tiff_wordalign(int fd, size_t size); +ssize_t tiff_wordalign(int fd, size_t size); #undef EXTERN #if defined(__cplusplus) @@ -209,4 +209,3 @@ EXTERN ssize_t tiff_wordalign(int fd, size_t size); #endif #endif /* __APPS_GRAPHICS_TIFF_TIFF_INTERNAL_H */ - diff --git a/graphics/traveler/src/trv_bitmapfile.c b/graphics/traveler/src/trv_bitmapfile.c index a17986868..9d98dc33c 100644 --- a/graphics/traveler/src/trv_bitmapfile.c +++ b/graphics/traveler/src/trv_bitmapfile.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_bitmapfile.c * This file contains the logic which loads texture bitmaps * @@ -59,7 +59,7 @@ * Description: * Read a file name from the input stream * - ***************************************************************************/ + ****************************************************************************/ static int trv_read_filename(FAR FILE *fp, FAR char *filename) { @@ -126,7 +126,7 @@ static int trv_read_filename(FAR FILE *fp, FAR char *filename) * Description: * This function loads the world data from the input file * - ***************************************************************************/ + ****************************************************************************/ static int trv_load_bitmaps(FAR FILE *fp, FAR const char *wldpath) { @@ -210,7 +210,7 @@ static int trv_load_bitmaps(FAR FILE *fp, FAR const char *wldpath) /**************************************************************************** * Public Functions - ***************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Name: trv_load_bitmapfile @@ -218,7 +218,7 @@ static int trv_load_bitmaps(FAR FILE *fp, FAR const char *wldpath) * Description: * This function opens the input file and loads the world data from it * - ***************************************************************************/ + ****************************************************************************/ int trv_load_bitmapfile(FAR const char *bitmapfile, FAR const char *wldpath) { diff --git a/graphics/traveler/src/trv_bitmaps.c b/graphics/traveler/src/trv_bitmaps.c index c9518ab60..eb0d073bb 100644 --- a/graphics/traveler/src/trv_bitmaps.c +++ b/graphics/traveler/src/trv_bitmaps.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_bitmaps.c * This file contains low-level texture bitmap logic * @@ -74,13 +74,13 @@ trv_pixel_t g_ground_color; * Private Functions ****************************************************************************/ -/************************************************************************* +/**************************************************************************** * Name: trv_free_texture * * Description: * Free both the bitmap and the bitmap container * - ************************************************************************/ + ****************************************************************************/ static void trv_free_texture(FAR struct trv_bitmap_s *bitmap) { @@ -101,7 +101,7 @@ static void trv_free_texture(FAR struct trv_bitmap_s *bitmap) * * Description: * - ***************************************************************************/ + ****************************************************************************/ int trv_initialize_bitmaps(void) { @@ -119,13 +119,13 @@ int trv_initialize_bitmaps(void) return OK; } -/************************************************************************* +/**************************************************************************** * Name: trv_release_bitmaps * * Description: * This function deallocates all bitmaps. * - ************************************************************************/ + ****************************************************************************/ void trv_release_bitmaps(void) { diff --git a/graphics/traveler/src/trv_color.c b/graphics/traveler/src/trv_color.c index 8760165a3..4c4825c07 100644 --- a/graphics/traveler/src/trv_color.c +++ b/graphics/traveler/src/trv_color.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_color.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. @@ -88,7 +88,7 @@ /**************************************************************************** * Private Type Declarations - ************************************************************************/ + ****************************************************************************/ /* The following enumeration defines indices into the g_unit_vector array */ @@ -125,7 +125,7 @@ struct color_form_s /**************************************************************************** * Private Variables - *************************************************************************/ + ****************************************************************************/ #if RGB_CUBE_SIZE < MIN_LUM_LEVELS static FAR struct trv_color_lum_s *g_pixel2um_lut; @@ -204,7 +204,7 @@ static float g_trv_cube2pixel; /**************************************************************************** * Private Functions - ************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Name: trv_lum2formtype @@ -213,7 +213,7 @@ static float g_trv_cube2pixel; * Convert an ordered RGB-Luminance value a color form (index into * XXXForm arrays). * - ***************************************************************************/ + ****************************************************************************/ #if RGB_CUBE_SIZE < MIN_LUM_LEVELS static uint8_t trv_lum2formtype(struct color_form_s *lum) @@ -256,7 +256,7 @@ static uint8_t trv_lum2formtype(struct color_form_s *lum) * Convert an RGB-Luminance value into a color form code (index into * g_unit_vector array). * - ************************************************************************/ + ****************************************************************************/ #if RGB_CUBE_SIZE < MIN_LUM_LEVELS static enum unit_vector_index_e trv_lum2colorform(struct trv_color_lum_s *lum) @@ -345,13 +345,13 @@ static enum unit_vector_index_e trv_lum2colorform(struct trv_color_lum_s *lum) /**************************************************************************** * Public Functions - ************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Name: trv_color_allocate * * Description: - ************************************************************************/ + ****************************************************************************/ void trv_color_allocate(FAR struct trv_palette_s *pinfo) { @@ -501,7 +501,7 @@ void trv_color_allocate(FAR struct trv_palette_s *pinfo) * When all color mapping has been performed, this function should be * called to release all resources dedicated to color mapping. * - ***************************************************************************/ + ****************************************************************************/ void trv_color_endmapping(void) { @@ -526,7 +526,7 @@ void trv_color_endmapping(void) * Description: * Free the color lookup table * - ***************************************************************************/ + ****************************************************************************/ void trv_color_free(struct trv_palette_s *pinfo) { @@ -542,7 +542,7 @@ void trv_color_free(struct trv_palette_s *pinfo) * Description: Map a RGB triplet into the corresponding pixel. The * value range of ech RGB value is assume to lie within 0 through * TRV_PIXEL_MAX. - ************************************************************************/ + ****************************************************************************/ trv_pixel_t trv_color_rgb2pixel(struct trv_color_rgb_s *pixel) { @@ -591,7 +591,7 @@ trv_pixel_t trv_color_rgb2pixel(struct trv_color_rgb_s *pixel) /**************************************************************************** * Name: trv_color_lum2pixel * Description: Convert an RGB-Luminance value into a pixel - ************************************************************************/ + ****************************************************************************/ trv_pixel_t trv_color_lum2pixel(struct trv_color_lum_s *lum) { @@ -641,7 +641,7 @@ trv_pixel_t trv_color_lum2pixel(struct trv_color_lum_s *lum) /**************************************************************************** * Name: trv_color_pixel2lum * Description: Convert a pixel value into RGB-Luminance value. - ************************************************************************/ + ****************************************************************************/ void trv_color_pixel2lum(trv_pixel_t pixval, struct trv_color_lum_s *lum) diff --git a/graphics/traveler/src/trv_doors.c b/graphics/traveler/src/trv_doors.c index 3fe3785e0..9387a05f4 100644 --- a/graphics/traveler/src/trv_doors.c +++ b/graphics/traveler/src/trv_doors.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_doors.c * This file contains the logic which manages world door logic. * @@ -57,7 +57,7 @@ /**************************************************************************** * Private Type Declarations - ***************************************************************************/ + ****************************************************************************/ /* These are possible values for the g_opendoor state variable */ @@ -97,7 +97,7 @@ struct trv_opendoor_s g_opendoor; * * Description: * - ***************************************************************************/ + ****************************************************************************/ static void trv_door_startopen (void) { @@ -288,7 +288,7 @@ void trv_door_initialize(void) g_opendoor.state = DOOR_IDLE; } -/*************************************************************************** +/**************************************************************************** * Name: trv_door_animate * * Description: @@ -297,7 +297,7 @@ void trv_door_initialize(void) * is started. This function then calls trv_door_animation which must be * called on each cycle to perform the door movement. * - ***************************************************************************/ + ****************************************************************************/ void trv_door_animate(void) { diff --git a/graphics/traveler/src/trv_fsutils.c b/graphics/traveler/src/trv_fsutils.c index e27f673dc..f3dba07f2 100644 --- a/graphics/traveler/src/trv_fsutils.c +++ b/graphics/traveler/src/trv_fsutils.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_fsutils.c * Miscellaneous file access utilities * @@ -55,7 +55,7 @@ * Description: * Read a decimal number from the steam 'fp' * - ***************************************************************************/ + ****************************************************************************/ int16_t trv_read_decimal(FAR FILE *fp) { @@ -105,7 +105,7 @@ int16_t trv_read_decimal(FAR FILE *fp) * to the file. The pointer returned by this function is allocated and * must be freed by the caller. * - ***************************************************************************/ + ****************************************************************************/ FAR char *trv_fullpath(FAR const char *path, FAR const char *name) { diff --git a/graphics/traveler/src/trv_graphicfile.c b/graphics/traveler/src/trv_graphicfile.c index 4e598fd58..a8bee0aed 100644 --- a/graphics/traveler/src/trv_graphicfile.c +++ b/graphics/traveler/src/trv_graphicfile.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_graphicfile.c * Load image from a graphic file * @@ -60,7 +60,7 @@ * graphic file formats can be supported. Currently only the ancient * PCX format is supported. * - ***************************************************************************/ + ****************************************************************************/ FAR struct trv_graphicfile_s *tvr_graphicfile_read(char *filename) { @@ -83,7 +83,7 @@ FAR struct trv_graphicfile_s *tvr_graphicfile_read(char *filename) * REVISIT: Here would be the place where we would decide on the format of * the graphic file. Here we just assume that the file is PCX. */ - + gfile = trv_load_pcx(fp, filename); if (gfile == NULL) { @@ -94,13 +94,13 @@ FAR struct trv_graphicfile_s *tvr_graphicfile_read(char *filename) return gfile; } -/************************************************************************* +/**************************************************************************** * Name: trv_graphicfile_new * * Description: * Allocate a new graphic file structure * - ************************************************************************/ + ****************************************************************************/ FAR struct trv_graphicfile_s *trv_graphicfile_new(void) { @@ -117,14 +117,14 @@ FAR struct trv_graphicfile_s *trv_graphicfile_new(void) return gfile; } -/************************************************************************* +/**************************************************************************** * Name: trv_graphicfile_free * * Description: * Free the graphic file structure after also freeing in additional * resources attached to the structure. - - ************************************************************************/ + + ****************************************************************************/ void trv_graphicfile_free(FAR struct trv_graphicfile_s *gfile) { @@ -144,14 +144,14 @@ void trv_graphicfile_free(FAR struct trv_graphicfile_s *gfile) } } -/************************************************************************* +/**************************************************************************** * Name: trv_graphicfile_pixel * * Description: * Return the RGB color value for a pixel at location (x,y) in the * texture bitmap. * - ************************************************************************/ + ****************************************************************************/ struct trv_color_rgb_s trv_graphicfile_pixel(FAR struct trv_graphicfile_s *gfile, int x, int y) diff --git a/graphics/traveler/src/trv_input.c b/graphics/traveler/src/trv_input.c index 15b41ad4f..c14dc42af 100644 --- a/graphics/traveler/src/trv_input.c +++ b/graphics/traveler/src/trv_input.c @@ -120,7 +120,7 @@ struct trv_input_s g_trv_input; /**************************************************************************** * Private Function Prototypes - *****************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_GRAPHICS_TRAVELER_JOYSTICK static struct trv_joystick_s g_trv_joystick; @@ -145,15 +145,15 @@ static struct trv_joystick_s g_trv_joystick; #ifdef CONFIG_GRAPHICS_TRAVELER_AJOYSTICK static int trv_joystick_wait(void) { - sigset_t sigset; + sigset_t set; struct siginfo value; int ret; /* Wait for a signal */ - (void)sigemptyset(&sigset); - (void)sigaddset(&sigset, CONFIG_GRAPHICS_TRAVELER_JOYSTICK_SIGNO); - ret = sigwaitinfo(&sigset, &value); + (void)sigemptyset(&set); + (void)sigaddset(&set, CONFIG_GRAPHICS_TRAVELER_JOYSTICK_SIGNO); + ret = sigwaitinfo(&set, &value); if (ret < 0) { int errcode = errno; diff --git a/graphics/traveler/src/trv_main.c b/graphics/traveler/src/trv_main.c index 56316277a..9ef348214 100644 --- a/graphics/traveler/src/trv_main.c +++ b/graphics/traveler/src/trv_main.c @@ -83,13 +83,13 @@ /**************************************************************************** * Public Data - *************************************************************************/ + ****************************************************************************/ bool g_trv_terminate; /**************************************************************************** * Private Data - *************************************************************************/ + ****************************************************************************/ static const char g_default_worldfile[] = "transfrm.wld"; static const char g_default_worldpath[] = CONFIG_GRAPHICS_TRAVELER_DEFPATH; @@ -283,7 +283,7 @@ int traveler_main(int argc, char *argv[]) switch (*ptr) { case 'p' : - wldpath = ptr++; + wldpath = ptr++; break; default: diff --git a/graphics/traveler/src/trv_paltbl.c b/graphics/traveler/src/trv_paltbl.c index 47cb82237..c72d1c1a1 100644 --- a/graphics/traveler/src/trv_paltbl.c +++ b/graphics/traveler/src/trv_paltbl.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_paltbl.c * This file contains the logic that creates the range palette table that is * used to modify the palette with range to hit @@ -64,7 +64,7 @@ /**************************************************************************** * Private Type Declarations - ***************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_GRAPHICS_TRAVELER_PALRANGES struct trv_palrange_s @@ -94,7 +94,7 @@ trv_pixel_t *g_paltable[NUM_ZONES]; * * Description: * - ***************************************************************************/ + ****************************************************************************/ static int trv_allocate_paltbl(uint32_t entrysize) { @@ -124,7 +124,7 @@ static int trv_allocate_paltbl(uint32_t entrysize) * Description: * This function loads the g_paltable from the specified file * - ***************************************************************************/ + ****************************************************************************/ int trv_load_paltable(FAR const char *file) { @@ -326,12 +326,12 @@ int trv_load_paltable(FAR const char *file) #endif /* CONFIG_GRAPHICS_TRAVELER_PALRANGES */ } -/************************************************************************* +/**************************************************************************** * Function: trv_release_paltable * * Description: * - ************************************************************************/ + ****************************************************************************/ void trv_release_paltable(void) { diff --git a/graphics/traveler/src/trv_pcx.c b/graphics/traveler/src/trv_pcx.c index 5ff2d0cb7..2120e4b74 100644 --- a/graphics/traveler/src/trv_pcx.c +++ b/graphics/traveler/src/trv_pcx.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_pcx.c * PCX graphic file support * @@ -56,7 +56,7 @@ * * Description: * - ***************************************************************************/ + ****************************************************************************/ static void trv_load_pcxheader(FAR FILE *fp, struct pcx_header_s *header) { @@ -78,7 +78,7 @@ static void trv_load_pcxheader(FAR FILE *fp, struct pcx_header_s *header) * * Description: * - ***************************************************************************/ + ****************************************************************************/ static void trv_load_pcxdata(FAR FILE *fp, int32_t imagesize, FAR uint8_t *imagebuffer) @@ -127,7 +127,7 @@ static void trv_load_pcxdata(FAR FILE *fp, int32_t imagesize, * * Description: * - ***************************************************************************/ + ****************************************************************************/ static void trv_load_pcxpalette(FAR FILE *fp, FAR struct trv_color_rgb_s *palette) @@ -160,7 +160,7 @@ static void trv_load_pcxpalette(FAR FILE *fp, * Description: * This function loads a PCX file into a memory. * - ***************************************************************************/ + ****************************************************************************/ FAR struct trv_graphicfile_s *trv_load_pcx(FAR FILE *fp, FAR const char *filename) diff --git a/graphics/traveler/src/trv_planefiles.c b/graphics/traveler/src/trv_planefiles.c index 828d6c06d..b6503c2ae 100644 --- a/graphics/traveler/src/trv_planefiles.c +++ b/graphics/traveler/src/trv_planefiles.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_planefiles.c * This file contains the logic to manage the world data files * @@ -50,7 +50,7 @@ /**************************************************************************** * Private Type Declarations - ***************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Private Functions @@ -63,7 +63,7 @@ * * This function loads the world data for one plane * - ***************************************************************************/ + ****************************************************************************/ static int trv_load_worldplane(FAR FILE *fp, FAR struct trv_rect_head_s *head, uint8_t nrects) @@ -107,7 +107,7 @@ static int trv_load_worldplane(FAR FILE *fp, FAR struct trv_rect_head_s *head, * Function: trv_load_planes * Description: * This function loads the world data from the opened file - ***************************************************************************/ + ****************************************************************************/ static int trv_load_planes(FAR FILE *fp) { @@ -153,7 +153,7 @@ static int trv_load_planes(FAR FILE *fp) * * This function opens the input file and loads the world plane data from it * - ***************************************************************************/ + ****************************************************************************/ int trv_load_planefile(FAR const char *wldfile) { diff --git a/graphics/traveler/src/trv_planelists.c b/graphics/traveler/src/trv_planelists.c index 49d5f8e7f..a6f066254 100644 --- a/graphics/traveler/src/trv_planelists.c +++ b/graphics/traveler/src/trv_planelists.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_planelist.c * This file contains the logic to manage world plane lists. * @@ -68,7 +68,7 @@ FAR struct trv_rect_list_s *g_rect_freelist; * Description: * This function deallocates one plane of the world * - ***************************************************************************/ + ****************************************************************************/ static void trv_release_worldplane(FAR struct trv_rect_list_s *rect) { @@ -91,7 +91,7 @@ static void trv_release_worldplane(FAR struct trv_rect_list_s *rect) * * Description: * - ***************************************************************************/ + ****************************************************************************/ int trv_initialize_planes(void) { @@ -112,7 +112,7 @@ int trv_initialize_planes(void) * Description: * This function adds a plane to a world plane list * - ***************************************************************************/ + ****************************************************************************/ void trv_add_plane(FAR struct trv_rect_list_s *rect, FAR struct trv_rect_head_s *list) @@ -190,7 +190,7 @@ void trv_add_plane(FAR struct trv_rect_list_s *rect, * This function removes the specified plane from the world plane srclist * then adds it to the world plane destlist * - ***************************************************************************/ + ****************************************************************************/ void trv_move_plane(FAR struct trv_rect_list_s *rect, FAR struct trv_rect_head_s *destlist, @@ -229,7 +229,7 @@ void trv_move_plane(FAR struct trv_rect_list_s *rect, * Description: * This function concatenates two world plane lists * - ***************************************************************************/ + ****************************************************************************/ void trv_merge_planelists(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist) @@ -323,13 +323,13 @@ void trv_merge_planelists(FAR struct trv_rect_head_s *outlist, inlist->tail = NULL; } -/************************************************************************* +/**************************************************************************** * Function: trv_new_plane * * Description: * This function allocates memory for a new plane rectangle. * - ************************************************************************/ + ****************************************************************************/ FAR struct trv_rect_list_s *trv_new_plane(void) { @@ -354,14 +354,14 @@ FAR struct trv_rect_list_s *trv_new_plane(void) return rect; } -/************************************************************************* +/**************************************************************************** * Name: trv_release_planes * * Description: * * This function deallocates the entire world. * - ************************************************************************/ + ****************************************************************************/ void trv_release_planes(void) { diff --git a/graphics/traveler/src/trv_rayavoid.c b/graphics/traveler/src/trv_rayavoid.c index cfdccf828..51c9588a1 100644 --- a/graphics/traveler/src/trv_rayavoid.c +++ b/graphics/traveler/src/trv_rayavoid.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_rayavoid.c * This file contains the logic which determines if the desired player motion * would cause a collision with various walls or if the motion would cause @@ -38,7 +38,7 @@ * ****************************************************************************/ -/***************************************************************************** +/**************************************************************************** * Included files ****************************************************************************/ @@ -48,7 +48,7 @@ #include "trv_world.h" #include "trv_rayavoid.h" -/***************************************************************************** +/**************************************************************************** * Pre-processor Definitions ****************************************************************************/ @@ -56,7 +56,7 @@ #define MIN_APPROACH_DISTANCE (64/4) /* One quarter cell */ -/***************************************************************************** +/**************************************************************************** * Private Data ****************************************************************************/ @@ -68,11 +68,11 @@ static struct trv_rect_data_s *g_clip_rect; -/***************************************************************************** +/**************************************************************************** * Public Functions ****************************************************************************/ -/***************************************************************************** +/**************************************************************************** * Name: trv_ray_test_xplane * * Description: @@ -84,7 +84,7 @@ static struct trv_rect_data_s *g_clip_rect; * trv_rayclip_player_xmotion and depends on the side-effect setting of * g_clip_rect. * - *****************************************************************************/ + ****************************************************************************/ FAR struct trv_rect_data_s *trv_ray_test_xplane(FAR struct trv_camera_s *pov, trv_coord_t dist, int16_t yaw, @@ -94,7 +94,7 @@ FAR struct trv_rect_data_s *trv_ray_test_xplane(FAR struct trv_camera_s *pov, return g_clip_rect; } -/***************************************************************************** +/**************************************************************************** * Name: trv_rayclip_player_xmotion * * Description: @@ -103,7 +103,7 @@ FAR struct trv_rect_data_s *trv_ray_test_xplane(FAR struct trv_camera_s *pov, * a collision with an X plane. This logic is essentially a modified X * ray cast. * - *****************************************************************************/ + ****************************************************************************/ trv_coord_t trv_rayclip_player_xmotion(FAR struct trv_camera_s *pov, trv_coord_t dist, int16_t yaw, @@ -322,7 +322,7 @@ trv_coord_t trv_rayclip_player_xmotion(FAR struct trv_camera_s *pov, return reqdeltax; } -/***************************************************************************** +/**************************************************************************** * Name: trv_ray_test_yplane * * Description: @@ -343,7 +343,7 @@ FAR struct trv_rect_data_s *trv_ray_test_yplane(FAR struct trv_camera_s *pov, return g_clip_rect; } -/***************************************************************************** +/**************************************************************************** * Name: trv_rayclip_player_ymotion * * Description: @@ -569,7 +569,7 @@ trv_coord_t trv_rayclip_player_ymotion(FAR struct trv_camera_s *pov, return reqdeltay; } -/***************************************************************************** +/**************************************************************************** * Name: trv_ray_adjust_zpos * * Description: diff --git a/graphics/traveler/src/trv_raycast.c b/graphics/traveler/src/trv_raycast.c index 88fbe5b72..bf6e27948 100644 --- a/graphics/traveler/src/trv_raycast.c +++ b/graphics/traveler/src/trv_raycast.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_raycast.c * This file contains the low-level ray casting logic * @@ -103,7 +103,7 @@ static int32_t g_adj_cotpitch; * NOTE: The X-Ray caster must run first because it initializes a * data structure needed by both the Y and Z ray casters. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_xcaster14(FAR struct trv_raycast_s *result) { @@ -332,7 +332,7 @@ static void trv_ray_xcaster14(FAR struct trv_raycast_s *result) * NOTE: The X-Ray caster must run first because it initializes a * data structure needed by both the Y and Z ray casters. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_xcaster23(FAR struct trv_raycast_s *result) { @@ -559,7 +559,7 @@ static void trv_ray_xcaster23(FAR struct trv_raycast_s *result) * * NOTE: The X-Ray is assumed to have been performed first! * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_ycaster12(FAR struct trv_raycast_s *result) { @@ -785,7 +785,7 @@ static void trv_ray_ycaster12(FAR struct trv_raycast_s *result) * * NOTE: The X-Ray is assumed to have been performed first! * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_ycaster34(FAR struct trv_raycast_s *result) { @@ -1014,7 +1014,7 @@ static void trv_ray_ycaster34(FAR struct trv_raycast_s *result) * * NOTE: It is assumed that both the X and Y ray casters have already * ran! - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_zcasteru(FAR struct trv_raycast_s *result) { @@ -1163,7 +1163,7 @@ static void trv_ray_zcasteru(FAR struct trv_raycast_s *result) * NOTE: It is assumed that both the X and Y ray casters have already * ran! * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_zcasterl(FAR struct trv_raycast_s *result) { @@ -1310,7 +1310,7 @@ static void trv_ray_zcasterl(FAR struct trv_raycast_s *result) * quadrants so that simpler casting algorithms can be used. It also * enforces the order of casting: X first, then Y, and finally Z. * - ***************************************************************************/ + ****************************************************************************/ void trv_raycast(int16_t pitch, int16_t yaw, int16_t screenyaw, FAR struct trv_raycast_s *result) diff --git a/graphics/traveler/src/trv_raycntl.c b/graphics/traveler/src/trv_raycntl.c index f1f8b1cec..f802eb3ef 100644 --- a/graphics/traveler/src/trv_raycntl.c +++ b/graphics/traveler/src/trv_raycntl.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_raycntl.c * This file contains the high-level ray caster control logic * @@ -136,7 +136,7 @@ static int16_t g_pitch[VGULP_SIZE]; * recursively resolve the cell until all four corners are the same. * When the are the same, then rend the cell to the display buffer. * - ***************************************************************************/ + ****************************************************************************/ static void trv_resolve_cell(uint8_t toprow, uint8_t leftcol, uint8_t height, uint8_t width) @@ -593,7 +593,7 @@ static void trv_resolve_cell(uint8_t toprow, uint8_t leftcol, * This is the heart of the system. it casts out 320 rays and builds the * 3-D image from their intersections with the walls. * - ***************************************************************************/ + ****************************************************************************/ void trv_raycaster(FAR struct trv_camera_s *player, FAR struct trv_graphics_info_s *ginfo) @@ -764,7 +764,7 @@ void trv_raycaster(FAR struct trv_camera_s *player, * Prevention of this condition is the best approach. However, total * elimination of the condition is impossible. * - ***************************************************************************/ + ****************************************************************************/ uint8_t trv_get_texture(uint8_t row, uint8_t col) { diff --git a/graphics/traveler/src/trv_rayprune.c b/graphics/traveler/src/trv_rayprune.c index ce1bb7a83..b0e5516db 100644 --- a/graphics/traveler/src/trv_rayprune.c +++ b/graphics/traveler/src/trv_rayprune.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_rayprune.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. @@ -86,7 +86,7 @@ /**************************************************************************** * Private Type Declarations - ***************************************************************************/ + ****************************************************************************/ enum working_plane_state_e { @@ -173,7 +173,7 @@ static struct trv_rect_head_s g_discard_zplane; /* List of discarded Z=plane * camera position and "clockwise" of the current yaw is moved into * the output X plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawxprune_14cw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, @@ -262,7 +262,7 @@ static void trv_ray_yawxprune_14cw(FAR struct trv_rect_head_s *outlist, * camera position and "counterclockwise" of the current yaw is moved into * the output X plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawxprune_14ccw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, @@ -351,7 +351,7 @@ static void trv_ray_yawxprune_14ccw(FAR struct trv_rect_head_s *outlist, * camera position and "clockwise" of the current yaw is moved into * the output X plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawxprune_23cw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, @@ -440,7 +440,7 @@ static void trv_ray_yawxprune_23cw(FAR struct trv_rect_head_s *outlist, * camera position and "counterclockwise" of the current yaw is moved * into the output X plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawxprune_23ccw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, @@ -529,7 +529,7 @@ static void trv_ray_yawxprune_23ccw(FAR struct trv_rect_head_s *outlist, * camera position and "clockwise" of the current yaw is moved into * the output Y plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawyprune_12cw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, @@ -620,7 +620,7 @@ static void trv_ray_yawyprune_12cw(FAR struct trv_rect_head_s *outlist, * camera position and "counterclockwise" of the current yaw is moved into * the output Y plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawyprune_12ccw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, @@ -711,7 +711,7 @@ static void trv_ray_yawyprune_12ccw(FAR struct trv_rect_head_s *outlist, * camera position and "clockwise" of the current yaw is moved into * the output Y plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawyprune_34cw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, @@ -802,7 +802,7 @@ static void trv_ray_yawyprune_34cw(FAR struct trv_rect_head_s *outlist, * camera position and "counterclockwise" of the current yaw is moved * into the output Y plane list. * - ***************************************************************************/ + ****************************************************************************/ static void trv_ray_yawyprune_34ccw(FAR struct trv_rect_head_s *outlist, FAR struct trv_rect_head_s *inlist, diff --git a/graphics/traveler/src/trv_rayrend.c b/graphics/traveler/src/trv_rayrend.c index f9c45c3ad..876c7b57a 100644 --- a/graphics/traveler/src/trv_rayrend.c +++ b/graphics/traveler/src/trv_rayrend.c @@ -1,4 +1,4 @@ -/***************************************************************************** +/**************************************************************************** * apps/graphics/traveler/src/trv_rayrend.c * This file contains the functions needed to render a screen. * @@ -210,7 +210,7 @@ static void trv_rend_zcell(uint8_t row, uint8_t col, uint8_t height, uint8_t wid endcol = col + width; endrow = row + height; - + /* Calculate the horizontal interpolation values */ /* This is the H starting position (first row, first column) */ @@ -221,7 +221,7 @@ static void trv_rend_zcell(uint8_t row, uint8_t col, uint8_t height, uint8_t wid hcolstep = TDIV((g_ray_hit[row][endcol].xpos - g_ray_hit[row][col].xpos), width, scale); - + /* This is the change in xpos per column in the last row */ tmpcolstep = @@ -264,7 +264,7 @@ static void trv_rend_zcell(uint8_t row, uint8_t col, uint8_t height, uint8_t wid vrowstep = TDIV((g_ray_hit[endrow][col].ypos - g_ray_hit[row][col].ypos), height, scale); - + /* Determine the palette mapping table zone for each row */ if (IS_SHADED(g_ray_hit[row][col].rect)) @@ -386,7 +386,7 @@ static void trv_rend_zrow(uint8_t row, uint8_t col, uint8_t width) { palptr = GET_PALPTR(0); } - + /* Within this function, all references to width are really * (width-1) */ @@ -396,7 +396,7 @@ static void trv_rend_zrow(uint8_t row, uint8_t col, uint8_t width) /* Get the index to the right side */ endcol = col + width; - + /* Calculate the horizontal interpolation values */ /* This is the H starting position (first column) */ @@ -407,18 +407,18 @@ static void trv_rend_zrow(uint8_t row, uint8_t col, uint8_t width) hcolstep = TDIV((g_ray_hit[row][endcol].xpos - g_ray_hit[row][col].xpos), width, scale); - + /* Calculate the vertical interpolation values */ /* This is the V starting position (first column) */ ypos.w = TALIGN(g_ray_hit[row][col].ypos, scale); - + /* This is the change in ypos per column */ vcolstep = TDIV((g_ray_hit[row][endcol].ypos - g_ray_hit[row][col].ypos), width, scale); - + /* Interpolate to texture each column in the row */ for (j = col; j <= endcol; j++) @@ -443,7 +443,7 @@ static void trv_rend_zcol(uint8_t row, uint8_t col, uint8_t height) uint8_t i, endrow; FAR uint8_t *palptr; FAR uint8_t *outpixel; - uint8_t scale; + uint8_t scale; FAR trv_pixel_t *texture; FAR struct trv_bitmap_s *bmp; union tex_ndx_u xpos; @@ -493,7 +493,7 @@ static void trv_rend_zcol(uint8_t row, uint8_t col, uint8_t height) { palptr = GET_PALPTR(0); } - + /* Within this function, all references to height are really * (height-1) */ @@ -519,13 +519,13 @@ static void trv_rend_zcol(uint8_t row, uint8_t col, uint8_t height) /* This is the V starting position (first row) */ ypos.w = TALIGN(g_ray_hit[row][col].ypos, scale); - + /* This is the change in ypos for each row */ vrowstep = TDIV((g_ray_hit[endrow][col].ypos - g_ray_hit[row][col].ypos), height, scale); - + /* Now, interpolate to texture each row (vertical component) */ for (i = row; i <= endrow; i++) @@ -678,7 +678,7 @@ static void trv_rend_wall(uint8_t row, uint8_t col, { palptr = GET_PALPTR(0); } - + /* Within this function, all references to height and width are really * (height-1) and (width-1) */ @@ -701,12 +701,12 @@ static void trv_rend_wall(uint8_t row, uint8_t col, hcolstep = TDIV((g_ray_hit[row][endcol].xpos - g_ray_hit[row][col].xpos), width, scale); - + /* Calculate the vertical interpolation values */ /* This is the V starting position (first row, first column) */ vstart = TALIGN(g_ray_hit[row][col].ypos, scale); - + /* This is the change in ypos per column in the first row */ vcolstep = @@ -728,7 +728,7 @@ static void trv_rend_wall(uint8_t row, uint8_t col, vrowstep = TDIV((g_ray_hit[endrow][col].ypos - g_ray_hit[row][col].ypos), height, scale); - + /* Now, interpolate to texture each row (vertical component) */ for (i = row; i <= endrow; i++) @@ -855,7 +855,7 @@ static void trv_rend_wallrow(uint8_t row, uint8_t col, uint8_t width) { palptr = GET_PALPTR(0); } - + /* Within this function, all references to width are really * (width-1) */ @@ -865,7 +865,7 @@ static void trv_rend_wallrow(uint8_t row, uint8_t col, uint8_t width) /* Get the index to the right side */ endcol = col + width; - + /* Calculate the horizontal interpolation values */ /* This is the H starting position (first column) */ @@ -881,13 +881,13 @@ static void trv_rend_wallrow(uint8_t row, uint8_t col, uint8_t width) /* This is the V starting position (first column) */ ypos.w = TALIGN(g_ray_hit[row][col].ypos, scale); - + /* This is the change in ypos per column */ vcolstep = TDIV((g_ray_hit[row][endcol].ypos - g_ray_hit[row][col].ypos), width, scale); - + /* Interpolate to texture each column in the row */ for (j = col; j <= endcol; j++) @@ -895,7 +895,7 @@ static void trv_rend_wallrow(uint8_t row, uint8_t col, uint8_t width) /* Extract the pixel from the texture */ inpixel = texture[TNDX(xpos.s.i, ypos.s.i, tsize, tmask)]; - + /* If this is an INVISIBLE_PIXEL in a TRANSPARENT_WALL, then * we will have to take some pretty extreme measures to get the * correct value of the pixel @@ -991,7 +991,7 @@ static void trv_rend_wallcol(uint8_t row, uint8_t col, uint8_t height) { palptr = GET_PALPTR(0); } - + /* Within this function, all references to height are really * (height-1) */ @@ -1010,7 +1010,7 @@ static void trv_rend_wallcol(uint8_t row, uint8_t col, uint8_t height) /* This is the V starting position (first row, first column) */ ypos.w = TALIGN(g_ray_hit[row][col].ypos, scale); - + /* This is the change in ypos for each row */ vrowstep = diff --git a/graphics/traveler/src/trv_texturefile.c b/graphics/traveler/src/trv_texturefile.c index 671e01c83..37f7650a9 100644 --- a/graphics/traveler/src/trv_texturefile.c +++ b/graphics/traveler/src/trv_texturefile.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_texturefile.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. @@ -69,7 +69,7 @@ * Return the log base 2 of the argument, or -1 if the argument is not * an integer power of 2. * - ***************************************************************************/ + ****************************************************************************/ static int trv_log2(uint16_t x) { @@ -87,7 +87,7 @@ static int trv_log2(uint16_t x) * Name: trv_new_texture * * Description: - ***************************************************************************/ + ****************************************************************************/ static FAR struct trv_bitmap_s * trv_new_texture(uint16_t width, uint16_t height) @@ -140,14 +140,14 @@ trv_new_texture(uint16_t width, uint16_t height) bitmap->w = width; bitmap->h = height; bitmap->log2h = log2h; - + return bitmap; } /**************************************************************************** * Name: trv_quantize_texture * Description: - ***************************************************************************/ + ****************************************************************************/ static void trv_quantize_texture(FAR struct trv_graphicfile_s *gfile, FAR struct trv_bitmap_s *bitmap) @@ -162,7 +162,7 @@ static void trv_quantize_texture(FAR struct trv_graphicfile_s *gfile, for (y = gfile->height - 1; y >= 0; y--) { pixel = trv_graphicfile_pixel(gfile, x, y); - *destpixel++ = trv_color_rgb2pixel(&pixel); + *destpixel++ = trv_color_rgb2pixel(&pixel); } } } @@ -176,7 +176,7 @@ static void trv_quantize_texture(FAR struct trv_graphicfile_s *gfile, * * Description: * - ***************************************************************************/ + ****************************************************************************/ FAR struct trv_bitmap_s *trv_read_texture(FAR const char *filename) { diff --git a/graphics/traveler/src/trv_world.c b/graphics/traveler/src/trv_world.c index f13e797e3..d9ce2efd7 100644 --- a/graphics/traveler/src/trv_world.c +++ b/graphics/traveler/src/trv_world.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/src/trv_world.c * This file contains the logic that creates and destroys the world. * @@ -91,7 +91,7 @@ /**************************************************************************** * Private Type Declarations - ***************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Private Function Prototypes @@ -166,7 +166,7 @@ static const char g_world_images_name[] = WORLD_IMAGES; * Reads a short value from the INI file and assures that it is within * range for an a int16_t * - ***************************************************************************/ + ****************************************************************************/ static int trv_ini_short(INIHANDLE inihandle, FAR int16_t *value, FAR const char *section, FAR const char *name) @@ -221,7 +221,7 @@ static int trv_ini_short(INIHANDLE inihandle, FAR int16_t *value, * Description: * Reads a long value from the INI file * - ***************************************************************************/ + ****************************************************************************/ #if 0 /* Not used */ static uint8_t trv_ini_long(INIHANDLE inihandle, FAR long *value, @@ -240,7 +240,7 @@ static uint8_t trv_ini_long(INIHANDLE inihandle, FAR long *value, * Description: * Reads a file name from the the INI file. * - ***************************************************************************/ + ****************************************************************************/ static int trv_ini_filename(INIHANDLE inihandle, FAR const char *path, FAR const char *section, FAR const char *name, @@ -280,7 +280,7 @@ static int trv_ini_filename(INIHANDLE inihandle, FAR const char *path, * This is the guts of trv_world_create. It is implemented as a separate * function in order to simplify error handling * - ***************************************************************************/ + ****************************************************************************/ static int trv_manage_wldfile(INIHANDLE inihandle, FAR const char *wldpath) { @@ -430,7 +430,7 @@ static int trv_manage_wldfile(INIHANDLE inihandle, FAR const char *wldpath) * Description: * Load the world data structures from information in an INI file * - ***************************************************************************/ + ****************************************************************************/ int trv_world_create(FAR const char *wldpath, FAR const char *wldfile) { @@ -449,7 +449,7 @@ int trv_world_create(FAR const char *wldpath, FAR const char *wldfile) if (!inihandle) { fprintf(stderr, "ERROR: Could not open INI file=\"%s/%s\"\n", - wldpath, wldfile); + wldpath, wldfile); return -ENOENT; } @@ -469,7 +469,7 @@ int trv_world_create(FAR const char *wldpath, FAR const char *wldfile) * Description: * Destroy the world and release all of its resources * - ***************************************************************************/ + ****************************************************************************/ void trv_world_destroy(void) { diff --git a/graphics/traveler/tools/misc/mktrig.c b/graphics/traveler/tools/misc/mktrig.c index 6d5d89848..f245c11bd 100644 --- a/graphics/traveler/tools/misc/mktrig.c +++ b/graphics/traveler/tools/misc/mktrig.c @@ -1,5 +1,5 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/tools/misc/mktrig.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. @@ -132,7 +132,7 @@ int main(int argc, char **argv, char **envp) value16 = (uint16_t)((long)(valuef)); fprintf(outfile, "0x%04x", (unsigned int)value16); - + i++; j++; if ((j < 8) && (i < 2400)) diff --git a/graphics/traveler/tools/misc/pll2txt.c b/graphics/traveler/tools/misc/pll2txt.c index 594e7681e..38bc37640 100644 --- a/graphics/traveler/tools/misc/pll2txt.c +++ b/graphics/traveler/tools/misc/pll2txt.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/tools/misc/pll2txt.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. @@ -106,9 +106,9 @@ int main(int argc, char **argv, char **envp) FILE *instream; FILE *outstream = stdout; - while ((option = getopt(argc, argv, "ho:")) != EOF) - { - switch (option) + while ((option = getopt(argc, argv, "ho:")) != EOF) + { + switch (option) { case 'h' : b_use_hex = true; diff --git a/graphics/traveler/tools/misc/txt2pll.c b/graphics/traveler/tools/misc/txt2pll.c index c7b9a9e9d..e714f4d7d 100644 --- a/graphics/traveler/tools/misc/txt2pll.c +++ b/graphics/traveler/tools/misc/txt2pll.c @@ -1,4 +1,4 @@ -/******************************************************************************* +/**************************************************************************** * apps/graphics/traveler/tools/misc/txt2pll.c * * Copyright (C) 2014 Gregory Nutt. All rights reserved. @@ -257,11 +257,11 @@ int main(int argc, char **argv, char** envp) /* Write header information */ - if (fwrite((char*)&header, SIZEOF_TRVPLANEFILEHEADER_T, 1, outstream) != 1) - { + if (fwrite((char*)&header, SIZEOF_TRVPLANEFILEHEADER_T, 1, outstream) != 1) + { fprintf(stderr, "Failed to write file header\n"); return EXIT_FAILURE; - } + } /* Read X Planes */ diff --git a/include/.gitignore b/include/.gitignore index bee9a7372..a86d54aac 100644 --- a/include/.gitignore +++ b/include/.gitignore @@ -1 +1,2 @@ /pcode +/uavcan diff --git a/include/modbus/mb.h b/include/modbus/mb.h index cf1e867bb..c2b95f8fd 100644 --- a/include/modbus/mb.h +++ b/include/modbus/mb.h @@ -65,7 +65,8 @@ #include #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif #include "mbport.h" @@ -236,6 +237,7 @@ eMBErrorCode eMBDisable(void); * returns eMBErrorCode::MB_EILLSTATE. Otherwise it returns * eMBErrorCode::MB_ENOERR. */ + eMBErrorCode eMBPoll(void); /* Configure the slave id of the device. @@ -257,6 +259,7 @@ eMBErrorCode eMBPoll(void); * is too small it returns eMBErrorCode::MB_ENORES. Otherwise * it returns eMBErrorCode::MB_ENOERR. */ + eMBErrorCode eMBSetSlaveID(uint8_t ucSlaveID, bool xIsRunning, uint8_t const *pucAdditional, uint16_t usAdditionalLen); @@ -282,6 +285,7 @@ eMBErrorCode eMBSetSlaveID(uint8_t ucSlaveID, bool xIsRunning, * case the values in config.h should be adjusted. If the argument was not * valid it returns eMBErrorCode::MB_EINVAL. */ + eMBErrorCode eMBRegisterCB(uint8_t ucFunctionCode, pxMBFunctionHandler pxHandler); @@ -325,6 +329,7 @@ eMBErrorCode eMBRegisterCB(uint8_t ucFunctionCode, * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case * a SLAVE DEVICE FAILURE exception is sent as a response. */ + eMBErrorCode eMBRegInputCB(uint8_t * pucRegBuffer, uint16_t usAddress, uint16_t usNRegs); @@ -360,6 +365,7 @@ eMBErrorCode eMBRegInputCB(uint8_t * pucRegBuffer, uint16_t usAddress, * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case * a SLAVE DEVICE FAILURE exception is sent as a response. */ + eMBErrorCode eMBRegHoldingCB(uint8_t * pucRegBuffer, uint16_t usAddress, uint16_t usNRegs, eMBRegisterMode eMode); @@ -396,6 +402,7 @@ eMBErrorCode eMBRegHoldingCB(uint8_t * pucRegBuffer, uint16_t usAddress, * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case * a SLAVE DEVICE FAILURE exception is sent as a response. */ + eMBErrorCode eMBRegCoilsCB(uint8_t *pucRegBuffer, uint16_t usAddress, uint16_t usNCoils, eMBRegisterMode eMode); @@ -427,10 +434,11 @@ eMBErrorCode eMBRegCoilsCB(uint8_t *pucRegBuffer, uint16_t usAddress, * - eMBErrorCode::MB_EIO If an unrecoverable error occurred. In this case * a SLAVE DEVICE FAILURE exception is sent as a response. */ + eMBErrorCode eMBRegDiscreteCB(uint8_t *pucRegBuffer, uint16_t usAddress, uint16_t usNDiscrete); #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif diff --git a/include/modbus/mb_m.h b/include/modbus/mb_m.h index 3723b0edd..491c1b06d 100644 --- a/include/modbus/mb_m.h +++ b/include/modbus/mb_m.h @@ -67,7 +67,8 @@ #include #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif #include "mbport.h" @@ -459,7 +460,7 @@ void vMBMasterSetErrorType(eMBMasterErrorEventType errorType); eMBMasterReqErrCode eMBMasterWaitRequestFinish(void); #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_INCLUDE_MODBUS_MB_M_H */ diff --git a/include/modbus/mbframe.h b/include/modbus/mbframe.h index 01014989d..40312ff51 100644 --- a/include/modbus/mbframe.h +++ b/include/modbus/mbframe.h @@ -33,7 +33,8 @@ #define __APPS_INCLUDE_MODBUS_MBFRAME_H #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif /**************************************************************************** @@ -84,7 +85,7 @@ typedef eMBErrorCode (*peMBFrameSend)(uint8_t slaveAddress, typedef void (*pvMBFrameClose)(void); #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_INCLUDE_MODBUS_MBFRAME_H */ diff --git a/include/modbus/mbfunc.h b/include/modbus/mbfunc.h index 7cecd8fc8..82f4ee8cc 100644 --- a/include/modbus/mbfunc.h +++ b/include/modbus/mbfunc.h @@ -33,7 +33,8 @@ #define __APPS_INCLUDE_MODBUS_MBFUNC_H #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif /**************************************************************************** @@ -81,7 +82,7 @@ eMBException eMBFuncReadWriteMultipleHoldingRegister(uint8_t *pucFrame, uint16_t #endif #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_INCLUDE_MODBUS_MBFUNC_H */ diff --git a/include/modbus/mbport.h b/include/modbus/mbport.h index 7a811a97b..d1d4bc500 100644 --- a/include/modbus/mbport.h +++ b/include/modbus/mbport.h @@ -44,7 +44,8 @@ ****************************************************************************/ #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif typedef enum @@ -185,7 +186,7 @@ bool xMBTCPPortSendResponse(const uint8_t *pucMBTCPFrame, uint16_t usTCPLength); #endif #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_INCLUDE_MODBUS_MBPORT_H */ diff --git a/include/modbus/mbproto.h b/include/modbus/mbproto.h index f61e858e5..e42e7a284 100644 --- a/include/modbus/mbproto.h +++ b/include/modbus/mbproto.h @@ -33,7 +33,8 @@ #define __APPS_INCLUDE_MODBUS_MBPROTO_H #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif /**************************************************************************** @@ -87,7 +88,7 @@ typedef struct } xMBFunctionHandler; #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_INCLUDE_MODBUS_MBPROTO_H */ diff --git a/include/modbus/mbutils.h b/include/modbus/mbutils.h index fbeba53dc..1bb33c53c 100644 --- a/include/modbus/mbutils.h +++ b/include/modbus/mbutils.h @@ -33,7 +33,8 @@ #define __APPS_INCLUDE_MODBUS_MBUTILS_H #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif /**************************************************************************** @@ -104,7 +105,7 @@ void xMBUtilSetBits(uint8_t *ucByteBuf, uint16_t usBitOffset, uint8_t xMBUtilGetBits(uint8_t *ucByteBuf, uint16_t usBitOffset, uint8_t ucNBits); #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_INCLUDE_MODBUS_MBUTILS_H */ diff --git a/include/nxplayer.h b/include/nxplayer.h index 657f94e5c..4487cfab5 100644 --- a/include/nxplayer.h +++ b/include/nxplayer.h @@ -127,7 +127,7 @@ extern "C" * Returned Value: * Pointer to created NxPlayer context or NULL if error. * - **************************************************************************/ + ****************************************************************************/ FAR struct nxplayer_s *nxplayer_create(void); @@ -143,7 +143,7 @@ FAR struct nxplayer_s *nxplayer_create(void); * Returned Value: * None * - **************************************************************************/ + ****************************************************************************/ void nxplayer_release(FAR struct nxplayer_s *pPlayer); @@ -158,7 +158,7 @@ void nxplayer_release(FAR struct nxplayer_s *pPlayer); * Returned Value: * None * - **************************************************************************/ + ****************************************************************************/ void nxplayer_reference(FAR struct nxplayer_s *pPlayer); @@ -178,7 +178,7 @@ void nxplayer_reference(FAR struct nxplayer_s *pPlayer); * Returned Value: * OK if context initialized successfully, error code otherwise. * - **************************************************************************/ + ****************************************************************************/ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer, FAR const char *device); @@ -202,7 +202,7 @@ int nxplayer_setdevice(FAR struct nxplayer_s *pPlayer, * Returned Value: * OK if file found, device found, and playback started. * - **************************************************************************/ + ****************************************************************************/ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, FAR const char *filename, int filefmt, int subfmt); @@ -218,7 +218,7 @@ int nxplayer_playfile(FAR struct nxplayer_s *pPlayer, * Returned Value: * OK if file found, device found, and playback started. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_STOP int nxplayer_stop(FAR struct nxplayer_s *pPlayer); @@ -235,7 +235,7 @@ int nxplayer_stop(FAR struct nxplayer_s *pPlayer); * Returned Value: * OK if file found, device found, and playback started. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME int nxplayer_pause(FAR struct nxplayer_s *pPlayer); @@ -252,7 +252,7 @@ int nxplayer_pause(FAR struct nxplayer_s *pPlayer); * Returned Value: * OK if file found, device found, and playback started. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_PAUSE_RESUME int nxplayer_resume(FAR struct nxplayer_s *pPlayer); @@ -278,7 +278,7 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer); * Returned Value: * OK if fast forward operation successful. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD int nxplayer_fforward(FAR struct nxplayer_s *pPlayer, uint8_t subsample); @@ -305,7 +305,7 @@ int nxplayer_fforward(FAR struct nxplayer_s *pPlayer, uint8_t subsample); * Returned Value: * OK if rewind operation successfully initiated. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_REWIND int nxplayer_rewind(FAR struct nxplayer_s *pPlayer, uint8_t subsample); @@ -325,7 +325,7 @@ int nxplayer_rewind(FAR struct nxplayer_s *pPlayer, uint8_t subsample); * Returned Value: * OK if rewind operation successfully cancelled. * - **************************************************************************/ + ****************************************************************************/ #if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND) int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused); @@ -345,7 +345,7 @@ int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused); * Returned Value: * OK if file found, device found, and playback started. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume); @@ -365,7 +365,7 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume); * Returned Value: * OK if file found, device found, and playback started. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_VOLUME #ifndef CONFIG_AUDIO_EXCLUDE_BALANCE @@ -385,7 +385,7 @@ int nxplayer_setbalance(FAR struct nxplayer_s *pPlayer, uint16_t balance); * Returned Value: * None * - **************************************************************************/ + ****************************************************************************/ void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, FAR const char *mediadir); @@ -406,7 +406,7 @@ void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, * Returned Value: * OK if equalization was set correctly. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_EQUALIZER int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer, @@ -426,7 +426,7 @@ int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer, * Returned Value: * OK if the bass level was set successfully * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_TONE int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t bass); @@ -445,7 +445,7 @@ int nxplayer_setbass(FAR struct nxplayer_s *pPlayer, uint8_t bass); * Returned Value: * OK if the treble level was set successfully * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_TONE int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t treble); @@ -463,7 +463,7 @@ int nxplayer_settreble(FAR struct nxplayer_s *pPlayer, uint8_t treble); * Returned Value: * OK if file found, device found, and playback started. * - **************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_NXPLAYER_INCLUDE_SYSTEM_RESET int nxplayer_systemreset(FAR struct nxplayer_s *pPlayer); diff --git a/include/readline.h b/include/readline.h index df0f38ed4..5993c3be8 100644 --- a/include/readline.h +++ b/include/readline.h @@ -1,7 +1,7 @@ /**************************************************************************** * apps/include/readline.h * - * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2011, 2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -43,9 +43,41 @@ #include #include +#ifdef CONFIG_SYSTEM_READLINE + /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ +/* Tab completion cannot be supported if there is no console echo */ + +#ifndef CONFIG_READLINE_ECHO +# undef CONFIG_READLINE_TABCOMPLETION +#endif + +/* Make sure that the are valid values for all tab-completion settings */ + +#ifdef CONFIG_READLINE_TABCOMPLETION +# ifndef CONFIG_READLINE_MAX_BUILTINS +# define CONFIG_READLINE_MAX_BUILTINS 64 +# endif + +# ifndef CONFIG_READLINE_MAX_EXTCMDS +# define CONFIG_READLINE_MAX_EXTCMDS 64 +# endif +#endif + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +#if defined(CONFIG_READLINE_TABCOMPLETION) && \ + defined(CONFIG_READLINE_HAVE_EXTMATCH) +struct extmatch_vtable_s +{ + CODE int (*count_matches)(FAR char *name, FAR int *matches, int namelen); + CODE FAR const char *(*getname)(int index); +}; +#endif /**************************************************************************** * Public Data @@ -63,6 +95,67 @@ extern "C" * Public Function Prototypes ****************************************************************************/ +/**************************************************************************** + * Name: readline_prompt + * + * If a prompt string is used by the application, then the application + * must provide the prompt string to readline() by calling this function. + * This is needed only for tab completion in cases where is it necessary + * to reprint the prompt string. + * + * Input Parameters: + * prompt - The prompt string. This function may then be + * called with that value in order to restore the previous vtable. + * + * Returned values: + * Returns the previous value of the prompt string. This function may + * then be called with that value in order to restore the previous prompt. + * + * Assumptions: + * The prompt string is statically allocated a global. readline() will + * simply remember the pointer to the string. The string must stay + * allocated and available. Only one prompt string is supported. If + * there are multiple clients of readline(), they must all share the same + * prompt string (with exceptions in the case of the kernel build). + * + ****************************************************************************/ + +#ifdef CONFIG_READLINE_TABCOMPLETION +FAR const char *readline_prompt(FAR const char *prompt); +#else +# define readline_prompt(p) +#endif + +/**************************************************************************** + * Name: readline_extmatch + * + * If the applications supports a command set, then it may call this + * function in order to provide support for tab complete on these + * "external" commands + * + * Input Parameters: + * vtbl - Callbacks to access the external names. + * + * Returned values: + * Returns the previous vtable pointer. This function may then be + * called with that value in order to restore the previous vtable. + * + * Assumptions: + * The vtbl string is statically allocated a global. readline() will + * simply remember the pointer to the structure. The structure must stay + * allocated and available. Only one instance of such a structure is + * supported. If there are multiple clients of readline(), they must all + * share the same tab-completion logic (with exceptions in the case of + * the kernel build). + * + ****************************************************************************/ + +#if defined(CONFIG_READLINE_TABCOMPLETION) && \ + defined(CONFIG_READLINE_HAVE_EXTMATCH) +FAR const struct extmatch_vtable_s * + readline_extmatch(FAR const struct extmatch_vtable_s *vtbl); +#endif + /**************************************************************************** * Name: readline * @@ -90,7 +183,7 @@ extern "C" * EOF is returned to indicate either an end of file condition or a * failure. * - **************************************************************************/ + ****************************************************************************/ #if CONFIG_NFILE_STREAMS > 0 ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream); @@ -121,7 +214,7 @@ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream); * EOF is returned to indicate either an end of file condition or a * failure. * - **************************************************************************/ + ****************************************************************************/ #if CONFIG_NFILE_STREAMS > 0 # define std_readline(b,s) readline(b,s,stdin,stdout) @@ -134,4 +227,5 @@ ssize_t std_readline(FAR char *buf, int buflen); } #endif +#endif /* CONFIG_SYSTEM_READLINE */ #endif /* __APPS_INCLUDE_READLINE_H */ diff --git a/include/symtab.h b/include/symtab.h new file mode 100644 index 000000000..c1d59c51d --- /dev/null +++ b/include/symtab.h @@ -0,0 +1,102 @@ +/**************************************************************************** + * apps/include/symtab.h + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Gregory Nutt + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * 3. Neither the name NuttX nor the names of its contributors may be + * used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + * + ****************************************************************************/ + +#ifndef __APPS_INCLUDE_SYMTAB_H +#define __APPS_INCLUDE_SYMTAB_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +/* struct symbtab_s describes one entry in the symbol table. A symbol table + * is a fixed size array of struct symtab_s. The information is intentionally + * minimal and supports only: + * + * 1. Function pointers as sym_values. Of other kinds of values need to be + * supported, then typing information would also need to be included in + * the structure. + * + * 2. Fixed size arrays. There is no explicit provisional for dynamically + * adding or removing entries from the symbol table (realloc might be + * used for that purpose if needed). The intention is to support only + * fixed size arrays completely defined at compilation or link time. + */ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +#undef EXTERN +#if defined(__cplusplus) +#define EXTERN extern "C" +extern "C" +{ +#else +#define EXTERN extern +#endif + +/**************************************************************************** + * Name: symtab_initialize + * + * Description: + * Setup a user provided symbol table. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void symtab_initialize(void); + +#undef EXTERN +#if defined(__cplusplus) +} +#endif + +#endif /* __APPS_INCLUDE_SYMTAB_H */ + diff --git a/include/usbmonitor.h b/include/usbmonitor.h index 3dd50eef0..909b630e9 100644 --- a/include/usbmonitor.h +++ b/include/usbmonitor.h @@ -82,7 +82,7 @@ extern "C" * Returned values: * Standard task return values (zero meaning success). * - **************************************************************************/ + ****************************************************************************/ int usbmonitor_start(int argc, char **argv); int usbmonitor_stop(int argc, char **argv); diff --git a/interpreters/Kconfig b/interpreters/Kconfig index 3bace79e4..bed828685 100644 --- a/interpreters/Kconfig +++ b/interpreters/Kconfig @@ -3,6 +3,8 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +menu "Interpreters" + source "$APPSDIR/interpreters/bas/Kconfig" source "$APPSDIR/interpreters/ficl/Kconfig" @@ -20,3 +22,4 @@ if INTERPRETERS_PCODE endif source "$APPSDIR/interpreters/micropython/Kconfig" +endmenu # Interpreters diff --git a/interpreters/bas/bas_fs.c b/interpreters/bas/bas_fs.c index ee1029f4f..3f1485bd1 100644 --- a/interpreters/bas/bas_fs.c +++ b/interpreters/bas/bas_fs.c @@ -1671,7 +1671,7 @@ long int FS_lof(int chn) return -1; } - return (long int)(endpos / g_file[chn]->recLength); + return (long int)(endpos / g_file[chn]->recLength); } long int FS_recLength(int chn) diff --git a/interpreters/bas/bas_token.c b/interpreters/bas/bas_token.c index dc33ad7a8..d8ce86f94 100644 --- a/interpreters/bas/bas_token.c +++ b/interpreters/bas/bas_token.c @@ -3622,10 +3622,11 @@ YY_RULE_SETUP #line 1171 "bas_token.l" { if (cur) - { - cur->statement=stmt_QUOTE_REM; - strcpy(cur->u.rem=malloc(strlen(yytext+1)+1),yytext+1); - } + { + cur->statement=stmt_QUOTE_REM; + strcpy(cur->u.rem=malloc(strlen(yytext+1)+1),yytext+1); + } + return T_QUOTE; } YY_BREAK @@ -4240,8 +4241,8 @@ static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file) * In that case, we don't want to reset the lineno or column. */ - if (b != YY_CURRENT_BUFFER) - { + if (b != YY_CURRENT_BUFFER) + { b->yy_bs_lineno = 1; b->yy_bs_column = 0; } @@ -4352,9 +4353,9 @@ static void yyensure_buffer_stack (void) (num_to_alloc * sizeof(struct yy_buffer_state*)); if (! (yy_buffer_stack)) YY_FATAL_ERROR("out of dynamic memory in yyensure_buffer_stack()"); - + memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*)); - + (yy_buffer_stack_max) = num_to_alloc; (yy_buffer_stack_top) = 0; return; diff --git a/interpreters/ficl/src/nuttx.c b/interpreters/ficl/src/nuttx.c index 16b3fa1db..1d05d90c6 100644 --- a/interpreters/ficl/src/nuttx.c +++ b/interpreters/ficl/src/nuttx.c @@ -22,44 +22,50 @@ void ficlFree(void *p) free(p); } -void ficlCallbackDefaultTextOut(ficlCallback *callback, char *message) +void ficlCallbackDefaultTextOut(ficlCallback *callback, char *message) { FICL_IGNORE(callback); if (message != NULL) + { fputs(message, stdout); + } else + { fflush(stdout); - return; + } } int ficlFileStatus(char *filename, int *status) { - struct stat statbuf; - if (stat(filename, &statbuf) == 0) + struct stat statbuf; + if (stat(filename, &statbuf) == 0) { - *status = statbuf.st_mode; - return 0; + *status = statbuf.st_mode; + return 0; } - *status = ENOENT; - return -1; + + *status = ENOENT; + return -1; } long ficlFileSize(ficlFile *ff) { - struct stat statbuf; - if (ff == NULL) - return -1; - - statbuf.st_size = -1; - if (fstat(fileno(ff->f), &statbuf) != 0) - return -1; - - return statbuf.st_size; + struct stat statbuf; + if (ff == NULL) + { + return -1; + } + + statbuf.st_size = -1; + if (fstat(fileno(ff->f), &statbuf) != 0) + { + return -1; + } + + return statbuf.st_size; } void ficlSystemCompilePlatform(ficlSystem *system) { - return; + return; } - - diff --git a/modbus/Kconfig b/modbus/Kconfig index 29b073c16..33b3b517a 100644 --- a/modbus/Kconfig +++ b/modbus/Kconfig @@ -3,6 +3,8 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +menu "FreeModBus" + config MODBUS bool "Modbus support via FreeModBus" default n @@ -159,3 +161,4 @@ config MB_MASTER_TOTAL_SLAVE_NUM endif # MB_ASCII_MASTER || MB_RTU_MASTER endif # MODBUS +endmenu # FreeModBus diff --git a/modbus/ascii/mbascii.h b/modbus/ascii/mbascii.h index f4c901a4b..71d63117b 100644 --- a/modbus/ascii/mbascii.h +++ b/modbus/ascii/mbascii.h @@ -33,11 +33,12 @@ #define __APPS_MODBUS_ASCII_MBASCII_H #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif /**************************************************************************** - * Global Function Prototypes + * Public Function Prototypes ****************************************************************************/ #ifdef CONFIG_MB_ASCII_ENABLED @@ -55,7 +56,7 @@ bool xMBASCIITimerT1SExpired(void); #endif #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_MODBUS_ASCII_MBASCII_H */ diff --git a/modbus/functions/mbfuncdisc.c b/modbus/functions/mbfuncdisc.c index 79cfacd94..3919b2915 100644 --- a/modbus/functions/mbfuncdisc.c +++ b/modbus/functions/mbfuncdisc.c @@ -62,7 +62,7 @@ eMBException prveMBError2Exception(eMBErrorCode eErrorCode); * Public Functions ****************************************************************************/ -#ifdef CONFIG_MB_FUNC_READ_COILS_ENABLED +#ifdef CONFIG_MB_FUNC_READ_DISCRETE_INPUTS_ENABLED eMBException eMBFuncReadDiscreteInputs(uint8_t *pucFrame, uint16_t *usLen) { uint16_t usRegAddress; diff --git a/modbus/nuttx/port.h b/modbus/nuttx/port.h index 5b7416873..f4b6e11be 100644 --- a/modbus/nuttx/port.h +++ b/modbus/nuttx/port.h @@ -44,14 +44,13 @@ * Pre-processor Definitions ****************************************************************************/ -#define INLINE -#define PR_BEGIN_EXTERN_C extern "C" { -#define PR_END_EXTERN_C } - #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif +#define INLINE + #define ENTER_CRITICAL_SECTION( ) vMBPortEnterCritical() #define EXIT_CRITICAL_SECTION( ) vMBPortExitCritical() @@ -88,7 +87,7 @@ bool xMBPortSerialPoll(void); bool xMBPortSerialSetTimeout(uint32_t dwTimeoutMs); #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_MODBUS_NUTTX_PORT_H */ diff --git a/modbus/rtu/mbcrc.h b/modbus/rtu/mbcrc.h index 94bb3751a..707feb8ef 100644 --- a/modbus/rtu/mbcrc.h +++ b/modbus/rtu/mbcrc.h @@ -33,7 +33,7 @@ #define __APPS_MODBUS_RTU_MBCRC_H /**************************************************************************** - * Global Function Prototypes + * Public Function Prototypes ****************************************************************************/ uint16_t usMBCRC16(uint8_t *pucFrame, uint16_t usLen); diff --git a/modbus/rtu/mbrtu.c b/modbus/rtu/mbrtu.c index 50e69cdbb..8fbef1904 100644 --- a/modbus/rtu/mbrtu.c +++ b/modbus/rtu/mbrtu.c @@ -230,7 +230,7 @@ eMBErrorCode eMBRTUSend(uint8_t ucSlaveAddress, const uint8_t *pucFrame, uint16_ usSndBufferCount += usLength; /* Calculate CRC16 checksum for Modbus-Serial-Line-PDU. */ - + usCRC16 = usMBCRC16((uint8_t *) pucSndBufferCur, usSndBufferCount); ucRTUBuf[usSndBufferCount++] = (uint8_t)(usCRC16 & 0xFF); ucRTUBuf[usSndBufferCount++] = (uint8_t)(usCRC16 >> 8); diff --git a/modbus/rtu/mbrtu.h b/modbus/rtu/mbrtu.h index 7187d8aec..7d13abff3 100644 --- a/modbus/rtu/mbrtu.h +++ b/modbus/rtu/mbrtu.h @@ -33,7 +33,8 @@ #define __APPS_MODBUS_RTU_MBRTU_H #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif /**************************************************************************** @@ -68,7 +69,7 @@ bool xMBMasterRTUTimerExpired(void); #endif #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_MODBUS_RTU_MBRTU_H */ diff --git a/modbus/tcp/mbtcp.c b/modbus/tcp/mbtcp.c index eae06875d..456798e4d 100644 --- a/modbus/tcp/mbtcp.c +++ b/modbus/tcp/mbtcp.c @@ -89,7 +89,7 @@ eMBErrorCode eMBTCPDoInit(uint16_t ucTCPPort) { eStatus = MB_EPORTERR; } - + return eStatus; } diff --git a/modbus/tcp/mbtcp.h b/modbus/tcp/mbtcp.h index c45720013..b44de01f1 100644 --- a/modbus/tcp/mbtcp.h +++ b/modbus/tcp/mbtcp.h @@ -33,7 +33,8 @@ #define __APPS_MODBUS_TCP_MBTCP_H #ifdef __cplusplus -PR_BEGIN_EXTERN_C +extern "C" +{ #endif /**************************************************************************** @@ -55,7 +56,7 @@ eMBErrorCode eMBTCPSend(uint8_t _unused, const uint8_t *pucFrame, uint16_t usLength); #ifdef __cplusplus -PR_END_EXTERN_C +} #endif #endif /* __APPS_MODBUS_TCP_MBTCP_H */ diff --git a/netutils/Kconfig b/netutils/Kconfig index 4031a8b87..8c214c0c5 100644 --- a/netutils/Kconfig +++ b/netutils/Kconfig @@ -3,7 +3,7 @@ # see the file kconfig-language.txt in the NuttX tools repository. # -comment "Networking Utilities" +menu "Network Utilities" source "$APPSDIR/netutils/codecs/Kconfig" source "$APPSDIR/netutils/dhcpc/Kconfig" @@ -22,3 +22,5 @@ source "$APPSDIR/netutils/ntpclient/Kconfig" source "$APPSDIR/netutils/discover/Kconfig" source "$APPSDIR/netutils/xmlrpc/Kconfig" source "$APPSDIR/netutils/pppd/Kconfig" + +endmenu # Network Utilities diff --git a/netutils/dhcpc/dhcpc.c b/netutils/dhcpc/dhcpc.c index 7c42543bd..4cbead2a9 100644 --- a/netutils/dhcpc/dhcpc.c +++ b/netutils/dhcpc/dhcpc.c @@ -58,7 +58,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define STATE_INITIAL 0 @@ -339,7 +339,7 @@ static uint8_t dhcpc_parsemsg(struct dhcpc_state_s *pdhcpc, int buflen, } /**************************************************************************** - * Global Functions + * Public Functions ****************************************************************************/ /**************************************************************************** diff --git a/netutils/dhcpd/dhcpd.c b/netutils/dhcpd/dhcpd.c index 9b685f90d..ef5286a85 100644 --- a/netutils/dhcpd/dhcpd.c +++ b/netutils/dhcpd/dhcpd.c @@ -771,7 +771,7 @@ static int dhcpd_addoption32(uint8_t code, uint32_t value) * Name: dhcp_addoption32p ****************************************************************************/ -#if HAVE_DNSIP +#ifdef HAVE_DSNIP static int dhcp_addoption32p(uint8_t code, FAR uint8_t *value) { uint8_t option[6]; @@ -1005,7 +1005,7 @@ static int dhcpd_sendpacket(int bbroadcast) static inline int dhcpd_sendoffer(in_addr_t ipaddr, uint32_t leasetime) { in_addr_t netaddr; -#if HAVE_DNSIP +#ifdef HAVE_DSNIP uint32_t dnsaddr; dnsaddr = htonl(CONFIG_NETUTILS_DHCPD_DNSIP); #endif @@ -1025,13 +1025,13 @@ static inline int dhcpd_sendoffer(in_addr_t ipaddr, uint32_t leasetime) /* Add the leasetime to the response options */ dhcpd_addoption32(DHCP_OPTION_LEASE_TIME, htonl(leasetime)); -#if HAVE_NETMASK +#ifdef HAVE_NETMASK dhcpd_addoption32(DHCP_OPTION_SUBNET_MASK, htonl(CONFIG_NETUTILS_DHCPD_NETMASK)); #endif -#if HAVE_ROUTERIP +#ifdef HAVE_ROUTERIP dhcpd_addoption32(DHCP_OPTION_ROUTER, htonl(CONFIG_NETUTILS_DHCPD_ROUTERIP)); #endif -#if HAVE_DNSIP +#ifdef HAVE_DSNIP dhcp_addoption32p(DHCP_OPTION_DNS_SERVER, (FAR uint8_t*)&dnsaddr); #endif @@ -1065,7 +1065,7 @@ int dhcpd_sendack(in_addr_t ipaddr) { uint32_t leasetime = CONFIG_NETUTILS_DHCPD_LEASETIME; in_addr_t netaddr; -#if HAVE_DNSIP +#ifdef HAVE_DSNIP uint32_t dnsaddr; dnsaddr = htonl(CONFIG_NETUTILS_DHCPD_DNSIP); #endif @@ -1087,13 +1087,13 @@ int dhcpd_sendack(in_addr_t ipaddr) /* Add the lease time to the response */ dhcpd_addoption32(DHCP_OPTION_LEASE_TIME, htonl(leasetime)); -#if HAVE_NETMASK +#ifdef HAVE_NETMASK dhcpd_addoption32(DHCP_OPTION_SUBNET_MASK, htonl(CONFIG_NETUTILS_DHCPD_NETMASK)); #endif -#if HAVE_ROUTERIP +#ifdef HAVE_ROUTERIP dhcpd_addoption32(DHCP_OPTION_ROUTER, htonl(CONFIG_NETUTILS_DHCPD_ROUTERIP)); #endif -#if HAVE_DNSIP +#ifdef HAVE_DSNIP dhcp_addoption32p(DHCP_OPTION_DNS_SERVER, (FAR uint8_t*)&dnsaddr); #endif diff --git a/netutils/ftpc/ftpc_transfer.c b/netutils/ftpc/ftpc_transfer.c index 8dbb2d0ad..b84cf509b 100644 --- a/netutils/ftpc/ftpc_transfer.c +++ b/netutils/ftpc/ftpc_transfer.c @@ -322,9 +322,9 @@ int ftpc_xfrinit(FAR struct ftpc_session_s *session) } return OK; - errout_with_data: +errout_with_data: ftpc_sockclose(&session->data); - errout: +errout: return ERROR; } @@ -371,8 +371,10 @@ int ftpc_xfrmode(struct ftpc_session_s *session, uint8_t xfrmode) */ ret = ftpc_cmd(session, "TYPE %c", xfrmode == FTPC_XFRMODE_ASCII ? 'A' : 'I'); + UNUSED(ret); session->xfrmode = xfrmode; } + return OK; } diff --git a/netutils/ftpd/ftpd.c b/netutils/ftpd/ftpd.c index d3d523ae4..51cf1c315 100644 --- a/netutils/ftpd/ftpd.c +++ b/netutils/ftpd/ftpd.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/n etutils/ftpd.c * - * Copyright (C) 2012 Gregory Nutt. All rights reserved. + * Copyright (C) 2012, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Includes original code as well as logic adapted from hwport_ftpd, written @@ -977,7 +977,7 @@ static ssize_t ftpd_response(int sd, int timeout, FAR const char *fmt, ...) va_list ap; va_start(ap, fmt); - avsprintf(&buffer, fmt, ap); + vasprintf(&buffer, fmt, ap); va_end(ap); if (!buffer) @@ -1871,7 +1871,7 @@ static int ftpd_stream(FAR struct ftpd_session_s *session, int cmdtype) goto errout_with_session; } - for (;;) + for (;;) { /* Read from the source (file or TCP connection) */ @@ -4042,7 +4042,7 @@ static FAR void *ftpd_worker(FAR void *arg) /* Then loop processing FTP commands */ - for (;;) + for (;;) { /* Receive the next command */ diff --git a/netutils/netlib/netlib_parsehttpurl.c b/netutils/netlib/netlib_parsehttpurl.c index a4d4c7051..584866de2 100644 --- a/netutils/netlib/netlib_parsehttpurl.c +++ b/netutils/netlib/netlib_parsehttpurl.c @@ -31,11 +31,11 @@ * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * - *****************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Included Files - *****************************************************************************/ + ****************************************************************************/ #include @@ -47,14 +47,14 @@ /**************************************************************************** * Private Data - *****************************************************************************/ + ****************************************************************************/ const char g_http[] = "http://"; #define HTTPLEN 7 /**************************************************************************** * Public Functions - *****************************************************************************/ + ****************************************************************************/ /**************************************************************************** * Name: netlib_parsehttpurl diff --git a/netutils/pppd/ahdlc.c b/netutils/pppd/ahdlc.c index 0245a6a1b..06cdb814c 100644 --- a/netutils/pppd/ahdlc.c +++ b/netutils/pppd/ahdlc.c @@ -365,12 +365,12 @@ u8_t ahdlc_tx(struct ppp_context_s *ctx, u16_t protocol, u8_t *header, #if PACKET_TX_DEBUG DEBUG1(("\n")); - for(i = 0; i < headerlen; ++i) + for (i = 0; i < headerlen; ++i) { DEBUG1(("0x%02x ", header[i])); } - for(i = 0; i < datalen; ++i) + for (i = 0; i < datalen; ++i) { DEBUG1(("0x%02x ", buffer[i])); } @@ -405,7 +405,7 @@ u8_t ahdlc_tx(struct ppp_context_s *ctx, u16_t protocol, u8_t *header, /* Write header if it exists */ - for(i = 0; i < headerlen; ++i) + for (i = 0; i < headerlen; ++i) { /* Get next byte from buffer */ @@ -418,7 +418,7 @@ u8_t ahdlc_tx(struct ppp_context_s *ctx, u16_t protocol, u8_t *header, /* Write frame bytes */ - for(i = 0; i < datalen; ++i) + for (i = 0; i < datalen; ++i) { /* Get next byte from buffer */ diff --git a/netutils/pppd/pap.c b/netutils/pppd/pap.c index 1e5363aa4..77e3f1a08 100644 --- a/netutils/pppd/pap.c +++ b/netutils/pppd/pap.c @@ -42,6 +42,7 @@ * Included Files ****************************************************************************/ +#include #include "ppp_conf.h" #include "ppp_arch.h" #include "ppp.h" @@ -156,16 +157,16 @@ void pap_task(struct ppp_context_s *ctx, u8_t *buffer) /* Write options */ - t = strlen((char*)ctx->pap_username); + t = strlen((char*)ctx->settings->pap_username); /* Write peer length */ *bptr++ = (u8_t)t; - bptr = memcpy(bptr, ctx->pap_username, t); + bptr = memcpy(bptr, ctx->settings->pap_username, t); - t = strlen((char*)ctx->pap_password); + t = strlen((char*)ctx->settings->pap_password); *bptr++ = (u8_t)t; - bptr = memcpy(bptr, ctx->pap_password, t); + bptr = memcpy(bptr, ctx->settings->pap_password, t); /* Write length */ diff --git a/netutils/pppd/ppp.c b/netutils/pppd/ppp.c index 2851039a5..15abcf022 100644 --- a/netutils/pppd/ppp.c +++ b/netutils/pppd/ppp.c @@ -99,7 +99,7 @@ static void ppp_reject_protocol(struct ppp_context_s *ctx, u16_t protocol, dptr = buffer + count + 6; sptr = buffer + count; - for(i = 0; i < count; ++i) + for (i = 0; i < count; ++i) { *dptr-- = *sptr--; } @@ -127,7 +127,7 @@ void dump_ppp_packet(u8_t *buffer, u16_t len) int i; DEBUG1(("\n")); - for(i = 0;i < len; ++i) + for (i = 0;i < len; ++i) { if ((i & 0x1f) == 0x10) { @@ -371,41 +371,42 @@ void ppp_upcall(struct ppp_context_s *ctx, u16_t protocol, u8_t *buffer, u16_t l { /* Demux on protocol field */ - switch(protocol) { - case LCP: /* We must support some level of LCP */ - DEBUG1(("LCP Packet - ")); - lcp_rx(ctx, buffer, len); - DEBUG1(("\n")); - break; + switch (protocol) + { + case LCP: /* We must support some level of LCP */ + DEBUG1(("LCP Packet - ")); + lcp_rx(ctx, buffer, len); + DEBUG1(("\n")); + break; #ifdef CONFIG_NETUTILS_PPPD_PAP - case PAP: /* PAP should be compile in optional */ - DEBUG1(("PAP Packet - ")); - pap_rx(ctx, buffer, len); - DEBUG1(("\n")); - break; + case PAP: /* PAP should be compile in optional */ + DEBUG1(("PAP Packet - ")); + pap_rx(ctx, buffer, len); + DEBUG1(("\n")); + break; #endif /* CONFIG_NETUTILS_PPPD_PAP */ - case IPCP: /* IPCP should be compile in optional. */ - DEBUG1(("IPCP Packet - ")); - ipcp_rx(ctx, buffer, len); - DEBUG1(("\n")); - break; + case IPCP: /* IPCP should be compile in optional. */ + DEBUG1(("IPCP Packet - ")); + ipcp_rx(ctx, buffer, len); + DEBUG1(("\n")); + break; - case IPV4: /* We must support IPV4 */ - DEBUG1(("IPV4 Packet---\n")); - memcpy(ctx->ip_buf, buffer, len); - ctx->ip_len = len; - ctx->ip_no_data_time = 0; - DEBUG1(("\n")); - break; + case IPV4: /* We must support IPV4 */ + DEBUG1(("IPV4 Packet---\n")); + memcpy(ctx->ip_buf, buffer, len); + ctx->ip_len = len; + ctx->ip_no_data_time = 0; + DEBUG1(("\n")); + break; - default: - DEBUG1(("Unknown PPP Packet Type 0x%04x - ",protocol)); - ppp_reject_protocol(ctx, protocol, buffer, len); - DEBUG1(("\n")); - break; - } + default: + DEBUG1(("Unknown PPP Packet Type 0x%04x - ",protocol)); + ppp_reject_protocol(ctx, protocol, buffer, len); + DEBUG1(("\n")); + break; + } } } @@ -417,7 +418,7 @@ void ppp_upcall(struct ppp_context_s *ctx, u16_t protocol, u8_t *buffer, u16_t l * length of the codespace * ****************************************************************************/ - + u16_t scan_packet(struct ppp_context_s *ctx, u16_t protocol, const u8_t *list, u8_t *buffer, u8_t *options, u16_t len) { @@ -460,7 +461,7 @@ u16_t scan_packet(struct ppp_context_s *ctx, u16_t protocol, const u8_t *list, bad = 1; *tptr++ = i; j = *tptr++ = *bptr++; - for(i = 0; i < j - 2; ++i) + for (i = 0; i < j - 2; ++i) { *tptr++ = *bptr++; } diff --git a/netutils/pppd/pppd.c b/netutils/pppd/pppd.c index 3a51a4f45..7f2c68ffe 100644 --- a/netutils/pppd/pppd.c +++ b/netutils/pppd/pppd.c @@ -113,7 +113,9 @@ static int tun_alloc(char *dev) int fd, err; if ((fd = open("/dev/tun", O_RDWR)) < 0) + { return fd; + } printf("tun fd:%i\n", fd); @@ -151,7 +153,9 @@ static int open_tty(char *dev) int err; if ((fd = open(dev, O_RDWR)) < 0) + { return fd; + } if ((err = make_nonblock(fd)) < 0) { diff --git a/netutils/thttpd/Kconfig b/netutils/thttpd/Kconfig index d08f76054..68d6d79b7 100644 --- a/netutils/thttpd/Kconfig +++ b/netutils/thttpd/Kconfig @@ -6,7 +6,7 @@ config NETUTILS_THTTPD bool "THTTPD webserver" default n - depends on NXFLAT || FS_BINFS + depends on (NXFLAT || FS_BINFS) && !DISABLE_POLL ---help--- Enable support for the THTTPD webservert. diff --git a/netutils/thttpd/thttpd_alloc.c b/netutils/thttpd/thttpd_alloc.c index 12872f192..7bf072a58 100644 --- a/netutils/thttpd/thttpd_alloc.c +++ b/netutils/thttpd/thttpd_alloc.c @@ -97,7 +97,7 @@ void httpd_memstats(void) #endif /**************************************************************************** - * Global Functions + * Public Functions ****************************************************************************/ #ifdef CONFIG_THTTPD_MEMDEBUG diff --git a/netutils/thttpd/thttpd_alloc.h b/netutils/thttpd/thttpd_alloc.h index e8c8f80c3..386164a06 100644 --- a/netutils/thttpd/thttpd_alloc.h +++ b/netutils/thttpd/thttpd_alloc.h @@ -48,7 +48,7 @@ #ifdef CONFIG_THTTPD /**************************************************************************** - * Global Functions + * Public Functions ****************************************************************************/ /* Allows all memory management calls to be intercepted */ diff --git a/netutils/webclient/webclient.c b/netutils/webclient/webclient.c index 8aaffcfd9..d8e6dc367 100644 --- a/netutils/webclient/webclient.c +++ b/netutils/webclient/webclient.c @@ -96,7 +96,7 @@ #endif /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #ifndef CONFIG_WEBCLIENT_TIMEOUT diff --git a/nshlib/Kconfig b/nshlib/Kconfig index 348d55d64..3ae39f098 100644 --- a/nshlib/Kconfig +++ b/nshlib/Kconfig @@ -3,11 +3,14 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +menu "NSH Library" + config NSH_LIBRARY bool "NSH Library" default n select NETUTILS_NETLIB if NET select LIBC_NETDB if NET + select READLINE_HAVE_EXTMATCH ---help--- Build the NSH support library. This is used, for example, by examples/nsh in order to implement the full NuttShell (NSH). @@ -850,15 +853,15 @@ config NSH_NETINIT_THREAD But if there is no network connected, then the start-up delay can be very long depending upon things like the particular PHY, driver - timeout delay times, and numbers of retries. A failed negotiation + timeout delay times and number of retries. A failed negotiation can potentially take a very long time, perhaps as much as a minute... Long enough that you might think that the board would never come up! - One solution is to enabled by this option. If NSH_NETINIT_THREAD - is selected, the network bring-up will all occur in parallel with + One solution is enabled by this option. If NSH_NETINIT_THREAD + is selected, the network bring-up will occur in parallel with NSH on a separate thread. In this case, the NSH prompt will occur - immediately with the network becoming available some time layer (if + immediately with the network becoming available some time later (if if all). This thread will terminate once it successfully initializes the network @@ -1236,7 +1239,7 @@ endmenu # IP Address Configuration config NSH_DNS bool "Use DNS" default n - depends on NSH_LIBRARY && NETUTILS_DNSCLIENT + depends on NSH_LIBRARY && NETDB_DNSCLIENT ---help--- Configure to use a DNS. @@ -1380,3 +1383,4 @@ endif # NSH_TELNET_LOGIN endif # NSH_TELNET endmenu # Telnet Configuration endif # NSH_LIBRARY +endmenu # NSH Library diff --git a/nshlib/nsh.h b/nshlib/nsh.h index c8a087a8b..7cf6140b1 100644 --- a/nshlib/nsh.h +++ b/nshlib/nsh.h @@ -57,7 +57,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* The background commands require pthread support */ @@ -155,7 +155,8 @@ * domain sockets were enable. */ -#if !defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_SLIP) && !defined(CONFIG_NET_TUN) +#if !defined(CONFIG_NET_ETHERNET) && !defined(CONFIG_NET_LOOPBACK) && \ + !defined(CONFIG_NET_SLIP) && !defined(CONFIG_NET_TUN) /* No link layer protocol is a good indication that there is no network * device. */ @@ -1055,4 +1056,49 @@ void nsh_usbtrace(void); # endif #endif +/**************************************************************************** + * Name: nsh_extmatch_count + * + * Description: + * This support function is used to provide support for realine tab- + * completion logic nsh_extmatch_count() counts the number of matching + * nsh command names + * + * Input Parameters: + * name - A point to the name containing the name to be matched. + * matches - A table is size CONFIG_READLINE_MAX_EXTCMDS that can + * be used to remember matching name indices. + * namelen - The lenght of the name to match + * + * Returned Values: + * The number commands that match to the first namelen characters. + * + ****************************************************************************/ + +#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION) && \ + defined(CONFIG_READLINE_HAVE_EXTMATCH) +int nsh_extmatch_count(FAR char *name, FAR int *matches, int namelen); +#endif + +/**************************************************************************** + * Name: nsh_extmatch_getname + * + * Description: + * This support function is used to provide support for realine tab- + * completion logic nsh_extmatch_getname() will return the full command + * string from an index that was previously saved by nsh_exmatch_count(). + * + * Input Parameters: + * index - The index of the command name to be returned. + * + * Returned Values: + * The numb + * + ****************************************************************************/ + +#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION) && \ + defined(CONFIG_READLINE_HAVE_EXTMATCH) +FAR const char *nsh_extmatch_getname(int index); +#endif + #endif /* __APPS_NSHLIB_NSH_H */ diff --git a/nshlib/nsh_builtin.c b/nshlib/nsh_builtin.c index 59e54ae85..ed5a076bf 100644 --- a/nshlib/nsh_builtin.c +++ b/nshlib/nsh_builtin.c @@ -63,7 +63,7 @@ #ifdef CONFIG_NSH_BUILTIN_APPS /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nshlib/nsh_command.c b/nshlib/nsh_command.c index 0d18905d1..855ebb09d 100644 --- a/nshlib/nsh_command.c +++ b/nshlib/nsh_command.c @@ -45,6 +45,10 @@ # include #endif +#if defined(CONFIG_SYSTEM_READLINE) && defined(CONFIG_READLINE_HAVE_EXTMATCH) +# include +#endif + #include "nsh.h" #include "nsh_console.h" @@ -407,7 +411,7 @@ static const struct cmdmap_s g_cmdmap[] = #endif #ifndef CONFIG_NSH_DISABLE_UNAME -#if CONFIG_NET +#ifdef CONFIG_NET { "uname", cmd_uname, 1, 7, "[-a | -imnoprsv]" }, #else { "uname", cmd_uname, 1, 7, "[-a | -imoprsv]" }, @@ -824,3 +828,73 @@ int nsh_command(FAR struct nsh_vtbl_s *vtbl, int argc, char *argv[]) ret = handler(vtbl, argc, argv); return ret; } + +/**************************************************************************** + * Name: nsh_extmatch_count + * + * Description: + * This support function is used to provide support for realine tab- + * completion logic nsh_extmatch_count() counts the number of matching + * nsh command names + * + * Input Parameters: + * name - A point to the name containing the name to be matched. + * matches - A table is size CONFIG_READLINE_MAX_EXTCMDS that can + * be used to remember matching name indices. + * namelen - The lenght of the name to match + * + * Returned Values: + * The number commands that match to the first namelen characters. + * + ****************************************************************************/ + +#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION) && \ + defined(CONFIG_READLINE_HAVE_EXTMATCH) +int nsh_extmatch_count(FAR char *name, FAR int *matches, int namelen) +{ + int nr_matches = 0; + int i; + + for (i = 0; i < NUM_CMDS; i++) + { + if (strncmp(name, g_cmdmap[i].cmd, namelen) == 0) + { + matches[nr_matches] = i; + nr_matches++; + + if (nr_matches >= CONFIG_READLINE_MAX_EXTCMDS) + { + break; + } + } + } + + return nr_matches; +} +#endif + +/**************************************************************************** + * Name: nsh_extmatch_getname + * + * Description: + * This support function is used to provide support for realine tab- + * completion logic nsh_extmatch_getname() will return the full command + * string from an index that was previously saved by nsh_exmatch_count(). + * + * Input Parameters: + * index - The index of the command name to be returned. + * + * Returned Values: + * The numb + * + ****************************************************************************/ + +#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION) && \ + defined(CONFIG_READLINE_HAVE_EXTMATCH) +FAR const char *nsh_extmatch_getname(int index) +{ + DEBUGASSERT(index > 0 && index <= NUM_CMDS); + return g_cmdmap[index].cmd; +} +#endif + diff --git a/nshlib/nsh_console.c b/nshlib/nsh_console.c index 0910f76f1..0c2b54ac3 100644 --- a/nshlib/nsh_console.c +++ b/nshlib/nsh_console.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/nshlib/nsh_console.c * - * Copyright (C) 2007-2009, 2011-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2009, 2011-2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -240,13 +240,13 @@ static int nsh_consoleoutput(FAR struct nsh_vtbl_s *vtbl, va_list ap; char *str; - /* Use avsprintf() to allocate a buffer and fill it with the formatted + /* Use vasprintf() to allocate a buffer and fill it with the formatted * data */ va_start(ap, fmt); str = NULL; - (void)avsprintf(&str, fmt, ap); + (void)vasprintf(&str, fmt, ap); /* Was a string allocated? */ diff --git a/nshlib/nsh_dbgcmds.c b/nshlib/nsh_dbgcmds.c index 9f7ec205e..c11e15ec6 100644 --- a/nshlib/nsh_dbgcmds.c +++ b/nshlib/nsh_dbgcmds.c @@ -54,7 +54,7 @@ #include "nsh_console.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nshlib/nsh_envcmds.c b/nshlib/nsh_envcmds.c index 8ff65d3d5..e6beb3a73 100644 --- a/nshlib/nsh_envcmds.c +++ b/nshlib/nsh_envcmds.c @@ -50,7 +50,7 @@ #include "nsh_console.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nshlib/nsh_fileapps.c b/nshlib/nsh_fileapps.c index 6e35a97d2..26db6e950 100644 --- a/nshlib/nsh_fileapps.c +++ b/nshlib/nsh_fileapps.c @@ -54,7 +54,7 @@ #ifdef CONFIG_NSH_FILE_APPS /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nshlib/nsh_fscmds.c b/nshlib/nsh_fscmds.c index ed0c1c7a5..ea8578bb5 100644 --- a/nshlib/nsh_fscmds.c +++ b/nshlib/nsh_fscmds.c @@ -82,7 +82,7 @@ #include "nsh_console.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define LSFLAGS_SIZE 1 @@ -129,14 +129,14 @@ static char g_iobuffer[IOBUFFERSIZE]; #if !defined(CONFIG_NSH_DISABLE_CP) || defined(CONFIG_NSH_FULLPATH) static void trim_dir(char *arg) { - /* Skip any trailing '/' characters (unless it is also the leading '/') */ + /* Skip any trailing '/' characters (unless it is also the leading '/') */ - int len = strlen(arg) - 1; - while (len > 0 && arg[len] == '/') - { + int len = strlen(arg) - 1; + while (len > 0 && arg[len] == '/') + { arg[len] = '\0'; len--; - } + } } #endif @@ -439,6 +439,7 @@ static int cat_common(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, buffer = (FAR char *)malloc(IOBUFFERSIZE); if(buffer == NULL) { + (void)close(fd); nsh_output(vtbl, g_fmtcmdfailed, cmd, "malloc", NSH_ERRNO); return ERROR; } @@ -487,7 +488,7 @@ static int cat_common(FAR struct nsh_vtbl_s *vtbl, FAR const char *cmd, /* EINTR is not an error (but will stop stop the cat) */ - #ifndef CONFIG_DISABLE_SIGNALS +#ifndef CONFIG_DISABLE_SIGNALS if (errval == EINTR) { nsh_output(vtbl, g_fmtsignalrecvd, cmd); @@ -1347,8 +1348,8 @@ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) newpath = nsh_getfullpath(vtbl, argv[2]); if (!newpath) { - nsh_freefullpath(newpath); - return ERROR; + ret = ERROR; + goto errout_with_oldpath; } /* Perform the mount */ @@ -1361,8 +1362,10 @@ int cmd_mv(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) /* Free the file paths */ - nsh_freefullpath(oldpath); nsh_freefullpath(newpath); + +errout_with_oldpath: + nsh_freefullpath(oldpath); return ret; } #endif diff --git a/nshlib/nsh_init.c b/nshlib/nsh_init.c index a59c5b323..24f3fce07 100644 --- a/nshlib/nsh_init.c +++ b/nshlib/nsh_init.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/nshlib/nsh_init.c * - * Copyright (C) 2007-2012, 2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2012, 2014-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -40,12 +40,14 @@ #include #include + +#include #include #include "nsh.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -60,7 +62,16 @@ * Private Data ****************************************************************************/ -/**************************************************************************** +#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION) && \ + defined(CONFIG_READLINE_HAVE_EXTMATCH) +static const struct extmatch_vtable_s g_nsh_extmatch = +{ + nsh_extmatch_count, /* count_matches */ + nsh_extmatch_getname /* getname */ +}; +#endif + + /************************************************************************** * Public Data ****************************************************************************/ @@ -90,6 +101,18 @@ void nsh_initialize(void) { +#if defined(CONFIG_NSH_READLINE) && defined(CONFIG_READLINE_TABCOMPLETION) + /* Configure the NSH prompt */ + + (void)readline_prompt(g_nshprompt); + +#ifdef CONFIG_READLINE_HAVE_EXTMATCH + /* Set up for tab completion on NSH commands */ + + (void)readline_extmatch(&g_nsh_extmatch); +#endif +#endif + /* Mount the /etc filesystem */ (void)nsh_romfsetc(); diff --git a/nshlib/nsh_mmcmds.c b/nshlib/nsh_mmcmds.c index 58209ee7c..b186377d2 100644 --- a/nshlib/nsh_mmcmds.c +++ b/nshlib/nsh_mmcmds.c @@ -45,7 +45,7 @@ #include "nsh_console.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nshlib/nsh_mntcmds.c b/nshlib/nsh_mntcmds.c index c42cf5eeb..10d341ca9 100644 --- a/nshlib/nsh_mntcmds.c +++ b/nshlib/nsh_mntcmds.c @@ -59,7 +59,7 @@ #include "nsh_console.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** @@ -109,6 +109,12 @@ static const char* get_fstype(FAR struct statfs *statbuf) break; #endif +#ifdef CONFIG_FS_TMPFS + case TMPFS_MAGIC: + fstype = "tmpfs"; + break; +#endif + #ifdef CONFIG_FS_BINFS case BINFS_MAGIC: fstype = "binfs"; diff --git a/nshlib/nsh_netcmds.c b/nshlib/nsh_netcmds.c index 39be39e65..7a4be5034 100644 --- a/nshlib/nsh_netcmds.c +++ b/nshlib/nsh_netcmds.c @@ -515,6 +515,12 @@ static int ifconfig_callback(FAR struct net_driver_s *dev, void *arg) break; # endif +# if defined(CONFIG_NET_LOOPBACK) + case NET_LL_LOOPBACK: + nsh_output(vtbl, "%s\tLink encap:Local Loopback", dev->d_ifname); + break; +# endif + # if defined(CONFIG_NET_SLIP) case NET_LL_SLIP: nsh_output(vtbl, "%s\tLink encap:SLIP", dev->d_ifname); @@ -543,6 +549,9 @@ static int ifconfig_callback(FAR struct net_driver_s *dev, void *arg) nsh_output(vtbl, "%s\tLink encap:Ethernet HWaddr %s at %s\n", dev->d_ifname, ether_ntoa(&dev->d_mac), status); +#elif defined(CONFIG_NET_LOOPBACK) + nsh_output(vtbl, "%s\tLink encap:Local Loopback at %s\n", dev->d_ifname, status); + #elif defined(CONFIG_NET_SLIP) nsh_output(vtbl, "%s\tLink encap:SLIP at %s\n", dev->d_ifname, status); @@ -846,11 +855,11 @@ static int nsh_gethostip(FAR char *hostname, FAR union ip_addr_u *ipaddr, } #endif - /* The inet_pton() function returns 1 if the conversion succeeds. It will - * return 0 if the input is not a valid IPv4 dotted-decimal string or a - * valid IPv6 address string, or -1 with errno set to EAFNOSUPPORT if - * the address family argument is unsupported. - */ + /* The inet_pton() function returns 1 if the conversion succeeds. It will + * return 0 if the input is not a valid IPv4 dotted-decimal string or a + * valid IPv6 address string, or -1 with errno set to EAFNOSUPPORT if + * the address family argument is unsupported. + */ return (ret > 0) ? OK : ERROR; diff --git a/nshlib/nsh_netinit.c b/nshlib/nsh_netinit.c index 393997e33..38e20aeb2 100644 --- a/nshlib/nsh_netinit.c +++ b/nshlib/nsh_netinit.c @@ -103,19 +103,32 @@ #if defined(CONFIG_NET_ETHERNET) # define NET_DEVNAME "eth0" +# define NSH_HAVE_NETDEV #elif defined(CONFIG_NET_SLIP) # define NET_DEVNAME "sl0" # ifndef CONFIG_NSH_NOMAC # error "CONFIG_NSH_NOMAC must be defined for SLIP" # endif +# define NSH_HAVE_NETDEV #elif defined(CONFIG_NET_TUN) # define NET_DEVNAME "tun0" +# define NSH_HAVE_NETDEV #elif defined(CONFIG_NET_LOCAL) # define NET_DEVNAME "lo" -#else +# define NSH_HAVE_NETDEV +#elif !defined(CONFIG_NET_LOOPBACK) # error ERROR: No link layer protocol defined #endif +/* If we have no network device (only only the local loopback device), then we + * cannot support the network monitor. + */ + +#ifndef NSH_HAVE_NETDEV +# undef CONFIG_NSH_NETINIT_MONITOR +#endif + + /* We need a valid IP domain (any domain) to create a socket that we can use * to comunicate with the network device. */ @@ -208,6 +221,7 @@ static const uint16_t g_ipv6_netmask[8] = static void nsh_netinit_configure(void) { +#ifdef NSH_HAVE_NETDEV #ifdef CONFIG_NET_IPv4 struct in_addr addr; #endif @@ -328,6 +342,7 @@ static void nsh_netinit_configure(void) dhcpc_close(handle); } #endif +#endif /* NSH_HAVE_NETDEV */ nvdbg("Exit\n"); } diff --git a/nshlib/nsh_proccmds.c b/nshlib/nsh_proccmds.c index 43791c41e..2f5f5a2b5 100644 --- a/nshlib/nsh_proccmds.c +++ b/nshlib/nsh_proccmds.c @@ -106,7 +106,6 @@ static const char *g_ttypenames[4] = "KTHREAD", "--?-- " }; -#endif static FAR const char *g_policynames[4] = { @@ -115,6 +114,7 @@ static FAR const char *g_policynames[4] = "SPOR", "OTHR" }; +#endif /**************************************************************************** * Public Data diff --git a/nshlib/nsh_romfsetc.c b/nshlib/nsh_romfsetc.c index eba60af92..15c5ee8b8 100644 --- a/nshlib/nsh_romfsetc.c +++ b/nshlib/nsh_romfsetc.c @@ -62,7 +62,7 @@ #endif /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nshlib/nsh_script.c b/nshlib/nsh_script.c index b115dc8fb..12945ea4a 100644 --- a/nshlib/nsh_script.c +++ b/nshlib/nsh_script.c @@ -45,7 +45,7 @@ #if CONFIG_NFILE_DESCRIPTORS > 0 && CONFIG_NFILE_STREAMS > 0 && !defined(CONFIG_NSH_DISABLESCRIPT) /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/nshlib/nsh_syscmds.c b/nshlib/nsh_syscmds.c index 0874046eb..d672ee937 100644 --- a/nshlib/nsh_syscmds.c +++ b/nshlib/nsh_syscmds.c @@ -255,7 +255,7 @@ int cmd_uname(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) set |= UNAME_KERNEL; break; -#if CONFIG_NET +#ifdef CONFIG_NET case 'n': set |= UNAME_NODE; break; @@ -332,7 +332,7 @@ int cmd_uname(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) str = info.sysname; break; -#if CONFIG_NET +#ifdef CONFIG_NET case 1: /* Print noname */ str = info.nodename; break; diff --git a/nshlib/nsh_test.c b/nshlib/nsh_test.c index f76da5417..8e581d5e2 100644 --- a/nshlib/nsh_test.c +++ b/nshlib/nsh_test.c @@ -74,7 +74,7 @@ #if !defined(CONFIG_NSH_DISABLESCRIPT) && !defined(CONFIG_NSH_DISABLE_TEST) /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define TEST_TRUE OK diff --git a/nshlib/nsh_timcmds.c b/nshlib/nsh_timcmds.c index 78066b354..55fa88a78 100644 --- a/nshlib/nsh_timcmds.c +++ b/nshlib/nsh_timcmds.c @@ -48,7 +48,7 @@ #include "nsh_console.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define MAX_TIME_STRING 80 @@ -328,17 +328,18 @@ int cmd_date(FAR struct nsh_vtbl_s *vtbl, int argc, char **argv) goto errout; } - /* Display or set the time */ + /* Display or set the time */ - if (newtime) - { - ret = date_settime(vtbl, argv[0], newtime); - } - else - { - ret = date_showtime(vtbl, argv[0]); - } - return ret; + if (newtime) + { + ret = date_settime(vtbl, argv[0], newtime); + } + else + { + ret = date_showtime(vtbl, argv[0]); + } + + return ret; errout: nsh_output(vtbl, errfmt, argv[0]); diff --git a/nshlib/nsh_usbconsole.c b/nshlib/nsh_usbconsole.c index bcc2ef300..894a0ea68 100644 --- a/nshlib/nsh_usbconsole.c +++ b/nshlib/nsh_usbconsole.c @@ -63,7 +63,7 @@ * Pre-processor Definitions ****************************************************************************/ - /**************************************************************************** +/**************************************************************************** * Private Types ****************************************************************************/ diff --git a/nshlib/nsh_usbkeyboard.c b/nshlib/nsh_usbkeyboard.c index 91aeaaa9a..145256fee 100644 --- a/nshlib/nsh_usbkeyboard.c +++ b/nshlib/nsh_usbkeyboard.c @@ -55,7 +55,7 @@ * Pre-processor Definitions ****************************************************************************/ - /**************************************************************************** +/**************************************************************************** * Private Types ****************************************************************************/ diff --git a/platform/Kconfig b/platform/Kconfig index 218119e85..8fd145b6e 100644 --- a/platform/Kconfig +++ b/platform/Kconfig @@ -3,6 +3,8 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +menu "Platform-specific Support" + config PLATFORM_CONFIGDATA bool "Platform configuration data" default n @@ -15,3 +17,5 @@ config PLATFORM_CONFIGDATA FLASH, etc. source "$APPSDIR/platform/mikroe-stm32f4/Kconfig" + +endmenu # Platform-specific Support diff --git a/platform/mikroe-stm32f4/mikroe_configdata.c b/platform/mikroe-stm32f4/mikroe_configdata.c index 91c444175..c1a9b538e 100644 --- a/platform/mikroe-stm32f4/mikroe_configdata.c +++ b/platform/mikroe-stm32f4/mikroe_configdata.c @@ -53,7 +53,7 @@ #ifdef CONFIG_PLATFORM_CONFIGDATA /************************************************************************************ - * Definitions + * Pre-processor Definitions ************************************************************************************/ /************************************************************************************ @@ -111,7 +111,7 @@ int platform_setconfig(enum config_data_e id, int instance, #ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_FS FILE* fd; #endif -#if CONFIG_MIKROE_STM32F4_CONFIGDATA_PART +#ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_PART struct config_data_s config; int ret; int fd; @@ -166,7 +166,7 @@ int platform_setconfig(enum config_data_e id, int instance, fclose(fd); return OK; -#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM +#elif defined(CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM) /* We are reading from a read-only system, so nothing to do. */ @@ -224,13 +224,13 @@ int platform_getconfig(enum config_data_e id, int instance, size_t bytes; enum config_data_e saved_id; int saved_instance; -#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM +#elif defined(CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM) static const uint8_t touch_cal_data[] = { 0x9a, 0x2f, 0x00, 0x00, 0x40, 0xbc, 0x69, 0xfe, 0x70, 0x2e, 0x00, 0x00, 0xb8, 0x2d, 0xdb, 0xff }; #endif -#if CONFIG_MIKROE_STM32F4_CONFIGDATA_PART +#ifdef CONFIG_MIKROE_STM32F4_CONFIGDATA_PART struct config_data_s config; int ret; int fd; @@ -298,7 +298,7 @@ int platform_getconfig(enum config_data_e id, int instance, return OK; -#elif CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM +#elif defined(CONFIG_MIKROE_STM32F4_CONFIGDATA_ROM) memcpy(configdata, touch_cal_data, datalen); return OK; diff --git a/platform/stm3240g-eval/stm32_cxxinitialize.c b/platform/stm3240g-eval/stm32_cxxinitialize.c index 69362e117..d713b7270 100644 --- a/platform/stm3240g-eval/stm32_cxxinitialize.c +++ b/platform/stm3240g-eval/stm32_cxxinitialize.c @@ -120,7 +120,7 @@ extern uint32_t _etext; * definition only provides the 'contract' between application * specific C++ code and platform-specific toolchain support * - ***************************************************************************/ + ****************************************************************************/ void up_cxxinitialize(void) { diff --git a/platform/stm32f4discovery/stm32_cxxinitialize.c b/platform/stm32f4discovery/stm32_cxxinitialize.c index c11d83a2d..618297f86 100644 --- a/platform/stm32f4discovery/stm32_cxxinitialize.c +++ b/platform/stm32f4discovery/stm32_cxxinitialize.c @@ -118,7 +118,7 @@ extern uint32_t _etext; * function definition only provides the 'contract' between application * specific C++ code and platform-specific toolchain support * - ***************************************************************************/ + ****************************************************************************/ void up_cxxinitialize(void) { diff --git a/platform/stm32f746g-disco/stm32_cxxinitialize.c b/platform/stm32f746g-disco/stm32_cxxinitialize.c index 722685125..6ddaae424 100644 --- a/platform/stm32f746g-disco/stm32_cxxinitialize.c +++ b/platform/stm32f746g-disco/stm32_cxxinitialize.c @@ -118,7 +118,7 @@ extern uint32_t _etext; * function defintion only provides the 'contract' between application * specific C++ code and platform-specific toolchain support * - ***************************************************************************/ + ****************************************************************************/ void up_cxxinitialize(void) { diff --git a/system/Kconfig b/system/Kconfig index 7e4a61fe8..a7fae6f7e 100644 --- a/system/Kconfig +++ b/system/Kconfig @@ -3,6 +3,8 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +menu "System Libraries and NSH Add-Ons" + source "$APPSDIR/system/free/Kconfig" source "$APPSDIR/system/cle/Kconfig" source "$APPSDIR/system/cu/Kconfig" @@ -23,6 +25,7 @@ source "$APPSDIR/system/sudoku/Kconfig" source "$APPSDIR/system/lm75/Kconfig" source "$APPSDIR/system/vi/Kconfig" source "$APPSDIR/system/stackmonitor/Kconfig" +source "$APPSDIR/system/symtab/Kconfig" source "$APPSDIR/system/cdcacm/Kconfig" source "$APPSDIR/system/composite/Kconfig" source "$APPSDIR/system/usbmsc/Kconfig" @@ -30,3 +33,4 @@ source "$APPSDIR/system/usbmonitor/Kconfig" source "$APPSDIR/system/zmodem/Kconfig" source "$APPSDIR/system/zoneinfo/Kconfig" +endmenu # System Libraries and NSH Add-Ons diff --git a/system/Make.defs b/system/Make.defs index c7acecd61..b818a9709 100644 --- a/system/Make.defs +++ b/system/Make.defs @@ -114,6 +114,10 @@ ifeq ($(CONFIG_SYSTEM_STACKMONITOR),y) CONFIGURED_APPS += system/stackmonitor endif +ifeq ($(CONFIG_SYSTEM_SYMTAB),y) +CONFIGURED_APPS += system/symtab +endif + ifeq ($(CONFIG_SYSTEM_USBMSC),y) CONFIGURED_APPS += system/usbmsc endif diff --git a/system/Makefile b/system/Makefile index f23bbfdcb..a5ba4e506 100644 --- a/system/Makefile +++ b/system/Makefile @@ -39,7 +39,7 @@ SUBDIRS = cdcacm cle composite cu flash_eraseall free i2c hex2bin inifile SUBDIRS += install lm75 mdio netdb nxplayer ramtest ramtron readline sdcard -SUBDIRS += stackmonitor sudoku usbmonitor usbmsc vi zmodem zoneinfo +SUBDIRS += stackmonitor sudoku symtab usbmonitor usbmsc vi zmodem zoneinfo # Create the list of installed runtime modules (INSTALLED_DIRS) diff --git a/system/composite/composite.h b/system/composite/composite.h index 1f4274f62..d64228dd2 100644 --- a/system/composite/composite.h +++ b/system/composite/composite.h @@ -129,6 +129,10 @@ /* Trace initialization *****************************************************/ +#ifndef CONFIG_USBDEV_TRACE_INITIALIDSET +# define CONFIG_USBDEV_TRACE_INITIALIDSET 0 +#endif + #ifdef CONFIG_SYSTEM_COMPOSITE_TRACEINIT # define TRACE_INIT_BITS (TRACE_INIT_BIT) #else diff --git a/system/composite/composite_main.c b/system/composite/composite_main.c index 2c9b0ed12..a31c60079 100644 --- a/system/composite/composite_main.c +++ b/system/composite/composite_main.c @@ -1,7 +1,7 @@ /**************************************************************************** * system/composite/composite_main.c * - * Copyright (C) 2012-2014 Gregory Nutt. All rights reserved. + * Copyright (C) 2012-2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -706,7 +706,6 @@ int conn_main(int argc, char *argv[]) */ #ifdef CONFIG_NSH_BUILTIN_APPS - /* Check if there is a non-NULL USB mass storage device handle (meaning that the * USB mass storage device is already configured). */ @@ -751,7 +750,7 @@ int conn_main(int argc, char *argv[]) check_test_memory_usage("After composite_initialize()"); -#if CONFIG_USBDEV_TRACE && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 +#if defined(CONFIG_USBDEV_TRACE) && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 /* If USB tracing is enabled and tracing of initial USB events is specified, * then dump all collected trace data to stdout */ @@ -760,7 +759,7 @@ int conn_main(int argc, char *argv[]) ret = dumptrace(); if (ret < 0) { - goto errout; + goto errout_bad_dump; } #endif @@ -831,11 +830,16 @@ int conn_main(int argc, char *argv[]) final_memory_usage("Final memory usage"); return 0; -errout: +#if defined(CONFIG_USBDEV_TRACE) && CONFIG_USBDEV_TRACE_INITIALIDSET != 0 +errout_bad_dump: +#endif + #if !defined(CONFIG_NSH_BUILTIN_APPS) && !defined(CONFIG_DISABLE_SIGNALS) +errout: close(g_composite.infd); close(g_composite.outfd); #endif + composite_uninitialize(g_composite.cmphandle); final_memory_usage("Final memory usage"); return 1; diff --git a/system/cu/cu_main.c b/system/cu/cu_main.c index 5cce8e1a8..877c57d00 100644 --- a/system/cu/cu_main.c +++ b/system/cu/cu_main.c @@ -223,7 +223,7 @@ static void print_help(void) " -s: Use given speed (default %d)\n" " -r: Disable RTS/CTS flow control (default: on)\n" " -?: This help\n", - CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE, + CONFIG_SYSTEM_CUTERM_DEFAULT_DEVICE, CONFIG_SYSTEM_CUTERM_DEFAULT_BAUD); } diff --git a/system/hex2bin/hex2bin.c b/system/hex2bin/hex2bin.c index 46d4fc583..5bbe89d5f 100644 --- a/system/hex2bin/hex2bin.c +++ b/system/hex2bin/hex2bin.c @@ -299,7 +299,7 @@ static int readstream(FAR struct lib_instream_s *instream, *line = '\0'; return nbytes; } -#elif CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_EITHER_CRLF) if (ch == '\n' || ch == '\r') { *line = '\0'; diff --git a/system/i2c/i2c_bus.c b/system/i2c/i2c_bus.c index a684166ff..3a1d110d7 100644 --- a/system/i2c/i2c_bus.c +++ b/system/i2c/i2c_bus.c @@ -44,7 +44,7 @@ #include "i2ctool.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/system/i2c/i2c_common.c b/system/i2c/i2c_common.c index aa4868ffe..514e50d72 100644 --- a/system/i2c/i2c_common.c +++ b/system/i2c/i2c_common.c @@ -44,7 +44,7 @@ #include "i2ctool.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/system/i2c/i2c_dev.c b/system/i2c/i2c_dev.c index a9da1a03f..43517dff0 100644 --- a/system/i2c/i2c_dev.c +++ b/system/i2c/i2c_dev.c @@ -46,7 +46,7 @@ #include "i2ctool.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/system/i2c/i2c_set.c b/system/i2c/i2c_set.c index 5baf7f835..5e1f90871 100644 --- a/system/i2c/i2c_set.c +++ b/system/i2c/i2c_set.c @@ -46,7 +46,7 @@ #include "i2ctool.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/system/i2c/i2c_verf.c b/system/i2c/i2c_verf.c index 109e9c4ce..fd9d20ef1 100644 --- a/system/i2c/i2c_verf.c +++ b/system/i2c/i2c_verf.c @@ -46,7 +46,7 @@ #include "i2ctool.h" /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/system/i2c/i2ctool.h b/system/i2c/i2ctool.h index 43a0ba291..a27f9aeb7 100644 --- a/system/i2c/i2ctool.h +++ b/system/i2c/i2ctool.h @@ -52,7 +52,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* Configuration ************************************************************/ /* CONFIG_NSH_BUILTIN_APPS - Build the tools as an NSH built-in command diff --git a/system/mdio/mdio_main.c b/system/mdio/mdio_main.c index 2c5976d67..74549a27d 100644 --- a/system/mdio/mdio_main.c +++ b/system/mdio/mdio_main.c @@ -52,7 +52,7 @@ #include /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ #define CONFIG_HELLO_IPADDR 0xc0a8eacd diff --git a/system/netdb/netdb_main.c b/system/netdb/netdb_main.c index c195ad34d..d4436c1c6 100644 --- a/system/netdb/netdb_main.c +++ b/system/netdb/netdb_main.c @@ -65,6 +65,15 @@ # define CONFIG_SYSTEM_NETDB_PRIORITY 50 #endif +/* REVIST: Currently the availability of gethostbyaddr() depends on + * CONFIG_NETDB_HOSTFILE. That might not always be true, however. + */ + +#undef HAVE_GETHOSTBYADDR +#ifdef CONFIG_NETDB_HOSTFILE +# define HAVE_GETHOSTBYADDR 1 +#endif + /**************************************************************************** * Private Functions ****************************************************************************/ @@ -73,13 +82,15 @@ static void show_usage(FAR const char *progname, int exitcode) noreturn_function static void show_usage(FAR const char *progname, int exitcode) { fprintf(stderr, "USAGE: %s --ipv4 \n", progname); +#ifdef HAVE_GETHOSTBYADDR fprintf(stderr, " %s --ipv6 \n", progname); fprintf(stderr, " %s --host \n", progname); +#endif fprintf(stderr, " %s --help\n", progname); exit(exitcode); } - /**************************************************************************** +/**************************************************************************** * Public Functions ****************************************************************************/ @@ -110,6 +121,7 @@ int netdb_main(int argc, char **argv) show_usage(argv[0], EXIT_FAILURE); } +#ifdef HAVE_GETHOSTBYADDR /* Handle: netdb --ipv4 */ else if (strcmp(argv[1], "--ipv4") == 0) @@ -161,6 +173,7 @@ int netdb_main(int argc, char **argv) return EXIT_FAILURE; } } +#endif /* HAVE_GETHOSTBYADDR */ /* Handle: netdb --host */ diff --git a/system/nxplayer/nxplayer.c b/system/nxplayer/nxplayer.c index 410548cf6..123be07ef 100644 --- a/system/nxplayer/nxplayer.c +++ b/system/nxplayer/nxplayer.c @@ -1132,7 +1132,7 @@ int nxplayer_setvolume(FAR struct nxplayer_s *pPlayer, uint16_t volume) * Returned Value: * OK if equalization was set correctly. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_EQUALIZER int nxplayer_setequalization(FAR struct nxplayer_s *pPlayer, @@ -1375,7 +1375,7 @@ int nxplayer_resume(FAR struct nxplayer_s *pPlayer) * Returned Value: * OK if fast forward operation successful. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_FFORWARD int nxplayer_fforward(FAR struct nxplayer_s *pPlayer, uint8_t subsample) @@ -1431,7 +1431,7 @@ int nxplayer_fforward(FAR struct nxplayer_s *pPlayer, uint8_t subsample) * Returned Value: * OK if rewind operation successfully initiated. * - **************************************************************************/ + ****************************************************************************/ #ifndef CONFIG_AUDIO_EXCLUDE_REWIND int nxplayer_rewind(FAR struct nxplayer_s *pPlayer, uint8_t subsample) @@ -1480,7 +1480,7 @@ int nxplayer_rewind(FAR struct nxplayer_s *pPlayer, uint8_t subsample) * Returned Value: * OK if rewind operation successfully cancelled. * - **************************************************************************/ + ****************************************************************************/ #if !defined(CONFIG_AUDIO_EXCLUDE_FFORWARD) || !defined(CONFIG_AUDIO_EXCLUDE_REWIND) int nxplayer_cancel_motion(FAR struct nxplayer_s *pPlayer, bool paused) @@ -1863,7 +1863,7 @@ void nxplayer_setmediadir(FAR struct nxplayer_s *pPlayer, * Returned values: * Pointer to the created context or NULL if there was an error. * - **************************************************************************/ + ****************************************************************************/ FAR struct nxplayer_s *nxplayer_create(void) { @@ -1928,7 +1928,7 @@ FAR struct nxplayer_s *nxplayer_create(void) * * Returned values: None * - **************************************************************************/ + ****************************************************************************/ void nxplayer_release(FAR struct nxplayer_s* pPlayer) { @@ -1993,7 +1993,7 @@ void nxplayer_release(FAR struct nxplayer_s* pPlayer) * * Returned values: None * - **************************************************************************/ + ****************************************************************************/ void nxplayer_reference(FAR struct nxplayer_s* pPlayer) { @@ -2029,7 +2029,7 @@ void nxplayer_reference(FAR struct nxplayer_s* pPlayer) * * Returned values: None * - **************************************************************************/ + ****************************************************************************/ void nxplayer_detach(FAR struct nxplayer_s* pPlayer) { diff --git a/system/nxplayer/nxplayer_main.c b/system/nxplayer/nxplayer_main.c index 2f64a932b..a6dd76ccc 100644 --- a/system/nxplayer/nxplayer_main.c +++ b/system/nxplayer/nxplayer_main.c @@ -589,7 +589,7 @@ static int nxplayer_cmd_help(FAR struct nxplayer_s *pPlayer, char* parg) * EOF is returned to indicate either an end of file condition or a * failure. * - **************************************************************************/ + ****************************************************************************/ #ifdef CONFIG_BUILD_KERNEL int main(int argc, FAR char *argv[]) diff --git a/system/prun/prun.h b/system/prun/prun.h index f9a3b843b..ddb6ee650 100644 --- a/system/prun/prun.h +++ b/system/prun/prun.h @@ -41,7 +41,7 @@ ****************************************************************************/ /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /**************************************************************************** diff --git a/system/readline/Kconfig b/system/readline/Kconfig index 021399262..d382a7b67 100644 --- a/system/readline/Kconfig +++ b/system/readline/Kconfig @@ -3,6 +3,10 @@ # see the file kconfig-language.txt in the NuttX tools repository. # +config READLINE_HAVE_EXTMATCH + bool + default n + menuconfig SYSTEM_READLINE bool "readline() Support" default n @@ -20,4 +24,76 @@ config READLINE_ECHO already has local echo support or you need to suppress the back-channel responses for any other reason. -endif +if READLINE_ECHO + +config READLINE_TABCOMPLETION + bool "Tab completion" + default n + depends on (BUILD_FLAT && BUILTIN) || READLINE_HAVE_EXTMATCH + ---help--- + Build in support for Unix-style tab completion. This feature was + originally provided by Nghia Ho. + +if READLINE_TABCOMPLETION + +config READLINE_MAX_BUILTINS + int "Maximum built-in matches" + default 64 + depends on BUILTIN + ---help--- + This the maximum number of matching names of builtin commands that + will be displayed. + +config READLINE_MAX_EXTCMDS + int "Maximum external command matches" + default 64 + depends on READLINE_HAVE_EXTMATCH + ---help--- + This the maximum number of matching names of external commands that + will be displayed. + +endif # READLINE_TABCOMPLETION + +config READLINE_CMD_HISTORY + bool "Command line history" + default n + ---help--- + Build in support for Unix-style command history using up and down + arrow keys. This feature was originally provided by Nghia Ho. + + NOTE: Command line history is kept in an in-memory array and is + shared. In the FLAT or PROTECTED builds, this history is shared by + all threads; in the KERNEL build, the command line history is shared + by all threads in the process. This means that in a FLAT build, for + example, a built-in application started from NSH will have the same + history as does NSH if it also uses readline(). This also means + that different NSH sessions on serial, USB, or Telnet will also + share the same history array. + + In a KERNEL build, each process will have a separately allocated + history array so the issue is lessened. + +if READLINE_CMD_HISTORY + +config READLINE_CMD_HISTORY_LINELEN + int "Command line history length" + default 64 if DEFAULT_SMALL + default 80 if !DEFAULT_SMALL + ---help--- + The maximum length of one command line in the in-memory array. The + total memory usage for the command line array will be + READLINE_CMD_HISTORY_LINELEN x READLINE_CMD_HISTORY_LEN. Default: 64/80 + +config READLINE_CMD_HISTORY_LEN + int "Command line history records" + default 4 if DEFAULT_SMALL + default 16 if !DEFAULT_SMALL + ---help--- + The number of lines of history that will be buffered in the in- + memory array. The total memory usage for the command line array + will be READLINE_CMD_HISTORY_LINELEN x READLINE_CMD_HISTORY_LEN. + Default: 16 + +endif # READLINE_CMD_HISTORY +endif # READLINE_ECHO +endif # SYSTEM_READLINE diff --git a/system/readline/readline.c b/system/readline/readline.c index 13e07e652..611f04364 100644 --- a/system/readline/readline.c +++ b/system/readline/readline.c @@ -186,7 +186,7 @@ static void readline_write(FAR struct rl_common_s *vtbl, #endif /**************************************************************************** - * Global Functions + * Public Functions ****************************************************************************/ /**************************************************************************** @@ -216,7 +216,7 @@ static void readline_write(FAR struct rl_common_s *vtbl, * EOF is returned to indicate either an end of file condition or a * failure. * - **************************************************************************/ + ****************************************************************************/ ssize_t readline(FAR char *buf, int buflen, FILE *instream, FILE *outstream) { diff --git a/system/readline/readline.h b/system/readline/readline.h index f38b7af78..de84ce7ae 100644 --- a/system/readline/readline.h +++ b/system/readline/readline.h @@ -118,7 +118,7 @@ struct rl_common_s * EOF is returned to indicate either an end of file condition or a * failure. * - **************************************************************************/ + ****************************************************************************/ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf, int buflen); diff --git a/system/readline/readline_common.c b/system/readline/readline_common.c index fc49f563b..47a11fae9 100644 --- a/system/readline/readline_common.c +++ b/system/readline/readline_common.c @@ -1,7 +1,7 @@ /**************************************************************************** * apps/system/readline/readline_common.c * - * Copyright (C) 2007-2008, 2011-2013 Gregory Nutt. All rights reserved. + * Copyright (C) 2007-2008, 2011-2013, 2015 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -48,27 +48,11 @@ #include #include +#include #include #include "readline.h" -/**************************************************************************** - * Pre-processor Definitions - ****************************************************************************/ - -/**************************************************************************** - * Private Type Declarations - ****************************************************************************/ - -/**************************************************************************** - * Private Function Prototypes - ****************************************************************************/ - -/**************************************************************************** - * Public Data - ****************************************************************************/ -extern const char g_nshprompt[]; - /**************************************************************************** * Private Data ****************************************************************************/ @@ -76,18 +60,381 @@ extern const char g_nshprompt[]; static const char g_erasetoeol[] = VT100_CLEAREOL; +#ifdef CONFIG_READLINE_TABCOMPLETION +/* Prompt string to present at the beginning of the line */ + +static FAR const char *g_readline_prompt = NULL; + +#ifdef CONFIG_READLINE_HAVE_EXTMATCH +static FAR const struct extmatch_vtable_s *g_extmatch_vtbl = NULL; +#endif +#endif /* CONFIG_READLINE_TABCOMPLETION */ + +#ifdef CONFIG_READLINE_CMD_HISTORY +/* Nghia Ho: command history + * + * g_cmd_history[][] Circular buffer + * g_cmd_history_head Head of the circular buffer, most recent command + * g_cmd_history_steps_from_head Offset from head + * g_cmd_history_len Number of elements in the circular buffer + */ + +static char g_cmd_history[CONFIG_READLINE_CMD_HISTORY_LEN][CONFIG_READLINE_CMD_HISTORY_LINELEN]; +static int g_cmd_history_head = -1; +static int g_cmd_history_steps_from_head = 1; +static int g_cmd_history_len = 0; +#endif /* CONFIG_READLINE_CMD_HISTORY */ + /**************************************************************************** * Private Functions ****************************************************************************/ -static void tab_completion(FAR struct rl_common_s *vtbl, char *buf, int *len); + +/**************************************************************************** + * Name: count_builtin_maches + * + * Description: + * Count the number of builtin commands + * + * Input Parameters: + * matches - Array to save builtin command index. + * len - The length of the matching name to try + * + * Returned Value: + * The number of matching names + * + ****************************************************************************/ + +#if defined(CONFIG_READLINE_TABCOMPLETION) && defined(CONFIG_BUILTIN) +static int count_builtin_maches(FAR char *buf, FAR int *matches, int namelen) +{ +#if CONFIG_READLINE_MAX_BUILTINS > 0 + FAR const char *name; + int nr_matches = 0; + int i; + + for (i = 0; (name = builtin_getname(i)) != NULL; i++) + { + if (strncmp(buf, name, namelen) == 0) + { + matches[nr_matches] = i; + nr_matches++; + + if (nr_matches >= CONFIG_READLINE_MAX_BUILTINS) + { + break; + } + } + } + + return nr_matches; + +#else + return 0; +#endif +} +#endif + +/**************************************************************************** + * Name: tab_completion + * + * Description: + * Nghia - Unix like tab completion, only for builtin apps + * + * Input Parameters: + * vtbl - vtbl used to access implementation specific interface + * buf - The user allocated buffer to be filled. + * buflen - the size of the buffer. + * + * Returned Value: + * None. + * + ****************************************************************************/ + +#ifdef CONFIG_READLINE_TABCOMPLETION +static void tab_completion(FAR struct rl_common_s *vtbl, char *buf, + int *nch) +{ + FAR const char *name = NULL; + char tmp_name[CONFIG_TASK_NAME_SIZE + 1]; +#ifdef CONFIG_BUILTIN + int nr_builtin_matches = 0; + int builtin_matches[CONFIG_READLINE_MAX_BUILTINS]; +#endif +#ifdef CONFIG_READLINE_HAVE_EXTMATCH + int nr_ext_matches = 0; + int ext_matches[CONFIG_READLINE_MAX_EXTCMDS]; +#endif + int nr_matches; + int len = *nch; + int name_len; + int i; + int j; + + if (len >= 1) + { +#ifdef CONFIG_BUILTIN + /* Count the matching builtin commands */ + + nr_builtin_matches = count_builtin_maches(buf, builtin_matches, len); + nr_matches = nr_builtin_matches; +#else + nr_matches = 0; +#endif + +#ifdef CONFIG_READLINE_HAVE_EXTMATCH + /* Is there registered external handling logic? */ + + nr_ext_matches = 0; + if (g_extmatch_vtbl != NULL) + { + /* Count the number of external commands */ + + nr_ext_matches = g_extmatch_vtbl->count_matches(buf, ext_matches, len); + nr_matches += nr_ext_matches; + } + +#endif + + /* Is there only one matching name? */ + + if (nr_matches == 1) + { + /* Yes... that that is the one we want. Was it a match with a + * builtin command? Or with an external command. + */ + +#ifdef CONFIG_BUILTIN +#ifdef CONFIG_READLINE_HAVE_EXTMATCH + if (nr_builtin_matches == 1) +#endif + { + /* It is a match with a builtin command */ + + name = builtin_getname(builtin_matches[0]); + } +#endif + +#ifdef CONFIG_READLINE_HAVE_EXTMATCH +#ifdef CONFIG_BUILTIN + else +#endif + { + /* It is a match with an external command */ + + name = g_extmatch_vtbl->getname(ext_matches[0]); + } +#endif + + /* Copy the name to the command buffer and to the display. */ + + name_len = strlen(name); + + for (j = len; j < name_len; j++) + { + buf[j] = name[j]; + RL_PUTC(vtbl, name[j]); + } + + /* Don't remove extra characters after the completed word, if any. */ + + if (len < name_len) + { + *nch = name_len; + } + } + + /* Are there multiple matching names? */ + + else if (nr_matches > 1) + { + RL_PUTC(vtbl, '\n'); + + /* See how many characters we can auto complete for the user + * For example, if we have the following commands: + * - prog1 + * - prog2 + * - prog3 + * then it should automatically complete up to prog. + * We do this in one pass using a temp. + */ + + memset(tmp_name, 0, sizeof(tmp_name)); + +#ifdef CONFIG_READLINE_HAVE_EXTMATCH + /* Show the possible external completions */ + + for (i = 0; i < nr_ext_matches; i++) + { + name = g_extmatch_vtbl->getname(ext_matches[i]); + + /* Initialize temp */ + + if (tmp_name[0] == '\0') + { + strcpy(tmp_name, name); + } + + RL_PUTC(vtbl, ' '); + RL_PUTC(vtbl, ' '); + + for (j = 0; j < strlen(name); j++) + { + /* Removing characters that aren't common to all the + * matches. + */ + + if (name[j] != tmp_name[j]) + { + tmp_name[j] = '\0'; + } + + RL_PUTC(vtbl, name[j]); + } + + RL_PUTC(vtbl, '\n'); + } +#endif + +#ifdef CONFIG_BUILTIN + /* Show the possible builtin completions */ + + for (i = 0; i < nr_builtin_matches; i++) + { + name = builtin_getname(builtin_matches[i]); + + /* Initialize temp */ + + if (tmp_name[0] == '\0') + { + strcpy(tmp_name, name); + } + + RL_PUTC(vtbl, ' '); + RL_PUTC(vtbl, ' '); + + for (j = 0; j < strlen(name); j++) + { + /* Removing characters that aren't common to all the + * matches. + */ + + if (name[j] != tmp_name[j]) + { + tmp_name[j] = '\0'; + } + + RL_PUTC(vtbl, name[j]); + } + + RL_PUTC(vtbl, '\n'); + } +#endif + strcpy(buf, tmp_name); + + name_len = strlen(tmp_name); + + /* Output the original prompt */ + + if (g_readline_prompt != NULL) + { + for (i = 0; i < strlen(g_readline_prompt); i++) + { + RL_PUTC(vtbl, g_readline_prompt[i]); + } + } + + for (i = 0; i < name_len; i++) + { + RL_PUTC(vtbl, buf[i]); + } + + /* Don't remove extra characters after the completed word, if any. */ + + if (len < name_len) + { + *nch = name_len; + } + } + } +} +#endif /**************************************************************************** * Public Functions ****************************************************************************/ +/**************************************************************************** + * Name: readline_prompt + * + * If a prompt string is used by the application, then the application + * must provide the prompt string to readline() by calling this function. + * This is needed only for tab completion in cases where is it necessary + * to reprint the prompt string. + * + * Input Parameters: + * prompt - The prompt string. This function may then be + * called with that value in order to restore the previous vtable. + * + * Returned values: + * Returns the previous value of the prompt string. This function may + * then be called with that value in order to restore the previous prompt. + * + * Assumptions: + * The prompt string is statically allocated a global. readline() will + * simply remember the pointer to the string. The string must stay + * allocated and available. Only one prompt string is supported. If + * there are multiple clients of readline(), they must all share the same + * prompt string (with exceptions in the case of the kernel build). + * + ****************************************************************************/ + +#ifdef CONFIG_READLINE_TABCOMPLETION +FAR const char *readline_prompt(FAR const char *prompt) +{ + FAR const char *ret = g_readline_prompt; + g_readline_prompt = prompt; + return ret; +} +#endif + +/**************************************************************************** + * Name: readline_extmatch + * + * If the applications supports a command set, then it may call this + * function in order to provide support for tab complete on these + * "external" commands + * + * Input Parameters: + * vtbl - Callbacks to access the external names. + * + * Returned values: + * Returns the previous vtable pointer. This function may then be + * called with that value in order to restore the previous vtable. + * + * Assumptions: + * The vtbl string is statically allocated a global. readline() will + * simply remember the pointer to the structure. The structure must stay + * allocated and available. Only one instance of such a structure is + * supported. If there are multiple clients of readline(), they must all + * share the same tab-completion logic (with exceptions in the case of + * the kernel build). + * + ****************************************************************************/ + +#if defined(CONFIG_READLINE_TABCOMPLETION) && defined(CONFIG_READLINE_HAVE_EXTMATCH) +FAR const struct extmatch_vtable_s * + readline_extmatch(FAR const struct extmatch_vtable_s *vtbl) +{ + FAR const struct extmatch_vtable_s *ret = g_extmatch_vtbl; + g_extmatch_vtbl = vtbl; + return ret; +} +#endif + /**************************************************************************** * Name: readline_common * + * Description: * readline() reads in at most one less than 'buflen' characters from * 'instream' and stores them into the buffer pointed to by 'buf'. * Characters are echoed on 'outstream'. Reading stops after an EOF or a @@ -102,22 +449,24 @@ static void tab_completion(FAR struct rl_common_s *vtbl, char *buf, int *len); * different creature. * * Input Parameters: - * buf - The user allocated buffer to be filled. - * buflen - the size of the buffer. - * instream - The stream to read characters from - * outstream - The stream to each characters to. + * vtbl - vtbl used to access implementation specific interface + * buf - The user allocated buffer to be filled. + * buflen - the size of the buffer. * - * Returned values: + * Returned Value: * On success, the (positive) number of bytes transferred is returned. * EOF is returned to indicate either an end of file condition or a * failure. * - **************************************************************************/ + ****************************************************************************/ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf, int buflen) { - int escape; - int nch; + int escape; + int nch; +#ifdef CONFIG_READLINE_CMD_HISTORY + int i; +#endif /* Sanity checks */ @@ -181,6 +530,70 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf, int buflen) { /* We are finished with the escape sequence */ +#ifdef CONFIG_READLINE_CMD_HISTORY + /* Nghia Ho: intercept up and down arrow keys */ + + if (g_cmd_history_len > 0) + { + if (ch == 'A') /* up arrow */ + { + /* Go to the past command in history */ + + g_cmd_history_steps_from_head--; + + if (-g_cmd_history_steps_from_head >= g_cmd_history_len) + { + g_cmd_history_steps_from_head = -(g_cmd_history_len - 1); + } + } + else if (ch == 'B') /* down arrow */ + { + /* Go to the recent command in history */ + + g_cmd_history_steps_from_head++; + + if (g_cmd_history_steps_from_head > 1) + { + g_cmd_history_steps_from_head = 1; + } + } + + /* Clear out current command from the prompt */ + + while (nch > 0) + { + nch--; + +#ifdef CONFIG_READLINE_ECHO + RL_PUTC(vtbl, ASCII_BS); + RL_WRITE(vtbl, g_erasetoeol, sizeof(g_erasetoeol)); +#endif + } + + if (g_cmd_history_steps_from_head != 1) + { + int idx = g_cmd_history_head + g_cmd_history_steps_from_head; + + /* Circular buffer wrap around */ + + if (idx < 0) + { + idx = idx + CONFIG_READLINE_CMD_HISTORY_LEN; + } + else if (idx >= CONFIG_READLINE_CMD_HISTORY_LEN) + { + idx = idx - CONFIG_READLINE_CMD_HISTORY_LEN; + } + + for (i = 0; g_cmd_history[idx][i] != '\0'; i++) + { + buf[nch++] = g_cmd_history[idx][i]; + RL_PUTC(vtbl, g_cmd_history[idx][i]); + } + } + } +#endif /* CONFIG_READLINE_CMD_HISTORY */ + escape = 0; ch = 'a'; } @@ -243,10 +656,34 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf, int buflen) else if (ch == '\n') #elif defined(CONFIG_EOL_IS_CR) else if (ch == '\r') -#elif CONFIG_EOL_IS_EITHER_CRLF +#elif defined(CONFIG_EOL_IS_EITHER_CRLF) else if (ch == '\n' || ch == '\r') #endif { +#ifdef CONFIG_READLINE_CMD_HISTORY + /* Nghia Ho: save history of command, only if there was something + * typed besides return character. + */ + + if (nch >= 1) + { + g_cmd_history_head = (g_cmd_history_head + 1) % CONFIG_READLINE_CMD_HISTORY_LEN; + + for (i = 0; (i < nch) && i < (CONFIG_READLINE_CMD_HISTORY_LINELEN - 1); i++) + { + g_cmd_history[g_cmd_history_head][i] = buf[i]; + } + + g_cmd_history[g_cmd_history_head][i] = '\0'; + g_cmd_history_steps_from_head = 1; + + if (g_cmd_history_len < CONFIG_READLINE_CMD_HISTORY_LEN) + { + g_cmd_history_len++; + } + } +#endif /* CONFIG_READLINE_CMD_HISTORY */ + /* The newline is stored in the buffer along with the null * terminator. */ @@ -285,88 +722,11 @@ ssize_t readline_common(FAR struct rl_common_s *vtbl, FAR char *buf, int buflen) return nch; } } +#ifdef CONFIG_READLINE_TABCOMPLETION else if (ch == '\t') /* Nghia - TAB character */ { tab_completion(vtbl, buf, &nch); } - } -} - -/* - * Nghia - Unix like tab completion, only for builtin apps -*/ -void tab_completion(FAR struct rl_common_s *vtbl, char *buf, int *nch) -{ - int i, j; - int num_matches = 0; - int matches[128]; - FAR const char *name = NULL; - int len = *nch; - - if (len >= 1) - { - for (i = 0; (name = builtin_getname(i)) != NULL; i++) - { - if (!strncmp(buf, name, len)) - { - matches[num_matches] = i; - num_matches++; - - if (num_matches >= sizeof(matches) / sizeof(int)) - { - break; - } - } - } - - if (num_matches == 1) - { - name = builtin_getname(matches[0]); - - int name_len = strlen(name); - - for (j = len; j < name_len; j++) - { - buf[j] = name[j]; - RL_PUTC(vtbl, name[j]); - } - - // don't remove extra characters after the completed word, if any - if (len < name_len) - { - *nch = name_len; - } - } - else if (num_matches > 1) - { - RL_PUTC(vtbl, '\n'); - - // possible completion - for (i = 0; i < num_matches; i++) - { - name = builtin_getname(matches[i]); - - RL_PUTC(vtbl, ' '); - RL_PUTC(vtbl, ' '); - - for (j = 0; j < strlen(name); j++) - { - RL_PUTC(vtbl, name[j]); - } - - RL_PUTC(vtbl, '\n'); - } - - // output the original prompt - for (i = 0; i < strlen(g_nshprompt); i++) - { - RL_PUTC(vtbl, g_nshprompt[i]); - } - - for (i = 0; i < len; i++) - { - RL_PUTC(vtbl, buf[i]); - } - } +#endif } } diff --git a/system/readline/std_readline.c b/system/readline/std_readline.c index 5f44fcf43..ba064abaf 100644 --- a/system/readline/std_readline.c +++ b/system/readline/std_readline.c @@ -147,7 +147,7 @@ static void readline_write(FAR struct rl_common_s *vtbl, * EOF is returned to indicate either an end of file condition or a * failure. * - **************************************************************************/ + ****************************************************************************/ ssize_t std_readline(FAR char *buf, int buflen) { diff --git a/system/symtab/.gitignore b/system/symtab/.gitignore new file mode 100644 index 000000000..84ab58307 --- /dev/null +++ b/system/symtab/.gitignore @@ -0,0 +1,12 @@ +/symtab.inc +/Make.dep +/.depend +/.built +/*.asm +/*.rel +/*.lst +/*.sym +/*.adb +/*.lib +/*.src +/*.obj diff --git a/system/symtab/Kconfig b/system/symtab/Kconfig new file mode 100644 index 000000000..ac83a48fa --- /dev/null +++ b/system/symtab/Kconfig @@ -0,0 +1,15 @@ +# +# For a description of the syntax of this configuration file, +# see the file kconfig-language.txt in the NuttX tools repository. +# + +config SYSTEM_SYMTAB + bool "User-provided symbol table" + default n + depends on EXECFUNCS_HAVE_SYMTAB && LIB_BOARDCTL + select BOARDCTL_SYMTAB + ---help--- + Build and include default symbol table in the NuttX application. + The symbol table is selected by call symtab_initialize(). The + table apps/system/symtab/symtab.inc has to be generated using + mksymtab manually before this option is selected. diff --git a/system/symtab/Makefile b/system/symtab/Makefile new file mode 100644 index 000000000..196c1a786 --- /dev/null +++ b/system/symtab/Makefile @@ -0,0 +1,104 @@ +############################################################################ +# apps/system/system/Makefile +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# +############################################################################ + +-include $(TOPDIR)/.config +-include $(TOPDIR)/Make.defs +include $(APPDIR)/Make.defs + +ifeq ($(WINTOOL),y) +INCDIROPT = -w +endif + +# Symbol table support + +ASRCS = +CSRCS = symtab.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(CONFIG_WINDOWS_NATIVE),y) + BIN = ..\..\libapps$(LIBEXT) +else +ifeq ($(WINTOOL),y) + BIN = ..\\..\\libapps$(LIBEXT) +else + BIN = ../../libapps$(LIBEXT) +endif +endif + +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 + +install: + +context: + +# 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 diff --git a/system/symtab/README.txt b/system/symtab/README.txt new file mode 100644 index 000000000..8de5e98ac --- /dev/null +++ b/system/symtab/README.txt @@ -0,0 +1,61 @@ +symtab +====== + +Symbol Tables and Build Modes +----------------------------- +This directory provide support for a symbol table which provides all/most of +system and C library services/functions to the application and NSH. + +Symbol tables have differing usefulness in different NuttX build modes: + + 1. In the FLAT build (CONFIG_BUILD_FLAT), symbol tables are used to bind + addresses in loaded ELF or NxFLAT modules to base code that usually + resides in FLASH memory. Both OS interfaces and user/application + libraries are made available to the loaded module via symbol tables. + + 2. Symbol tables may be of value in a protected build + (CONFIG_BUILD_PROTECTED) where the newly started user task must + share resources with other user code (but should use system calls to + interact with the OS). + + 3. But in the kernel build mode (CONFIG_BUILD_KERNEL), only fully linked + executables loadable via execl(), execv(), or posix_spawan() can used. + There is no use for a symbol table with the kernel build since all + memory resources are separate; nothing is share-able with the newly + started process. + +Creating the Canned Symbol Table +-------------------------------- +The support is selected by CONFIG_SYSTEM_SYMTAB option and table has to be +prepared in advance manually. It can be prepared from NuttX top level +directory by using the following commands: + + cd + cat syscall/syscall.csv libc/libc.csv | sort > /symtab/symtab.csv + tools/mksymtab /symtab/symtab.csv /symtab/symtab.inc + +where: + is the path to the NuttX top level build directory + is the path to the top level application directory + +You may want omit syscall/syscall.csv in the above command in the protected +mode. It is optional since the system calls are provided through system +call traps. + +Your board-level start up code code then needs to select the symbol table +by calling the function symtab_initialize(): + + #include + ... + symtab_initialize(); + +Code/Text Size Implications +--------------------------- +The option can have substantial effect on system image size, mainly +code/text. That is because the instructions to generate symtab.inc +above will cause EVERY interface in the NuttX RTOS and the C library to be +included into build. Add to that the size of a huge symbol table. + +In order to reduce the code/text size, you may want to manually prune the +auto-generated symtab.inc file to remove all interfaces that you do +not wish to include into the base FLASH image. diff --git a/system/symtab/symtab.c b/system/symtab/symtab.c new file mode 100644 index 000000000..49709c258 --- /dev/null +++ b/system/symtab/symtab.c @@ -0,0 +1,79 @@ +/**************************************************************************** + * apps/system/symtab/lib_symtab.c + * + * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Author: Pavel Pisa + * + * 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 + +#ifdef CONFIG_SYSTEM_SYMTAB + +#include +#include +#include + +#include "symtab.inc" + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: symtab_initialize + * + * Description: + * Setup a user provided symbol table. + * + * Input Parameters: + * None + * + * Returned Value: + * None + * + ****************************************************************************/ + +void symtab_initialize(void) +{ + /* We set the symbol table indirectly through the boardctl() */ + + struct boardioc_symtab_s symdesc; + + symdesc.symtab = g_symtab; + symdesc.nsymbols = NSYMBOLS; + (void)boardctl(BOARDIOC_SYMTAB, (uintptr_t)&symdesc); +} + +#endif /* CONFIG_SYSTEM_SYMTAB */ diff --git a/system/zmodem/host/nuttx/compiler.h b/system/zmodem/host/nuttx/compiler.h index f71dcff09..d145115f0 100644 --- a/system/zmodem/host/nuttx/compiler.h +++ b/system/zmodem/host/nuttx/compiler.h @@ -41,7 +41,7 @@ ****************************************************************************/ /**************************************************************************** - * Definitions + * Pre-processor Definitions ****************************************************************************/ /* GCC-specific definitions *************************************************/ @@ -158,11 +158,11 @@ #endif /**************************************************************************** - * Global Function Prototypes + * Public Function Prototypes ****************************************************************************/ /**************************************************************************** - * Global Function Prototypes + * Public Function Prototypes ****************************************************************************/ #endif /* __APPS_SYSTEM_ZMODEM_HOST_NUTTX_COMPILER_H */ diff --git a/system/zmodem/zm_send.c b/system/zmodem/zm_send.c index 7ddd4d5db..89d1663eb 100644 --- a/system/zmodem/zm_send.c +++ b/system/zmodem/zm_send.c @@ -1716,7 +1716,7 @@ int zms_send(ZMSHANDLE handle, FAR const char *filename, * irrecoverable error is detected or until the file is sent correctly. */ - return zm_datapump(&pzms->cmn); + return zm_datapump(&pzms->cmn); } /**************************************************************************** diff --git a/tools/mkkconfig.bat b/tools/mkkconfig.bat new file mode 100755 index 000000000..c2a2a1986 --- /dev/null +++ b/tools/mkkconfig.bat @@ -0,0 +1,141 @@ +@Echo off + +REM apps/tools/mkkconfig.bat +REM +REM Copyright (C) 2015 Gregory Nutt. All rights reserved. +REM Author: Gregory Nutt +REM +REM Redistribution and use in source and binary forms, with or without +REM modification, are permitted provided that the following conditions +REM are met: +REM +REM 1. Redistributions of source code must retain the above copyright +REM notice, this list of conditions and the following disclaimer. +REM 2. Redistributions in binary form must reproduce the above copyright +REM notice, this list of conditions and the following disclaimer in +REM the documentation and/or other materials provided with the +REM distribution. +REM 3. Neither the name NuttX nor the names of its contributors may be +REM used to endorse or promote products derived from this software +REM without specific prior written permission. +REM +REM THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +REM "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +REM LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +REM FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +REM COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +REM INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +REM BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +REM OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +REM AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +REM LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +REM ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +REM POSSIBILITY OF SUCH DAMAGE. +REM + +REM Parse command line arguments + +SET topdir= +SET kconfig=Kconfig + +:ArgLoop +IF "%1"=="" GOTO :EndOfLoop +IF "%1"=="-t" GOTO :SetTopDir +IF "%1"=="-o" GOTO :SetKconfig +IF "%1"=="-h" GOTO :ShowUsage + +Echo ERROR: Unrecogized option %1 +GOTO :ShowUsage + +:SetDebug +SET debug=-d +GOTO :NextArg + +:SetTopDir +SHIFT +SET topdir=%1 +GOTO :NextArg + +:SetKconfig +SHIFT +SET kconfig=%1 + +:NextArg +SHIFT +GOTO :ArgLoop + +REM Check input Parameters + +:EndOfLoop +IF "%topdir%"=="" ( + IF EXIST tools\mkkconfig.bat ( + SET topdir=%cd% + ) ELSE ( + cd .. + IF %ERRORLEVEL% GTR 0 ( + Echo ERROR: failed cd .. + GOTO :End + ) + IF EXIST tools\mkkconfig.bat ( + SET topdir=%cd% + ) ELSE ( + Echo ERROR: Cannot find top directory + GOTO :End + ) + ) +) ELSE ( + IF NOT EXIST "%topdir%" ( + Echo ERROR: %topdir% does not EXIST + GOTO :End + ) + Cd %topdir% + IF %ERRORLEVEL% GTR 0 ( + Echo ERROR: failed cd %topdir% + GOTO :End + ) +) + +IF EXIST %kconfig% ( + Del /f /q %kconfig% +REM IF %ERRORLEVEL% GTR 0 ( +REM Echo ERROR: failed to remove %kconfig% +REM GOTO :End +REM ) +) + +Echo # > %kconfig% +Echo # For a description of the syntax of this configuration file, >> %kconfig% +Echo # see the file kconfig-language.txt in the NuttX tools repository. >> %kconfig% +Echo # >> %kconfig% + +DIR /B /A:D >_tmp_.dat + +Echo source "$APPSDIR/builtin/Kconfig" >> %kconfig% +FOR /F "tokens=*" %%s IN (_tmp_.dat) do ( + if "%%s" NEQ "builtin" Echo source "$APPSDIR/%%s/Kconfig" >> %kconfig% +) +DEL _tmp_.dat + +GOTO :End + +REM Exit showing usage + +:ShowUsage +Echo USAGE: %0 [-d] [-t ^] [-o ^] +Echo %0 [-h] +Echo Where: +Echo ^<-d^>: +Echo Enables debug output +Echo -t ^: +Echo Identifies the top applicatino directory +Echo -o ^: +Echo Identifies the specific configuratin for the selected ^. +Echo This must correspond to a sub-directory under the board directory at +Echo under nuttx/configs/^/. +Echo ^<-h^>: +Echo Prints this message and exits. + +REM Exit + +:End + diff --git a/tools/mkkconfig.sh b/tools/mkkconfig.sh new file mode 100755 index 000000000..714ca5117 --- /dev/null +++ b/tools/mkkconfig.sh @@ -0,0 +1,107 @@ +#!/bin/bash +# apps/tools/mkkconfig.sh +# +# Copyright (C) 2015 Gregory Nutt. All rights reserved. +# Author: Gregory Nutt +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions +# are met: +# +# 1. Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# 2. Redistributions in binary form must reproduce the above copyright +# notice, this list of conditions and the following disclaimer in +# the documentation and/or other materials provided with the +# distribution. +# 3. Neither the name NuttX nor the names of its contributors may be +# used to endorse or promote products derived from this software +# without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS +# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE +# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, +# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, +# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS +# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED +# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT +# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN +# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE +# POSSIBILITY OF SUCH DAMAGE. +# + +# Get the input parameter list + +USAGE="USAGE: mkkconfig.sh [-d] [-h] [-t ] [-o ]" +unset TOPDIR +KCONFIG=Kconfig + +while [ ! -z "$1" ]; do + case $1 in + -d ) + set -x + ;; + -t ) + shift + TOPDIR=$1 + ;; + -o ) + shift + KCONFIG=$1 + ;; + -h ) + echo $USAGE + exit 0 + ;; + * ) + echo "ERROR: Unrecognized argument: $1" + echo $USAGE + exit 1 + ;; + esac + shift +done + +# Check arguments + +if [ -z "$TOPDIR" ]; then + if [ -x "tools/mkkconfig.sh" ]; then + TOPDIR=$PWD + else + cd .. || { echo "cd .. failed"; exit 1; } + if [ -x "tools/mkkconfig.sh" ]; then + TOPDIR=$PWD + else + echo "ERROR: This script must be executed from a known location" + echo " OR you must provide the path in the command line" + echo $USAGE + exit 1 + fi + fi +else + if [ ! -x "${TOPDIR}/tools/mkkconfig.sh" ]; then + echo "ERROR: \"${TOPDIR}\" is not correct" + echo $USAGE + exit 1 + fi + cd ${TOPDIR} || { echo "cd ${TOPDIR} failed"; exit 1; } +fi + +if [ -f ${TOPDIR}/${KCONFIG} ]; then + rm ${TOPDIR}/${KCONFIG} || { echo "ERROR: Failed to remove ${TOPDIR}/${KCONFIG}"; exit 1; } +fi + +KCONFIG_LIST=`ls -1 */Kconfig` + +echo "#" > ${TOPDIR}/${KCONFIG} +echo "# For a description of the syntax of this configuration file," >> ${TOPDIR}/${KCONFIG} +echo "# see the file kconfig-language.txt in the NuttX tools repository." >> ${TOPDIR}/${KCONFIG} +echo "#" >> ${TOPDIR}/${KCONFIG} +echo "" >> ${TOPDIR}/${KCONFIG} + +for FILE in ${KCONFIG_LIST}; do + echo "source \"\$APPSDIR/${FILE}\"" >> ${TOPDIR}/${KCONFIG} +done +