The serial-port interface
serial-port interface enables input and output access to a specific serial port on a device typically running Ubuntu Core. As a result, and because it provides such privileged access to configure serial port hardware,
serial-port is considered a restricted interface.
snap interface serial-port to see which serial-port devices are available on the system:
$ snap interface serial-port name: serial-port summary: allows accessing a specific serial port slots: - core:model01 (allows accessing a specific serial port) - core:monome (allows accessing a specific serial port)
Once connected, the consuming snap can use the device via the path specified by the connected slot.
See Interface management and Supported interfaces for further details on how interfaces are used.
- Should specify a single path attribute:
path(slot): path to serial device node e.g.
- Or three attributes:
usb-vendor(slot): integer representing the USB Vendor ID, must be in range 0 < vid <= 65535
usb-product(slot): integer representing the USB Product ID, must be in range 0 <= vid <= 65535
path(slot): path of the form
/dev/serial-port-...where a symlink will be created to the device e.g.
To use a serial-port device, the snap developer must add
plugs: [ serial-port ] to a snap’s snapcraft.yaml. The snap user can then access a specific serial-port device with an interface connection.
From a Brand Store context, the intention for IO interfaces like these, including gpio and i2c, is that they’re driven from a device’s gadget snap instead from the core system snap or other connecting snap. This should mean that no change is required in a connecting snap other the appropriately-configured plug.
This approach is more robust because it allows the gadget snap providing the slot to centralise and arbitrate the connection conditions. These conditions would include which other snaps, identified by their snap ID, can connect to the slots the gadget offers and, consequently, gain privileged access to the hardware.
See Auto-connections for more details on when an automatic connection is triggered or processed.
The following example shows the slot configuration, such as from the gadget snap, and includes which snaps are permitted to connect automatically:
serial-port: allow-auto-connection: - on-store: - (whatever) plug-names: - serial-foo plug-snap-id: - foooVbn5YriRw2sRVw7Cuj5PbjJjwnFb slot-attributes: path: /dev/whatever slot-names: - serial-foo
All attributes must match for an auto-connection attempt to be successful. The above example requires a connecting snap to have a matching snap-id and plug name. For example, the following snapcraft.yaml stanza for the connecting snap would not connect:
apps: whatever: plugs: serial-port
While the following snapcraft.yaml stanza for the connecting snap would automatically connect:
apps: whatever: plugs: serial-foo plugs: serial-foo: interface: serial-port
The test code can be found in the snapd repository: serial_port_test.go.
The source code for the interface is in the snapd repository:
Last updated a month ago.