Important: Please read the Qt Code of Conduct -

[solved] QSerialPort error - "is a directory"

  • 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?

    #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[0] = 0x01;
    byteArrayRequest[1] = 0x01;
    if (
        qDebug() << "Writing\n";
        qDebug() << serialPort.errorString();
        qDebug() << "Problem opening port\n";
    return a.exec(&#41;;



    Can anyone please advise?


  • Lifetime Qt Champion


    What does ls -la /dev/ttyUSB0 return ?

  • [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

  • Lifetime Qt Champion

    Are you member of the uucp group ?

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

    I have run my code as root.

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

    This post was useful ->

    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 :)

  • Lifetime Qt Champion

    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 :)

Log in to reply