简体   繁体   中英

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?

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

使用:

serial->setPortName("ttyACM0");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM