From 589fab595ad96d75d8a2bfba051b608c5f0b438b Mon Sep 17 00:00:00 2001 From: Corentin LABBE Date: Wed, 14 Feb 2018 15:09:45 +0100 Subject: Force the use of hexadecimal values for product/vendor IDs Using "idproduct: 6001" let python convert 6001 to 24577 and so corrupt the UDEV line. --- lavalab-gen.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'lavalab-gen.py') diff --git a/lavalab-gen.py b/lavalab-gen.py index 5e79dc5..f151aa1 100755 --- a/lavalab-gen.py +++ b/lavalab-gen.py @@ -92,13 +92,19 @@ def main(args): baud = b["uart"].get("baud", baud_default) idvendor = b["uart"]["idvendor"] idproduct = b["uart"]["idproduct"] + if type(idproduct) == str: + print("Please put hexadecimal IDs for product %s (like 0x%s)" % (board_name,idproduct)) + sys.exit(1) + if type(idvendor) == str: + print("Please put hexadecimal IDs for vendor %s (like 0x%s)" % (board_name,idvendor)) + sys.exit(1) line = template_conmux.substitute(board=board_name, baud=baud) if "serial" in uart: serial = b["uart"]["serial"] - udev_line += template_udev_serial.substitute(board=board_name, serial=serial, idvendor=idvendor, idproduct=idproduct) + udev_line += template_udev_serial.substitute(board=board_name, serial=serial, idvendor="%04x" % idvendor, idproduct="%04x" % idproduct) else: devpath = b["uart"]["devpath"] - udev_line += template_udev_devpath.substitute(board=board_name, devpath=devpath, idvendor=idvendor, idproduct=idproduct) + udev_line += template_udev_devpath.substitute(board=board_name, devpath=devpath, idvendor="%04x" % idvendor, idproduct="%04x" % idproduct) if "devices" in dockcomp["services"][lab_name]: dc_devices = dockcomp["services"][lab_name]["devices"] else: -- cgit 1.2.3-korg