Need help with access to USB serial ports [Was: Classic confinement request: zworkbench]


#1

This is IDE for programing PLC, need access for serial ports.


#2

are these actual serial ports, not usb-serial (for which you would be able to use the raw-usb interface like i.e. the rpiboot snap) ?


#3

You could also try using the new serial-hotplug in the edge channel of the core snap. See Hotplug support for more details


#4

Hello! I am use usb-serial (rs485) converter. On host machine add user to dialout group. Then make “cat /dev/ttyUSB0” - works.

Then
Attemp 1:
Add to snapcraft.yaml:

plugs:
serial-port:
interface: serial-port
apps:
zworkbench:
plugs:
- serial-port

Result: Not work

Attemp 2:
Add to snapcraft.yaml:

plugs:
  serial-port:
    interface: serial-port
    **path: /dev/tty[A-U]***
apps:
  zworkbench:
    plugs:
      - serial-port

Result: Not work

Attemp 3:
Add to snapcraft.yaml:

slots:
    ttyUSB0:
      interface: serial-port
      path: /dev/ttyUSB0

Result: Not work (required manual confirm, as classic)

Attemp 4:
run snap run --shell zworbench, run in snap “cat /dev/ttyUSB0”
Result: Not work (Permission denied)

Attemp 5:
Find project “tio”, experiment with my usb-rs485 conventer. WORK! Find snapcraft.yaml (https://github.com/tio/tio.snapcraft/blob/master/snap/snapcraft.yaml) for tio, it is use “classic”…
Add classic for zworkbench… Result, need confirm =) Add topic in forum… wait =)))
Result: Not work (required manual confirm)


#5

Also with strict mode I use in snapcraft.yaml, i think if use classic is will be simple for this project:

<… cut other more line in snapcraft.yaml …>

plugs:
kde-frameworks-5-plug:
interface: content
content: kde-frameworks-5-all
default-provider: kde-frameworks-5
target: kf5
serial-port:
interface: serial-port
path: /dev/tty[A-U]*

apps:
zworkbench:
command: zworkbench
environment:
LD_LIBRARY_PATH: “$LD_LIBRARY_PATH:/$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio”
desktop: usr/share/applications/zworkbench.desktop
plugs:
- network
- network-bind
- network-manager
- network-observe
- home
- opengl
- pulseaudio
- mount-observe
- optical-drive
- camera
- removable-media
- screen-inhibit-control
- x11
- unity7
- desktop
- desktop-legacy
- wayland
- gsettings
- kde-frameworks-5-plug
- serial-port
slots:
- mpris


#6

Now test add raw-usb for strict. Result: Not works, also can not open port in snap app. In host all works =(


#7

Enable hotplug, restart snapd, reconnect-connect usb-rs485. Result: not work =(


#8

did you actually verify that hotplug is enabled and working first ?

sudo snap refresh core --edge
sudo snap set core experimental.hotplug=true

now plugging in a serial USB device:

$ dmesg | tail -3
[   98.838110] usb 4-1: Manufacturer: Prolific Technology Inc.
[   98.840462] pl2303 4-1:1.0: pl2303 converter detected
[   98.862564] usb 4-1: pl2303 converter now attached to ttyUSB0

and verifying that snapd created a hotplug interface:

$ snap interface serial-port
name:    serial-port
summary: allows accessing a specific serial port
slots:
  - core:pl2303serialport (allows accessing a specific serial port)
$ snap connections system|grep serial
serial-port              -                      :pl2303serialport         -

now your app should be able to connect to it via a serial-port plug that uses /dev/ttyUSB0 as path …


#9

Hello! coverter connected, file “/dev/ttyUSB0” exist. Enabled serial-port interface, but not connected to serial-port snap. =(
Result screenshot:

P.S. Our users can not program PLC device without access to serial port… You can enable classic for zworkbench app? I am update info in snap info site of the zworkbench, add screenshot, add email, add site, add icon. =)


#10

did you run:

sudo snap refresh core --edge
sudo snap set core experimental.hotplug=true

it does not look like hotplug is actually enabled at all … perhaps @pstolowski could also give us some more hints here.

note that snaps where an interface exists to achieve their functionality are per store-rule not allowed to get classic confinement … we need to get your serial interface to work.


#11

If the only reason for classic is access to /dev/ttyUSB0, then the request is denied since that can be handled via raw-usb or the new hotplug feature. While this seems to be understood by everyone in this discussion, I wanted other @reviewers to understand nothing more needs to be done with this request. Please proceed to work with others to enable your snap to work in strict mode. Thanks.


#12

To that end, I renamed the topic and moved it to the appropriate category.


#13

Hello! Sorry for delay!

Why project tio use classic??? Tio use only serial-ports. Please denied classic for tio project =)))

Result:
experimental.hotplug=true <- not work
serial-port <- not work
raw-usb <- not work

Work only if install with --devmode parameter =(((

My snap:
<… cut other build lines …>
plugs:
kde-frameworks-5-plug:
interface: content
content: kde-frameworks-5-all
default-provider: kde-frameworks-5
target: kf5
serial-port:
interface: serial-port

apps:
zworkbench:
command: zworkbench
environment:
LD_LIBRARY_PATH: “$LD_LIBRARY_PATH:/$SNAP/usr/lib/$SNAPCRAFT_ARCH_TRIPLET/pulseaudio”
desktop: usr/share/applications/zworkbench.desktop
plugs:
- network
- network-bind
- network-manager
- network-observe
- home
- opengl
- pulseaudio
- mount-observe
- optical-drive
- camera
- removable-media
- screen-inhibit-control
- x11
- unity7
- desktop
- desktop-legacy
- wayland
- gsettings
- kde-frameworks-5-plug
- serial-port
- raw-usb
slots:
- mpris