Added exithandlers so that the examples can be run as loadable (and unloadble) modules

This commit is contained in:
adamdunkels 2007-03-25 12:10:29 +00:00
parent 4fa44208eb
commit c3457e82a4
9 changed files with 76 additions and 14 deletions

View file

@ -28,7 +28,7 @@
*
* This file is part of the Contiki operating system.
*
* $Id: test-abc.c,v 1.2 2007/03/22 23:58:37 adamdunkels Exp $
* $Id: test-abc.c,v 1.3 2007/03/25 12:10:29 adamdunkels Exp $
*/
/**
@ -53,13 +53,15 @@ AUTOSTART_PROCESSES(&test_abc_process);
static void
abc_recv(struct abc_conn *c)
{
/* log_message("abc message received", rimebuf_dataptr());*/
printf("abc message received '%s'\n", (char *)rimebuf_dataptr());
}
const static struct abc_callbacks abc_call = {abc_recv};
static struct abc_conn abc;
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(test_abc_process, ev, data)
{
PROCESS_EXITHANDLER(abc_close(&abc);)
PROCESS_BEGIN();
abc_open(&abc, 128, &abc_call);
@ -75,6 +77,7 @@ PROCESS_THREAD(test_abc_process, ev, data)
abc_send(&abc);
}
PROCESS_END();
}
/*---------------------------------------------------------------------------*/