Comment 2 for bug 1645445

Revision history for this message
Jamie Strandboge (jdstrand) wrote :

Thank you for filing a bug.

The fact that this is a symlink to /dev/ttyUSB0 suggests this should be part of the serial-port interface in some way. The serial-port interface can create symlink udev rules from product and vendor ids specified by the gadget snap slot. Eg, if the gadget snap for the ROS device had this:

name: my-gadget
slots:
  kobuki-device:
    interface: serial-port
    path: /dev/kobuki
    usb-vendor: 0x0403
    usb-product: 0x6001

Then the following rule would be created (assuming serialUdevSymlinkPattern has adjusted to handle this):
SUBSYSTEM=="tty", SUBSYSTEMS=="usb", ATTRS{idVendor}=="0x0403", ATTRS{idProduct}=="0x6001", SYMLINK+="kobuki"

and plugging snaps simply:

name: my-snap
plugs:
  kobuki:
    interface: serial-port

then you manually connect with:
$ sudo my-snap:kobuki my-gadget:kobuki-device

which allows my-snap access to the device with usb-vendor 0x0403 and usb-product 0x6001 (snapd does this via device cgroup) and it can be accessed via /dev/kobuki.

@Michael, is the udev rule that I posted above sufficient for your needs? Based on /lib/udev/rules.d/50-udev-default.rules it looks like serial devices get GROUP:="dialout" already. I think all that remains is ATTRS{serial}=="kobuki*" and MODE:="0666"; local testing shows that it may get 0660 by default. This won't affect daemons on snappy since those run as root, but it will mean that regular users need to use sudo unless they are added to the dialout group (and I think this is the correct approach btw-- snappy can make group membership handling for the default user easier in the future).