A
A
AlexSer2019-11-08 14:47:44
Qt
AlexSer, 2019-11-08 14:47:44

Why doesn't QT read from serial?

Here is the Qt code for connecting to serial port

serialPort=new QSerialPort(this);
             serialPort->setPortName(port);
             serialPort->setBaudRate(baudrate);
             serialPort->setDataBits(QSerialPort::Data8);
             serialPort->setParity(QSerialPort::NoParity);
             serialPort->setStopBits(QSerialPort::OneStop);
             serialPort->setFlowControl(QSerialPort::NoFlowControl);
             serialPort->open(QIODevice::ReadWrite);
             if(serialPort->isOpen()){
                 QMessageBox::about(this,"title","Соединение установлено успешно");
                 dialogSettCom->close();
             }else{
                  QMessageBox::warning(this,"title","Соединение не установлено");
             }
               qDebug()<<serialPort->readAll();

The question is why there is no constant reading from the port?
tried through while(serial->isOpen) then only empty data is displayed. And thus displays only the first stream of data.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Armenian Radio, 2019-11-08
@AlexSer

Because you need to handle the readyRead() signal

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question