Qt - serial port name in ubuntu
I have a problem finding the serial port name on Ubuntu. As you know, we can use this code to read the serial port on Windows, for example:
serial->setPortName("com3");
but when I compile this code on Ubuntu I cannot use this code:
serial->setPortName("/dev/ttyACM0");
I know the name of my serial port is ttyACM0 and I can read data on it by issuing this command:
cat /dev/ttyACM0
but why can't I use this name in my code? What should I do?
To get permission for a regular user, please add your sysadmin to the group that is responsible for serial ports like emulated via usb.
It's either tty
, uucp
or something. It varies from distribution to distribution, but you can check it easily by running the following command:
ls -l /dev/ttyACM0
Then check the group column and run sysadmin:
sudo usermod -a -G group username
Please do not detect security vulnerabilities by granting global write access to others as follows:
sudo chmod 666 /dev/ttyACM0
source to share