The serial interface constantly denies requests

My actual problem is that every time I want to access my serial interface (Arduino), the system returns Permission denied .

root@laptop :/home/user #> cu -l /dev/ttyACM0 -s 115200 /usr/bin/cu: open (/dev/ttyACM0): Permission denied /usr/bin/cu: /dev/ttyACM0: Line in Use root@laptop :/home/user #> ls -la /dev/ttyACM* crw-rw---- 1 root dialout 166, 0 Mรคr 14 10:37 /dev/ttyACM0 crw-rw---- 1 root dialout 166, 0 Mรคr 14 10:37 /dev/ttyACM1 crw-rw---- 1 root dialout 166, 0 Mรคr 14 10:37 /dev/ttyACM2 crw-rw---- 1 root dialout 166, 0 Mรคr 14 10:37 /dev/ttyACM3 

what else is the place to find the cause of this error?

Thanks for any advice!

+4
source share
3 answers

I have never used Arduino, so I assume that your method is right. The first thing I will try is sudo with the first command:

 sudo cu -l /dev/ttyACM0 -s 115200 

But, since the second Line in Use message, it may also be that /dev/ttyACM0 already actually accepted / blocked. In other words, is there any process using the port? I cannot test it on the serial port, but I would try piping the output of list open files for the grep command :

 lsof | grep ACM 

It should list the process ID of the process that is blocked for the port. Then you can use the kill command to stop this process:

 kill <PID_FROM_OUTPUT_OF_UPPER_COMMAND> 

To ensure that you have successfully stopped the process, you can pass the command show all active processes to the grep command:

 ps x | grep <PID_FROM_OUTPUT_OF_UPPER_COMMAND> 

which should not return a result if the process was successfully stopped. If not, this line will come out, so you can try with the -9 flag as follows:

 kill -9 <PID_FROM_OUTPUT_OF_UPPER_COMMAND> 

and he will eventually stop.

Without testing, I'm not sure if the lsof command, written in the current form, displays the accepted tty devices. If so, then there should be some combination of flags that will list them, since everything on Unix is โ€‹โ€‹a file.

So, the principle must be valid: find out which process uses the device and stop it ( ps and kill commands will work as soon as you have the correct process identifier).

If all this is not so, then perhaps your method is incorrect. In this case, I would start to carefully re-read the Arduino documentation again :)

+5
source

As mentioned in HappyHacking, you need to run the following command:

sudo adduser [user] dialout

Then log out and log in.

+1
source

I created a new file in /etc/udev/rules.d/51-arduino.rule with the following contents:

 SUBSYSTEMS=="usb", KERNEL=="ttyACM0", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", GROUP="dialout", MODE="0666" 

Be sure to configure idVendor and idProduct correctly. After a reboot, device privileges are set.

+1
source

Source: https://habr.com/ru/post/1469187/


All Articles