duanchifo2866 2017-02-25 12:55 采纳率: 100%
浏览 1212
已采纳

求助:后缀管道时/ dev / ttyACM0文件不存在

当我以常规用户的身份手动运行脚本时,一切正常。但是,如果收到一封电子邮件并通过管道发送到Go脚本中,我就无法打开串口,因为文件不存在。

postfix   1239  1025  0 13:20 ? 00:00:00 pipe -n watchParadox -t unix flags=F user=watch argv=/usr/local/bin/watch -paradox
watch     1240  1239  0 13:20 ? 00:00:00 /usr/local/bin/watch -paradox

脚本运行在已添加到拨号组的“监视用户”下,“后缀用户”(Postfix User)也在“拨号”中运行。

在我的脚本中,我运行ls-la命令来找出哪些文件确实存在:

drwxr-xr-x   6 root root  380 Feb 25 13:19 .
dr-xr-xr-x. 18 root root 4096 Feb 22 17:53 ..
lrwxrwxrwx   1 root root   11 Feb 25 13:19 core -> /proc/kcore
lrwxrwxrwx   1 root root   13 Feb 25 13:19 fd -> /proc/self/fd
crw-rw-rw-   1 root root 1, 7 Feb 25 13:19 full
drwxr-xr-x   2 root root    0 Feb 25 13:19 hugepages
lrwxrwxrwx   1 root root   28 Feb 25 13:19 log -> /run/systemd/journal/dev-log
drwxrwxrwt   2 root root   40 Feb 25 13:19 mqueue
crw-rw-rw-   1 root root 1, 3 Feb 25 13:19 null
lrwxrwxrwx   1 root root    8 Feb 25 13:19 ptmx -> pts/ptmx
drwxr-xr-x   2 root root    0 Feb 25 13:19 pts
crw-rw-rw-   1 root root 1, 8 Feb 25 13:19 random
drwxrwxrwt   2 root root   40 Feb 25 13:19 shm
lrwxrwxrwx   1 root root   15 Feb 25 13:19 stderr -> /proc/self/fd/2
lrwxrwxrwx   1 root root   15 Feb 25 13:19 stdin -> /proc/self/fd/0
lrwxrwxrwx   1 root root   15 Feb 25 13:19 stdout -> /proc/self/fd/1
crw-rw-rw-   1 root root 5, 0 Feb 25 13:19 tty
crw-rw-rw-   1 root root 1, 9 Feb 25 13:19 urandom 

我确信下面的文件存在,但在执行后缀管道时不显示。

crw-rw---- 1 root dialout 166, 0 25. úno 13.19 ttyACM0

我在文件上尝试了 chmod 777,但是没有找到那个部分。用 Go 函数的 https://github.com/tarm/serial 打开文件:

os.OpenFile("ttyACM0", syscall.O_RDWR|syscall.O_NOCTTY|syscall.O_NONBLOCK, 0666)

得到这个结果:

ttyACM0: no such file or directory

问题没有出在路径上,因为我尝试了相对(使用chdir)和绝对值,结果是相同的。

我甚至禁用了 SELinux,这不是我想做的,在寻找解决方案的过程中我尝试了任何我能想到的方法。

代码没有问题,因为脚本的手动执行是正确的。我认为还是Linux的设置有问题。

  • 写回答

2条回答 默认 最新

  • duan0417 2017-02-28 20:26
    关注

    It seems like it was truly Linux problem and some underlying fabrics of it which I do not understand. I was running Fedora25 but the problem does not occur on Debian8.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?
  • ¥15 c++头文件不能识别CDialog
  • ¥15 Excel发现不可读取的内容
  • ¥15 关于#stm32#的问题:CANOpen的PDO同步传输问题
  • ¥20 yolov5自定义Prune报错,如何解决?