4

I am trying to connect a microcontroller to a host computer using a USB virtual com port. However, I do not have root privileges on the host computer. The controller shows up as /dev/ttyACM0.

When I try to connect to it using the pyserial module, an error occurs saying "permission denied".

Is there a way to work around this without using any sudo commands? Maybe somehow forcing the microcontroller to announce itself not as ACM? Could the permission problem be avoided in this way?

$ ls -l /dev/ttyACM0
crw-rw----. 1 root dialout 166, 0 Apr 4 13:44 /dev/ttyACM0
$ id
uid=1003(mri) gid=1001(nmruser) groups=1001(nmruser),100(users),1000(nmrsu) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c102‌​3

Unfortunately I cannot change the permissions. The host is the computer of an MRI scanner. Its system is maintained by the manufacturer of the scanner. I considered using Ethernet, but I was hoping there is a way to avoid it.

0

2 Answers 2

3

By default, raw access to most (if not all) devices is only allowed for root. You would have to change the permissions on /dev/ttyACM0 to allow your user account to use it. A common group for this use is dialout, but it could be any user/group with write access to the 'file'.

You can change the permissions with chmod and chown:

$ chmod 664 /dev/ttyACM0
$ chown root:dialout /dev/ttyACM0

Every serial connection you are going to make is going to have this problem. If you want to avoid this, you would have to use an out-of-band medium, which is not locked down by default, such as Ethernet. You could then set up an HTTP or MQTT server to transfer data between the host and the microcontroller.

1
  • 2
    I don't know what your credentials are, but I wouldn't want to mess around with an MRI scanner. Good luck!
    – mtak
    Commented Apr 4, 2017 at 7:05
1

Ask the person who has root access to set up an udev rule that assigns a custom name, group and group r/w permissions to what is now /dev/ttyACM0. Also, you should become a member of this group.

After that, you can open the device without beeing root.

You can't make this change without having root rights, or physical access so you can become root once for this occasion.

1
  • Can you explain how I can assign a group to /dev/ttyACM0? I used SUBSYSTEMS=="usb", ATTRS{idVendor}=="f055", MODE="0666", GROUP="groupname". This only changes the group of /dev/bus/usb/x/y.
    – Furo
    Commented Apr 4, 2017 at 15:00

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .