From 39098934a6b6bb2fabd314a66cd9744484ea61fa Mon Sep 17 00:00:00 2001 From: nifi Date: Mon, 9 Oct 2006 09:19:02 +0000 Subject: [PATCH] refactored putchar to make it replacable --- platform/esb/Makefile.esb | 4 ++-- platform/esb/contiki-esb-main.c | 13 ++++------ platform/esb/dev/rs232-putchar.c | 41 ++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+), 11 deletions(-) create mode 100644 platform/esb/dev/rs232-putchar.c diff --git a/platform/esb/Makefile.esb b/platform/esb/Makefile.esb index 2a0f0029e..350d04ce0 100644 --- a/platform/esb/Makefile.esb +++ b/platform/esb/Makefile.esb @@ -1,4 +1,4 @@ -# $Id: Makefile.esb,v 1.2 2006/10/06 07:58:19 adamdunkels Exp $ +# $Id: Makefile.esb,v 1.3 2006/10/09 09:19:02 nifi Exp $ SENSORS = sensors.c irq.c button-sensor.c pir-sensor.c vib-sensor.c \ sound-sensor.c radio-sensor.c ctsrts-sensor.c battery-sensor.c \ @@ -12,7 +12,7 @@ endif CONTIKI_TARGET_SOURCEFILES += $(SENSORS) $(ESB) \ contiki-esb-default-init-lowlevel.c \ contiki-esb-default-init-apps.c contiki-esb-default-init-net.c \ - rs232.c fader.c $(CONTIKI_TARGET_MAIN) + rs232.c rs232-putchar.c fader.c $(CONTIKI_TARGET_MAIN) include $(CONTIKI)/platform/$(TARGET)/apps/Makefile.apps diff --git a/platform/esb/contiki-esb-main.c b/platform/esb/contiki-esb-main.c index 730e81d34..938f7674c 100644 --- a/platform/esb/contiki-esb-main.c +++ b/platform/esb/contiki-esb-main.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: contiki-esb-main.c,v 1.2 2006/10/06 07:49:31 adamdunkels Exp $ + * @(#)$Id: contiki-esb-main.c,v 1.3 2006/10/09 09:19:02 nifi Exp $ */ #include @@ -154,15 +154,10 @@ void arg_init(void) {} void arg_free(char *arg) {} /*---------------------------------------------------------------------------*/ -int -putchar(int c) -{ - rs232_send(c); - return c; -} - void uip_log(char *m) { - printf("uIP log: '%s'\n", m); + printf("uIP log: '%s'", m); + /* Needed to force link with putchar */ + putchar('\n'); } diff --git a/platform/esb/dev/rs232-putchar.c b/platform/esb/dev/rs232-putchar.c new file mode 100644 index 000000000..98830a26b --- /dev/null +++ b/platform/esb/dev/rs232-putchar.c @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2006, 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. + * + * This file is part of the Contiki operating system. + * + * @(#)$Id: rs232-putchar.c,v 1.1 2006/10/09 09:19:02 nifi Exp $ + */ + +#include "dev/rs232.h" + +int +putchar(int c) +{ + rs232_send(c); + return c; +}