Hey everyone,
I am new to MicroPython and microcontrollers in general.
I am trying to use MicroPython's virtual comm port class to display some status messages from the Pyboard on the host computer and transfer some files from the board to the host. However, I do not have root access on the host computer.
For Ubuntu I can work around this by setting the usb_mode of the Pyboard to 'VCP+MSC'. This gives me 666 permission for /dev/ttyACM0. To me this seems like an Ubuntu bug. Also, it does not work on other distros (I checked CentOS and Gentoo).
Is there a way to connect to the Pyboard via virtual comm (e.g. using pyserial on the host) without root access on the host computer?
Best,
Flo
PS: I checked out dhylands json-ipc and rshell, but both do not work without root, as the permission is denied to connect to /dev/ttyACM0.
Using USB vitual comm port without root on host
Re: Using USB vitual comm port without root on host
Under ubuntu, the simplest way to get permissions to the serial ports is to add your user to the dialout group. Replace USERNAME with your ubuntu login username (You can use the whoami command to determine your username.
Alternatively, you can also use some udev rules. The udev rules on this page: https://github.com/micropython/micropyt ... -Discovery should also work for the pyboard.
Be aware that changing the usb_mode may also change the USB PID. The pyboard can have a PID of 9800 for VCP+MSC, 9801 or VCP+HID, or 9802 for VCP only mode.
Code: Select all
sudo usermod -a -G dialout USERNAME
Alternatively, you can also use some udev rules. The udev rules on this page: https://github.com/micropython/micropyt ... -Discovery should also work for the pyboard.
Be aware that changing the usb_mode may also change the USB PID. The pyboard can have a PID of 9800 for VCP+MSC, 9801 or VCP+HID, or 9802 for VCP only mode.
Re: Using USB vitual comm port without root on host
I have done both. I added myself to dailout and used the udev rules on my private computer. This indeed resolves all the permission issues.
The intended host, however, is the computer of an MRI scanner. Its system is maintained by the manufacturer, meaning I cannot run any sudo commands.
I also asked about this on superuser(https://superuser.com/questions/1195006 ... oot-access). It seems the only way to avoid the permission issues is to use e.g. Ethernet instead.
As an alternative, I was thinking to use the board in mass storage mode and write a file with output to the sd card and use machine.reset() regularly. Using reset should trigger the auto mount on the host (remounting requires sudo). After auto mount the new file should be visible to the host, and a simple python script running on the host could print its content to the screen.
I know this is an unusual approach and iffy at best.
The intended host, however, is the computer of an MRI scanner. Its system is maintained by the manufacturer, meaning I cannot run any sudo commands.
I also asked about this on superuser(https://superuser.com/questions/1195006 ... oot-access). It seems the only way to avoid the permission issues is to use e.g. Ethernet instead.
As an alternative, I was thinking to use the board in mass storage mode and write a file with output to the sd card and use machine.reset() regularly. Using reset should trigger the auto mount on the host (remounting requires sudo). After auto mount the new file should be visible to the host, and a simple python script running on the host could print its content to the screen.
I know this is an unusual approach and iffy at best.
Re: Using USB vitual comm port without root on host
That's a problem.
There isn't anything that can be done from the device to give you permissions to use it (at least as a serial device). That requires root access.
There isn't anything that can be done from the device to give you permissions to use it (at least as a serial device). That requires root access.
- pythoncoder
- Posts: 5956
- Joined: Fri Jul 18, 2014 8:01 am
- Location: UK
- Contact:
Re: Using USB vitual comm port without root on host
@furo Using mass storage mode and sharing a data file between the Pyboard and the host PC can lead to problems. USB mass storage mode is not designed for shared file access. You might get away with it if you find a way to guarantee that there is no concurrent access to the file: i.e. the Pyboard closes the file before the PC attempts to access it, and the PC closes it before the Pyboard opens it.
But even that may not ensure reliability.
But even that may not ensure reliability.
Peter Hinch
Index to my micropython libraries.
Index to my micropython libraries.
Re: Using USB vitual comm port without root on host
Thanks for the replies!
I eventually managed to get the root password and used udev rules to grant the user permission to read and write to the serial device.
This worked without hiccups on the first computer I tried it on (CentOS 7, udev 219). Afterwards I tried it on another computer in our lab running CentOS 5 (udev 095). On this system the udev rules seem to have no effect at all.
Have you encountered similar problems before or do you have any tips on what I could try?
I don't know if this is relevant, but you can find the details of the kernel configurations of the CentOS 5 machine here.
I eventually managed to get the root password and used udev rules to grant the user permission to read and write to the serial device.
This worked without hiccups on the first computer I tried it on (CentOS 7, udev 219). Afterwards I tried it on another computer in our lab running CentOS 5 (udev 095). On this system the udev rules seem to have no effect at all.
Have you encountered similar problems before or do you have any tips on what I could try?
I don't know if this is relevant, but you can find the details of the kernel configurations of the CentOS 5 machine here.
Re: Using USB vitual comm port without root on host
IIRC, older vesions of udev used SYSFS{idProduct} rather than ATTRS[idProduct} (i.e. used SYSFS rather than ATTRS)