【问题标题】:open Unix, Linux System Call Permission denied for Arduino Uno为 Arduino Uno 打开 Unix、Linux 系统调用权限被拒绝
【发布时间】:2016-11-26 21:52:18
【问题描述】:

这是我的 C++ 代码:

#include <iostream>
#include <errno.h>
#include <fcntl.h>
#include <string.h>
#include <termios.h>
#include <unistd.h>

void createConnect(){

        const char *portname = "/dev/ttyACM0";
        int fd = open (portname, O_RDWR | O_NOCTTY | O_SYNC);
        if (fd < 0)
        {
           std::cout << "error: " <<  errno << " portname: " << portname << " strerror: " << strerror << std::endl;
        }

    }

这是输出:

错误:13 端口名:/dev/ttyACM0 strerror:1

当我将手机连接到 USB 端口时,此代码不会给出错误。但是当我将 Arduino Uno 连接到 USB 端口时,此代码给出了错误。错误是“权限被拒绝”。我该如何解决这个问题?

【问题讨论】:

    标签: c++ linux arduino-uno


    【解决方案1】:

    要解决这个问题,请在终端中编写以下内容:

    sudo chmod 666 /dev/ttyACM0

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2013-01-08
      • 1970-01-01
      • 2013-03-13
      • 2020-05-31
      • 1970-01-01
      • 2018-09-08
      • 2018-03-20
      • 2016-03-13
      相关资源
      最近更新 更多