Important: Please read the Qt Code of Conduct -

[SOLVED]Serialport permission programmatically

  • Hi!

    In my application I'm using a virtual serial port which is actually a USB-UART converter chip. If it is connected it recognized as /dev/ttyUSBx, where x=0...3. Each time I want to use that particular port I have to fire up the terminal and look it up with dmesg | grep ttyUSB*, then sudo chmod 0666 ttyUSBx to gain access. How can I do this programmatically?

    Thank you.

  • Lifetime Qt Champion


    Simpler (and more secure) way: check the group of ttyUSB* (if on *buntu should be dialout) and add your user to that group (don't forget to logout/login).

    If the group is root, add an udev rule to make so that the device gets another group and add your user to that group.

    Hope it helps.

  • Hi Sgaist,

    thank you for the tip! I added myself to the dialout group and after reboot my app was able to access the port. Cheers!

Log in to reply