fixed alignment problem with rime/chameleon

This commit is contained in:
nifi 2008-04-01 13:10:22 +00:00
parent b0d37c34e3
commit fabe4393f7
2 changed files with 10 additions and 7 deletions

View file

@ -28,7 +28,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: chameleon-bitopt.c,v 1.2 2008/02/28 21:25:34 oliverschmidt Exp $ * $Id: chameleon-bitopt.c,v 1.3 2008/04/01 13:10:22 nifi Exp $
*/ */
/** /**
@ -45,7 +45,7 @@
#include <string.h> #include <string.h>
struct bitopt_hdr { struct bitopt_hdr {
uint16_t channel; uint8_t channel[2];
}; };
static const uint8_t bitmask[9] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0, static const uint8_t bitmask[9] = { 0x00, 0x80, 0xc0, 0xe0, 0xf0,
@ -268,7 +268,8 @@ pack_header(struct channel *c)
rimebuf_hdralloc(sizeof(struct bitopt_hdr)); rimebuf_hdralloc(sizeof(struct bitopt_hdr));
hdr = (struct bitopt_hdr *)rimebuf_hdrptr(); hdr = (struct bitopt_hdr *)rimebuf_hdrptr();
hdr->channel = c->channelno; hdr->channel[0] = c->channelno & 0xff;
hdr->channel[1] = (c->channelno & 0xff) << 8;
return 1; /* Send out packet */ return 1; /* Send out packet */
} }
@ -288,7 +289,7 @@ unpack_header(void)
for. */ for. */
hdr = (struct bitopt_hdr *)rimebuf_dataptr(); hdr = (struct bitopt_hdr *)rimebuf_dataptr();
rimebuf_hdrreduce(sizeof(struct bitopt_hdr)); rimebuf_hdrreduce(sizeof(struct bitopt_hdr));
c = channel_lookup(hdr->channel); c = channel_lookup((hdr->channel[1] << 8) + (hdr->channel[0]));
if(c == NULL) { if(c == NULL) {
PRINTF("chameleon-bitopt: input: channel %d not found\n", hdr->channel); PRINTF("chameleon-bitopt: input: channel %d not found\n", hdr->channel);
return NULL; return NULL;

View file

@ -33,7 +33,7 @@
* *
* This file is part of the Contiki operating system. * This file is part of the Contiki operating system.
* *
* $Id: rimeaddr.c,v 1.6 2007/08/30 14:39:17 matsutsuka Exp $ * $Id: rimeaddr.c,v 1.7 2008/04/01 13:10:22 nifi Exp $
*/ */
/** /**
@ -52,13 +52,15 @@ const rimeaddr_t rimeaddr_null = { { 0, 0 } };
void void
rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src) rimeaddr_copy(rimeaddr_t *dest, const rimeaddr_t *src)
{ {
dest->u16[0] = src->u16[0]; dest->u8[0] = src->u8[0];
dest->u8[1] = src->u8[1];
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
int int
rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2) rimeaddr_cmp(const rimeaddr_t *addr1, const rimeaddr_t *addr2)
{ {
return addr1->u16[0] == addr2->u16[0]; return addr1->u8[0] == addr2->u8[0] &&
addr1->u8[1] == addr2->u8[1];
} }
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
void void