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 <keithp@keithp.com>
ao_wake_task(&ao_packet_task);
ao_usb_flush();
ao_sleep(&ao_stdin_ready);
+ if (!ao_packet_enable)
+ break;
}
return c;
}
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));
}
}