From 63c832394a829f41b8f77d075786530536360349 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Sun, 29 Aug 2010 23:22:27 -0700 Subject: [PATCH] altos: shut down packet mode cleanly Instead of constantly bashing the packet master thread, let it shut itself down in an orderly fashion. It will shut down fairly quickly as all of the activities in that thread are bounded. Otherwise, the master packet thread might leave mutexes locked and all sorts of other horrors. Tested on Linux and Mac OS X and shown to be reliable. Signed-off-by: Keith Packard --- src/ao_packet_master.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/ao_packet_master.c b/src/ao_packet_master.c index 50f5aeff..641b49f4 100644 --- a/src/ao_packet_master.c +++ b/src/ao_packet_master.c @@ -29,6 +29,8 @@ ao_packet_getchar(void) __critical ao_wake_task(&ao_packet_task); ao_usb_flush(); ao_sleep(&ao_stdin_ready); + if (!ao_packet_enable) + break; } return c; } @@ -127,10 +129,9 @@ ao_packet_forward(void) __reentrant ao_delay(AO_MS_TO_TICKS(100)); ao_packet_enable = 0; while (ao_packet_echo_task.wchan || ao_packet_task.wchan) { - ao_radio_abort(); - ao_wake_task(&ao_packet_echo_task); - ao_wake_task(&ao_packet_task); - ao_yield(); + if (ao_packet_echo_task.wchan) + ao_wake_task(&ao_packet_echo_task); + ao_delay(AO_MS_TO_TICKS(10)); } } -- 2.30.2