Auto-connection request for `arduino-mhall` serial-port

edit: updated request

  • serial-port for arduino, arduino-mhall119 and s4a

    For the same purpose; all snaps need access to Arduino boards over serial.

  • raw-usb for arduino-mhall119


Is it possible to auto-connect serial-port to arduino-mhall?

The snap uses the serial-port interface to upload firmware to arduino-compatible devices. The Arduino IDE is more or less useless without the ability to flash devices. The snap communicates with the boards using various /dev/tty* devices such as /dev/ttyUSB0.

When I enable sudo snap set core experimental.hotplug=true and connect the plug sudo snap connect arduino-mhall119:serial-port core:usb20-serial, I can flash devices from the snap. I tested with a few arduino boards and they all show up as core:usb20-serial.

2 Likes

I just spoke to Michael (mhall119) about another matter, and mentioned this thread. I think we should probably look to move the snap away from him (he agrees) to another account - probably snapcrafters - or indeed yourself if you want to maintain it going forward - under the name arduino. We can’t rename the snap, but Michael is happy to publish a yad-based popup to drive existing users to another snap.

Something like this, that we did for vscode -> code migration.

Screenshot%20from%202020-02-21%2017-13-18

We should probably request additional plugs for the “new” snap rather than monkey around with Michael’s old one?

Given the existing 12.000 installs, my plan was to simply maintain them both for a while. This one with a pop-up like vscode has and the arduino one as the “correct” one. It’s not much extra work for me to maintain them both since they will be virtually the same.

However, given that the snap is basically non-functional right now, I don’t think many people are actually using it, so the amount of people impacted is small anyway…

1 Like

Note that in order to accomplish what is being asked here, you will need a “greedy” plug declaration, and I’m not sure if greedy plugs with hotplug works correctly yet. See Plug/slot declaration rules: greedy plugs.

@pstolowski do you know if hotplug “just works” with greedy plugs yet?

One thing I noticed is that, when I plug in multiple arduino boards, I still only get one slot: core:usb20-serial. When I try to flash them from the arduino IDE, one of them randomly gives a “permission denied” error. In general, the last one you plug in is the one you can access, but sometimes it changes.

Is this expected behavior? Should I see multiple slots or should multiple serial-ports work with the same slot?

Oh that sounds like a bug with the hotplug system then. Each device is supposed to get it’s own slot. I imagine the logic we have around choosing a unique name for a serial port slot might break down when you plug in multiple devices with exactly the same vendor id and product id. Could you file a bug at bugs.launchpad.net/snapd ?

1 Like

Ok so to clarify - is this requesting auto-connection of serial-port for both arduino and arduino-mhall or just arduino?

I am not sure whether I actually need serial-port anymore for either snap because raw-usb seems to do what I need at the moment. Does serial-port have an advantage over raw-usb?

it helps the users that actually have a serial port on their mainboard (they are rare but i suppose you can still buy them :wink: )

Ok, then I’m requesting auto-connections for the following

I’m not entirely sure what the rules are for these requests. Should I create a new topic per snap or per request?

1 Like

Any update on this request?

@jdstrand @popey Can I get an update on these requests?

Ok, I’m a bit confused from the cross-posting. It seems all that is needed is serial-port with hotplug, but there is a mixture of requests for serial-port and raw-usb. Can you clarify your current requests and justifications?

Thanks for taking a look at this. I’ll also respond here to your questions about the other two requests 1 2.

The snaps are arduino, s4a and arduino-mhall119. They all need access to Arduino-compatible boards connected via USB. There are several reasons why serial-port is not sufficient for this yet. (these are the reasons why the snaps need raw-usb)

  • Hotplug support is still experimental. At the moment, using it requires users to run a bunch of commands. I’d like the Arduino IDE to just work. As popey said “Arduino developers range from expert to complete newbie with a kit as a present for their birthday. We should make it as smooth as possible.” The s4a - “Scratch for Arduino” snap targets kids directly, to help them program Arduino’s and robots without writing code.
  • When I plug in multiple arduino boards, I only get one slot: core:usb20-serial. The slot only gives access to one of the devices, it seemingly picks one device at random and gives the snap access to that one device. Other devices are not accessible.
  • This requires greedy plugs, which doesn’t seem to work with hotplug at the moment.

However, I do like the design of Hotplug support, and I’d like to tinker with it, so that’s why I’m also asking for a greedy auto-connection to the serial-port interface. This will also make it easy to switch to serial-port immediately when it leaves “experimental” and the bugs are fixed.

Let me know if you want me to open a single thread for all the requests. I didn’t do that now because some of the threads already have votes in them.

@jdstrand @reviewers, do you need more information or can the voting continue?

Note that greedy plugs are supported in some way today AIUI, but I don’t know and it doesn’t seem that anyone has actually commented on or tested whether it works with hotplug…

FWIW, I think the below kind of declaration would be sufficient for accessing all serial-port slots, hotplug or otherwise, but I have no way to test this. @jdstrand and/or @roadmr do you have a way to test end-to-end if greedy plugs work with hotplug with something like the following snap-declaration for some test snap?

plugs:
  serial-port:
    allow-auto-connection:
      slots-per-plug: *

I’m happy to try this out. However, this still leaves the issue that hotplug support is currently experimental and that it has an issue when multiple Arduino boards are connected.

I would really like to get this snap working out of the box. In the five weeks since I posted this request, the arduino snap has risen from 0 to 8.000 active installs and it keeps growing steady. I would like to give these people the best out-of-the-box experience and make their Arduino experience on Ubuntu as painless as possible.

+1 to auto-connect serial-port (with greedy plugs) and raw-usb. @reviewers - can others vote on this?

1 Like

@galgalesh - assuming the request goes through for serial-port, I’ll grant slots-per-plug: * in the snap declaration and you can test out that functionality.

1 Like

I need to quote the star (*), otherwise this throws a yaml linting error. A non-quoted star apparently has special meaning in yaml.

I now have this in my snapcraft.yaml:

plugs:
  gtk-2-engines:
    interface: content
    target: $SNAP/lib/gtk-2.0
    default-provider: gtk2-common-themes
  gtk-2-themes:
    interface: content
    target: $SNAP/data-dir/themes
    default-provider: gtk-common-themes
  icon-themes:
    interface: content
    target: $SNAP/data-dir/icons
    default-provider: gtk-common-themes
  sound-themes:
    interface: content
    target: $SNAP/data-dir/sounds
    default-provider: gtk-common-themes
  serial-port:
    allow-auto-connection:
      slots-per-plug: "*"

However, I get a warning from review-tools:

Review Tools did not fully pass for this snap.
Specific measures might need to be taken on the Snap Store before this snap can be fully accepted.
Linting Issues:
- unknown attribute 'allow-auto-connection' for interface 'serial-port' (plugs)

Should review-tools be updated for this syntax or am I using it incorrectly?