diff --git a/platform/esb/dev/tr1001-gcr.c b/platform/esb/dev/tr1001-gcr.c index 4ffb59a33..5c73e00f1 100644 --- a/platform/esb/dev/tr1001-gcr.c +++ b/platform/esb/dev/tr1001-gcr.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tr1001-gcr.c,v 1.2 2006/10/06 07:57:14 adamdunkels Exp $ + * @(#)$Id: tr1001-gcr.c,v 1.3 2006/10/09 11:56:13 adamdunkels Exp $ */ /** * \addtogroup esb @@ -109,8 +109,6 @@ struct tr1001_hdr { */ #define TR1001_HDRLEN sizeof(struct tr1001_hdr) -#define BUF ((uip_tcpip_hdr *)&uip_buf[UIP_LLH_LEN]) - #define OFF 0 #define ON 1 static u8_t onoroff = ON; @@ -659,7 +657,7 @@ tr1001_send(u8_t *packet, u16_t len) } /*---------------------------------------------------------------------------*/ unsigned short -tr1001_poll(void) +tr1001_poll(u8_t *buf, u16_t bufsize) { unsigned short tmplen; @@ -669,12 +667,14 @@ tr1001_poll(void) tmplen = tr1001_rxlen; - if(tmplen > UIP_BUFSIZE - (UIP_LLH_LEN - TR1001_HDRLEN)) { + /* if(tmplen > UIP_BUFSIZE - (UIP_LLH_LEN - TR1001_HDRLEN)) { tmplen = UIP_BUFSIZE - (UIP_LLH_LEN - TR1001_HDRLEN); + }*/ + if(tmplen > bufsize - TR1001_HDRLEN) { + tmplen = bufsize - TR1001_HDRLEN; } - memcpy(&uip_buf[UIP_LLH_LEN], &tr1001_rxbuf[TR1001_HDRLEN], - tmplen); + memcpy(buf, &tr1001_rxbuf[TR1001_HDRLEN], tmplen); /* header + content + CRC */ sstrength = (tmp_sstrength / (TR1001_HDRLEN + tr1001_rxlen + 2)) << 1; diff --git a/platform/esb/dev/tr1001.c b/platform/esb/dev/tr1001.c index eebd7157e..8e9c29165 100644 --- a/platform/esb/dev/tr1001.c +++ b/platform/esb/dev/tr1001.c @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tr1001.c,v 1.3 2006/10/06 07:57:14 adamdunkels Exp $ + * @(#)$Id: tr1001.c,v 1.4 2006/10/09 11:56:13 adamdunkels Exp $ */ /** * \addtogroup esb @@ -632,12 +632,14 @@ tr1001_poll(void) tmplen = tr1001_rxlen; - if(tmplen > UIP_BUFSIZE - (UIP_LLH_LEN - TR1001_HDRLEN)) { + /* if(tmplen > UIP_BUFSIZE - (UIP_LLH_LEN - TR1001_HDRLEN)) { tmplen = UIP_BUFSIZE - (UIP_LLH_LEN - TR1001_HDRLEN); + }*/ + if(tmplen > bufsize - TR1001_HDRLEN) { + tmplen = bufsize - TR1001_HDRLEN; } - memcpy(&uip_buf[UIP_LLH_LEN], &tr1001_rxbuf[TR1001_HDRLEN], - tmplen); + memcpy(buf, &tr1001_rxbuf[TR1001_HDRLEN], tmplen); /* header + content + CRC */ sstrength = (tmp_sstrength / (TR1001_HDRLEN + tr1001_rxlen + 2)) << 1; diff --git a/platform/esb/dev/tr1001.h b/platform/esb/dev/tr1001.h index a901ed0de..8106a9ae8 100644 --- a/platform/esb/dev/tr1001.h +++ b/platform/esb/dev/tr1001.h @@ -28,7 +28,7 @@ * * This file is part of the Contiki operating system. * - * @(#)$Id: tr1001.h,v 1.1 2006/06/18 07:49:33 adamdunkels Exp $ + * @(#)$Id: tr1001.h,v 1.2 2006/10/09 11:56:13 adamdunkels Exp $ */ #ifndef __TR1001_H__ #define __TR1001_H__ @@ -121,7 +121,7 @@ u8_t tr1001_send(u8_t *packet, u16_t len); * \return The length of the received packet, or 0 if no packet has * been received. */ -unsigned short tr1001_poll(void); +unsigned short tr1001_poll(u8_t *buf, u16_t bufsize); extern unsigned char tr1001_rxbuf[]; extern volatile unsigned char tr1001_rxstate; diff --git a/platform/esb/net/tr1001-drv.c b/platform/esb/net/tr1001-drv.c index 282e08b73..0f6bbe639 100644 --- a/platform/esb/net/tr1001-drv.c +++ b/platform/esb/net/tr1001-drv.c @@ -1,34 +1,34 @@ /* * Copyright (c) 2005, 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. * * This file is part of the Contiki operating system. * - * @(#)$Id: tr1001-drv.c,v 1.1 2006/06/18 08:19:10 adamdunkels Exp $ + * @(#)$Id: tr1001-drv.c,v 1.2 2006/10/09 11:56:13 adamdunkels Exp $ */ #include "contiki-esb.h" @@ -52,10 +52,10 @@ PROCESS_THREAD(tr1001_drv_process, ev, data) PROCESS_WAIT_EVENT_UNTIL(ev == PROCESS_EVENT_POLL); - uip_len = tr1001_poll(); + uip_len = tr1001_poll(&uip_buf[UIP_LLH_LEN], UIP_BUFSIZE - UIP_LLH_LEN); if(uip_len > 0) { - uip_len = hc_inflate(); + uip_len = hc_inflate(&uip_buf[UIP_LLH_LEN], uip_len); tcpip_input(); } } @@ -72,10 +72,8 @@ tr1001_drv_request_poll(void) u8_t tr1001_drv_send(void) { - int len; - - len = hc_compress(); - return tr1001_send(&uip_buf[UIP_LLH_LEN], len); + uip_len = hc_compress(&uip_buf[UIP_LLH_LEN], uip_len); + return tr1001_send(&uip_buf[UIP_LLH_LEN], uip_len); } /*---------------------------------------------------------------------------*/ void