Qt - ubuntu中的串行端口名称 [英] Qt - serial port name in ubuntu

查看:897
本文介绍了Qt - ubuntu中的串行端口名称的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Ubuntu上找到串行端口名称有问题。正如你所知,对于在Windows上阅读串行端口,我们可以使用这个代码例如:

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");

但是当我在Ubuntu上编译这个代码时,我不能使用这个代码:

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

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

我知道我的串口名是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?

推荐答案

为了获得常规用户的权限,请将sysadmin添加到

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.

它是 tty uucp 或某事。它从分布到分布不同,但您可以通过运行以下命令轻松检查:

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

然后检查组列,并得到sysadmin这样做:

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

这篇关于Qt - ubuntu中的串行端口名称的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆