QSerialPort Mac OS authorization



  • Hello,
    I use MacOS Sierra and Qt Creator.
    I've just start a project with an USB/RS485 adapter, so I naturally use the QSerialPort module.
    I start by opening the device:
    if (!serialPort.open(QIODevice::ReadWrite))
    {
    ....
    }

    My serial port is something like: tty.usbserial-xxxxxx.
    But when I execute the program, it was unable to open the serial port. The only solution for me is to launch the program manually from my build directory with the sudo command.
    It appears as a problem of rights, like adding the user to the dialout group in Linux, but I can't find anything about it on Mac.
    Some of my colleagues use Qt on MacOS with several UART devices and they never had any issues with it.

    Did I miss something?


  • Lifetime Qt Champion

    Hi and welcome to devnet,

    What did you install to make your serial port(s) work ?

    What version of macOS are you using ?



  • Thank you SGaist.
    I'm using Sierra, what do you mean by "what did you install"?
    My USB device is based on a FTDI chip, it works out of the box and appears in /dev when I plug it.
    When I launch ./myapp I got:
    QIODevice::write (QSerialPort): device not open

    When I launch sudo ./myapp everything works fine.



  • I use a USB-Serial adapter on my Mac (Yosemite) and I have never had permission problems. I had to install the prolific driver for the device so I assume this is the difference.

    On GNU/Linux I had to change the permissions on the device to allow user level access. Something like chmod 666 /dev/ttyUSB0 would work until it was removed and re-connected. I used '666' because it was easy to remember but you really only need read/write access for the current user (or users).

    I am sure there is a way to set default permissions on this device when you connect it (something automatic). I was thinking about looking into this on GNU/Linux but never got around to it. It hasn't come up on OS X for me at least so I am not sure what the mechanism to do this would be.



  • The only difference is that you are use a Prolific driver not a FTDI one.
    I've try to switch from Apple FTDI drivers to official FTDI drivers without success.
    I hope somebody will have the same problem one day to help me found a fix.


  • Lifetime Qt Champion

    Did you follow the FTDI guide for the installation ?



  • Yes but I didn't notice section 7 "Disabling the Apple-provided VCP on OS X 10.9 and later".
    The AppleUSBFTDI.kext didn't appear on my system but messing up with Kernel Extensions solved my problem.
    I can now access my device everytime I execute my program whatever the method.

    Thanks for the reminder SGaist.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.