Platform Independent Serial Port Programming with Qt

Since Qt 5.1 there is a QSerialPort Class included. Maybe this artikle is still of some use for older Qt versions.


The Bones Speech and Sound Module is an Text to Speech hardware module communicating via a HDLC like protocol over FTDI USB serial port. Included with the Development Board of the module is a platform independent demo application showing the capabilities of the module. This Demo application is build upon Qt and the excellent QextSerialPort library to access the serial port.

BSM

Using the serial port library is pretty easy.

First step is to look for available ports. We will filter all non FTDI Ports because our Adapter is based on FTDI:

Then we have to create a port and connect its signals to to corresponding slots:

Sending messages is a no-brainer, too:

Receiving bytes is done via the readyRead signal. Because BSM Messages are send in an HDLC like protocol we have to seperate protocoll messages from debug output. This is done by looking for the start/end flags:

 

The full source of the application is available on Github: https://github.com/MikeBergmann/BSMDemo

I hope it is of some use to you.

Share Button
The following two tabs change content below.

Mike Bergmann

Technical software developer loving low level, bit peeking, embedded development as well as GUI, OO, and X-platform development.