Qt - Serial port on windows responds but on linux no!

1

I resort to you because I have a problem reading the serial port. It turns out that my demo runs correctly on windows but I do not get any kind of answer on linux. The device to which I connect is an antenna, to which you must send the command "log gpgga ontime 1" + the carriage return. My code is as follows:

void MainWindow::on_btnObtener_clicked()
{
    foreach(const QSerialPortInfo &info, QSerialPortInfo::availablePorts())
    {

        qDebug() << "Puerto: " << info.portName();
        qDebug() << "Nro. Serie: " << info.serialNumber();
        qDebug() << "Fabricante: " << info.manufacturer();
        qDebug() << "Descripcion: " << info.description();

        if (info.portName().trimmed().compare("ttyUSB0") == 0)
        {
            auxserial = new QSerialPort(info);
            auxserial->setBaudRate(QSerialPort::Baud9600);
            connect(auxserial, &QSerialPort::readyRead, this, &MainWindow::readData);

            if (auxserial->open(QIODevice::ReadWrite))
            {
                const QByteArray buffer = "log gprmc ontime 1";
                auxserial->write(buffer);
                auxserial->flush();

                const QByteArray fin = "\r\n";
                auxserial->write(fin);

                auxserial->flush();
                qInfo() << "Puerto Abierto correctamente";
                break;
            }
        }
    }
}

void MainWindow::readData()
{
    while(auxserial->canReadLine())
        qInfo() << auxserial->readLine();
}

Now, on windows it works correctly and even, if I purposely write the command wrong, it returns the response of the antenna with an error message emitted by the antenna. HOWEVER SINCE LINUX, nothing of this happens ... it tells me that the port is open correctly, but it does not respond OK or ERROR. That could be happening?

EDIT: I just discovered that there are linux that have problems with the adapter "CH341 USB Adapter" ... in this case I am using a Debian 9

Thanks

    
asked by Emiliano Torres 07.11.2018 в 17:46
source

1 answer

1

I already found the solution ... obviously the problem was the adapter CH340-341, given that in some Linux distros it is good and in others not, because of a parity problem in the driver. In the video of the link, it is explained how to solve it. It worked for me, I hope that others who have the same problem can solve it.

link

Thanks

    
answered by 12.11.2018 / 15:34
source