I have a node.js snap trying to access the ttyS4 (GPS) data. However I get this error:
(node:5643) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error: Permission denied, cannot open /dev/ttyS4
I’ve seen samples where people are using the serial-port interface, but there are no interfaces called serial-port installed on the device, so I tried connecting kernel-module-control and hardware-observe. There is an interface called caracalla:ttys4, so I tried connecting that on too.
According to the documentation: “Note that the slot (serial-port) is meant to be implemented by a gadget snap (this is not provided by the core snap)”. I don’t know what that means, but serial-port is not in the list of interfaces…
Here is the snapcraft.yaml:
...
apps:
microservicebus-node:
command: bin/startsnap
plugs:
- kernel-module-control
- hardware-observe
- ubx
parts:
node:
source: https://github.com/qbranch-code/microservicebus-node.git
source-branch: master
plugin: nodejs
node-engine: 7.10.0
stage-packages: [python2.7, build-essential]
node-packages: [serialport]
After i have created the snap and installed it, I ran:
snap connect microservicebus-node:kernel-module-control core:kernel-module-control
snap connect microservicebus-node:hardware-observe core:hardware-observe
snap connect microservicebus-node:ubc caracalla:ttys4
Checking the interface connections using snap interfaces microservicebus-node:
Slot Plug
caracalla:ttys4 locationd:ubx,microservicebus-node:ubx
:hardware-observe caracalla,ccm-wda,dcc,dcm,microservicebus-node,udisks2
:kernel-module-control caracalla,dcc,dcm,microservicebus-node
All looks good, but running the application gives me:
(node:5643) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): Error: Error: Permission denied, cannot open /dev/ttyS4
Thank you!