From b12d1dada94cd7083c2a5a023ec2e7a9a51c192a Mon Sep 17 00:00:00 2001 From: patacongo Date: Fri, 14 Sep 2012 14:07:21 +0000 Subject: Add XML RPC server plus NXWM build fixes from Max Holtzberg git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5150 42af7a65-404d-4744-a932-0658087f49c3 --- apps/ChangeLog.txt | 4 + apps/examples/Kconfig | 4 + apps/examples/Make.defs | 4 + apps/examples/README.txt | 25 +- apps/examples/xmlrpc/Kconfig | 45 ++ apps/examples/xmlrpc/Makefile | 106 ++++ apps/examples/xmlrpc/calls.c | 122 ++++ apps/examples/xmlrpc/xmlrpc_main.c | 419 +++++++++++++ apps/include/netutils/xmlrpc.h | 123 ++++ apps/netutils/Kconfig | 4 + apps/netutils/Make.defs | 4 + apps/netutils/Makefile | 2 +- apps/netutils/README.txt | 2 + apps/netutils/xmlrpc/Kconfig | 23 + apps/netutils/xmlrpc/Makefile | 99 +++ apps/netutils/xmlrpc/response.c | 287 +++++++++ apps/netutils/xmlrpc/xmlparser.c | 416 +++++++++++++ nuttx/ChangeLog | 9 +- nuttx/Makefile | 2 +- nuttx/arch/arm/src/stm32/Kconfig | 38 ++ nuttx/arch/arm/src/stm32/stm32_eth.c | 60 +- nuttx/configs/olimex-stm32-p107/nsh/defconfig | 2 +- nuttx/configs/sim/nxwm/defconfig | 2 +- nuttx/configs/stm3220g-eval/nxwm/defconfig | 2 +- nuttx/configs/stm3240g-eval/README.txt | 8 + nuttx/configs/stm3240g-eval/nxwm/defconfig | 2 +- nuttx/configs/stm3240g-eval/xmlrpc/Make.defs | 198 ++++++ nuttx/configs/stm3240g-eval/xmlrpc/defconfig | 866 ++++++++++++++++++++++++++ nuttx/configs/stm3240g-eval/xmlrpc/setenv.sh | 75 +++ nuttx/lib/string/Make.defs | 6 +- nuttx/lib/string/lib_strtod.c | 7 + nuttx/sched/task_exithook.c | 1 + nuttx/tools/xmlrpc_test.py | 48 ++ 33 files changed, 2990 insertions(+), 25 deletions(-) create mode 100644 apps/examples/xmlrpc/Kconfig create mode 100644 apps/examples/xmlrpc/Makefile create mode 100644 apps/examples/xmlrpc/calls.c create mode 100644 apps/examples/xmlrpc/xmlrpc_main.c create mode 100644 apps/include/netutils/xmlrpc.h create mode 100644 apps/netutils/xmlrpc/Kconfig create mode 100644 apps/netutils/xmlrpc/Makefile create mode 100644 apps/netutils/xmlrpc/response.c create mode 100644 apps/netutils/xmlrpc/xmlparser.c create mode 100644 nuttx/configs/stm3240g-eval/xmlrpc/Make.defs create mode 100644 nuttx/configs/stm3240g-eval/xmlrpc/defconfig create mode 100644 nuttx/configs/stm3240g-eval/xmlrpc/setenv.sh create mode 100644 nuttx/tools/xmlrpc_test.py diff --git a/apps/ChangeLog.txt b/apps/ChangeLog.txt index b7b71862e..7650b0ff4 100644 --- a/apps/ChangeLog.txt +++ b/apps/ChangeLog.txt @@ -325,4 +325,8 @@ utility (also contribed by Max Holtzberg). * apps/examples/*/main.c: Too many files called main.c. Each renamed to something unique so that they will not collide in the archive. + * apps/netutils/xmlrpc: The Embeddable Lightweight XML-RPC Server + discussed at http://www.drdobbs.com/web-development/\ + an-embeddable-lightweight-xml-rpc-server/184405364. Contributed by + Max Holtzberg. diff --git a/apps/examples/Kconfig b/apps/examples/Kconfig index 786012593..865268add 100644 --- a/apps/examples/Kconfig +++ b/apps/examples/Kconfig @@ -202,3 +202,7 @@ endmenu menu "WLAN Example" source "$APPSDIR/examples/wlan/Kconfig" endmenu + +menu "XML RPC Example" +source "$APPSDIR/examples/xmlrpc/Kconfig" +endmenu diff --git a/apps/examples/Make.defs b/apps/examples/Make.defs index 3bc72b52e..a6e0ae88e 100644 --- a/apps/examples/Make.defs +++ b/apps/examples/Make.defs @@ -225,3 +225,7 @@ endif ifeq ($(CONFIG_EXAMPLES_WLAN),y) CONFIGURED_APPS += examples/wlan endif + +ifeq ($(CONFIG_EXAMPLES_XMLRPC),y) +CONFIGURED_APPS += examples/xmlrpc +endif diff --git a/apps/examples/README.txt b/apps/examples/README.txt index 934eded4d..12d6d3892 100644 --- a/apps/examples/README.txt +++ b/apps/examples/README.txt @@ -1668,8 +1668,27 @@ examples/wget file in the configuration driver with instruction to build applications like: - CONFIGURED_APPS += uiplib - CONFIGURED_APPS += resolv - CONFIGURED_APPS += webclient + CONFIGURED_APPS += uiplib + CONFIGURED_APPS += resolv + CONFIGURED_APPS += webclient +examples/xmlrpc + + This example exercises the "Embeddable Lightweight XML-RPC Server" which + is discussed at: + + http://www.drdobbs.com/web-development/an-embeddable-lightweight-xml-rpc-server/184405364 + + Configuration options: + CONFIG_EXAMPLES_XMLRPC_BUFFERSIZE - HTTP buffer size. Default 1024 + CONFIG_EXAMPLES_XMLRPC_DHCPC - Use DHCP Client. Default n. Ignored + if CONFIG_NSH_BUILTIN_APPS is selected. + CONFIG_EXAMPLES_XMLRPC_NOMAC - Use Canned MAC Address. Defaul n. Ignored + if CONFIG_NSH_BUILTIN_APPS is selected. + CONFIG_EXAMPLES_XMLRPC_IPADDR - Target IP address. Default 0x0a000002. + Ignored if CONFIG_NSH_BUILTIN_APPS is selected. + CONFIG_EXAMPLES_XMLRPC_DRIPADDR - Default Router IP address (Gateway). + 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. diff --git a/apps/examples/xmlrpc/Kconfig b/apps/examples/xmlrpc/Kconfig new file mode 100644 index 000000000..ee61feb50 --- /dev/null +++ b/apps/examples/xmlrpc/Kconfig @@ -0,0 +1,45 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config EXAMPLES_XMLRPC + bool "XML RPC example" + default n + depends on NET_TCP && !DISABLE_POLL + select NETUTILS_XMLRPC + ---help--- + An example for the netutils/xmlrpc library. + This example implements a lightweight HTTP server and uses the xmlrpc lib + for parsing xml remote procedure calls. + +config EXAMPLES_XMLRPC_BUFFERSIZE + int "HTTP buffer size" + default 1024 + +config EXAMPLES_XMLRPC_DHCPC + bool "DHCP Client" + default n + depends on EXAMPLES_XMLRPC && !NSH_BUILTIN_APPS + select NETUTILS_DHCPC + select NETUTILS_RESOLV + +config EXAMPLES_XMLRPC_NOMAC + bool "Use Canned MAC Address" + default n + depends on EXAMPLES_XMLRPC && !NSH_BUILTIN_APPS + +config EXAMPLES_XMLRPC_IPADDR + hex "Target IP address" + default 0x0a000002 + depends on EXAMPLES_XMLRPC && !NSH_BUILTIN_APPS && !EXAMPLES_XMLRPC_DHCPC + +config EXAMPLES_XMLRPC_DRIPADDR + hex "Default Router IP address (Gateway)" + default 0x0a000001 + depends on EXAMPLES_XMLRPC && !NSH_BUILTIN_APPS + +config EXAMPLES_XMLRPC_NETMASK + hex "Network Mask" + default 0xffffff00 + depends on EXAMPLES_XMLRPC && !NSH_BUILTIN_APPS diff --git a/apps/examples/xmlrpc/Makefile b/apps/examples/xmlrpc/Makefile new file mode 100644 index 000000000..9fa03bf7e --- /dev/null +++ b/apps/examples/xmlrpc/Makefile @@ -0,0 +1,106 @@ +############################################################################ +# apps/examples/xmlrpc/Makefile +# +# Copyright (C) 2012 Max Holtzberg. All rights reserved. +# Copyright (C) 2008, 2010-2012 Gregory Nutt. All rights reserved. +# +# Authors: Max Holtzberg +# 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 + +# XML RPC built-in application info + +APPNAME = xmlrpc +PRIORITY = SCHED_PRIORITY_DEFAULT +STACKSIZE = 2048 + +ASRCS = +CSRCS = xmlrpc_main.c calls.c + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: clean depend distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +.context: +ifeq ($(CONFIG_NSH_BUILTIN_APPS),y) + $(call REGISTER,$(APPNAME),$(PRIORITY),$(STACKSIZE),$(APPNAME)_main) + @touch $@ +endif + +context: .context + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/apps/examples/xmlrpc/calls.c b/apps/examples/xmlrpc/calls.c new file mode 100644 index 000000000..bda164f4d --- /dev/null +++ b/apps/examples/xmlrpc/calls.c @@ -0,0 +1,122 @@ +/**************************************************************************** + * apps/examples/xmlrpc/calls.c + * + * Copyright (C) 2012 Max Holtzberg. All rights reserved. + * Author: Max Holtzberg + * + * Based on the embeddable lightweight XML-RPC server code discussed + * in the article at: http://www.drdobbs.com/web-development/\ + * an-embeddable-lightweight-xml-rpc-server/184405364 + * + * Copyright (c) 2002 Cogito LLC. All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, is hereby granted without fee 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 of Cogito LLC 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 COGITO LLC AND CONTRIBUTERS 'AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COGITO LLC + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARAY, 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 + +/**************************************************************************** + * Private Function Prototypes + ****************************************************************************/ + +static int calls_get_device_stats(struct xmlrpc_s *xmlcall); + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +struct xmlrpc_entry_s get_device_stats = +{ + .name = "get_device_stats", + .func = calls_get_device_stats +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int calls_get_device_stats(struct xmlrpc_s *xmlcall) +{ + char username[80], password[80]; + char lastCommand[80], curState[80]; + int request = 0, status, ret; + + do + { + ret = xmlrpc_getstring(xmlcall, username); + if (ret != XMLRPC_NO_ERROR) + { + break; + } + + ret = xmlrpc_getstring(xmlcall, password); + if (ret != XMLRPC_NO_ERROR) + { + break; + } + + ret = xmlrpc_getinteger(xmlcall, &request); + if (ret != XMLRPC_NO_ERROR) + { + break; + } + } + while (0); + + if (ret == XMLRPC_NO_ERROR) + { + /* Dummy up some data... */ + + status = 1; + strcpy(lastCommand, "reboot"); + strcpy(curState, "Normal Operation"); + + ret = xmlrpc_buildresponse(xmlcall, "{iss}", + "status", status, + "lastCommand", lastCommand, + "currentState", curState); + } + + return ret; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +void calls_register(void) +{ + xmlrpc_register(&get_device_stats); +} diff --git a/apps/examples/xmlrpc/xmlrpc_main.c b/apps/examples/xmlrpc/xmlrpc_main.c new file mode 100644 index 000000000..5f5ce5f06 --- /dev/null +++ b/apps/examples/xmlrpc/xmlrpc_main.c @@ -0,0 +1,419 @@ +/**************************************************************************** + * apps/examples/xmlrpc/xmlrpc_main.c + * + * Copyright (C) 2012 Max Holtzberg. All rights reserved. + * Author: Max Holtzberg + * + * Based on the embeddable lightweight XML-RPC server code discussed + * in the article at: http://www.drdobbs.com/web-development/\ + * an-embeddable-lightweight-xml-rpc-server/184405364 + * + * Copyright (c) 2002 Cogito LLC. All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, is hereby granted without fee 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 of Cogito LLC 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 COGITO LLC AND CONTRIBUTERS 'AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COGITO LLC + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARAY, 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. + ****************************************************************************/ + +/* + * Lightweight Embedded XML-RPC Server main + * + * mtj@cogitollc.com + * + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include +#include +#include + +#include +#include + +#ifdef CONFIG_EXAMPLES_XMLRPC_DHCPC +# include +#endif + +/* Here we include the header file for the application(s) we use in + * our project as defined in the config//defconfig file + */ + +/* DHCPC may be used in conjunction with any other feature (or not) */ + +#ifdef CONFIG_EXAMPLES_XMLRPC_DHCPC +# include +# include +#endif + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static const char *notimplemented = { "HTTP/1.1 501 Not Implemented\n\n" }; +static const char *separator = { "\015\012\015\012" }; + +/**************************************************************************** + * External Function Prototypes + ****************************************************************************/ + +extern void calls_register(void); + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: xmlrpc_findbody + * + * Description: + * Find the message body of an HTTP Request Message + * + ****************************************************************************/ + +static char *xmlrpc_findbody(char *buf) +{ + char *temp; + + temp = strstr(buf, separator); + + if (temp == NULL) + { + return NULL; + } + else + { + return temp + 4; + } +} + +/**************************************************************************** + * Name: xmlrpc_getheader + * + * Description: + * Find the HTTP header and return it's value. + * + ****************************************************************************/ + +static int xmlrpc_getheader(char *buffer, char *header, char *value, int size) +{ + char *temp; + int i = 0; + + temp = strstr(buffer, header); + if (temp) + { + /* Skip the header element */ + + temp += strlen(header); + + /* Skip any white-space */ + + while (*temp == ' ') + { + temp++; + } + + /* Copy the rest to the value parameter */ + + while ((*temp != ' ') && (*temp != '\n') && (i < size)) + { + value[i++] = *temp++; + } + + value[i] = 0; + return i; + } + + return -1; +} + +/**************************************************************************** + * Name: xmlrpc_handler + * + * Description: + * Parse and handle the current HTTP request message. + * + ****************************************************************************/ + +static void xmlrpc_handler(int fd) +{ + fd_set rfds; + struct timeval tv; + int ret, len, max = 0, loadlen = -1; + char buffer[CONFIG_EXAMPLES_XMLRPC_BUFFERSIZE] = { 0 }; + char value[CONFIG_XMLRPC_STRINGSIZE + 1]; + char *temp; + + /* Read in the Request Header */ + + do + { + FD_ZERO(&rfds); + FD_SET(fd, &rfds); + + tv.tv_sec = 1; + tv.tv_usec = 0; + + ndbg("[%d] select...\n", fd); + ret = select(fd + 1, &rfds, NULL, NULL, &tv); + ndbg("[%d] data ready\n", fd); + + if (ret > 0) + { + if (FD_ISSET(fd, &rfds)) + { + len = recv(fd, &buffer[max], 1024, 0); + ndbg("[%d] %d bytes received\n", fd, len); + + if (len > 0) + { + max += len; + buffer[max] = 0; + + ret = xmlrpc_getheader(buffer, "Content-Length:", value, + CONFIG_EXAMPLES_XMLRPC_BUFFERSIZE); + if (ret > 0) + loadlen = atoi(value); + } + else + { + ret = -1; + break; + } + } + } + else + { + /* Timeout... */ + + ndbg("[%d] timeout\n", fd); + ret = -1; + break; + } + + temp = strstr(buffer, separator); + + if (temp) + { + if (strlen(temp) - 4 == loadlen) + break; + } + + } + while (1); + + /* Determine request */ + + if (!strncmp(buffer, "POST", 4)) + { + temp = xmlrpc_findbody(buffer); + xmlrpc_parse(fd, temp); + } + else + { + write(fd, notimplemented, strlen(notimplemented)); + } +} + +/**************************************************************************** + * Name: xmlrpc_netinit + * + * Description: + * Setup network configuration. + * + ****************************************************************************/ + +static int xmlrpc_netinit(void) +{ + /* If this task is excecutated as an NSH built-in function, then the network + * has already been configured by NSH's start-up logic. + */ + +#ifndef CONFIG_NSH_BUILTIN_APPS + struct in_addr addr; +#if defined(CONFIG_EXAMPLES_XMLRPC_DHCPC) || defined(CONFIG_EXAMPLES_XMLRPC_NOMAC) + uint8_t mac[IFHWADDRLEN]; +#endif +#ifdef CONFIG_EXAMPLES_XMLRPC_DHCPC + void *handle; +#endif + +/* Many embedded network interfaces must have a software assigned MAC */ + +#ifdef CONFIG_EXAMPLES_XMLRPC_NOMAC + mac[0] = 0x00; + mac[1] = 0xe0; + mac[2] = 0xde; + mac[3] = 0xad; + mac[4] = 0xbe; + mac[5] = 0xef; + uip_setmacaddr("eth0", mac); +#endif + + /* Set up our host address */ + +#ifdef CONFIG_EXAMPLES_XMLRPC_DHCPC + addr.s_addr = 0; +#else + addr.s_addr = HTONL(CONFIG_EXAMPLES_XMLRPC_IPADDR); +#endif + uip_sethostaddr("eth0", &addr); + + /* Set up the default router address */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_XMLRPC_DRIPADDR); + uip_setdraddr("eth0", &addr); + + /* Setup the subnet mask */ + + addr.s_addr = HTONL(CONFIG_EXAMPLES_XMLRPC_NETMASK); + uip_setnetmask("eth0", &addr); + +#ifdef CONFIG_EXAMPLES_XMLRPC_DHCPC + /* Set up the resolver */ + + resolv_init(); + + /* Get the MAC address of the NIC */ + + uip_getmacaddr("eth0", mac); + + /* Set up the DHCPC modules */ + + handle = dhcpc_open(&mac, IFHWADDRLEN); + + /* Get an IP address. Note: there is no logic here for renewing the address + * in this example. The address should be renewed in ds.lease_time/2 + * seconds. + */ + + printf("Getting IP address\n"); + if (handle) + { + struct dhcpc_state ds; + (void)dhcpc_request(handle, &ds); + uip_sethostaddr("eth1", &ds.ipaddr); + + if (ds.netmask.s_addr != 0) + { + uip_setnetmask("eth0", &ds.netmask); + } + + if (ds.default_router.s_addr != 0) + { + uip_setdraddr("eth0", &ds.default_router); + } + + if (ds.dnsaddr.s_addr != 0) + { + resolv_conf(&ds.dnsaddr); + } + + dhcpc_close(handle); + printf("IP: %s\n", inet_ntoa(ds.ipaddr)); + } + +#endif /* CONFIG_EXAMPLES_XMLRPC_DHCPC */ +#endif /* CONFIG_NSH_BUILTIN_APPS */ + + return OK; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +/**************************************************************************** + * Name: xmlrpc_main + * + * Description: + * The embedded HTTP server main + * + ****************************************************************************/ + +int xmlrpc_main(int argc, char *argv[]) +{ + int listenfd, connfd, on = 1; + socklen_t clilen; + struct sockaddr_in cliaddr, servaddr; + + if (xmlrpc_netinit() < 0) + { + ndbg("Could not initialize the network interface\n"); + return ERROR; + } + + /* Register RPC functions. */ + + calls_register(); + + listenfd = socket(AF_INET, SOCK_STREAM, 0); + + setsockopt(listenfd, SOL_SOCKET, SO_REUSEADDR, &on, sizeof(on)); + + bzero((void *)&servaddr, sizeof(servaddr)); + servaddr.sin_family = AF_INET; + servaddr.sin_addr.s_addr = htonl(INADDR_ANY); + servaddr.sin_port = htons(80); + + bind(listenfd, (struct sockaddr *)&servaddr, sizeof(servaddr)); + + listen(listenfd, 5); + + for (;;) + { + clilen = sizeof(cliaddr); + connfd = accept(listenfd, (struct sockaddr *)&cliaddr, &clilen); + if (connfd <= 0) + { + break; + } + ndbg("Connection accepted: %d\n", connfd); + + xmlrpc_handler(connfd); + close(connfd); + ndbg("[%d] connection closed\n", connfd); + } + + close(listenfd); + return (0); +} diff --git a/apps/include/netutils/xmlrpc.h b/apps/include/netutils/xmlrpc.h new file mode 100644 index 000000000..3136e35ef --- /dev/null +++ b/apps/include/netutils/xmlrpc.h @@ -0,0 +1,123 @@ +/**************************************************************************** + * apps/include/netutils/xmlrpc.h + * + * Copyright (C) 2012 Max Holtzberg. All rights reserved. + * Author: Max Holtzberg + * + * Based on the embeddable lightweight XML-RPC server code discussed + * in the article at: http://www.drdobbs.com/web-development/\ + * an-embeddable-lightweight-xml-rpc-server/184405364 + * + * Copyright (c) 2002 Cogito LLC. All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, is hereby granted without fee 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 of Cogito LLC 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 COGITO LLC AND CONTRIBUTERS 'AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COGITO LLC + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARAY, 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. + ****************************************************************************/ + +/* + * Lightweight Embedded XML-RPC Server Types and Definitions + * + * mtj@cogitollc.com + * + */ + +#ifndef __APPS_INCLUDE_NETUTILS_XMLRPC_H +#define __APPS_INCLUDE_NETUTILS_XMLRPC_H + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +/* Error definitions. */ + +#define XMLRPC_NO_ERROR (0) +#define XMLRPC_PARSE_ERROR (-1) +#define XMLRPC_NO_SUCH_FUNCTION (-2) +#define XMLRPC_UNEXPECTED_INTEGER_ARG (-3) +#define XMLRPC_UNEXPECTED_BOOLEAN_ARG (-4) +#define XMLRPC_UNEXPECTED_DOUBLE_ARG (-5) +#define XMLRPC_UNEXPECTED_STRING_ARG (-6) +#define XMLRPC_BAD_RESPONSE_ARG (-7) +#define XMLRPC_INTERNAL_ERROR (-99) + +#define MAX_ARGS 10 +#define MAX_RESPONSE 2048 + +/**************************************************************************** + * Public Types + ****************************************************************************/ + +struct xmlrpc_arg_s +{ + union + { + int i; + char boolean; + double d; + char string[CONFIG_XMLRPC_STRINGSIZE+1]; + } u; +}; + +struct xmlrpc_s +{ + char name[CONFIG_XMLRPC_STRINGSIZE+1]; + struct xmlrpc_arg_s arguments[MAX_ARGS]; + char args[MAX_ARGS]; + int argsize; + int arg; + char response[MAX_RESPONSE]; + int error; +}; + +struct xmlrpc_entry_s +{ + struct xmlrpc_entry_s *next; + int (*func)(struct xmlrpc_s*); + char *name; +}; + +/**************************************************************************** + * Public Function Prototypes + ****************************************************************************/ + +void xmlrpc_register(struct xmlrpc_entry_s *call); +int xmlrpc_parse(int sock, char *buffer); +int xmlrpc_getinteger(struct xmlrpc_s *xmlcall, int *arg); +int xmlrpc_getbool(struct xmlrpc_s *xmlcall, int *arg); +int xmlrpc_getdouble(struct xmlrpc_s *xmlcall, double *arg); +int xmlrpc_getstring(struct xmlrpc_s *xmlcall, char *arg); +int xmlrpc_buildresponse(struct xmlrpc_s *, char *, ...); + +#endif /* __APPS_INCLUDE_NETUTILS_XMLRPC_H */ diff --git a/apps/netutils/Kconfig b/apps/netutils/Kconfig index aa0f14963..4141e5b03 100644 --- a/apps/netutils/Kconfig +++ b/apps/netutils/Kconfig @@ -56,3 +56,7 @@ endmenu menu "UDP Discovery Utility" source "$APPSDIR/netutils/discover/Kconfig" endmenu + +menu "XML-RPC library" +source "$APPSDIR/netutils/xmlrpc/Kconfig" +endmenu diff --git a/apps/netutils/Make.defs b/apps/netutils/Make.defs index f957009b5..ae72ab0fd 100644 --- a/apps/netutils/Make.defs +++ b/apps/netutils/Make.defs @@ -85,3 +85,7 @@ endif ifeq ($(CONFIG_NETUTILS_DISCOVER),y) CONFIGURED_APPS += netutils/discover endif + +ifeq ($(CONFIG_NETUTILS_XMLRPC),y) +CONFIGURED_APPS += netutils/xmlrpc +endif diff --git a/apps/netutils/Makefile b/apps/netutils/Makefile index 03261c7a3..058b0f629 100644 --- a/apps/netutils/Makefile +++ b/apps/netutils/Makefile @@ -39,7 +39,7 @@ ifeq ($(CONFIG_NET),y) SUBDIRS = uiplib dhcpc dhcpd discover ftpc ftpd resolv smtp telnetd -SUBDIRS += webclient webserver tftpc thttpd +SUBDIRS += webclient webserver tftpc thttpd xmlrpc endif all: nothing diff --git a/apps/netutils/README.txt b/apps/netutils/README.txt index 231cf62c1..73e6689fe 100644 --- a/apps/netutils/README.txt +++ b/apps/netutils/README.txt @@ -66,6 +66,8 @@ highly influenced by uIP) include: CONFIGURED_APPS += uiplib CONFIGURED_APPS += thttpd + xmlrpc - The Embeddable Lightweight XML-RPC Server discussed at + http://www.drdobbs.com/web-development/an-embeddable-lightweight-xml-rpc-server/184405364 Tips for Using Telnetd ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/apps/netutils/xmlrpc/Kconfig b/apps/netutils/xmlrpc/Kconfig new file mode 100644 index 000000000..6765bda07 --- /dev/null +++ b/apps/netutils/xmlrpc/Kconfig @@ -0,0 +1,23 @@ +# +# For a description of the syntax of this configuration file, +# see misc/tools/kconfig-language.txt. +# + +config NETUTILS_XMLRPC + bool "XML RPC library" + default n + depends on NET_TCP + select NETUTILS_UIPLIB + ---help--- + Enables the Embeddable Lightweight XML-RPC Server discussed at + http://www.drdobbs.com/web-development/an-embeddable-lightweight-xml-rpc-server/184405364 + +if NETUTILS_XMLRPC + +config XMLRPC_STRINGSIZE + int "Maximum string length" + default 64 + ---help--- + Maximum string length for method names and XML RPC string values. + +endif diff --git a/apps/netutils/xmlrpc/Makefile b/apps/netutils/xmlrpc/Makefile new file mode 100644 index 000000000..903506f46 --- /dev/null +++ b/apps/netutils/xmlrpc/Makefile @@ -0,0 +1,99 @@ +############################################################################ +# apps/netutils/xmlrpc/Makefile +# +# Copyright (C) 2012 Max Holtzberg. All rights reserved. +# Copyright (C) 2011-2012 Gregory Nutt. All rights reserved. +# +# Authors: Max Holtzberg +# 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 + + +ASRCS = +CSRCS = + +ifeq ($(CONFIG_NET_TCP),y) +CSRCS += xmlparser.c response.c +endif + +AOBJS = $(ASRCS:.S=$(OBJEXT)) +COBJS = $(CSRCS:.c=$(OBJEXT)) + +SRCS = $(ASRCS) $(CSRCS) +OBJS = $(AOBJS) $(COBJS) + +ifeq ($(WINTOOL),y) + BIN = "${shell cygpath -w $(APPDIR)/libapps$(LIBEXT)}" +else + BIN = "$(APPDIR)/libapps$(LIBEXT)" +endif + +ROOTDEPPATH = --dep-path . + +# Common build + +VPATH = + +all: .built +.PHONY: context depend clean distclean + +$(AOBJS): %$(OBJEXT): %.S + $(call ASSEMBLE, $<, $@) + +$(COBJS): %$(OBJEXT): %.c + $(call COMPILE, $<, $@) + +.built: $(OBJS) + @( for obj in $(OBJS) ; do \ + $(call ARCHIVE, $(BIN), $${obj}); \ + done ; ) + @touch .built + +context: + +.depend: Makefile $(SRCS) + @$(MKDEP) $(ROOTDEPPATH) $(CC) -- $(CFLAGS) -- $(SRCS) >Make.dep + @touch $@ + +depend: .depend + +clean: + @rm -f *.o *~ .*.swp .built + $(call CLEAN) + +distclean: clean + @rm -f Make.dep .depend + +-include Make.dep diff --git a/apps/netutils/xmlrpc/response.c b/apps/netutils/xmlrpc/response.c new file mode 100644 index 000000000..2ae7414a7 --- /dev/null +++ b/apps/netutils/xmlrpc/response.c @@ -0,0 +1,287 @@ +/**************************************************************************** + * apps/netutils/xmlrpc/response.c + * + * Copyright (C) 2012 Max Holtzberg. All rights reserved. + * Author: Max Holtzberg + * + * Based on the embeddable lightweight XML-RPC server code discussed + * in the article at: http://www.drdobbs.com/web-development/\ + * an-embeddable-lightweight-xml-rpc-server/184405364 + * + * Copyright (c) 2002 Cogito LLC. All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, is hereby granted without fee 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 of Cogito LLC 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 COGITO LLC AND CONTRIBUTERS 'AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COGITO LLC + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARAY, 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. + ****************************************************************************/ + +/* + * Lightweight Embedded XML-RPC Server Response Generator + * + * mtj@cogitollc.com + * + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int xmlrpc_insertlength(struct xmlrpc_s * xmlcall) +{ + int len, digit, xdigit = 1000, i = 0; + char *temp; + + temp = strstr(xmlcall->response, "response, "xyza"); + + do + { + digit = (len / xdigit); + len -= (digit * xdigit); + xdigit /= 10; + + if ((digit == 0) && (xdigit > 1)) + temp[i++] = ' '; + else + temp[i++] = (0x30 + digit); + } + while (i < 4); + + return 0; +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int xmlrpc_getinteger(struct xmlrpc_s * xmlcall, int *arg) +{ + if ((xmlcall == NULL) || (arg == NULL)) + { + return XMLRPC_INTERNAL_ERROR; + } + + if ((xmlcall->arg < xmlcall->argsize) && + (xmlcall->args[xmlcall->arg] == 'i')) + { + *arg = xmlcall->arguments[xmlcall->arg++].u.i; + return 0; + } + + return XMLRPC_UNEXPECTED_INTEGER_ARG; +} + +int xmlrpc_getbool(struct xmlrpc_s * xmlcall, int *arg) +{ + if ((xmlcall == NULL) || (arg == NULL)) + { + return XMLRPC_INTERNAL_ERROR; + } + + if ((xmlcall->arg < xmlcall->argsize) && + (xmlcall->args[xmlcall->arg] == 'b')) + { + *arg = xmlcall->arguments[xmlcall->arg++].u.i; + return 0; + } + + return XMLRPC_UNEXPECTED_BOOLEAN_ARG; +} + +int xmlrpc_getdouble(struct xmlrpc_s * xmlcall, double *arg) +{ + if ((xmlcall == NULL) || (arg == NULL)) + { + return XMLRPC_INTERNAL_ERROR; + } + + if ((xmlcall->arg < xmlcall->argsize) && + (xmlcall->args[xmlcall->arg] == 'd')) + { + *arg = xmlcall->arguments[xmlcall->arg++].u.d; + return 0; + } + + return XMLRPC_UNEXPECTED_DOUBLE_ARG; +} + +int xmlrpc_getstring(struct xmlrpc_s* xmlcall, char *arg) +{ + if ((xmlcall == NULL) || (arg == NULL)) + { + return XMLRPC_INTERNAL_ERROR; + } + + if ((xmlcall->arg < xmlcall->argsize) && + (xmlcall->args[xmlcall->arg] == 's')) + { + strcpy(arg, xmlcall->arguments[xmlcall->arg++].u.string); + return 0; + } + + return XMLRPC_UNEXPECTED_STRING_ARG; +} + +int xmlrpc_buildresponse(struct xmlrpc_s* xmlcall, char *args, ...) +{ + va_list argp; + int i, ret = 0, index = 0, close = 0; + double d; + char *s; + int isStruct = 0; + + if ((xmlcall == NULL) || (args == NULL)) + { + return -1; + } + + strcpy(xmlcall->response, "HTTP/1.1 200 OK\n" + "Connection: close\n" + "Content-length: xyza\n" + "Content-Type: text/xml\n" + "Server: Lightweight XMLRPC\n\n" + "\n" "\n"); + + if (xmlcall->error) + { + strcat(&xmlcall->response[strlen(xmlcall->response)], " \n"); + } + else + { + strcat(&xmlcall->response[strlen(xmlcall->response)], + " \n"); + } + + va_start(argp, args); + + while (args[index]) + { + if (isStruct) + { + if ((args[index] != '{') && (args[index] != '}')) + { + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " \n"); + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " %s\n", va_arg(argp, char *)); + close = 1; + } + } + + switch (args[index]) + { + case '{': + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " \n"); + isStruct = 1; + break; + + case '}': + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " \n"); + isStruct = 0; + break; + + case 'i': + i = va_arg(argp, int); + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " %d\r\n", i); + break; + + case 'b': + i = va_arg(argp, int); + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " %d\r\n", i); + break; + + case 'd': + d = va_arg(argp, double); + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " %f\r\n", d); + break; + + case 's': + s = va_arg(argp, char *); + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " %s\r\n", s); + break; + + default: + return (XMLRPC_BAD_RESPONSE_ARG); + break; + + } + + if (close) + { + sprintf(&xmlcall->response[strlen(xmlcall->response)], + " \n"); + close = 0; + } + + index++; + } + + va_end(argp); + + if (xmlcall->error) + { + strcat(&xmlcall->response[strlen(xmlcall->response)], " \r\n"); + } + else + { + strcat(&xmlcall->response[strlen(xmlcall->response)], + " \r\n"); + } + + if (ret == 0) + { + strcat(&xmlcall->response[strlen(xmlcall->response)], + "\r\n"); + + xmlrpc_insertlength(xmlcall); + } + else + { + xmlcall->response[0] = 0; + } + + return ret; +} diff --git a/apps/netutils/xmlrpc/xmlparser.c b/apps/netutils/xmlrpc/xmlparser.c new file mode 100644 index 000000000..72387a08e --- /dev/null +++ b/apps/netutils/xmlrpc/xmlparser.c @@ -0,0 +1,416 @@ +/**************************************************************************** + * apps/netutils/xmlrpc/xmlparser.c + * + * Copyright (C) 2012 Max Holtzberg. All rights reserved. + * Author: Max Holtzberg + * + * Based on the embeddable lightweight XML-RPC server code discussed + * in the article at: http://www.drdobbs.com/web-development/\ + * an-embeddable-lightweight-xml-rpc-server/184405364 + * + * Copyright (c) 2002 Cogito LLC. All rights reserved. + * + * Redistribution and use in source and binary forms, with or + * without modification, is hereby granted without fee 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 of Cogito LLC 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 COGITO LLC AND CONTRIBUTERS 'AS IS' + * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A + * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COGITO LLC + * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARAY, 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. + ****************************************************************************/ + +/* + * Lightweight Embedded XML-RPC Server XML Parser + * + * mtj@cogitollc.com + * + */ + +/**************************************************************************** + * Included Files + ****************************************************************************/ + +#include +#include +#include +#include +#include +#include + +/**************************************************************************** + * Pre-processor Definitions + ****************************************************************************/ + +#define TAG 0 +#define VALUE 1 +#define DONE 2 + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +static struct xmlrpc_s g_xmlcall; +static char g_data[CONFIG_XMLRPC_STRINGSIZE+1]; +static struct xmlrpc_entry_s *g_entries = NULL; + +static const char *errorStrings[] = +{ + /* 0 */ "Internal error (unknown)", + /* 1 */ "Parse Error...", + /* 2 */ "Function not found...", + /* 3 */ "Unexpected Integer Argument...", + /* 4 */ "Unexpected Boolean Argument...", + /* 5 */ "Unexpected Double Argument...", + /* 6 */ "Unexpected String Argument...", + /* 7 */ "Bad Response Argument..." +}; + +#define MAX_ERROR_CODE (sizeof(errorStrings)/sizeof(char *)) + +struct parsebuf_s +{ + char *buf; + int len; + int index; +}; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +static int xmlrpc_call(struct xmlrpc_s * call) +{ + int ret = XMLRPC_NO_SUCH_FUNCTION; + struct xmlrpc_entry_s *entry = g_entries; + + while (entry != NULL) + { + if (strcmp(call->name, entry->name) == 0) + { + ret = entry->func(call); + break; + } + else + { + entry = entry->next; + } + } + + return ret; +} + +static int xmlrpc_getelement(struct parsebuf_s * pbuf, char *data, int dataSize) +{ + int j = 0; + int ret = XMLRPC_NO_ERROR; + + while (!isprint(pbuf->buf[pbuf->index])) + { + pbuf->index++; + } + + if (pbuf->index >= pbuf->len) + { + return DONE; + } + + if (pbuf->buf[pbuf->index] == '<') + { + ret = TAG; + } + else + { + ret = VALUE; + } + + data[j++] = pbuf->buf[pbuf->index++]; + + while (j < dataSize) + { + if (pbuf->buf[pbuf->index] == '>') + { + data[j++] = pbuf->buf[pbuf->index++]; + break; + } + else if ((pbuf->buf[pbuf->index] == '\n') || + (pbuf->buf[pbuf->index] == '<')) + { + break; + } + else + { + data[j++] = pbuf->buf[pbuf->index++]; + if (j >= dataSize) + ret = XMLRPC_PARSE_ERROR; + } + } + + data[j] = 0; + return ret; +} + +static int xmlrpc_parseparam(struct parsebuf_s * pbuf) +{ + int type; + + /* Next, we need a tag */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if (!((type == TAG) && (!strncmp(g_data, "", 7)))) + { + return XMLRPC_PARSE_ERROR; + } + + /* Now we get a variable tag, the type of the value */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if (type != TAG) + { + return XMLRPC_PARSE_ERROR; + } + + if (!strncmp(g_data, "", 4)) + { + g_xmlcall.args[g_xmlcall.argsize] = 'i'; + } + else if (!strncmp(g_data, "", 5)) + { + g_xmlcall.args[g_xmlcall.argsize] = 'i'; + } + else if (!strncmp(g_data, "", 9)) + { + g_xmlcall.args[g_xmlcall.argsize] = 'b'; + } + else if (!strncmp(g_data, "", 8)) + { + g_xmlcall.args[g_xmlcall.argsize] = 'd'; + } + else if (!strncmp(g_data, "", 8)) + { + g_xmlcall.args[g_xmlcall.argsize] = 's'; + } + else + { + return XMLRPC_PARSE_ERROR; + } + + /* Now, parse the actual value */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if (type != VALUE) + { + return XMLRPC_PARSE_ERROR; + } + + switch (g_xmlcall.args[g_xmlcall.argsize]) + { + case 'i': + case 'b': + g_xmlcall.arguments[g_xmlcall.argsize].u.i = atoi(g_data); + break; + case 'd': + g_xmlcall.arguments[g_xmlcall.argsize].u.d = atof(g_data); + break; + case 's': + strcpy(g_xmlcall.arguments[g_xmlcall.argsize].u.string, g_data); + break; + default: + return XMLRPC_PARSE_ERROR; + } + + g_xmlcall.argsize++; + + /* Now we close out the tag, starting with the type */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if (!((type == TAG) && (!strncmp(g_data, " close */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if (!((type == TAG) && (!strncmp(g_data, "", 8)))) + { + return XMLRPC_PARSE_ERROR; + } + + /* Finally, close out the tag */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if (!((type == TAG) && (!strncmp(g_data, "", 8)))) + { + return XMLRPC_PARSE_ERROR; + } + + return XMLRPC_NO_ERROR; +} + +static int xmlrpc_parseparams(struct parsebuf_s * pbuf) +{ + int type, ret = XMLRPC_PARSE_ERROR; + + /* First, look for the params tag */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if ((type == TAG) && (!strncmp(g_data, "", 8))) + { + while (1) + { + /* Get next tag */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if ((type == TAG) && (!strncmp(g_data, "", 7))) + { + ret = xmlrpc_parseparam(pbuf); + } + else if ((type == TAG) && (!strncmp(g_data, "", 9))) + { + return XMLRPC_NO_ERROR; + } + else + { + return XMLRPC_PARSE_ERROR; + } + } + } + + return ret; +} + +static int xmlrpc_parsemethod(struct parsebuf_s * pbuf) +{ + int type, ret = XMLRPC_PARSE_ERROR; + + bzero((void *)&g_xmlcall, sizeof(struct xmlrpc_s)); + + /* Look for the methodName tag */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if ((type == TAG) && (!strncmp(g_data, "", 12))) + { + /* Get the method name for the call */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if (type == VALUE) + { + /* Save the method name */ + + strcpy(g_xmlcall.name, g_data); + + /* Find the closing /methodCall */ + + type = xmlrpc_getelement(pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if ((type == TAG) && (!strncmp(g_data, "", 13))) + { + /* Now, it's time to parse the parameters */ + + ret = xmlrpc_parseparams(pbuf); + } + } + } + + return ret; +} + +static void xmlrpc_sendfault(int fault) +{ + fault = -fault; + if (fault >= MAX_ERROR_CODE) + { + fault = 0; + } + + xmlrpc_buildresponse(&g_xmlcall, "{is}", + "faultCode", fault, "faultString", errorStrings[fault]); +} + +/**************************************************************************** + * Public Functions + ****************************************************************************/ + +int xmlrpc_parse(int sock, char *buffer) +{ + struct parsebuf_s pbuf; + int type; + int ret = XMLRPC_PARSE_ERROR; + + pbuf.buf = buffer; + pbuf.len = strlen(buffer); + pbuf.index = 0; + + /* Parse the xml header tag */ + + type = xmlrpc_getelement(&pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if ((type == TAG) && (!strncmp(g_data, "", 12))) + { + /* Parse the remaining tags within the methodCall tag */ + + xmlrpc_parsemethod(&pbuf); + + /* Check for the closing /methodCall */ + + type = xmlrpc_getelement(&pbuf, g_data, CONFIG_XMLRPC_STRINGSIZE); + if ((type == TAG) && (!strncmp(g_data, "", 13))) + { + /* Successful parse, try to call a user function */ + + ret = xmlrpc_call(&g_xmlcall); + } + } + } + + if (ret == 0) + { + write(sock, g_xmlcall.response, strlen(g_xmlcall.response)); + } + else + { + /* Send fault response */ + + g_xmlcall.error = 1; + xmlrpc_sendfault(ret); + write(sock, g_xmlcall.response, strlen(g_xmlcall.response)); + } + + return ret; +} + +void xmlrpc_register(struct xmlrpc_entry_s *entry) +{ + if (g_entries == NULL) + { + g_entries = entry; + entry->next = NULL; + } + else + { + entry->next = g_entries; + g_entries = entry; + } +} diff --git a/nuttx/ChangeLog b/nuttx/ChangeLog index 1375bea43..b6817eab2 100644 --- a/nuttx/ChangeLog +++ b/nuttx/ChangeLog @@ -3341,4 +3341,11 @@ is enabled and (2) some data was obtained from read-ahead buffers. Blocking is a bad idea in that case because there is no timeout! (submitted by Max Holtzberg). - + * configs/stm3240g-eval/xmlrpc: An example configuration for the + Embeddable Lightweight XML-RPC Server at apps/examples/xmlrpc. + See http://www.drdobbs.com/web-development/\ + an-embeddable-lightweight-xml-rpc-server/184405364 for more info. + Contributed by Max Holtzberg. + * configs/*/nxwm/defconfig and sched/task_exithook.c: Fixes for + bugs that crept in during recent changes. (Submitted by Max + Holtzberg). diff --git a/nuttx/Makefile b/nuttx/Makefile index 0f3413cb1..375538919 100644 --- a/nuttx/Makefile +++ b/nuttx/Makefile @@ -603,7 +603,7 @@ distclean: clean subdir_distclean clean_context ifeq ($(CONFIG_BUILD_2PASS),y) @$(MAKE) -C $(CONFIG_PASS1_BUILDIR) TOPDIR="$(TOPDIR)" distclean endif - @rm -f Make.defs setenv.sh .config + @rm -f Make.defs setenv.sh .config .config.old # Application housekeeping targets. The APPDIR variable refers to the user # application directory. A sample apps/ directory is included with NuttX, diff --git a/nuttx/arch/arm/src/stm32/Kconfig b/nuttx/arch/arm/src/stm32/Kconfig index 6b2ac39d3..b5d0306da 100644 --- a/nuttx/arch/arm/src/stm32/Kconfig +++ b/nuttx/arch/arm/src/stm32/Kconfig @@ -1670,6 +1670,12 @@ config STM32_MII_MCO2 ---help--- Use MCO2 to clock the MII interface. Default: Use MC01 +config STM32_MII_EXTCLK + bool "External MII clock" + ---help--- + Clocking is provided by external logic. Don't use MCO for MII + clock. Default: Use MC0[1] + endchoice config STM32_AUTONEG @@ -1746,6 +1752,38 @@ config STM32_RMII default y if !STM32_MII depends on STM32_ETHMAC +choice + prompt "RMII clock configuration" + default STM32_RMII_MCO if STM32_STM32F10XX + default STM32_RMII_MCO1 if STM32_STM32F20XX || STM32_STM32F40XX + depends on STM32_RMII + +config STM32_RMII_MCO + bool "Use MC0 as RMII clock" + depends on STM32_STM32F10XX + ---help--- + Use MCO to clock the RMII interface. Default: Use MC0 + +config STM32_RMII_MCO1 + bool "Use MC01 as RMII clock" + depends on (STM32_STM32F20XX || STM32_STM32F40XX) + ---help--- + Use MCO1 to clock the RMII interface. Default: Use MC01 + +config STM32_RMII_MCO2 + bool "Use MC02 as RMII clock" + depends on (STM32_STM32F20XX || STM32_STM32F40XX) + ---help--- + Use MCO2 to clock the RMII interface. Default: Use MC01 + +config STM32_RMII_EXTCLK + bool "External RMII clock" + ---help--- + Clocking is provided by external logic. Don't use MCO for RMII + clock. Default: Use MC0[1] + +endchoice + menu "USB Host Configuration" config STM32_OTGFS_RXFIFO_SIZE diff --git a/nuttx/arch/arm/src/stm32/stm32_eth.c b/nuttx/arch/arm/src/stm32/stm32_eth.c index 4493983ad..59f3def7f 100644 --- a/nuttx/arch/arm/src/stm32/stm32_eth.c +++ b/nuttx/arch/arm/src/stm32/stm32_eth.c @@ -103,15 +103,30 @@ #ifdef CONFIG_STM32_MII # if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) -# if !defined(CONFIG_STM32_MII_MCO1) && !defined(CONFIG_STM32_MII_MCO2) -# warning "Neither CONFIG_STM32_MII_MCO1 nor CONFIG_STM32_MII_MCO2 defined" +# if !defined(CONFIG_STM32_MII_MCO1) && !defined(CONFIG_STM32_MII_MCO2) && !defined(CONFIG_STM32_MII_EXTCLK) +# warning "Neither CONFIG_STM32_MII_MCO1, CONFIG_STM32_MII_MCO2, nor CONFIG_STM32_MII_EXTCLK defined" # endif # if defined(CONFIG_STM32_MII_MCO1) && defined(CONFIG_STM32_MII_MCO2) # error "Both CONFIG_STM32_MII_MCO1 and CONFIG_STM32_MII_MCO2 defined" # endif # elif defined(CONFIG_STM32_CONNECTIVITYLINE) -# if !defined(CONFIG_STM32_MII_MCO) -# warning "CONFIG_STM32_MII_MCO not defined" +# if !defined(CONFIG_STM32_MII_MCO) && !defined(CONFIG_STM32_MII_EXTCLK) +# warning "Neither CONFIG_STM32_MII_MCO nor CONFIG_STM32_MII_EXTCLK defined" +# endif +# endif +#endif + +#ifdef CONFIG_STM32_RMII +# if defined(CONFIG_STM32_STM32F20XX) || defined(CONFIG_STM32_STM32F40XX) +# if !defined(CONFIG_STM32_RMII_MCO1) && !defined(CONFIG_STM32_RMII_MCO2) && !defined(CONFIG_STM32_RMII_EXTCLK) +# warning "Neither CONFIG_STM32_RMII_MCO1, CONFIG_STM32_RMII_MCO2, nor CONFIG_STM32_RMII_EXTCLK defined" +# endif +# if defined(CONFIG_STM32_RMII_MCO1) && defined(CONFIG_STM32_RMII_MCO2) +# error "Both CONFIG_STM32_RMII_MCO1 and CONFIG_STM32_RMII_MCO2 defined" +# endif +# elif defined(CONFIG_STM32_CONNECTIVITYLINE) +# if !defined(CONFIG_STM32_RMII_MCO) && !defined(CONFIG_STM32_RMII_EXTCLK) +# warning "Neither CONFIG_STM32_RMII_MCO nor CONFIG_STM32_RMII_EXTCLK defined" # endif # endif #endif @@ -2735,16 +2750,41 @@ static inline void stm32_ethgpioconfig(FAR struct stm32_ethmac_s *priv) #elif defined(CONFIG_STM32_RMII) + /* Select the RMII interface */ + + stm32_selectrmii(); + + /* Provide clocking via MCO, MCO1 or MCO2: + * + * "MCO1 (microcontroller clock output), used to output HSI, LSE, HSE or PLL + * clock (through a configurable prescaler) on PA8 pin." + * + * "MCO2 (microcontroller clock output), used to output HSE, PLL, SYSCLK or + * PLLI2S clock (through a configurable prescaler) on PC9 pin." + */ + +# if defined(CONFIG_STM32_RMII_MCO1) + /* Configure MC01 to drive the PHY. Board logic must provide MC01 clocking + * info. + */ + + stm32_configgpio(GPIO_MCO1); + stm32_mco1config(BOARD_CFGR_MC01_SOURCE, BOARD_CFGR_MC01_DIVIDER); + +# elif defined(CONFIG_STM32_RMII_MCO2) + /* Configure MC02 to drive the PHY. Board logic must provide MC02 clocking + * info. + */ + + stm32_configgpio(GPIO_MCO2); + stm32_mco2config(BOARD_CFGR_MC02_SOURCE, BOARD_CFGR_MC02_DIVIDER); + +# elif defined(CONFIG_STM32_RMII_MCO) /* Setup MCO pin for alternative usage */ -#if defined(CONFIG_STM32_MII_MCO) stm32_configgpio(GPIO_MCO); stm32_mcoconfig(BOARD_CFGR_MCO_SOURCE); -#endif - - /* Select the RMII interface */ - - stm32_selectrmii(); +# endif /* RMII interface pins (7): * diff --git a/nuttx/configs/olimex-stm32-p107/nsh/defconfig b/nuttx/configs/olimex-stm32-p107/nsh/defconfig index 87c3e829a..91e757cf1 100644 --- a/nuttx/configs/olimex-stm32-p107/nsh/defconfig +++ b/nuttx/configs/olimex-stm32-p107/nsh/defconfig @@ -370,7 +370,7 @@ CONFIG_NET_MULTICAST=n CONFIG_STM32_PHYADDR=1 CONFIG_STM32_MII=n CONFIG_STM32_RMII=y -CONFIG_STM32_MII_MCO=y +CONFIG_STM32_RMII_MCO=y CONFIG_STM32_AUTONEG=y #CONFIG_STM32_ETHFD #CONFIG_STM32_ETH100MB diff --git a/nuttx/configs/sim/nxwm/defconfig b/nuttx/configs/sim/nxwm/defconfig index 84c2f713e..4ce5a70c6 100644 --- a/nuttx/configs/sim/nxwm/defconfig +++ b/nuttx/configs/sim/nxwm/defconfig @@ -67,7 +67,7 @@ CONFIG_SIM_TOUCHSCREEN=n # # General OS setup # -CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_USER_ENTRYPOINT="user_start" CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=y diff --git a/nuttx/configs/stm3220g-eval/nxwm/defconfig b/nuttx/configs/stm3220g-eval/nxwm/defconfig index a6452094c..681f8c766 100644 --- a/nuttx/configs/stm3220g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3220g-eval/nxwm/defconfig @@ -256,7 +256,7 @@ CONFIG_HAVE_LIBM=n # # General OS setup # -CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_USER_ENTRYPOINT="user_start" CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n diff --git a/nuttx/configs/stm3240g-eval/README.txt b/nuttx/configs/stm3240g-eval/README.txt index e0238f4de..9193b9450 100644 --- a/nuttx/configs/stm3240g-eval/README.txt +++ b/nuttx/configs/stm3240g-eval/README.txt @@ -1320,3 +1320,11 @@ Where is one of the following: use NSH, then you don't care about this. This test is good for testing the Telnet daemon only because it works in a simpler environment than does the nsh configuration. + + xmlrpc + ------ + + An example configuration for the Embeddable Lightweight XML-RPC + Server at apps/examples/xmlrpc. See http://www.drdobbs.com/web-development/\ + an-embeddable-lightweight-xml-rpc-server/184405364 for more info. + Contributed by Max Holtzberg. \ No newline at end of file diff --git a/nuttx/configs/stm3240g-eval/nxwm/defconfig b/nuttx/configs/stm3240g-eval/nxwm/defconfig index 6e891f342..8252f5371 100644 --- a/nuttx/configs/stm3240g-eval/nxwm/defconfig +++ b/nuttx/configs/stm3240g-eval/nxwm/defconfig @@ -262,7 +262,7 @@ CONFIG_HAVE_LIBM=n # # General OS setup # -CONFIG_USER_ENTRYPOINT="nsh_main" +CONFIG_USER_ENTRYPOINT="user_start" CONFIG_DEBUG=n CONFIG_DEBUG_VERBOSE=n CONFIG_DEBUG_SYMBOLS=n diff --git a/nuttx/configs/stm3240g-eval/xmlrpc/Make.defs b/nuttx/configs/stm3240g-eval/xmlrpc/Make.defs new file mode 100644 index 000000000..0a97a215d --- /dev/null +++ b/nuttx/configs/stm3240g-eval/xmlrpc/Make.defs @@ -0,0 +1,198 @@ +############################################################################ +# configs/stm3240g-eval/xmlrpc/Make.defs +# +# Copyright (C) 2012 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}/tools/Config.mk + +# Setup for the selected toolchain + +ifeq ($(CONFIG_STM32_CODESOURCERYW),y) + # CodeSourcery under Windows + CROSSDEV = arm-none-eabi- + ARCROSSDEV = arm-none-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_CODESOURCERYL),y) + # CodeSourcery under Linux + CROSSDEV = arm-none-eabi- + ARCROSSDEV = arm-none-eabi- + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft + MAXOPTIMIZATION = -O2 +endif +ifeq ($(CONFIG_STM32_ATOLLIC_LITE),y) + # Atollic toolchain under Windows + CROSSDEV = arm-atollic-eabi- + ARCROSSDEV = + WINTOOL = y +ifeq ($(CONFIG_ARCH_FPU),y) + ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard +else + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +endif +ifeq ($(CONFIG_STM32_ATOLLIC_PRO),y) + # Atollic toolchain under Windows + CROSSDEV = arm-atollic-eabi- + ARCROSSDEV = arm-atollic-eabi- + WINTOOL = y +ifeq ($(CONFIG_ARCH_FPU),y) + ARCHCPUFLAGS = -mcpu=cortex-m4 -mthumb -march=armv7e-m -mfpu=fpv4-sp-d16 -mfloat-abi=hard +else + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +endif +ifeq ($(CONFIG_STM32_DEVKITARM),y) + # devkitARM under Windows + CROSSDEV = arm-eabi- + ARCROSSDEV = arm-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_RAISONANCE),y) + # Raisonance RIDE7 under Windows + CROSSDEV = arm-none-eabi- + ARCROSSDEV = arm-none-eabi- + WINTOOL = y + ARCHCPUFLAGS = -mcpu=cortex-m3 -mthumb -mfloat-abi=soft +endif +ifeq ($(CONFIG_STM32_BUILDROOT),y) + # NuttX buildroot under Linux or Cygwin + CROSSDEV = arm-elf- + ARCROSSDEV = arm-elf- + ARCHCPUFLAGS = -mtune=cortex-m3 -march=armv7-m -mfloat-abi=soft + MAXOPTIMIZATION = -Os +endif + +LDSCRIPT = ld.script + +ifeq ($(WINTOOL),y) + # Windows-native toolchains + DIRLINK = $(TOPDIR)/tools/winlink.sh + DIRUNLINK = $(TOPDIR)/tools/unlink.sh + MKDEP = $(TOPDIR)/tools/mknulldeps.sh + ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" + ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}" + ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}" + MAXOPTIMIZATION = -O2 +else + # Linux/Cygwin-native toolchain + MKDEP = $(TOPDIR)/tools/mkdeps.sh + ARCHINCLUDES = -I. -isystem $(TOPDIR)/include + ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx + ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT) +endif + +CC = $(CROSSDEV)gcc +CXX = $(CROSSDEV)g++ +CPP = $(CROSSDEV)gcc -E +LD = $(CROSSDEV)ld +AR = $(ARCROSSDEV)ar rcs +NM = $(ARCROSSDEV)nm +OBJCOPY = $(CROSSDEV)objcopy +OBJDUMP = $(CROSSDEV)objdump + +ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'} +ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1} + +ifeq ("${CONFIG_DEBUG_SYMBOLS}","y") + ARCHOPTIMIZATION = -g +else + ARCHOPTIMIZATION = $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer +endif + +ARCHCFLAGS = -fno-builtin +ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fno-rtti +ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow +ARCHWARNINGSXX = -Wall -Wshadow +ARCHDEFINES = +ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10 + +CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS) +CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe +CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS) +CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) +AFLAGS = $(CFLAGS) -D__ASSEMBLY__ + +NXFLATLDFLAGS1 = -r -d -warn-common +NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat.ld -no-check-sections +LDNXFLATFLAGS = -e main -s 2048 + +OBJEXT = .o +LIBEXT = .a +EXEEXT = + +ifneq ($(CROSSDEV),arm-elf-) + LDFLAGS += -nostartfiles -nodefaultlibs +endif +ifeq ($(CONFIG_DEBUG_SYMBOLS),y) + LDFLAGS += -g +endif + +define PREPROCESS + @echo "CPP: $1->$2" + @$(CPP) $(CPPFLAGS) $1 -o $2 +endef + +define COMPILE + @echo "CC: $1" + @$(CC) -c $(CFLAGS) $1 -o $2 +endef + +define COMPILEXX + @echo "CXX: $1" + @$(CXX) -c $(CXXFLAGS) $1 -o $2 +endef + +define ASSEMBLE + @echo "AS: $1" + @$(CC) -c $(AFLAGS) $1 -o $2 +endef + +define ARCHIVE + echo "AR: $2"; \ + $(AR) $1 $2 || { echo "$(AR) $1 $2 FAILED!" ; exit 1 ; } +endef + +define CLEAN + @rm -f *.o *.a +endef + +HOSTCC = gcc +HOSTINCLUDES = -I. +HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -g -pipe +HOSTLDFLAGS = + diff --git a/nuttx/configs/stm3240g-eval/xmlrpc/defconfig b/nuttx/configs/stm3240g-eval/xmlrpc/defconfig new file mode 100644 index 000000000..5c70327b9 --- /dev/null +++ b/nuttx/configs/stm3240g-eval/xmlrpc/defconfig @@ -0,0 +1,866 @@ +# +# Automatically generated file; DO NOT EDIT. +# Nuttx/ Configuration +# +CONFIG_NUTTX_NEWCONFIG=y + +# +# Build Setup +# +# CONFIG_EXPERIMENTAL is not set + +# +# Build Configuration +# +# CONFIG_APPS_DIR="../apps" +# CONFIG_BUILD_2PASS is not set + +# +# Binary Output Formats +# +# CONFIG_RRLOAD_BINARY is not set +# CONFIG_INTELHEX_BINARY is not set +# CONFIG_MOTOROLA_SREC is not set +CONFIG_RAW_BINARY=y + +# +# Customize Header Files +# +# CONFIG_ARCH_STDBOOL_H is not set +# CONFIG_ARCH_MATH_H is not set +# CONFIG_ARCH_STDARG_H is not set + +# +# Debug Options +# +CONFIG_DEBUG=y +# CONFIG_DEBUG_VERBOSE is not set +# CONFIG_DEBUG_ENABLE is not set +# CONFIG_DEBUG_SCHED is not set +# CONFIG_DEBUG_MM is not set +CONFIG_DEBUG_NET=y +# CONFIG_DEBUG_USB is not set +# CONFIG_DEBUG_FS is not set +# CONFIG_DEBUG_LIB is not set +# CONFIG_DEBUG_BINFMT is not set +# CONFIG_DEBUG_GRAPHICS is not set +# CONFIG_DEBUG_I2C is not set +# CONFIG_DEBUG_SPI is not set +# CONFIG_DEBUG_WATCHDOG is not set +# CONFIG_DEBUG_SYMBOLS is not set + +# +# System Type +# +# CONFIG_ARCH_8051 is not set +CONFIG_ARCH_ARM=y +# CONFIG_ARCH_AVR is not set +# CONFIG_ARCH_HC is not set +# CONFIG_ARCH_MIPS is not set +# CONFIG_ARCH_RGMP is not set +# CONFIG_ARCH_SH is not set +# CONFIG_ARCH_SIM is not set +# CONFIG_ARCH_X86 is not set +# CONFIG_ARCH_Z16 is not set +# CONFIG_ARCH_Z80 is not set +CONFIG_ARCH="arm" +# CONFIG_ARCH_CHIP_C5471 is not set +# CONFIG_ARCH_CHIP_CALYPSO is not set +# CONFIG_ARCH_CHIP_DM320 is not set +# CONFIG_ARCH_CHIP_IMX is not set +# CONFIG_ARCH_CHIP_KINETIS is not set +# CONFIG_ARCH_CHIP_LM3S is not set +# CONFIG_ARCH_CHIP_LPC17XX is not set +# CONFIG_ARCH_CHIP_LPC214X is not set +# CONFIG_ARCH_CHIP_LPC2378 is not set +# CONFIG_ARCH_CHIP_LPC31XX is not set +# CONFIG_ARCH_CHIP_LPC43XX is not set +# CONFIG_ARCH_CHIP_SAM3U is not set +CONFIG_ARCH_CHIP_STM32=y +# CONFIG_ARCH_CHIP_STR71X is not set +CONFIG_ARCH_CORTEXM4=y +CONFIG_ARCH_FAMILY="armv7-m" +CONFIG_ARCH_CHIP="stm32" +# CONFIG_ARCH_FPU is not set +CONFIG_ARCH_HAVE_MPU=y +# CONFIG_ARMV7M_MPU is not set +CONFIG_ARCH_IRQPRIO=y +CONFIG_BOARD_LOOPSPERMSEC=16717 +# CONFIG_ARCH_CALIBRATION is not set +# CONFIG_SERIAL_TERMIOS is not set +# CONFIG_NET_MULTICAST is not set + +# +# STM32 Configuration Options +# +# CONFIG_ARCH_CHIP_STM32F100C8 is not set +# CONFIG_ARCH_CHIP_STM32F100CB is not set +# CONFIG_ARCH_CHIP_STM32F100R8 is not set +# CONFIG_ARCH_CHIP_STM32F100RB is not set +# CONFIG_ARCH_CHIP_STM32F100V8 is not set +# CONFIG_ARCH_CHIP_STM32F100VB is not set +# CONFIG_ARCH_CHIP_STM32F103RET6 is not set +# CONFIG_ARCH_CHIP_STM32F103VCT6 is not set +# CONFIG_ARCH_CHIP_STM32F103VET6 is not set +# CONFIG_ARCH_CHIP_STM32F103ZET6 is not set +# CONFIG_ARCH_CHIP_STM32F105VBT7 is not set +# CONFIG_ARCH_CHIP_STM32F107VC is not set +# CONFIG_ARCH_CHIP_STM32F207IG is not set +# CONFIG_ARCH_CHIP_STM32F405RG is not set +# CONFIG_ARCH_CHIP_STM32F405VG is not set +# CONFIG_ARCH_CHIP_STM32F405ZG is not set +# CONFIG_ARCH_CHIP_STM32F407VE is not set +# CONFIG_ARCH_CHIP_STM32F407VG is not set +# CONFIG_ARCH_CHIP_STM32F407ZE is not set +# CONFIG_ARCH_CHIP_STM32F407ZG is not set +# CONFIG_ARCH_CHIP_STM32F407IE is not set +CONFIG_ARCH_CHIP_STM32F407IG=y +CONFIG_STM32_STM32F40XX=y +# CONFIG_STM32_CODESOURCERYW is not set +CONFIG_STM32_CODESOURCERYL=y +# CONFIG_STM32_ATOLLIC_LITE is not set +# CONFIG_STM32_ATOLLIC_PRO is not set +# CONFIG_STM32_DEVKITARM is not set +# CONFIG_STM32_RAISONANCE is not set +# CONFIG_STM32_BUILDROOT is not set +# CONFIG_STM32_DFU is not set + +# +# STM32 Peripheral Support +# +# CONFIG_STM32_ADC1 is not set +# CONFIG_STM32_ADC2 is not set +# CONFIG_STM32_ADC3 is not set +# CONFIG_STM32_CRC is not set +# CONFIG_STM32_DMA1 is not set +# CONFIG_STM32_DMA2 is not set +# CONFIG_STM32_BKPSRAM is not set +# CONFIG_STM32_CAN1 is not set +# CONFIG_STM32_CAN2 is not set +# CONFIG_STM32_CCMDATARAM is not set +# CONFIG_STM32_CRYP is not set +# CONFIG_STM32_DAC1 is not set +# CONFIG_STM32_DAC2 is not set +# CONFIG_STM32_DCMI is not set +CONFIG_STM32_ETHMAC=y +# CONFIG_STM32_FSMC is not set +# CONFIG_STM32_HASH is not set +CONFIG_STM32_I2C1=y +# CONFIG_STM32_I2C2 is not set +# CONFIG_STM32_I2C3 is not set +# CONFIG_STM32_IWDG is not set +# CONFIG_STM32_OTGFS is not set +# CONFIG_STM32_OTGHS is not set +CONFIG_STM32_PWR=y +# CONFIG_STM32_RNG is not set +# CONFIG_STM32_SDIO is not set +# CONFIG_STM32_SPI1 is not set +# CONFIG_STM32_SPI2 is not set +# CONFIG_STM32_SPI3 is not set +CONFIG_STM32_SYSCFG=y +# CONFIG_STM32_TIM1 is not set +# CONFIG_STM32_TIM2 is not set +# CONFIG_STM32_TIM3 is not set +# CONFIG_STM32_TIM4 is not set +# CONFIG_STM32_TIM5 is not set +# CONFIG_STM32_TIM6 is not set +# CONFIG_STM32_TIM7 is not set +# CONFIG_STM32_TIM8 is not set +# CONFIG_STM32_TIM9 is not set +# CONFIG_STM32_TIM10 is not set +# CONFIG_STM32_TIM11 is not set +# CONFIG_STM32_TIM12 is not set +# CONFIG_STM32_TIM13 is not set +# CONFIG_STM32_TIM14 is not set +# CONFIG_STM32_USART1 is not set +# CONFIG_STM32_USART2 is not set +CONFIG_STM32_USART3=y +# CONFIG_STM32_UART4 is not set +# CONFIG_STM32_UART5 is not set +# CONFIG_STM32_USART6 is not set +# CONFIG_STM32_WWDG is not set + +# +# Alternate Pin Mapping +# +# CONFIG_STM32_JTAG_DISABLE is not set +CONFIG_STM32_JTAG_FULL_ENABLE=y +# CONFIG_STM32_JTAG_NOJNTRST_ENABLE is not set +# CONFIG_STM32_JTAG_SW_ENABLE is not set +# CONFIG_STM32_FORCEPOWER is not set +# CONFIG_ARCH_BOARD_STM32_CUSTOM_CLOCKCONFIG is not set +# CONFIG_STM32_CCMEXCLUDE is not set + +# +# Ethernet MAC configuration +# +CONFIG_STM32_PHYADDR=1 +CONFIG_STM32_MII=y +CONFIG_STM32_MII_MCO1=y +# CONFIG_STM32_MII_MCO2 is not set +# CONFIG_STM32_MII_EXTCLK is not set +CONFIG_STM32_AUTONEG=y +CONFIG_STM32_PHYSR=16 +CONFIG_STM32_PHYSR_SPEED=0x0002 +CONFIG_STM32_PHYSR_100MBPS=0x0000 +CONFIG_STM32_PHYSR_MODE=0x0004 +CONFIG_STM32_PHYSR_FULLDUPLEX=0x0004 +# CONFIG_STM32_ETH_PTP is not set + +# +# USB Host Configuration +# + +# +# Architecture Options +# +# CONFIG_ARCH_NOINTC is not set +# CONFIG_ARCH_DMA is not set +CONFIG_ARCH_STACKDUMP=y + +# +# Board Settings +# +CONFIG_DRAM_START=0x20000000 +CONFIG_DRAM_SIZE=196608 +CONFIG_ARCH_HAVE_INTERRUPTSTACK=y +# CONFIG_ARCH_INTERRUPTSTACK is not set + +# +# Boot options +# +# CONFIG_BOOT_RUNFROMEXTSRAM is not set +CONFIG_BOOT_RUNFROMFLASH=y +# CONFIG_BOOT_RUNFROMISRAM is not set +# CONFIG_BOOT_RUNFROMSDRAM is not set +# CONFIG_BOOT_COPYTORAM is not set + +# +# Board Selection +# +CONFIG_ARCH_BOARD_STM3240G_EVAL=y +# CONFIG_ARCH_BOARD_CUSTOM is not set +CONFIG_ARCH_BOARD="stm3240g-eval" + +# +# Common Board Options +# +CONFIG_ARCH_HAVE_LEDS=y +CONFIG_ARCH_LEDS=y +CONFIG_ARCH_HAVE_BUTTONS=y +# CONFIG_ARCH_BUTTONS is not set +CONFIG_ARCH_HAVE_IRQBUTTONS=y + +# +# Board-Specific Options +# + +# +# RTOS Features +# +CONFIG_MSEC_PER_TICK=10 +CONFIG_RR_INTERVAL=200 +# CONFIG_SCHED_INSTRUMENTATION is not set +CONFIG_TASK_NAME_SIZE=0 +# CONFIG_JULIAN_TIME is not set +CONFIG_START_YEAR=2011 +CONFIG_START_MONTH=12 +CONFIG_START_DAY=6 +CONFIG_DEV_CONSOLE=y +# CONFIG_DEV_LOWCONSOLE is not set +# CONFIG_MUTEX_TYPES is not set +# CONFIG_PRIORITY_INHERITANCE is not set +# CONFIG_FDCLONE_DISABLE is not set +# CONFIG_FDCLONE_STDIO is not set +CONFIG_SDCLONE_DISABLE=y +# CONFIG_SCHED_WORKQUEUE is not set +CONFIG_SCHED_WAITPID=y +# CONFIG_SCHED_ATEXIT is not set +# CONFIG_SCHED_ONEXIT is not set +CONFIG_USER_ENTRYPOINT="xmlrpc_main" +# CONFIG_DISABLE_OS_API is not set + +# +# Sizes of configurable things (0 disables) +# +CONFIG_MAX_TASKS=16 +CONFIG_MAX_TASK_ARGS=4 +CONFIG_NPTHREAD_KEYS=4 +CONFIG_NFILE_DESCRIPTORS=8 +CONFIG_NFILE_STREAMS=8 +CONFIG_NAME_MAX=32 +CONFIG_PREALLOC_MQ_MSGS=4 +CONFIG_MQ_MAXMSGSIZE=32 +CONFIG_MAX_WDOGPARMS=2 +CONFIG_PREALLOC_WDOGS=8 +CONFIG_PREALLOC_TIMERS=4 + +# +# Stack and heap information +# +# CONFIG_CUSTOM_STACK is not set +CONFIG_IDLETHREAD_STACKSIZE=1024 +CONFIG_USERMAIN_STACKSIZE=4096 +CONFIG_PTHREAD_STACK_MIN=256 +CONFIG_PTHREAD_STACK_DEFAULT=2048 + +# +# Device Drivers +# +CONFIG_DEV_NULL=y +# CONFIG_DEV_ZERO is not set +# CONFIG_LOOP is not set +# CONFIG_RAMDISK is not set +# CONFIG_CAN is not set +# CONFIG_PWM is not set +CONFIG_I2C=y +# CONFIG_I2C_SLAVE is not set +CONFIG_I2C_TRANSFER=y +# CONFIG_I2C_WRITEREAD is not set +CONFIG_I2C_POLLED=y +# CONFIG_I2C_TRACE is not set +# CONFIG_SPI is not set +# CONFIG_RTC is not set +# CONFIG_WATCHDOG is not set +# CONFIG_ANALOG is not set +# CONFIG_BCH is not set +# CONFIG_INPUT is not set +# CONFIG_LCD is not set +# CONFIG_MMCSD is not set +# CONFIG_MTD is not set +# CONFIG_NETDEVICES is not set +# CONFIG_NET_SLIP is not set +# CONFIG_PIPES is not set +# CONFIG_PM is not set +# CONFIG_POWER is not set +# CONFIG_SENSORS is not set +# CONFIG_SERCOMM_CONSOLE is not set +CONFIG_SERIAL=y +# CONFIG_LOWLEVEL_CONSOLE is not set +# CONFIG_16550_UART is not set +CONFIG_ARCH_HAVE_USART3=y +CONFIG_MCU_SERIAL=y +CONFIG_STANDARD_SERIAL=y +CONFIG_CONFIG_SERIAL_NPOLLWAITERS=2 +CONFIG_USART3_SERIAL_CONSOLE=y +# CONFIG_NO_SERIAL_CONSOLE is not set + +# +# USART3 Configuration +# +CONFIG_USART3_RXBUFSIZE=128 +CONFIG_USART3_TXBUFSIZE=128 +CONFIG_USART3_BAUD=115200 +CONFIG_USART3_BITS=8 +CONFIG_USART3_PARITY=0 +CONFIG_USART3_2STOP=0 +# CONFIG_USBDEV is not set +# CONFIG_USBHOST is not set +# CONFIG_WIRELESS is not set + +# +# System Logging Device Options +# + +# +# System Logging +# +# CONFIG_RAMLOG is not set + +# +# Networking Support +# +CONFIG_NET=y +# CONFIG_NET_NOINTS is not set +CONFIG_NET_MULTIBUFFER=y +# CONFIG_NET_IPv6 is not set +CONFIG_NSOCKET_DESCRIPTORS=10 +CONFIG_NET_NACTIVESOCKETS=16 +CONFIG_NET_SOCKOPTS=y +CONFIG_NET_BUFSIZE=650 +# CONFIG_NET_TCPURGDATA is not set +CONFIG_NET_TCP=y +CONFIG_NET_TCP_CONNS=40 +CONFIG_NET_MAX_LISTENPORTS=40 +CONFIG_NET_TCP_READAHEAD_BUFSIZE=562 +CONFIG_NET_NTCP_READAHEAD_BUFFERS=16 +CONFIG_NET_TCP_RECVDELAY=0 +CONFIG_NET_TCPBACKLOG=y +CONFIG_NET_UDP=y +CONFIG_NET_UDP_CHECKSUMS=y +CONFIG_NET_UDP_CONNS=8 +CONFIG_NET_BROADCAST=y +CONFIG_NET_ICMP=y +CONFIG_NET_ICMP_PING=y +# CONFIG_NET_PINGADDRCONF is not set +# CONFIG_NET_IGMP is not set +CONFIG_NET_STATISTICS=y +CONFIG_NET_RECEIVE_WINDOW=562 +CONFIG_NET_ARPTAB_SIZE=16 +CONFIG_NET_ARP_IPIN=y + +# +# File Systems +# + +# +# File system configuration +# +CONFIG_FS_FAT=y +CONFIG_FAT_LCNAMES=y +CONFIG_FAT_LFN=y +CONFIG_FAT_MAXFNAME=32 +# CONFIG_FS_FATTIME is not set +# CONFIG_FAT_DMAMEMORY is not set +# CONFIG_FS_RAMMAP is not set +# CONFIG_NFS is not set +# CONFIG_FS_NXFFS is not set +# CONFIG_FS_ROMFS is not set + +# +# System Logging +# +# CONFIG_SYSLOG is not set + +# +# Memory Management +# +# CONFIG_MM_SMALL is not set +CONFIG_MM_REGIONS=2 +# CONFIG_GRAN is not set + +# +# Library Routines +# +CONFIG_STDIO_BUFFER_SIZE=256 +CONFIG_STDIO_LINEBUFFER=y +CONFIG_NUNGET_CHARS=2 +CONFIG_LIB_HOMEDIR="/" +# CONFIG_HAVE_LIBM is not set +# CONFIG_NOPRINTF_FIELDWIDTH is not set +# CONFIG_LIBC_FLOATINGPOINT is not set +# CONFIG_EOL_IS_CR is not set +# CONFIG_EOL_IS_LF is not set +# CONFIG_EOL_IS_BOTH_CRLF is not set +CONFIG_EOL_IS_EITHER_CRLF=y +# CONFIG_LIBC_STRERROR is not set +# CONFIG_LIBC_PERROR_STDOUT is not set +CONFIG_ARCH_LOWPUTC=y +CONFIG_LIB_SENDFILE_BUFSIZE=512 +# CONFIG_ARCH_ROMGETC is not set +# CONFIG_ARCH_OPTIMIZED_FUNCTIONS is not set +CONFIG_HAVE_CXX=y +CONFIG_HAVE_CXXINITIALIZE=y +# CONFIG_CXX_NEWLONG is not set + +# +# Application Configuration +# + +# +# Named Applications +# +# CONFIG_NAMEDAPP is not set + +# +# Examples +# + +# +# ADC Example +# +# CONFIG_EXAMPLES_ADC is not set + +# +# Buttons Example +# +# CONFIG_EXAMPLES_BUTTONS is not set + +# +# CAN Example +# +# CONFIG_EXAMPLES_CAN is not set + +# +# USB CDC/ACM Class Driver Example +# +# CONFIG_EXAMPLES_CDCACM is not set + +# +# USB composite Class Driver Example +# +# CONFIG_EXAMPLES_COMPOSITE is not set + +# +# DHCP Server Example +# +# CONFIG_EXAMPLES_DHCPD is not set + +# +# FTP Client Example +# +# CONFIG_EXAMPLES_FTPC is not set + +# +# FTP Server Example +# +# CONFIG_EXAMPLES_FTPD is not set + +# +# "Hello, World!" Example +# +# CONFIG_EXAMPLES_HELLO is not set + +# +# "Hello, World!" C++ Example +# +# CONFIG_EXAMPLES_HELLOXX is not set + +# +# USB HID Keyboard Example +# +# CONFIG_EXAMPLES_HIDKBD is not set + +# +# IGMP Example +# +# CONFIG_EXAMPLES_IGMP is not set + +# +# LCD Read/Write Example +# +# CONFIG_EXAMPLES_LCDRW is not set + +# +# Memory Management Example +# +# CONFIG_EXAMPLES_MM is not set + +# +# File System Mount Example +# +# CONFIG_EXAMPLES_MOUNT is not set + +# +# FreeModBus Example +# +# CONFIG_EXAMPLES_MODBUS is not set + +# +# Network Test Example +# +# CONFIG_EXAMPLES_NETTEST is not set + +# +# NuttShell (NSH) Example +# +# CONFIG_EXAMPLES_NSH is not set + +# +# NULL Example +# +# CONFIG_EXAMPLES_NULL is not set + +# +# NX Graphics Example +# +# CONFIG_EXAMPLES_NX is not set + +# +# NxConsole Example +# +# CONFIG_EXAMPLES_NXCONSOLE is not set + +# +# NXFFS File System Example +# +# CONFIG_EXAMPLES_NXFFS is not set + +# +# NXFLAT Example +# +# CONFIG_EXAMPLES_NXFLAT is not set + +# +# NX Graphics "Hello, World!" Example +# +# CONFIG_EXAMPLES_NXHELLO is not set + +# +# NX Graphics image Example +# +# CONFIG_EXAMPLES_NXIMAGE is not set + +# +# NX Graphics lines Example +# +# CONFIG_EXAMPLES_NXLINES is not set + +# +# NX Graphics Text Example +# +# CONFIG_EXAMPLES_NXTEXT is not set + +# +# OS Test Example +# +# CONFIG_EXAMPLES_OSTEST is not set + +# +# Pascal "Hello, World!"example +# +# CONFIG_EXAMPLES_PASHELLO is not set + +# +# Pipe Example +# +# CONFIG_EXAMPLES_PIPE is not set + +# +# Poll Example +# +# CONFIG_EXAMPLES_POLL is not set + +# +# Pulse Width Modulation (PWM) Example +# + +# +# Quadrature Encoder Example +# +# CONFIG_EXAMPLES_QENCODER is not set + +# +# RGMP Example +# +# CONFIG_EXAMPLES_RGMP is not set + +# +# ROMFS Example +# +# CONFIG_EXAMPLES_ROMFS is not set + +# +# sendmail Example +# +# CONFIG_EXAMPLES_SENDMAIL is not set + +# +# Serial Loopback Example +# +# CONFIG_EXAMPLES_SERLOOP is not set + +# +# Telnet Daemon Example +# +# CONFIG_EXAMPLES_TELNETD is not set + +# +# THTTPD Web Server Example +# +# CONFIG_EXAMPLES_THTTPD is not set + +# +# TIFF Generation Example +# +# CONFIG_EXAMPLES_TIFF is not set + +# +# Touchscreen Example +# +# CONFIG_EXAMPLES_TOUCHSCREEN is not set + +# +# UDP Example +# +# CONFIG_EXAMPLES_UDP is not set + +# +# UDP Discovery Daemon Example +# +# CONFIG_EXAMPLE_DISCOVER is not set + +# +# uIP Web Server Example +# +# CONFIG_EXAMPLES_UIP is not set + +# +# USB Serial Test Example +# +# CONFIG_EXAMPLES_USBSERIAL is not set + +# +# USB Mass Storage Class Example +# +# CONFIG_EXAMPLES_USBMSC is not set + +# +# USB Serial Terminal Example +# +# CONFIG_EXAMPLES_USBTERM is not set + +# +# Watchdog timer Example +# +# CONFIG_EXAMPLES_WATCHDOG is not set + +# +# wget Example +# +# CONFIG_EXAMPLES_WGET is not set + +# +# WLAN Example +# +# CONFIG_EXAMPLES_WLAN is not set + +# +# XML RPC Example +# +CONFIG_EXAMPLES_XMLRPC=y +CONFIG_EXAMPLES_XMLRPC_BUFFERSIZE=1024 +CONFIG_EXAMPLES_XMLRPC_DHCPC=y +CONFIG_EXAMPLES_XMLRPC_NOMAC=y +CONFIG_EXAMPLES_XMLRPC_DRIPADDR=0x0a000001 +CONFIG_EXAMPLES_XMLRPC_NETMASK=0xffffff00 + +# +# Interpreters +# + +# +# Interpreters +# +# CONFIG_FICL is not set +# CONFIG_PCODE is not set + +# +# Network Utilities +# + +# +# Networking Utilities +# + +# +# DHCP client +# +CONFIG_NETUTILS_DHCPC=y + +# +# DHCP server +# +# CONFIG_NETUTILS_DHCPD is not set + +# +# FTP client +# +# CONFIG_NETUTILS_FTPC is not set + +# +# FTP server +# +# CONFIG_NETUTILS_FTPD is not set + +# +# Name resolution +# +CONFIG_NETUTILS_RESOLV=y +CONFIG_NET_RESOLV_ENTRIES=4 + +# +# SMTP +# +# CONFIG_NETUTILS_SMTP is not set + +# +# TFTP client +# +# CONFIG_NETUTILS_TELNETD is not set + +# +# TFTP client +# +# CONFIG_NETUTILS_TFTPC is not set + +# +# THTTPD web server +# +# CONFIG_NETUTILS_THTTPD is not set + +# +# uIP support library +# +CONFIG_NETUTILS_UIPLIB=y + +# +# uIP web client +# +# CONFIG_NETUTILS_WEBCLIENT is not set + +# +# uIP web server +# +# CONFIG_NETUTILS_WEBSERVER is not set + +# +# UDP Discovery Utility +# +# CONFIG_NETUTILS_DISCOVER is not set + +# +# XML-RPC library +# +CONFIG_NETUTILS_XMLRPC=y +CONFIG_XMLRPC_STRINGSIZE=64 + +# +# ModBus +# + +# +# FreeModbus +# +# CONFIG_MODBUS is not set + +# +# NSH Library +# +# CONFIG_NSH_LIBRARY is not set + +# +# System NSH Add-Ons +# + +# +# Custom free memory command +# +# CONFIG_SYSTEM_FREE is not set + +# +# I2C tool +# +# CONFIG_SYSTEM_I2CTOOL is not set + +# +# FLASH Program Installation +# +# CONFIG_SYSTEM_INSTALL is not set + +# +# readline() support +# +# CONFIG_SYSTEM_READLINE is not set + +# +# VSN board Add-Ons +# + +# +# VSN board add-ons +# +# CONFIG_VSN_POWEROFF is not set +# CONFIG_VSN_RAMTRON is not set +# CONFIG_VSN_SDCARD is not set +# CONFIG_VSN_SYSINFO is not set diff --git a/nuttx/configs/stm3240g-eval/xmlrpc/setenv.sh b/nuttx/configs/stm3240g-eval/xmlrpc/setenv.sh new file mode 100644 index 000000000..847be2a89 --- /dev/null +++ b/nuttx/configs/stm3240g-eval/xmlrpc/setenv.sh @@ -0,0 +1,75 @@ +#!/bin/bash +# configs/stm3240g-eval/xmlrpc/setenv.sh +# +# Copyright (C) 2012 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. +# + +if [ "$_" = "$0" ] ; then + echo "You must source this script, not run it!" 1>&2 + exit 1 +fi + +WD=`pwd` +if [ ! -x "setenv.sh" ]; then + echo "This script must be executed from the top-level NuttX build directory" + exit 1 +fi + +if [ -z "${PATH_ORIG}" ]; then + export PATH_ORIG="${PATH}" +fi + +# This the Cygwin path to the location where I installed the RIDE +# toolchain under windows. You will also have to edit this if you install +# the RIDE toolchain in any other location +#export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/Raisonance/Ride/arm-gcc/bin" + +# This the Cygwin path to the location where I installed the CodeSourcery +# toolchain under windows. You will also have to edit this if you install +# the CodeSourcery toolchain in any other location +export TOOLCHAIN_BIN="/cygdrive/c/Program Files (x86)/CodeSourcery/Sourcery G++ Lite/bin" + +# These are the Cygwin paths to the locations where I installed the Atollic +# toolchain under windows. You will also have to edit this if you install +# the Atollic toolchain in any other location. /usr/bin is added before +# the Atollic bin path because there is are binaries named gcc.exe and g++.exe +# at those locations as well. +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for ARM Pro 2.3.0/ARMTools/bin" +#export TOOLCHAIN_BIN="/usr/bin:/cygdrive/c/Program Files (x86)/Atollic/TrueSTUDIO for STMicroelectronics STM32 Lite 2.3.0/ARMTools/bin" + +# This the Cygwin path to the location where I build the buildroot +# toolchain. +#export TOOLCHAIN_BIN="${WD}/../misc/buildroot/build_arm_nofpu/staging_dir/bin" + +# Add the path to the toolchain to the PATH varialble +export PATH="${TOOLCHAIN_BIN}:/sbin:/usr/sbin:${PATH_ORIG}" + +echo "PATH : ${PATH}" diff --git a/nuttx/lib/string/Make.defs b/nuttx/lib/string/Make.defs index 014623eef..6b21c7f14 100644 --- a/nuttx/lib/string/Make.defs +++ b/nuttx/lib/string/Make.defs @@ -42,11 +42,7 @@ CSRCS += lib_checkbase.c lib_isbasedigit.c lib_memset.c lib_memchr.c \ lib_strncasecmp.c lib_strncat.c lib_strncmp.c lib_strncpy.c \ lib_strndup.c lib_strcasestr.c lib_strpbrk.c lib_strrchr.c\ lib_strspn.c lib_strstr.c lib_strtok.c lib_strtokr.c lib_strtol.c \ - lib_strtoll.c lib_strtoul.c lib_strtoull.c - -ifeq ($(CONFIG_LIBC_FLOATINGPOINT),y) -CSRCS += lib_strtod.c -endif + lib_strtoll.c lib_strtoul.c lib_strtoull.c lib_strtod.c # Add the string directory to the build diff --git a/nuttx/lib/string/lib_strtod.c b/nuttx/lib/string/lib_strtod.c index 86719c510..8fecd4571 100644 --- a/nuttx/lib/string/lib_strtod.c +++ b/nuttx/lib/string/lib_strtod.c @@ -37,10 +37,15 @@ * Included Files ****************************************************************************/ +#include +#include + #include #include #include +#ifdef CONFIG_HAVE_DOUBLE + /**************************************************************************** * Pre-processor definitions ****************************************************************************/ @@ -232,3 +237,5 @@ double_t strtod(const char *str, char **endptr) return number; } +#endif /* CONFIG_HAVE_DOUBLE */ + diff --git a/nuttx/sched/task_exithook.c b/nuttx/sched/task_exithook.c index 8497af7ee..e94476f2a 100644 --- a/nuttx/sched/task_exithook.c +++ b/nuttx/sched/task_exithook.c @@ -181,6 +181,7 @@ static inline void task_onexit(FAR _TCB *tcb, int status) tcb->onexitfunc = NULL; } #endif +} #else # define task_onexit(tcb,status) #endif diff --git a/nuttx/tools/xmlrpc_test.py b/nuttx/tools/xmlrpc_test.py new file mode 100644 index 000000000..64cc89dc9 --- /dev/null +++ b/nuttx/tools/xmlrpc_test.py @@ -0,0 +1,48 @@ +#!/usr/bin/env python +############################################################################ +# tools/xmlrpc_test.py +# +# Copyright (C) 2012 Max Holtzberg. All rights reserved. +# Author: Max Holtzberg +# +# 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. +# +############################################################################ + +import sys +import xmlrpclib + +if __name__ == '__main__': + if len(sys.argv) != 2: + print 'Usage: %s ' % sys.argv[0] + quit(1) + + server_url = 'http://%s/device' % sys.argv[1] + server = xmlrpclib.ServerProxy(server_url) + result = server.get_device_stats("username", "password", 0) + print result -- cgit v1.2.3