Home > Mobile >  QT how to judge whether there is a serial communication, data from the serial port to send to come o
QT how to judge whether there is a serial communication, data from the serial port to send to come o

Time:09-29

How to judge whether there is data from serial port to send to come over?
In my function, a serial port to send instructions when I use the write function to a serial port to send instructions after
Then under the wirte function call serial - & gt; Waiting for the signal to have readyread waitforReadyread (2000) trigger
To determine whether there is data from serial port to send
Although I can receive data from serial port, is with the Readyread () signal is the binding of groove function can perform
But below I write function call waitforReadyread () will always return a value of false is that it can't capture readyread () signal,
What is the problem?

CodePudding user response:

CodePudding user response:

Data receiving interface look, again through the head + length data is read

CodePudding user response:

His top!!!!!! Why can't read directly below the write function readall data only in the slot of binding with the readyread signal readall will read the data

CodePudding user response:

refer to the second floor zzxap response:
data receiving interface look, again through the head + length judge data read

Hello, thank you for your reply
But the question now is I need to determine whether there is data from serial port to send rather than judge sent data is complete

CodePudding user response:

Time, or there is a mistake will returns false, you are a serial port is what mistakes, the error code print

CodePudding user response:

Open a cache, pour the read data cache, again when you want to use from the cache read out, the underlying drivers also receives the cache, but not quite, if the data quantity is big, it may lead to loss of data,

CodePudding user response:

Can not hang signal slot?

CodePudding user response:

I also come across this kind of situation, when I before Qt version 5.1.4 ensuring, send after, send wait for after the completion of the can use readall () to read all of the functions, I currently use qt5.11 version will not be able to do so, must be used in the readyread slot function readall () to read the data, feel may version, the difference between there may be other reasons

CodePudding user response:

I never waitforReadyread readyRead to readAll QT5.10

CodePudding user response:

Access to the buffer data length judgment, there is agreement to see check,

Qt number: public Qt_io_

CodePudding user response:

The building Lord, you won't be stuck in waitforReadyread function like this? After sending data should be waitforReadyread function is blocked?

CodePudding user response:

WaitforReadyread () is not set the timeout time, set to 1, the timeout will not occur
  •  Tags:  
  • Qt
  • Related