qt串口阻塞,等待数据从Qt中的串口到达

I use serial port connection in my qt application.

My problem- I cant get back the control (or the values comes from the comm port) after sending the command.

I have a class named serial.cpp which responsible to serial port connection.

This class contains 2 queues. one for save bytes from the comm port and second for the decoded messages. the class has the functions below:

void Serial::sendCommand(QString s)

{

QString sometext = s;

QByteArray ba = QByteArray::fromHex(sometext.toLatin1());

serial->write(ba);

}

void Serial::serialReceived()

{

QByteArray ba ;

serialArray = serial->readAll();

for (int i=0; i

{

queueBytes.enqueue(serialArray[i]); // queue for saving the bytes

}

QVector vect = queueBytes

你可能感兴趣的:(qt串口阻塞)