Discussion:
Serial getty on USB dongle insertion
(too old to reply)
Paul D. DeRocco
2017-07-13 00:38:04 UTC
Permalink
Raw Message
I've created a serial-***@ttyUSB2.service file, which is basically a
copy of serial-***@.service with a specific device name and a fixed baud
rate. It works fine when I plug in a serial dongle that gets assigned that
name. (I have permanent ttyUSB0 and ttyUSB1 devices which don't use
getty.)

If I logout, it just offers me a new login prompt. If I unplug the dongle,
the automatic retrying fails, and plugging it in again doesn't bring it
back to life.

If I use Restart=no, then I can terminate it either by logging out or
yanking the dongle, but it naturally won't restart if I plug the dongle in
again. Is there a way of configuring the service to start every time the
dongle is inserted, whether I logged out before yanking the dongle or not?
Or does this require some special udev rule?
--
Ciao, Paul D. DeRocco
Paul mailto:***@ix.netcom.com
Andrei Borzenkov
2017-07-13 03:37:50 UTC
Permalink
Raw Message
Post by Paul D. DeRocco
rate. It works fine when I plug in a serial dongle that gets assigned that
name. (I have permanent ttyUSB0 and ttyUSB1 devices which don't use
getty.)
If I logout, it just offers me a new login prompt. If I unplug the dongle,
the automatic retrying fails, and plugging it in again doesn't bring it
back to life.
If I use Restart=no, then I can terminate it either by logging out or
yanking the dongle, but it naturally won't restart if I plug the dongle in
again. Is there a way of configuring the service to start every time the
dongle is inserted, whether I logged out before yanking the dongle or not?
Or does this require some special udev rule?
Yes, set ENV{SYSTEMD_WANTS}="serial-***@ttyUSB2.service" property on
your device in udev rule; this will trigger starting of this service
when device appears. You probably also want to add
"BindsTo=dev-ttyUSB2.device" (or whatever name of your device unit is)
so systemd stops it when dongle is unplugged and does not attempt to
restart.
Paul D. DeRocco
2017-07-13 07:15:29 UTC
Permalink
Raw Message
Post by Andrei Borzenkov
your device in udev rule; this will trigger starting of this service
when device appears. You probably also want to add
"BindsTo=dev-ttyUSB2.device" (or whatever name of your device unit is)
so systemd stops it when dongle is unplugged and does not attempt to
restart.
Works like a charm. Thanks.
--
Ciao, Paul D. DeRocco
Paul mailto:***@ix.netcom.com
Loading...