Canonical Snapcraft
Menu Close menu
  • Snap Store
  • About Snapcraft
  • Learn
    • Blog
    • Build
    • Docs
    • Tutorials
  • IoT
  • Forum
  • My account
    • My published snaps
    • My validation sets
    • My stores
    • Account details
    • Sign out
  • Sign in
Toggle side navigation
Toggle side navigation

Snap documentation

Using snaps

  • Snap tutorials
    • Get started
    • Install the daemon
      • AlmaLinux OS
      • Arch Linux
      • Debian
      • Elementary OS
      • Fedora
      • Linux Mint
      • Manjaro Linux
      • Raspberry Pi OS
      • openSUSE
      • Pop!_OS
      • Rocky Linux
      • Ubuntu
  • Snap how-to guides
    • Work with snaps
      • Manage updates
      • Connect interfaces
      • Configure snaps
      • Apps and aliases
    • Manage snaps
      • Create data snapshots
      • Use resource quotas
      • Disk space awareness
      • Set system options
      • Control services
      • Using components
      • Configure snaps with confdb
      • Validation sets
      • Snap deltas
      • Use the REST API
    • Fix common issues
      • Test snapd fixes
      • Debug snaps
  • Snap reference
    • Operations
      • Glossary
      • System options
      • System architecture
      • Interfaces
        • Hardware interfaces
        • Media interfaces
        • Network interfaces
        • Security interfaces
        • System interfaces
        • Super-privileged interfaces
    • Administration
      • Network requirements
      • Distribution support
    • Development
      • Environment variables
      • REST API
        • snapd REST API
        • Error responses
      • YAML schemas
        • The snap format
        • The gadget snap
        • The kernel snap
    • Release notes
  • Snap explanation
    • How snaps work
      • Refresh awareness
      • Channels and tracks
      • Revisions
      • Transactional updates
      • Snap components
      • Snap performance
    • Interfaces
      • All about interfaces
      • Interface auto-connection
      • Interface hooks
    • Security
      • Security policies
      • Snap confinement
      • Classic confinement
      • Assertions
      • Snapd release process

Snapcraft build-tool

  • Snapcraft tutorials
    • Create a new snap
  • Snapcraft how-to guides
    • Snapcraft overview
    • Quickstart
      • Installation and setup
      • How snapcraft builds a snap
      • Basic snapcraft.yaml example
      • Intermediate snapcraft.yaml example
      • Build and publishing example
    • Create a snap
      • Build a checklist
      • Start snapcraft.yaml
      • Add global metadata
      • Build apps with parts
      • Use extensions
      • Add dependencies
      • Platforms and architectures
      • Define a command
      • Define a service
      • Add interfaces
      • Add configuration options
      • Use external metadata
      • Map files with layouts
      • Exclude data from snapshots
      • Add desktop menu support
      • Build snaps remotely
      • Linting classic snaps
      • Linting libraries
      • Iterate over a build
      • Troubleshoot snap building
      • Using craftctl
      • Classic confinement
    • Craft a snap
      • Cross-compile an autotools project
      • Example pre-built app
      • Example Python app
      • Example C or C++ app
      • Example Java app
      • Example Go app
      • Example Rust app
      • Example Node app
      • Example Ruby app
      • Example GTK4 app
      • Example GTK3 app
      • Example GTK2 app
      • Example Qt5 KDE app
      • Example Flutter app
      • Example Electron app
      • Example .NET app
      • Example MOOS app
      • Example ROS 2 app
      • Example ROS 1 app
      • Other platforms
    • Publish a snap
      • Upload your snap
      • Access the Snap Store
      • Create a Store listing
      • Publish to a branch
      • Progressive releases
      • Manage releases
      • Upload deltas
      • Snapcraft authentication
      • View usage metrics
      • Control data with epochs
      • Build from a private repository
      • GitHub workflow from a private repository
      • Use gdb and gdbserver
    • Robotics
      • ROS quickstart
      • ROS2 quickstart
      • Build with GitHub Actions
      • Access shared memory
      • ROS with no extensions
  • Snapcraft reference
    • Build configuration
      • snapcraft.yaml schema
    • Supported plugins
      • core24
        • Autotools
        • Ant
        • CMake
        • Colcon
        • Conda
        • Dump
        • Flutter
        • Golang
        • Make
        • Matter-SDK
        • Maven
        • Meson
        • Nil
        • NPM
        • Python
        • Rust
        • Scons
      • core22
        • .NET/dotnet
        • Ant
        • Autotools
        • CMake
        • Colcon
        • Conda
        • Crystal
        • Dump
        • Flutter
        • Golang
        • Make
        • Matter-SDK
        • Maven
        • Meson
        • Nil
        • NPM
        • Python
        • Rust
        • Scons
      • core20
        • Ant
        • Autotools
        • Catkin tools
        • Catkin plugin
        • CMake
        • Colcon
        • Conda
        • Crystal
        • Dump
        • Golang
        • NPM
        • Meson
        • Nil
        • Python
        • Qmake
        • Rust
      • core18
        • .NET/dotnet
        • Ant
        • Ament
        • Autotools
        • Catkin tools
        • Catkin plugin
        • CMake
        • Conda
        • Crystal
        • Flutter
        • Golang
        • Godeps
        • Gradle
        • Gulp
        • KBuild
        • Kernel
        • Make
        • Maven
        • Meson
        • Node.js
        • Ruby
        • Rust
        • Python
        • Qmake
        • Scons
        • WAF
    • Extensions
      • env-injector
      • Qt5 and KDE Frameworks
      • Flutter
      • ROS 1 Noetic
      • ROS 1 Noetic Content Sharing
      • ROS2 Foxy
      • ROS2 Foxy Content Sharing
      • ROS2 Humble
      • ROS2 Humble Content Sharing
      • ROS2 Jazzy
      • ROS2 Jazzy Content Sharing
      • GNOME
    • Environment variables
    • Package repositories
    • Platforms and architectures
    • Build options
    • Build providers
    • Snapcraft linters
    • Classic confinement
    • Release notes
  • Snapcraft explanation
    • Parts lifecycle
    • Architectures
    • Advanced grammar
    • Migrate between bases
      • Migrate to core24
      • Migrate to core22
    • Hooks
    • Using snapctl
    • Robotics
      • ROS troubleshooting
      • ROS architectures

Contribute to our docs

The serial-port interface

See More

The 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.

Use 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.

Interface documentation:

See Interface management and Supported interfaces for further details on how interfaces are used.


Developer details

Auto-Connect: no
Attributes:

  • Should specify a single path attribute:
    • path (slot): path to serial device node e.g. /dev/ttyS1
  • 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. /dev/serial-port-mydevice

Hardware IO interfaces covers some general considerations common to these kinds of devices.

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.

Code examples

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: serial_port.go


Last updated 1 year, 11 months ago.

Help improve this document in the forum.

Back to top

© 2025 Canonical Ltd.

Ubuntu and Canonical are registered trademarks of Canonical Ltd.
Powered by Charmed Kubernetes

Join the forum, contribute to or report problems with, snapd, Snapcraft, or this site.

  • Terms of Service
  • Data privacy
  • Manage your tracker settings
  • Service status
  • Other functions
  • Share on Twitter
  • Share on Facebook
  • Share on YouTube