Multi serial port application
-
Hi @aha_1980 ,
I am working for single port now ,its not able to open the port here is my code by using send pushbutton and connect()void Dialog :: open_serialport()
{
QSerialPort serial;
QString portName = ui->port_comboBox->currentText();
qDebug() << "The portName is " << portName;
bool currentPortNameChanged = false;
QString currentPortName;
if(currentPortName != portName)
{
currentPortName = portName;
currentPortNameChanged = true;
}if(currentPortName.isEmpty()) { qDebug() << "No port name specified"; } if(currentPortNameChanged) { serial.close(); serial.setPortName(portName); qDebug() << "portName" << portName; if(!serial.open(QIODevice::ReadWrite)) { qDebug() << "can not able to open the serial port"; } }
}
its giving error i am passing from gui ,please help me out.... -
@veera said in multi serial port application:
void Dialog :: open_serialport()
{
QSerialPort serial; <<<< WRONG ! its local variablemake it a class member of Dialog
-
@mrjj ,
just now declared a QSerialPort as data members of the dialog class in dialog.h still also i am getting same error...here is the declaration of the QSerialPort
#ifndef DIALOG_H
#define DIALOG_H#include <QDialog> #include <stdio.h> #include <QtSerialPort/QSerialPort> namespace Ui { class Dialog; } class Dialog : public QDialog { Q_OBJECT public: QSerialPort serial;
-
Super
but what error ? -
Hi
normally its ttyS4
for
serial->setPortName(p.name);Did you see the sample
http://doc.qt.io/qt-5/qtserialport-terminal-example.htmlIts available directly in Creator and you can use to test.