diff options
author | Bdale Garbee <bdale@gag.com> | 2015-07-16 13:36:59 -0600 |
---|---|---|
committer | Bdale Garbee <bdale@gag.com> | 2015-07-16 13:36:59 -0600 |
commit | f4f0f044df1251d64d44bf62d25b488fd04a05c8 (patch) | |
tree | 12efee1447a67d8cf37b6f447c011708264b8266 /ao-tools/lib | |
parent | b25690062ac04a588ad4d11740597c20e516eb1a (diff) | |
parent | 570daace9caf7647a09c53d5c75593cc4c98b93b (diff) |
Merge branch 'branch-1.6' into debian
Diffstat (limited to 'ao-tools/lib')
-rw-r--r-- | ao-tools/lib/cc-usb.c | 4 | ||||
-rw-r--r-- | ao-tools/lib/cc-usbdev.c | 6 | ||||
-rw-r--r-- | ao-tools/lib/cc.h | 2 |
3 files changed, 7 insertions, 5 deletions
diff --git a/ao-tools/lib/cc-usb.c b/ao-tools/lib/cc-usb.c index 1a4dc7a1..1e023c7e 100644 --- a/ao-tools/lib/cc-usb.c +++ b/ao-tools/lib/cc-usb.c @@ -207,8 +207,10 @@ _cc_usb_sync(struct cc_usb *cc, int wait_for_input, int write_timeout) write(2, cc->in_buf, cc->in_count); cc->in_count = 0; } - } else if (ret < 0) + } else if (ret <= 0) { perror("read"); + return -1; + } } if (fds.revents & POLLOUT) { ret = write(cc->fd, cc->out_buf, diff --git a/ao-tools/lib/cc-usbdev.c b/ao-tools/lib/cc-usbdev.c index 95bfa244..6c3ba591 100644 --- a/ao-tools/lib/cc-usbdev.c +++ b/ao-tools/lib/cc-usbdev.c @@ -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++) { diff --git a/ao-tools/lib/cc.h b/ao-tools/lib/cc.h index bff4b2c9..ff95e4fc 100644 --- a/ao-tools/lib/cc.h +++ b/ao-tools/lib/cc.h @@ -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); |