Using the QT interface, using QT multithreading, serial operation does not use the control, direct to the Win32 API to invoke, most of the serial operation are encapsulated in a class, in the auxiliary thread to set up the serial events and wait, according to my needs, set waiting for the arrival of specific characters, temporarily set to ' n ', which is the Terminator of a statement in the NMEA statement.
When a specific character arrives, the worker thread emit a signal to the GUI main thread, calls the serial operation class in the main thread for non-overlapping read operations, reads the byte length = the length of the string within the input buffer, and satisfies the need by dynamically allocating memory. Displays the read string in the main thread, and then frees the dynamically allocated memory.
Now the multithreaded part of the problem, most of the time today is debugging multithreading, in the beginning eclipse seems to be unable to use GDB to debug multiple threads in Windows, always error. Later, I do not know how to do it again, to catch up, and found that the main problem is waiting for the 500ms timeout, want to let the auxiliary thread sleep 100ms, use of sleeping (100), hey, it should be msleep (100).