I am building a snap that I would like to use a greedy plug declaration and allow auto connects. The snap consumes up to 9 serial ports at once. I would like have it work with the experimental hot plug feature as well.
I would like to make sure it does not grab any USB serial port and only grabs ones that the snap is made for. Is it possible to select only devices with specific
ID_MODEL as the ones to be auto connected? I cannot find any way on the
plug side to set this type of information about what to connect to.
@ogra I bet you have looked into things like this, any ideas?
the hotplug interface typically namespaces the slot names.
see “hotplug slots” at:
that should be sufficient …
Since you have a greedy snap declaration, with hotplug enabled, it will automatically get connected to all interfaces, this is by design with the greedy snap declaration. If your application needs to only use a specific slot, you should have that slot declared in a gadget snap where you can specify the exact vendor ID and product ID, or path, etc. that your snap is meant for. Then you can connect that slot to your application via the gadget snap’s
connections stanza in the gadget.yaml.
@ijohnson yes I am planning to use the greedy snap declaration with hotplug.
With a full gadget I agree with you, my hope is to make this snap work with any gadget. So I am working on a connect-plug-serial-port hook to check if a valid devices is attached then reject the plug/slot connection depending on success.
There are a number of compatible USB IDs that could be the right device, but that USB ID is not a sure fire way to assure it should be for this snap. The hook should reject any that are not for us.
Not ideal, but the best I can come up with now with the hardware that is in the field.