Snap interfaces serial-port error "serial-port path attribute must be a valid device node"

The demo snap have slots interface:serial-port
interface: serial-port
path: /dev/ttyGPS

after i install the demo snap,error is “2020-01-06T08:29:22Z INFO snap “demo” has bad plugs or slots: serial-ttygps (serial-port path attribute must be a valid device nod”

$ sudo snap install --dangerous /tmp/demo_0.1_armhf.snap
2020-01-06T08:29:22Z INFO snap “demo” has bad plugs or slots: serial-ttygps (serial-port path attribute must be a valid device node)
demo 0.1 installed
$ ls /dev/ttyGPS -l
lrwxrwxrwx 1 root root 11 Jan 1 1970 /dev/ttyGPS -> /dev/ttyLP1
how to fix interface:serial-port error? thanks

The current pattern is described as follows here:

It’s easy enough to add a rule to allow /dev/ttyGPS or /dev/ttyLP1, but I’m not familiar with those device nodes never having seen them before. Are /dev/ttyGPS and /dev/ttyLP1 device nodes specific to your model/board or this is a generic access? I couldn’t find any reference to /dev/ttyGPS from some simple searching (and nothing in, but I saw some references to /dev/ttyLP* in other random searches.

thanks for reply. the /dev/ttyGPS is specific to my iot device.
In fact i want to use serial-port for virtual port, such as /dev/tttyCOM1(/dev/pts/0)

if add the seial-port path with “/dev/ttyCOM1” or “/dev/ptx/0” ,there are all error for “serial-port path attribute must be a valid device node”

the seial-port path must be the format you mentioned?

whether the serial-port can support virtual port /dev/pts/x ?

the serial port interface is sadly restricted to exactly the regex that ian quoted above:

var serialDeviceNodePattern = regexp.MustCompile("^/dev/tty(mxc|USB|ACM|AMA|XRUSB|S|O)[0-9]+$")

anything not matching this pattern will be refused, if you want something like “COM” or “GPS” supported, it needs to be added to this pattern, similar to this patch:

in case your devices are USB based there is also the serial hotplug feature now:

So I think at this point our options to add to the serial-port interface are:

  • add /dev/ttyGPS
  • add /dev/ttyCOM[0-9]+
  • add /dev/ttyLP[0-9]+

I don’t feel comfortable adding /dev/pts/[0-9]+ because that’s not guaranteed to be a serial-port, but perhaps this is fine. I think the psuedo tty system is a bit messy which is why I personally feel hesitant about this, but that’s just my feel.

@jdstrand what are your thoughts on expanding the serial-port device node pattern to allow this use case?

snapd supports pseudo-terminals via /dev/pts via devpts with access to /dev/pts/* available via openpty() and working with /dev/ptmx (eg, @pangda - can you provide a working reproducer for how you are setting up and accessing the pts devices?

IIUC this support in snapd is for snapd to create snap-private devpts instances, not to access dev/pts outside of the snap (which is what would be happening with this symlink /dev/ttyCOM1 -> /dev/pts/0 that is referenced above), is that correct?