Hello.
To the device with Ubuntu-core connected on the USB device.
When I start the application, it detects the device that is connected and starts to work with it.
If the snap package is installed on Ubuntu desktop is connected without problems.
But I see such a message on Ubuntu-core
You need to grant permissions to a particular snap to talk to a particular device. This is done using the snapd interfaces system. Since it looks like you are dealing with a USB serial port I would recommend to look at some gadget snaps that do exactly that. Once your gadget declares the device then you can simply connect an application to it (the application needs to hold a serial-port plug so that it has something to connect).
I’m CCing my colleagues that deal with this very often as they can point to to examples/real gadgets that use this: @ogra and @morphis
Note that these are not actually denials (notice “ALLOWED” in the output), the are violations against policy. Right now, your snap is in devmode, so policy violations are logged, but not denied. If your snap is put in ‘strict’ mode, then these would turn into denials and you would see DENIED instead of ALLOWED.
Some comments on the violations:
/usr/share/applications/ are usually harmless. If you ‘plugs: [ unity7 ]’ (and connect the interface), this will go away
the /dev/dri/card0 denial will likely break your snap in strict mode. You need to ‘plugs: opengl ]’ (and connect the interface)
the /run/udev/data denial is likely harmless, but is solved when you ‘plugs: [ opengl ]’ (and connect the interface)
All that said, the above has nothing to do with /dev/ttyUSB0-- that is a different issue entirely. Looking at the violations it seems like you are running the snap as non-root. I suspect your user does not have the traditional permissions to access /dev/ttyUSB0. You can check this with ‘ls -l /dev/ttyUSB0’ and verifying the permissions on the device. If this is the case, you may want to keep an eye on Multiple users and groups in snaps.
I might also not that on Ubuntu Core, the unity7 and opengl interfaces are not available-- they are implicit classic interfaces. Your snap likely will need to use the framebuffer interface or mir if you need a graphical environment.
In my snap package there are 3 graphics applications and 1 console app. Just the console application should be connected on the port /dev/ttyUSB0 to the device.
The first 3 graphics applications are still unable to start due to the reason:
Failed to open settings file for writing.
QIODevice::write (QFile, "/var/snap/bsp095project/x1/BTL095/settings.json"): device not open
/snap/bsp095project/x1/bin/start_GUI.sh: line 11: 7688 Segmentation fault $SNAP/bin/./BTL095 $(cat "$HOME/PrimaryKey") $(cat "$HOME/SecondaryKey")
does your “start_GUI.sh” (or anything else) create that dir ?
there should be a “mkdir -p $SNAP_DATA/BTL095”, if you did not create the dir you can indeed to write a file to it …
Thank you for reminding me about the creation of this directory.
I now noticed one interesting thing, as it turned out the graphics can be launched and that at the start it created a directory, only through sudo.
It’s strange, why the graphics should be run with the rights of the root?
And now it’s clear to me the reason why I did not connect to the device through /dev/ttyUSB0.
I again used sudo bsp095project.BSP095launcherCore, and it’s running.
This is a well-iterated topic. Simply speaking the user doesn’t have rights to access /dev/ttyUSB0, not because of any confinement but simply because the file is owned by user/group with the permissions preventing your user from accessing it.