diydrones/ardupilot — pull request #1602 by bugobliterator (2014-11-14 11:10:25+00:00)
Title: Updated ToneAlarm Library with suggested changes

Following are the suggestions made by tridge which are worked upon under this pull request
>* I'd like to see ::printf() calls to show failure to open the period, duty and run files in case the module doesn't load, so the user knows how to debug it (that happened to me due to a module issue)
* the tune[] array should really be a constant array of structures, like the LinuxSPIDeviceManager::_device array, instead of copying the string pointers at startup
* the str, str1, str2 strings are not really needed
* I think toneAlarm_init() should return a bool, and ::printf() an error on failure
* I have fixed some of the places that write() is used where dprintf() should be used, but there are some others (eg. in stop()). See the dprintf() patch I pushed
* the magic constant 10 should be replaced by TOTAL_NUMBER_OF_TUNES-1 (or add a MAX_TUNE)
* I'd like to see some more paranoid checking in play_tune() to make sure it can't loop forever. This thread runs at top priority, and if it loops then we will fall out of the sky as nothing else will run at all. We need to make absolutely sure it will never loop forever. Defensive coding would be a good idea
* the NOTE_ and TONE_ defines should move to a separate ToneAlarmDriver.h I think
* it would be better if ToneAlarmDriver was a separate class, which Util instantiated as a private object