Dear friends I've done some digging, and worked out that the device querying code in udev-synce-serial is only necessary for trying to handle two-port devices. I think this can be better handled in the udev rules, from which we can launch udev-synce-serial only when required (i.e. on the 2nd port of a two port device), and thus remove all that logic from udev-synce-serial itself.
That means udev-synce-serial no longer has to call udevadm or use a library to interrogate the udev database, cutting a chunk of code. The patch below does just that. Regards Karl diff -Naur scripts.orig/85-synce.rules.in scripts/85-synce.rules.in --- scripts.orig/85-synce.rules.in 2010-07-19 18:24:17.000000000 +0100 +++ scripts/85-synce.rules.in 2010-12-23 09:24:35.267741000 +0000 @@ -8,4 +8,18 @@ SUBSYSTEM=="net", DRIVERS=="rndis_host", ATTRS{bInterfaceClass}=="ef", ATTRS{bInterfaceSubClass}=="01", ATTRS{bInterfaceProtocol}=="01", ENV{pocketpc}="env-synce", RUN+="@UDEVDIR@/synce-udev-rndis" # capabilities = serial, parent driver = ipaq -SUBSYSTEM=="tty", DRIVERS=="ipaq", ENV{pocketpc}="env-synce", RUN+="@UDEVDIR@/synce-udev-serial" +# If the device has more than one port, then we need to only use the last +# one. +# From ipaq.c we can see the choice is only ever 1 or 2 points +# depending on bNumEndpoints being <=3 or >3 respectively. +# So we use that knowledge to create rules to only use port_number=1 +# for 2 port devices +SUBSYSTEM!="tty", GOTO="synce_ipaq_end" + +DRIVERS=="ipaq",ATTRS{bNumEndpoints}=="", ENV{pocketpc}="env-synce" +DRIVERS=="ipaq",ATTRS{bNumEndpoints}=="0[0123]", ENV{pocketpc}="env-synce" +DRIVERS=="ipaq",ATTRS{port_number}=="1", ENV{pocketpc}="env-synce" + +ENV{pocketpc}=="env-synce", RUN+="@UDEVDIR@/synce-udev-serial" + +LABEL="synce_ipaq_end" diff -Naur scripts.orig/udev-synce-serial.in scripts/udev-synce-serial.in --- scripts.orig/udev-synce-serial.in 2010-08-25 12:44:02.000000000 +0100 +++ scripts/udev-synce-serial.in 2010-12-23 09:26:51.427741000 +0000 @@ -35,63 +35,6 @@ logger.critical("Udev environment not set: DEVPATH missing") sys.exit(1) - # need to check for 2 port devices here - # there are no python bindings for udev, so this is a little awkward - - # get device name - cmd_list = ["udevadm", "info", "--path="+devpath, "--query=name"] - try: - proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - output_text = proc.communicate()[0] - except Exception,e: - logger.error("failure running udevadm: %s" % e) - sys.exit(1) - - rc = proc.returncode - if rc != 0: - logger.error("udevadm failed with return code %d", rc) - sys.exit(1) - - devname = output_text.strip() - - # get parent device path - match_obj = re.match('^(.+)/'+name+"/"+subsystem+'/'+name, devpath) - if match_obj == None: - logger.error("failed to get parent device path from udev") - sys.exit(1) - - parent_devpath = match_obj.group(1) - - # find all relevant child devices of the parent - cmd_list = ["udevadm", "info", "--export-db"] - try: - proc = subprocess.Popen(cmd_list, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) - output_text = proc.communicate()[0] - except Exception,e: - logger.error("failure getting device db: %s" % e) - sys.exit(1) - - rc = proc.returncode - if rc != 0: - logger.error("udevadm failed with return code %d when getting device db",rc) - sys.exit(1) - - output_list = output_text.split('\n') - devpath_re = re.compile('^P: ('+parent_devpath+'.+/'+subsystem+'/.+)') - - devpath_list = [] - for line in output_list: - match_obj = devpath_re.match(line) - if match_obj != None: - path = match_obj.group(1) - devpath_list.append(path) - - if len(devpath_list) > 1: - devpath_list.sort() - if device_path != devpath_list[len(devpath_list) - 1]: - logger.warning("found inactive port, we need to mark this somehow") - sys.exit(0) - # get serial device file if platform.system() == "FreeBSD": logger.critical("do we support udev/devicekit on FreeBSD ???") ------------------------------------------------------------------------------ Learn how Oracle Real Application Clusters (RAC) One Node allows customers to consolidate database storage, standardize their database environment, and, should the need arise, upgrade to a full multi-node Oracle RAC database without downtime or disruption http://p.sf.net/sfu/oracle-sfdevnl _______________________________________________ SynCE-Devel mailing list SynCE-Devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/synce-devel