c++ - Issues Serial Port Watch using threads with an event loop and QSocketNotifiers -


I used to ask this question yesterday since I did not receive any data, but weird when I used to wait in the discoverer I started receveing ​​notifications from QSocketNotifier . The rest of the questions are the same, can someone give a suggestion? I have created a sample application from where the separate thread has been started to read and process data from the serial port. QSocketNotifier is used to find out whether the data has come on the serial port or not. I start the event loop by using the exec () statement in the running of the thread. But the socket notifier has worked, the signal is never generated for serial ports activation only once the application is running. And once it was generated it was generated very fast and the instrument was not equal to the frame rate

Here is a short code sample for the serial Communicator thread.

SerialPortWatchOne .cpp

  // Constructor Clays :: Clays () // // Setting Configuration Multiple Dynamics QSocketNotifier * Notifier = New QSocketNotifier (mPort- & gt; GetFileDescriptor, QSocketNotifier :: Read, It); Connect (indicator, signal (active (int)), this, slot (ReadAndProcessData ()); } Zero clause :: run () {exec (); // This is a phenomenon loop capable of forming the QT signal where the form is} zero klass :: ReadAndProcessData () {FlushBuf () starts; Int bytes_read = mPort- & gt; Redport (mBuf, 1000); If (byte_bread> gt; 0) // process data} ~ klass :: klass () {// desctruction code; stop(); // so that the thread releases all the resources before exiting the cleanliness}  

Note: klass is a thread and a member of the GUI thread and the GUI thread is instantiated in the c'tor. From time to time, the GUI updates its widgets with data from the clues thread.

Is there any suggestion that what is the problem? It has been done before anyone.

"itemprop =" text ">

The only thing that comes to mind is that you are using QSocketNotifier * SocketNotifier in an event running loop without socketNotifier-> thread, thread () thread. If the event loop is not running, you will not get any event handling. No event handling is any sign that has been removed from QSocketNotifier . But if you are using a different thread, you can use the blocking I / O call anyway.


Comments

Popular posts from this blog

c++ - Linux and clipboard -

Visual Studio 2005: How to speed up builds when a VSMDI is open? -

booting ubuntu from usb using virtualbox -