From 7f1dd819ef5d457439528b4a29b570a7eb691cc0 Mon Sep 17 00:00:00 2001 From: Simon Duquennoy Date: Fri, 22 Dec 2017 00:26:44 -0800 Subject: [PATCH] RPL BR: remove platform-specific code for sky. Add putchar with SLIP support to arch, like in other platforms --- arch/cpu/msp430/dev/uart0-putchar.c | 32 +++++++++- arch/cpu/msp430/dev/uart1-putchar.c | 32 +++++++++- arch/cpu/msp430/msp430-conf.h | 60 ++++++++++------- .../Makefile.rpl-border-router | 10 ++- os/services/rpl-border-router/module-macros.h | 3 +- .../sky/slip-bridge-putchar.c | 64 ------------------- 6 files changed, 105 insertions(+), 96 deletions(-) delete mode 100644 os/services/rpl-border-router/sky/slip-bridge-putchar.c diff --git a/arch/cpu/msp430/dev/uart0-putchar.c b/arch/cpu/msp430/dev/uart0-putchar.c index bf237695b..4c92f9160 100644 --- a/arch/cpu/msp430/dev/uart0-putchar.c +++ b/arch/cpu/msp430/dev/uart0-putchar.c @@ -1,9 +1,39 @@ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" #include "dev/uart0.h" -/* In case of IPv4: putchar() is defined by the SLIP driver */ +#include +/*---------------------------------------------------------------------------*/ +#define SLIP_END 0300 +#undef putchar +/*---------------------------------------------------------------------------*/ int putchar(int c) { +#if SLIP_ARCH_CONF_ENABLED + static char debug_frame = 0; + + if(!debug_frame) { /* Start of debug output */ + uart0_writeb(SLIP_END); + uart0_writeb('\r'); /* Type debug line == '\r' */ + debug_frame = 1; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ + + /* Need to also print '\n' because for example COOJA will not show + any output before line end */ uart0_writeb((char)c); + +#if SLIP_ARCH_CONF_ENABLED + /* + * Line buffered output, a newline marks the end of debug output and + * implicitly flushes debug output. + */ + if(c == '\n') { + uart0_writeb(SLIP_END); + debug_frame = 0; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ return c; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/dev/uart1-putchar.c b/arch/cpu/msp430/dev/uart1-putchar.c index 7623b435a..14146d9dc 100644 --- a/arch/cpu/msp430/dev/uart1-putchar.c +++ b/arch/cpu/msp430/dev/uart1-putchar.c @@ -1,9 +1,39 @@ +/*---------------------------------------------------------------------------*/ +#include "contiki.h" #include "dev/uart1.h" -/* In case of IPv4: putchar() is defined by the SLIP driver */ +#include +/*---------------------------------------------------------------------------*/ +#define SLIP_END 0300 +#undef putchar +/*---------------------------------------------------------------------------*/ int putchar(int c) { +#if SLIP_ARCH_CONF_ENABLED + static char debug_frame = 0; + + if(!debug_frame) { /* Start of debug output */ + uart1_writeb(SLIP_END); + uart1_writeb('\r'); /* Type debug line == '\r' */ + debug_frame = 1; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ + + /* Need to also print '\n' because for example COOJA will not show + any output before line end */ uart1_writeb((char)c); + +#if SLIP_ARCH_CONF_ENABLED + /* + * Line buffered output, a newline marks the end of debug output and + * implicitly flushes debug output. + */ + if(c == '\n') { + uart1_writeb(SLIP_END); + debug_frame = 0; + } +#endif /* SLIP_ARCH_CONF_ENABLED */ return c; } +/*---------------------------------------------------------------------------*/ diff --git a/arch/cpu/msp430/msp430-conf.h b/arch/cpu/msp430/msp430-conf.h index ec4f49a55..f4f0da54c 100644 --- a/arch/cpu/msp430/msp430-conf.h +++ b/arch/cpu/msp430/msp430-conf.h @@ -1,30 +1,30 @@ /* * Copyright (c) 2007, Swedish Institute of Computer Science - * All rights reserved. + * All rights reserved. * - * 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 of the Institute nor the names of its contributors - * may be used to endorse or promote products derived from this software - * without specific prior written permission. + * 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 of the Institute 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 INSTITUTE 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 INSTITUTE 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. + * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE 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 INSTITUTE 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 MSP430_CONF_H_ @@ -42,6 +42,20 @@ #else #define MSP430_CPU_SPEED 2457600UL #endif + +#ifndef SLIP_ARCH_CONF_ENABLED +/* + * Determine whether we need SLIP + * This will keep working while UIP_FALLBACK_INTERFACE and CMD_CONF_OUTPUT + * keep using SLIP + */ +#if defined(UIP_FALLBACK_INTERFACE) || defined(CMD_CONF_OUTPUT) +#define SLIP_ARCH_CONF_ENABLED 1 +#else +#define SLIP_ARCH_CONF_ENABLED 0 +#endif +#endif + /*---------------------------------------------------------------------------*/ #endif /* MSP430_CONF_H_ */ /*---------------------------------------------------------------------------*/ diff --git a/os/services/rpl-border-router/Makefile.rpl-border-router b/os/services/rpl-border-router/Makefile.rpl-border-router index f1f28e096..61ba5fa59 100644 --- a/os/services/rpl-border-router/Makefile.rpl-border-router +++ b/os/services/rpl-border-router/Makefile.rpl-border-router @@ -1,10 +1,8 @@ -CFLAGS += -DBUILD_WITH_RPL_BORDER_ROUTER=1 - include $(CONTIKI)/Makefile.identify-target -# Include 'embedded' module for non-native platforms -ifneq ($(TARGET),native) +# Include either native or embedded BR +ifeq ($(TARGET),native) + MODULES += os/services/rpl-border-router/native +else MODULES += os/services/rpl-border-router/embedded endif -# Include optional target-specific module -MODULES += os/services/rpl-border-router/$(TARGET) diff --git a/os/services/rpl-border-router/module-macros.h b/os/services/rpl-border-router/module-macros.h index 2f2a8306c..f3fad0b9b 100644 --- a/os/services/rpl-border-router/module-macros.h +++ b/os/services/rpl-border-router/module-macros.h @@ -28,4 +28,5 @@ * */ -#define UIP_FALLBACK_INTERFACE rpl_interface +#define BUILD_WITH_RPL_BORDER_ROUTER 1 +#define UIP_FALLBACK_INTERFACE rpl_interface diff --git a/os/services/rpl-border-router/sky/slip-bridge-putchar.c b/os/services/rpl-border-router/sky/slip-bridge-putchar.c deleted file mode 100644 index f7f501ba1..000000000 --- a/os/services/rpl-border-router/sky/slip-bridge-putchar.c +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2010, Swedish Institute of Computer Science. - * All rights reserved. - * - * 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 of the Institute 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 INSTITUTE 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 INSTITUTE 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 "contiki.h" -#include "dev/slip.h" - -#include -/*---------------------------------------------------------------------------*/ -#define SLIP_END 0300 -#undef putchar -/*---------------------------------------------------------------------------*/ -int -putchar(int c) -{ - static char debug_frame = 0; - - if(!debug_frame) { /* Start of debug output */ - slip_arch_writeb(SLIP_END); - slip_arch_writeb('\r'); /* Type debug line == '\r' */ - debug_frame = 1; - } - - /* Need to also print '\n' because for example COOJA will not show - any output before line end */ - slip_arch_writeb((char)c); - - /* - * Line buffered output, a newline marks the end of debug output and - * implicitly flushes debug output. - */ - if(c == '\n') { - slip_arch_writeb(SLIP_END); - debug_frame = 0; - } - return c; -} -/*---------------------------------------------------------------------------*/