Small correction, I am not able to open a new terminal on clicking connect push button for the COM port selected through combo box.
Small correction, I am not able to open a new terminal on clicking connect push button for the COM port selected through combo box.
Why do you think that opening a serial port should create a complete terminal application?
I suggest you study Qt's Terminal example. If you use Qt Creator, it is one of the examples on the Examples part of the Welcome page.
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Thanks, It was my understanding that just by configuring serial port and clicking a button would open a serial port.
Yes, I have already executed Terminal example while exploring documents. For now, I think not necessary to open a new terminal.
My serial interface frame format is, SOF | command | Len | Data | Checksum | EOF. I would like to extract my read data based on command types with variable Len. Which is the better way to store frame data, buffer or structure?
connect(serial, &QSerialPort::readyRead, this, &MainWindow::serialReadyRead);
void MainWindow::serialReadyRead()
{
QByteArray data = serial->readAll();
QString str = QString(data);
qDebug()<<"Received data : "<<data;
/* SOF | command | Len | Data | Checksum | EOF */
/* parsing serial frame data takes place here */
}
Where serialReadyRead() function, parses serial frame received data from another PC. Is there any correction required in the above implementation?
Best Regards,
Anita
Yes, the readyRead signal is generated after a few (one, several, different) bytes, not after a packet. Serial port knows nothing about your data structure. You have to build the package in the buffer yourself and start its analysis after receiving the EOF.
Thanks...
Just want to know, to build a package I am using QByteArray. But my Len and Checksum are of 2 bytes in size. How can I append 2 bytes to QByteArray?
Best Regards,
Anita
QByteArray::append() sounds like it could be useful for appending to a QByteArray.How can I append 2 bytes to QByteArray?
<=== The Great Pumpkin says ===>
Please use CODE tags when posting source code so it is more readable. Click "Go Advanced" and then the "#" icon to insert the tags. Paste your code between them.
Bookmarks