Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QSerialPortInfo list all available port on Linux

QSerialPortInfo list all available port on Linux

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 7.2k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nekyz
    wrote on last edited by
    #1

    Hello,

    I have a FTDI, USB to Serial connected to my own device, I try to list all port (as I can have multiple device connected), open a communication port & send data to my device.

    I have no problem for communicating on Windows, but on Linux & Mac I can't get the informations on my serial port.

    This is the code I used to show port :

    @QStringList SerialPortChannel::availablePorts()
    {
    QStringList ports;

    for (QSerialPortInfo port : QSerialPortInfo::availablePorts())
    {
        //Their is some sorting to do for just list the port I want, with vendor Id & product Id
        qDebug() << port.portName() << port.vendorIdentifier() << port.productIdentifier()
                 << port.hasProductIdentifier() << port.hasVendorIdentifier() << port.isBusy();
        ports += port.portName();
    }
    return ports;
    

    }@

    This is the my class constructor where I open the port :

    @SerialPortChannel::SerialPortChannel(QString port)
    : QObject()
    , m_port(port)
    {
    online = m_port.open(QIODevice::WriteOnly);
    if(online)
    qDebug() << "Connected to : " << port;

    //Configure the port
    m_port.setBaudRate(QSerialPort::Baud115200);
    m_port.setDataBits(QSerialPort::Data8);
    m_port.setStopBits(QSerialPort::OneStop);
    m_port.setParity(QSerialPort::NoParity);
    m_port.setFlowControl(QSerialPort::NoFlowControl);
    

    }@

    This work well on Windows, I can see my port.

    On Linux (Tested on Ubuntu 13.04 & Mint 15 Olivia ) : I can see my device with some name like : ttysUSB0, but any other informations like vendor id and product id are null. I can't open a communication, open return false. I have all informations listed on my OS, so it's a bug in my application.

    On Mac (10.8.5) , I can't even see the name and all others informations, but the device is connected to my Os as I can see him in the system info panel.

    What did I do wrong ? Is it something to configure on Linux or Mac ?

    1 Reply Last reply
    0
    • K Offline
      K Offline
      kuzulis
      Qt Champions 2020
      wrote on last edited by
      #2

      This is a main discussion:

      http://www.qtcentre.org/threads/56487-QSerialPortInfo-get-all-available-port-in-Linux-and-Mac?p=252525#post252525

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved