How do I get wmbusmeters:serial-port to point to /dev/ttyAMA0?
$ sudo snap connect wmbusmeters:serial-port /dev/ttyAMA0
$ sudo snap connect wmbusmeters:serial-port core:serial-port
error: snap "core" has no slot named "serial-port"
$ sudo snap connect wmbusmeters:serial-port core:/dev/ttyAMA0
error: snap "core" has no slot named "/dev/ttyAMA0"
I searched and searched - probably for the wrong thing - and haven’t found any for-dummies-explanation that shows which commands or configuration files to work with, so any pointers are very welcome!
The answer somewhat depends if your raspberry pi uses ubuntu-core as the operating system, or if it is using any other operating system.
On ubuntu-core, hardware accessories are usually statically described by the board-specific gadget snap. There you would find an interface that declares the /dev/ttyAMA0 serial port. On other systems this functionality is also available but it is somewhat more difficult to use, as you need to have a classic gadget that are fairly obscure. In both cases the declaration is static.
A long time ago snapd grew a limited capability to handle hot-plug devices, where without prior declaration an existing device is discovered and made available. This code, to the best of my knowledge, has not been enabled unconditionally and sits behind a feature flag that you may enable or disable on individual installations.
You can give this a try by running:
snap set system experimental.hotplug=true
This should give you a new serial port you can connect to with snap connect. If for whatever reason you want to back out of that, use snap unset system experimental.hotplug.
Classic gadget is just a gadget snap that is meant for classic and has interfaces. The problem is then you have to have a model assertion, a brand and a few things have to be signed right.
I did this a while ago but I cannot remember the details of how to do this with the snap store. I think it starts with a gadget snap that you upload as yourself to the store but I think this requires some permissions (gadgets) and you won’t be able to experiment entirely offline AFAIK.
As for the serial port, having a look at the code, at present, it is only limited to USB-attached serial. If you ran Ubuntu Core the serial port /ttyAMA0 is exported as bt-serial (you can look at /snap/pi/current/meta/snap.yaml to confirm that).
I think I understand.
It doesn’t sound like a feasible route.
I think I have to abandon snap and go another route.
Thank you very much for your insights!
I think you should be able to use your snap on a Ubuntu Core running on the same hardware. Running classic distributions like Raspbian on a Pi is good for development but not so good when you have many of them to look after or keep up-to-date.