Use etimer_restart() to avoid synchronization effects from the abc_send() invocation taking time to complete

This commit is contained in:
adamdunkels 2009-02-07 22:28:25 +00:00
parent 91d280c4c9
commit 67f649c4aa

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: example-abc.c,v 1.2 2008/10/02 21:08:58 fros4943 Exp $ * $Id: example-abc.c,v 1.3 2009/02/07 22:28:25 adamdunkels Exp $
*/ */
/** /**
@ -60,22 +60,25 @@ static struct abc_conn abc;
/*---------------------------------------------------------------------------*/ /*---------------------------------------------------------------------------*/
PROCESS_THREAD(example_abc_process, ev, data) PROCESS_THREAD(example_abc_process, ev, data)
{ {
static struct etimer et;
PROCESS_EXITHANDLER(abc_close(&abc);) PROCESS_EXITHANDLER(abc_close(&abc);)
PROCESS_BEGIN(); PROCESS_BEGIN();
abc_open(&abc, 128, &abc_call); abc_open(&abc, 128, &abc_call);
while(1) { etimer_set(&et, 2 * CLOCK_SECOND);
static struct etimer et;
etimer_set(&et, 2*CLOCK_SECOND); while(1) {
PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et)); PROCESS_WAIT_EVENT_UNTIL(etimer_expired(&et));
rimebuf_copyfrom("Hello", 6); rimebuf_copyfrom("Hello", 6);
abc_send(&abc); abc_send(&abc);
printf("abc message sent\n"); printf("abc message sent\n");
etimer_restart(&et);
} }
PROCESS_END(); PROCESS_END();