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. [solved] QSerialPort error - "is a directory"

[solved] QSerialPort error - "is a directory"

Scheduled Pinned Locked Moved General and Desktop
7 Posts 2 Posters 2.9k 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.
  • B Offline
    B Offline
    beakie
    wrote on last edited by
    #1

    This code gives an error of "Is a directory" when open() is called. I assume it's permissions or something but I can't find a single instance ANYWHERE online of someone else getting this error?

    [code]
    #include <QCoreApplication>
    #include <QDebug>
    #include <QtSerialPort/QSerialPort>
    #include <QtSerialPort/QSerialPortInfo>

    int main(int argc, char *argv[])
    {
    QCoreApplication a(argc, argv);
    QSerialPortInfo serialPortInfo("/dev/ttyUSB0");
    QSerialPort serialPort(serialPortInfo);

    QByteArray byteArrayRequest;
    byteArrayRequest.resize(2);
    byteArrayRequest[0] = 0x01;
    byteArrayRequest[1] = 0x01;
    
    if (serialPort.open(QIODevice::ReadWrite))
    {
        serialPort.setBaudRate(QSerialPort::Baud38400);
        qDebug() << "Writing\n";
        serialPort.write(byteArrayRequest);
        serialPort.close();
    }
    else
    {
        qDebug() << serialPort.errorString();
        qDebug() << "Problem opening port\n";
    }
    
    return a.exec(&#41;;
    

    }

    [/code]

    Can anyone please advise?

    Thanks

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      What does ls -la /dev/ttyUSB0 return ?

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0
      • B Offline
        B Offline
        beakie
        wrote on last edited by
        #3

        [quote author="SGaist" date="1393630095"]What does ls -la /dev/ttyUSB0 return ?[/quote]

        If the device IS NOT plugged in:
        ls: cannot access /dev/ttyUSB0: No such file or directory

        If the device IS plugged in:
        crw-rw---- 1 root uucp 188, 0 Mar 1 21:27 /dev/ttyUSB0

        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #4

          Are you member of the uucp group ?

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • B Offline
            B Offline
            beakie
            wrote on last edited by
            #5

            [quote author="SGaist" date="1393714479"]Are you member of the uucp group ?[/quote]

            I have run my code as root.

            1 Reply Last reply
            0
            • B Offline
              B Offline
              beakie
              wrote on last edited by
              #6

              OK, so I figured I must be referencing the port incorrectly.

              This post was useful -> http://qt-project.org/forums/viewthread/28942

              I changed the hardcoded reference to /dev/ttyUSB0 in my code and loaded it in the same way as the posts do and it worked fine!

              Thanks :)

              1 Reply Last reply
              0
              • SGaistS Offline
                SGaistS Offline
                SGaist
                Lifetime Qt Champion
                wrote on last edited by
                #7

                You're welcome !

                Since you have your serial port talking now, please update your thread title prepending [solved] so other forum users may know a solution has been found :)

                Interested in AI ? www.idiap.ch
                Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                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