diff options
author | Corentin LABBE <clabbe@baylibre.com> | 2018-11-15 12:09:20 +0100 |
---|---|---|
committer | Corentin LABBE <clabbe@baylibre.com> | 2018-11-16 14:15:22 +0100 |
commit | 05e45581d1173852e33d8a4d1c7b07346da7ec8c (patch) | |
tree | 1e48edef27ccf69e1972caab9643d73225e533df | |
parent | e64ad5a167f3a7cb7491a17a725c6ec365897302 (diff) |
lavalab-gen.py: Remove udev template for support of interfacenum
The current udev templating is bad since adding a new optional keyword
lead to numerous ifelse and templates.
This patch simply generate a udev line part by part.
This made adding interfacenum easier.
This will also permit to mix devpath/serial/etc.. without any problem
-rw-r--r-- | README.md | 1 | ||||
-rwxr-xr-x | lavalab-gen.py | 19 |
2 files changed, 8 insertions, 12 deletions
@@ -285,6 +285,7 @@ boards: idproduct: the PID of the UART (Formated as 0xXXXX) serial: The serial number in case of FTDI uart devpath: the UDEV devpath to this uart for UART without serial number + interfacenum: (optional) The interfacenumber of the serial. (Used with two serial in one device) use_ser2net: True/false (Use ser2net instead of conmux-console) use_screen: True/false (Use screen via ssh instead of conmux-console) connection_command: A command to be ran for getting a serial console diff --git a/lavalab-gen.py b/lavalab-gen.py index 5191f07..f873750 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -49,13 +49,6 @@ template_device_screen = string.Template(""" {% set connection_command = 'ssh -o StrictHostKeyChecking=no -t root@127.0.0.1 "TERM=xterm screen -x ${board}"' %} """) -template_udev_serial = string.Template("""# -SUBSYSTEM=="tty", ATTRS{idVendor}=="${idvendor}", ATTRS{idProduct}=="${idproduct}", ATTRS{serial}=="${serial}", MODE="0664", OWNER="uucp", SYMLINK+="${board}" -""") -template_udev_devpath = string.Template("""# -SUBSYSTEM=="tty", ATTRS{idVendor}=="${idvendor}", ATTRS{idProduct}=="${idproduct}", ATTRS{devpath}=="${devpath}", MODE="0664", OWNER="uucp", SYMLINK+="${board}" -""") - template_settings_conf = string.Template(""" { "DEBUG": false, @@ -451,12 +444,14 @@ def main(): if type(idvendor) == str: print("Please put hexadecimal IDs for vendor %s (like 0x%s)" % (board_name, idvendor)) sys.exit(1) + udev_line = 'SUBSYSTEM=="tty", ATTRS{idVendor}=="%04x", ATTRS{idProduct}=="%04x",' % (idvendor, idproduct) if "serial" in uart: - serial = board["uart"]["serial"] - udev_line = template_udev_serial.substitute(board=board_name, serial=serial, idvendor="%04x" % idvendor, idproduct="%04x" % idproduct) - else: - devpath = board["uart"]["devpath"] - udev_line = template_udev_devpath.substitute(board=board_name, devpath=devpath, idvendor="%04x" % idvendor, idproduct="%04x" % idproduct) + udev_line += 'ATTRS{serial}=="%s", ' % board["uart"]["serial"] + if "devpath" in uart: + udev_line += 'ATTRS{devpath}=="%s", ' % board["uart"]["devpath"] + if "interfacenum" in uart: + udev_line += 'ENV{ID_USB_INTERFACE_NUM}=="%s", ' % board["uart"]["interfacenum"] + udev_line += 'MODE="0664", OWNER="uucp", SYMLINK+="%s"\n' % board_name if not os.path.isdir("output/%s/udev" % host): os.mkdir("output/%s/udev" % host) fp = open("output/%s/udev/99-lavaworker-udev.rules" % host, "a") |