Potential alignment problem fix

This commit is contained in:
adamdunkels 2010-02-04 16:21:15 +00:00
parent e64d9466eb
commit ba56b22c03

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: shell-rime.c,v 1.15 2009/11/08 19:43:00 adamdunkels Exp $ * $Id: shell-rime.c,v 1.16 2010/02/04 16:21:15 adamdunkels Exp $
*/ */
/** /**
@ -323,7 +323,7 @@ PROCESS_THREAD(shell_send_process, ev, data)
struct collect_msg *msg; struct collect_msg *msg;
PROCESS_BEGIN(); PROCESS_BEGIN();
while(1) { while(1) {
PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input); PROCESS_WAIT_EVENT_UNTIL(ev == shell_event_input);
input = data; input = data;
@ -346,7 +346,6 @@ PROCESS_THREAD(shell_send_process, ev, data)
msg->timestamp = 0; msg->timestamp = 0;
#endif #endif
msg->crc = crc16_data(msg->data, len, 0); msg->crc = crc16_data(msg->data, len, 0);
/* printf("Sending %d bytes\n", len);*/
collect_send(&collect, COLLECT_REXMITS); collect_send(&collect, COLLECT_REXMITS);
} }
} }
@ -356,14 +355,17 @@ PROCESS_THREAD(shell_send_process, ev, data)
static void static void
recv_collect(const rimeaddr_t *originator, u8_t seqno, u8_t hops) recv_collect(const rimeaddr_t *originator, u8_t seqno, u8_t hops)
{ {
struct collect_msg *collect_msg; struct collect_msg collect_msg;
char *dataptr;
rtimer_clock_t latency; rtimer_clock_t latency;
int len; int len;
collect_msg = packetbuf_dataptr(); /* Copy the collect message header. */
memcpy(&collect_msg, packetbuf_dataptr(), sizeof(collect_msg));
dataptr = ((struct collect_msg *)packetbuf_dataptr())->data;
#if TIMESYNCH_CONF_ENABLED #if TIMESYNCH_CONF_ENABLED
latency = timesynch_time() - collect_msg->timestamp; latency = timesynch_time() - collect_msg.timestamp;
#else #else
latency = 0; latency = 0;
#endif #endif
@ -380,17 +382,16 @@ recv_collect(const rimeaddr_t *originator, u8_t seqno, u8_t hops)
if(packetbuf_datalen() >= COLLECT_MSG_HDRSIZE) { if(packetbuf_datalen() >= COLLECT_MSG_HDRSIZE) {
len = packetbuf_datalen() - COLLECT_MSG_HDRSIZE; len = packetbuf_datalen() - COLLECT_MSG_HDRSIZE;
if(collect_msg->crc == crc16_data(collect_msg->data, len, 0)) { if(collect_msg.crc == crc16_data(dataptr, len, 0)) {
msg.len = 5 + (packetbuf_datalen() - COLLECT_MSG_HDRSIZE) / 2; msg.len = 5 + (packetbuf_datalen() - COLLECT_MSG_HDRSIZE) / 2;
rimeaddr_copy((rimeaddr_t *)&msg.originator, originator); rimeaddr_copy((rimeaddr_t *)&msg.originator, originator);
msg.seqno = seqno; msg.seqno = seqno;
msg.hops = hops; msg.hops = hops;
msg.latency = latency; msg.latency = latency;
/* printf("recv_collect datalen %d\n", packetbuf_datalen());*/
shell_output(&collect_command, shell_output(&collect_command,
&msg, sizeof(msg), &msg, sizeof(msg),
collect_msg->data, packetbuf_datalen() - COLLECT_MSG_HDRSIZE); dataptr, packetbuf_datalen() - COLLECT_MSG_HDRSIZE);
} }
} }
} else if(waiting_for_nodes) { } else if(waiting_for_nodes) {