In these days of COVID19 and AI, when face to face communication is avoided and Alexa lurks in the corner of every room, people are beginning to sound like robots and robots sound ever more like humans. Still, sometimes a translator is needed.
Over the years I have developed many applications that “talk” to devices attached to a Windows desktop computer. The devices range from half a dozen different sensors on a racing sailboat to an infra-red spectrometer the size of a pinhead. For a list, see.
Such applications have two essential tasks, talking to the human user and talking to the device. Neither the human nor the device are very patient – they expect an instant response no matter what else is going on. So the application must be split into two separate threads of computation, one looking after the user and one looking after the device. The trick is synchronizing the two threads so that whatever is said by the user is translated and sent to the device, while anything communicated from the device is displayed to the user, without descending into confusion and chaos.
Developing multithreaded applications is a challenge. Ideally, the application developer should be able to concentrate on the translation tasks, employing a well tested library to keep track of the different threads and their inter-dependencies. The application code should run in exactly one thread, and the communications library should create and run the required threads so that the robots do not block communications with the user, or vice versa.
This week I added a class called com to the windex framework which does just this for robots that are connected to a serial port ( USB, COM, RS232, etc ). If this sounds like it might be useful, check it out