X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=aoview%2Faoview_dev.c;h=9b8cc19eae6bf61d31b3f902bc8fbc60bff10267;hb=80cadf44f5f1accd6ddfca25c2af8d4d424f26d9;hp=a326ad73defab28cd0a040716e8806e05062743b;hpb=be3f4fed7b863c8cdaabe32b61b65a8b3cd11355;p=fw%2Faltos diff --git a/aoview/aoview_dev.c b/aoview/aoview_dev.c index a326ad73..9b8cc19e 100644 --- a/aoview/aoview_dev.c +++ b/aoview/aoview_dev.c @@ -60,11 +60,17 @@ load_hex(char *dir, char *file) } static int -dir_filter_tty(const struct dirent *d) +dir_filter_tty_colon(const struct dirent *d) { return strncmp(d->d_name, "tty:", 4) == 0; } +static int +dir_filter_tty(const struct dirent *d) +{ + return strncmp(d->d_name, "tty", 3) == 0; +} + static char * usb_tty(char *sys) { @@ -76,6 +82,7 @@ usb_tty(char *sys) int num_interfaces; char endpoint_base[20]; char *endpoint_full; + char *tty_dir; int ntty; char *tty; @@ -87,15 +94,32 @@ usb_tty(char *sys) sprintf(endpoint_base, "%s:%d.%d", base, config, interface); endpoint_full = aoview_fullname(sys, endpoint_base); + + /* Check for tty:ttyACMx style names + */ ntty = scandir(endpoint_full, &namelist, - dir_filter_tty, + dir_filter_tty_colon, alphasort); - free(endpoint_full); - if (ntty) { + if (ntty > 0) { + free(endpoint_full); tty = aoview_fullname("/dev", namelist[0]->d_name + 4); free(namelist); return tty; } + + /* Check for tty/ttyACMx style names + */ + tty_dir = aoview_fullname(endpoint_full, "tty"); + free(endpoint_full); + ntty = scandir(tty_dir, &namelist, + dir_filter_tty, + alphasort); + free (tty_dir); + if (ntty > 0) { + tty = aoview_fullname("/dev", namelist[0]->d_name); + free(namelist); + return tty; + } } } return NULL; @@ -143,6 +167,8 @@ dir_filter_dev(const struct dirent *d) continue; if (c == '-') continue; + if (c == '.' && n != d->d_name + 1) + continue; return 0; } return 1;