user4000670
user4000670

Reputation:

Qt - serial port name in ubuntu

I have a problem with finding the serial port name on Ubuntu. As you know, for reading serial port on Windows, we can use this code for example:

serial->setPortName("com3");

but when I compile this code on Ubuntu, I can't use this code:

serial->setPortName("/dev/ttyACM0");

I know that my serial port name is ttyACM0 and I can read data on it by issuing this command:

cat /dev/ttyACM0

but why cannot I use this name in my code? What should I do?

Upvotes: 3

Views: 3206

Answers (2)

László Papp
László Papp

Reputation: 53173

In order to get permission for your regular user, please get your sysadmin add to the group that is in charge of the serial ports like that emulated over usb.

It is either tty, uucp or something. It varies from distribution to distribution, but you can easily check this by running the following command:

ls -l /dev/ttyACM0

Then check the group column and get the sysadmin do this:

sudo usermod -a -G group username

Please do not introduce security vulnerabilities by giving global write access to others like this:

sudo chmod 666 /dev/ttyACM0

Upvotes: 3

Oleg Shparber
Oleg Shparber

Reputation: 2752

Use:

serial->setPortName("ttyACM0");

Upvotes: 1

Related Questions