Reputation: 868
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 is another location to seek for the reason of this error?
Thanks for any advice!
Upvotes: 4
Views: 8135
Reputation: 1460
I created new file in /etc/udev/rules.d/51-arduino.rule with following content:
SUBSYSTEMS=="usb", KERNEL=="ttyACM0", ATTRS{idVendor}=="2341", ATTRS{idProduct}=="0043", GROUP="dialout", MODE="0666"
Be careful to set up idVendor and idProduct properly. After reboot the device privileges are set.
Upvotes: 1
Reputation: 622
As HappyHacking mentioned you need to execute the following command:
sudo adduser [user] dialout
Then logout of the user and log back in.
Upvotes: 1
Reputation: 5094
I have never used Arduino, so I'll suppose your method is right. First thing I would try is sudo
ing the first command:
sudo cu -l /dev/ttyACM0 -s 115200
But, since the second message is Line in Use
it might also be that the /dev/ttyACM0
is already actually taken/locked. In other words, is there any process using the port? I can't test it on a serial port, but I'd try piping the output of list open files command to grep command:
lsof | grep ACM
It should list the process identifer of the process which locked upon the port. Then you can use the kill command to stop that process:
kill <PID_FROM_OUTPUT_OF_UPPER_COMMAND>
To verify that you succesfully stopped the process you can pipe the output of list all active processes command to the grep command:
ps x | grep <PID_FROM_OUTPUT_OF_UPPER_COMMAND>
which should return no output if the process was successfully stopped. If not, it will ouput that line, so you can try with the -9 flag like this:
kill -9 <PID_FROM_OUTPUT_OF_UPPER_COMMAND>
and it will eventually stop.
Without testing, I'm not sure will the lsof
command written in the current form list the taken tty
devices. If that is the case then there must be some flag combination which will list them, since everything in Unix is a file.
So, the principle must be valid: find out which process is using the device and stop it (the ps
and kill
commands will work once you have the right process identifier).
If all of the above is not the case, then probably your method is wrong. In that case, I'd start by carefully rereading the Arduino documentation again :)
Upvotes: 5