open Serial port with ExtSerialPort in Qt5

1

Good afternoon / days I am developing an app with Qt5 in which I need to open and read a serial port, but it does not open I'm in Ubuntu 14.04

    //QextSerialPort *Puerto = new QextSerialPort(); //Intenté de esta forma y la siguiente
Puerto = new QextSerialPort("/dev/ttyUSB0");  // En mi header tengo declarado a puerto como QextSerialPort *Puerto
Puerto->setQueryMode(QextSerialPort::Polling);
Puerto->setPortName("/dev/ttyUSB0");
Puerto->setBaudRate(BAUD19200);
Puerto->setDataBits(DATA_8);
Puerto->setStopBits(STOP_1);
Puerto->setParity(PAR_NONE);
Puerto->setFlowControl(FLOW_OFF);
if(Puerto->open(QextSerialPort::ReadOnly)){ // Ya intenté con ReadWrite y WriteOnly
    qDebug() << "Puerto abierto";
    Puerto->close();
}else{
    qDebug() << "No se puede abrir el puerto";
}

Thank you very much for the help.

    
asked by Aarón Gutiérrez 30.05.2017 в 00:39
source

1 answer

0

I think you need to add the targets in your .pro file:

QT       -= gui

TARGET = qextserialport_sencill_transmisio
CONFIG   += console
CONFIG   -= app_bundle  # MacOS no es el objetivo

TEMPLATE = app

SOURCES += main.cpp

# Añadidos mios al proyecto creado por defecto.
# Como son dependientes de la plataforma destino, utilizamos
# opciones distintas según la plataforma objetivo

win32 {
    # anyadir las librerias de qext...
    LIBS += -LS:/dsii/dsii_qt/qextserialport/build
    LIBS += -lqextserialportd1

    # anaydir donde localizar los archivos de cabecera de qext...
    INCLUDEPATH += S:/dsii/dsii_qt/qextserialport

    # etiquetas para C que permite saber que tipo de implementación serie es
    DEFINES  = _TTY_WIN_
}

unix {
    # anyadir las librerias de qext...
    LIBS += -L/home/aperles/tmp/qextserialport/build
    LIBS += -lqextserialportd

    # anaydir donde localizar los archivos de cabecera de qext...
    INCLUDEPATH += /home/aperles/tmp/qextserialport

    # etiquetas para saber en que tipo de sistema estamos
    DEFINES   = _TTY_POSIX_

}
    
answered by 30.05.2017 / 00:57
source