Commit c74ce6ac authored by Guillaume Tucker's avatar Guillaume Tucker

Update udev rule to match major number 189 and use /dev device path

When the servo board gets attached, several USB device entries are
created in sysfs.  Rather than matching these, which cause the systemd
service to be spawned multiple times, match the parent USB device
entry by filtering with the MAJOR environment variable.  Also use the
raw device path in /dev rather than the sysfs path to find the udev
device.

This means the systemd service instance name has a more unique and
descriptive name, only one service gets started for each servo board
connected and there's no need to search for parent udev devices in
run-servod any more.
Signed-off-by: Guillaume Tucker's avatarGuillaume Tucker <guillaume.tucker@collabora.com>
parent 9e1a60de
......@@ -91,11 +91,8 @@ def run_servod():
print("Device path: {}".format(dev_path))
# Note: This is not ideal, especially as the servod service can get started
# multiple times for all the child nodes and called with devices that all
# have the same parent. Only one of them should succeed...
try:
ud_dev = pyudev.Device.from_path(ud_ctx, dev_path).parent
ud_dev = pyudev.Device.from_device_file(ud_ctx, dev_path)
except:
print("couldn't find udev device from {}".format(dev_path))
sys.exit(1)
......
......@@ -5,5 +5,5 @@ ConditionPathExists=/etc/google-servo.conf
[Service]
Type=notify
NotifyAccess=all
ExecStart=/usr/bin/run-servod /sys/bus/usb/devices/%i
ExecStart=/usr/bin/run-servod /dev/%I
Restart=on-failure
# google-servo* matches on our usbmisc child device, then we specify
# SUBSYSTEMS/DRIVERS to walk up from the specific interface, to the overall
# device, which will actually have a serial
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="5002", TAG+="systemd", ENV{SYSTEMD_WANTS}+="google-servo@$name.service", ENV{ID_MODEL}="Google Servo control board %n"
ACTION=="add", SUBSYSTEMS=="usb", ATTRS{idVendor}=="18d1", ATTRS{idProduct}=="5002", ENV{MAJOR}=="189", TAG+="systemd", ENV{SYSTEMD_WANTS}+="google-servo@$name.service", ENV{ID_MODEL}="Google Servo control board %n"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment