plugging away at this tonight and I’m wondering what the purpose of this check_dev_type function really is. The main thing that seems to be doing is ensuring that we only look at USB devices, and then returning the appropriate subsystem type so it can be added with dev_list_add().
So… can we ignore the node_pattern and just get/compare the subsystem type for that dev instead (comparing against sub_name)?
so… check_dev_type() becomes this instead:
device_t check_dev_type(struct udev_device *dev) {
device_t t = DEV_TYPE_INVALID;
const char *node = udev_device_get_devnode(dev);
const char *subsys = udev_device_get_subsystem(dev);
if (node) {
// for now, just get USB devices.
if (udev_device_get_parent_with_subsystem_devtype(dev, "usb", NULL)) {
for (int i = 0; i < DEV_TYPE_COUNT; i++) {
if (fnmatch(w[i].sub_name, subsys, 0) == 0) {
t = i;
break;
}
}
}
}
return t;
}
This appears to work with my Teensy grid (a /dev/ttyACM* device)