At work, we’ve developed several applications that need to run on different linux distros and while generally possible, there are times when installing,updating and running these applications become an issue for those that don’t have intimate knowledge of how the application works.
Snaps seem like a good way to alleviate or even eliminate these issues.
I am new to snaps and I’m loving the whole idea. I’ve spent a couple of days reading and testing. I’ve packaged several test applications and I’ve even uploaded one.
We work with lots of devices that use serial ports(mostly RS-232) as the main way of interfacing to the world so we use standard terminal programs like minicom, gtkterm and putty to configure them.
I’m still wrapping my head around the slot/plug concept and how to properly define and
use them so it is possible that I’m missing something.
I read somewhere that a snap can’t auto connect but rather one has to manually connect the snap to the serial-port interface because of the potential to modify devices connected via a serial port.
This I can understand and I find that manually connecting to the serial-port interface once after installation is reasonable so along as the connection persists after updates and reboots.
Today I packaged minicom in order to understand how snaps work with serial ports.
Knowing that the serial-port interface was not auto connected, I was not at all surprised that minicom could not access any of the available serial ports.
I attempted to manually connect to the serial-port interface but to my dismay, I was not able to. It’s as if the interface skeleton is there to be implemented by someone.
After some more searching, I found examples of people creating snaps called gadgets that expose serial devices by name like "/dev/ttyUSB0 " and “/dev/ttyS4” but I didn’t find any that listed all of the serial ports recognized by the OS. This is rather frustrating because the number and type of serial ports I use change on a daily basis.
Today I am using “/dev/ttyUSB3” and “/dev/ttyS0” But there are times
I need to access “/dev/ttyACM0” .
I can make it work with a gadget but this seems rather clunky and it just reinforces my sense that I am missing something obvious.
In order to get minicom to mostly work I had to:
- Add current user to the dialout group, log out and log in.(I’m o.k. with this step)
- install the minicom snap I created.(I’m o.k. with this step)
- install a gadget snap that exposes the serial ports for minicom to access.(Not sure I’m o.k. with this step)
- manually connect the minicom serial-port plug to the gadget’s serial-port socket.(I’m o.k. with this step as long it’s part of the core)
Aside from the standard terminal programs and the like, we have many custom programs that use serial ports and would benefit from an implemented serial-port interface that supports auto connect.
Here are the snapcraft.yaml files I created for testing minicom and my gadget.
summary: minicom test
summary: Gadget to expose serial ports to snaps
This gadget will expose serial ports to a snap. The serial port
list seems to be generated using file globbing instead of regex.
The serial ports listed will be similar to the list generated by
issuing the command "ls /dev/tty[A-U]".
This should list serial ports that fit the patterns
ttyS,ttyUSB* and ttyACM*
To use serial ports on your system make sure that the user is in the
dialout group. To add a user to the dialout group you can issue the
following command. “sudo usermod -a -G dialout USERNAME”
Afterwards logout and log back in.
I also read that I could modify,compile and install my own version of snapd but this seems like more work than it should be.
If it is in fact true that snapd doesn’t have a clean way of using serial ports without gadgets, could this be implemented in the core?
I think many programs would benefit from this, not just the obvious terminal ones.
There are lots of people that have no idea that they are using a serial port.
- I believe Arduino boards show up as “/dev/ttyUSB*”
- Many USB modems show up as “/dev/ttyACM*”
- Serial ports are used in robotics as well, I think I saw a turtlebot-snap somewhere that
had to write a gadget to access a serial port.
Thanks and keep up the good work.