Expand the raspberry pi gadget with a serial interface.
This requires me to build an image though, while: error: snap "ubuntu-image" is not available on beta for this architecture (arm64) but exists on other architectures (amd64, i386).
Use classic confinement.
Not really nice, and I’m not sure I can install that on ubuntu core.
You can cross build images from an amd64 device to target an arm64 device easily, just run the same ubuntu-image command on amd64 instead of your target device.
This would be used with auto-connect via greedy plugs, see for example the arduino snap which had this approved recently.
You can cross build images from an amd64 device to target an arm64 device easily, just run the same ubuntu-image command on amd64 instead of your target device.
Oh, the docs mention: " The ubuntu-image command needs to be run on the same architecture as the target image and needs only the filename of the model assertion to build an image."
This would be used with auto-connect via greedy plugs, see for example the arduino snap which had this approved recently.
So if my device shows up as - snapd:cp2102cp2109uartbrid (allows accessing a specific serial port), then in my snapcraftyaml, I need:
and then the snap declaration will be issued by the store team which will automatically connect your serial-port plug to the snapd:cp2102cp2109uartbrid plug when installed. I would recommend trying this out first before building a purpose built gadget as that is more maintenance than using greedy hot plugs, which were designed for this exact problem.
this doc is incorrect, thanks for letting us know we will make sure that is updated
CC @degville when back, that sentence should not say it needs to be run on the same architecture as the target image. The architecture is encoded into the model assertion.
So this is a bit nebulous, as it depends. We don’t currently expose any of the serial port slot attributes like the path or the vendor ID/product ID, etc. so there isn’t a way for your snap to know directly what path the newly provided serial port shows up as, i.e. /dev/ttyAMA0 or /dev/ttyUSB0, etc. What you could try to do is have a post-connect-serial-port hook which just tries to read every serial port path you expect and if it is able to read/connect to one, then save that by appending to a list saved with snapctl set serial-ports=[/dev/ttyAMA0,/dev/ttyUSB0] and then your main app could read that list of serial-ports.