ao-tools/ao-list: Show devices that have no TTY
authorKeith Packard <keithp@keithp.com>
Tue, 10 Mar 2015 15:35:02 +0000 (09:35 -0600)
committerKeith Packard <keithp@keithp.com>
Tue, 10 Mar 2015 15:35:02 +0000 (09:35 -0600)
chaoskey doesn't advertise itself as a modem, so the kernel doesn't
allocate a tty device.

Signed-off-by: Keith Packard <keithp@keithp.com>
ao-tools/ao-list/ao-list.c
ao-tools/lib/cc-usbdev.c
ao-tools/lib/cc.h

index c4b43d8fb1caf6416e5f13dad9a33ad2b2ca8b40..4c065e797f992fc5b5a254f971ea5440498f2fdd 100644 (file)
@@ -28,12 +28,12 @@ main (int argc, char **argv)
        struct cc_usbdev        *dev;
        int                     i;
 
-       devs = cc_usbdevs_scan();
+       devs = cc_usbdevs_scan(TRUE);
        if (devs) {
                for (i = 0; i < devs->ndev; i++) {
                        dev = devs->dev[i];
                        printf ("%-20.20s %6d %s\n",
-                               dev->product, dev->serial, dev->tty);
+                               dev->product, dev->serial, dev->tty ? dev->tty : "(none)");
                }
                cc_usbdevs_free(devs);
        }
index 95bfa244b6a5f9dfe0fa567b992d02221e47f149..6c3ba5910b3602465e918dc38f7bcec04d700e9f 100644 (file)
@@ -219,7 +219,7 @@ is_am(int idVendor, int idProduct) {
 }
 
 struct cc_usbdevs *
-cc_usbdevs_scan(void)
+cc_usbdevs_scan(int non_tty)
 {
        int                     e;
        struct dirent           **ents;
@@ -241,7 +241,7 @@ cc_usbdevs_scan(void)
                dir = cc_fullname(USB_DEVICES, ents[e]->d_name);
                dev = usb_scan_device(dir);
                free(dir);
-               if (is_am(dev->idVendor, dev->idProduct) && dev->tty) {
+               if (is_am(dev->idVendor, dev->idProduct) && (non_tty || dev->tty)) {
                        if (devs->dev)
                                devs->dev = realloc(devs->dev,
                                                    (devs->ndev + 1) * sizeof (struct usbdev *));
@@ -274,7 +274,7 @@ match_dev(char *product, int serial)
        int                     i;
        char                    *tty = NULL;
 
-       devs = cc_usbdevs_scan();
+       devs = cc_usbdevs_scan(FALSE);
        if (!devs)
                return NULL;
        for (i = 0; i < devs->ndev; i++) {
index bff4b2c9992cea601d785cfa08dbac6fc99e44e0..ff95e4fc9ad171e30d9e5b179960c65843dbef3b 100644 (file)
@@ -50,7 +50,7 @@ void
 cc_usbdevs_free(struct cc_usbdevs *usbdevs);
 
 struct cc_usbdevs *
-cc_usbdevs_scan(void);
+cc_usbdevs_scan(int non_tty);
 
 char *
 cc_usbdevs_find_by_arg(char *arg, char *default_product);