0

This is my c++ code:

#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;
        }

    }

This is output:

error: 13 portname: /dev/ttyACM0 strerror: 1

When I connect the phone to the USB port, this code don't give the error. But When I connect the Arduino Uno to the USB port, this code gives the error. Error is "Permission denied". How Can I solve this problem?

GG gg
  • 73
  • 1
  • 8

1 Answers1

0

To solve this, write the following in terminal:

sudo chmod 666 /dev/ttyACM0

GG gg
  • 73
  • 1
  • 8