RPL BR: remove platform-specific code for sky. Add putchar with SLIP support to arch, like in other platforms

This commit is contained in:
Simon Duquennoy 2017-12-22 00:26:44 -08:00
parent 91ca67d393
commit 7f1dd819ef
6 changed files with 105 additions and 96 deletions

View File

@ -1,9 +1,39 @@
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/uart0.h"
/* In case of IPv4: putchar() is defined by the SLIP driver */
#include <string.h>
/*---------------------------------------------------------------------------*/
#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;
}
/*---------------------------------------------------------------------------*/

View File

@ -1,9 +1,39 @@
/*---------------------------------------------------------------------------*/
#include "contiki.h"
#include "dev/uart1.h"
/* In case of IPv4: putchar() is defined by the SLIP driver */
#include <string.h>
/*---------------------------------------------------------------------------*/
#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;
}
/*---------------------------------------------------------------------------*/

View File

@ -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_ */
/*---------------------------------------------------------------------------*/

View File

@ -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)

View File

@ -28,4 +28,5 @@
*
*/
#define UIP_FALLBACK_INTERFACE rpl_interface
#define BUILD_WITH_RPL_BORDER_ROUTER 1
#define UIP_FALLBACK_INTERFACE rpl_interface

View File

@ -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 <string.h>
/*---------------------------------------------------------------------------*/
#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;
}
/*---------------------------------------------------------------------------*/