THE MAIN LOOP
The main loop in DEVICE.C should not be changed unless you find it extremely necessary. Some facts should be recognized about the main loop.
void main(int argc, char **argv)
The function tailer reads the command line and sets the options it must be called first so the other functions will know which options are used.
The function gaurdian checks if the port we want is in use and must be called immediately after we know which port we want (option returned by tailer). This will ensure that we don't interfere with the communications of another process.
The function initialize performs a number of tasks but most importantly it opens up the communication channels. It must be called before we try to communicate with ONSPEC or the device.
The function timeToQuit must be called each time through the loop and may be called more often through the program. This ensures that we abort if ONSPEC goes down or if our port has been taken.
Finally we must call the function exit before terminating. This will close communication, ensure that all threads of the I/O template will terminate, and release their resources.