Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-38639

QSerialPort prepends `/dev/cu.` to all serial port to be opened.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P4: Low
    • 4.8.x, 5.4.0
    • 5.2.1
    • Serial Port
    • None
    • MacOSX 10.9

    Description

      ok, after checking latest sources, I modified QSerialPort::open to add a few debug statements:

      qDebug() << "SYS LOC:" << systemLocation;
      descriptor = qt_safe_open(systemLocation.toLocal8Bit().constData(), flags);
      qDebug() << "descriptor:" << descriptor;
      

      and here's what I got:

      SYS LOC: "/dev/cu./dev/ttys002" 
      descriptor: -1 
      

      so it led me to the following code:

      #ifdef Q_OS_MAC
      static const QString defaultFilePathPrefix = QStringLiteral("/dev/cu.");
      static const QString unusedFilePathPrefix = QStringLiteral("/dev/tty.");
      #else
      static const QString defaultFilePathPrefix = QStringLiteral("/dev/");
      #endif
      
      QString QSerialPortPrivate::portNameToSystemLocation(const QString &port)
      {
          QString ret = port;
      
      #ifdef Q_OS_MAC
          ret.remove(unusedFilePathPrefix);
      #endif
      
          if (!ret.contains(defaultFilePathPrefix))
              ret.prepend(defaultFilePathPrefix);
          return ret;
      }
      

      that is making the assumption that all serial ports are /dev/cu. prefixed files. Whereas a PTY is not...

      As suggested by Sergey in QTBUG-32024, we can as well make all absolute path given to the open function skip the modifications, so an user can read from a chardev he has created outside of /dev.

      Attachments

        For Gerrit Dashboard: QTBUG-38639
        # Subject Branch Project Status CR V

        Activity

          People

            kuzulis Denis Shienkov
            zmo Bernard
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes