Qt GUI to Arduino Arduhdlc Example Project
Example project with Qt GUI Application controlling servo on Arduino UNO, over HDLC protocol. HDLC protocol is used to wrap all communication into HDLC frames. On both ends, on the Qt GUI and on the Arduino, valid HDLC frames are passed to command router or dispatcher.
Application defined "protocol" or frame structure is, that the first byte is command byte. Dispatcher then extracts the first byte of the frame, which in this program example is used to hold the command, and calls the right command, passing the frame to it as a reference. Command function then extracts the rest of the data from the frame, if it requires it.
Qt HDLC Singleton Class
Arduhdlc library can not be conveniently used in Qt, so it is converted to a singleton class. All function pointers are replaced with Qt's signals and slots. Any actions can then easily be connected to HDLC Class by connecting/disconnecting signals. User must implement the same receive and valid frame handler functions, than on the Arduino side when using Arduhdlc library.