diff options
Diffstat (limited to 'aoview/aoview_dev.c')
| -rw-r--r-- | aoview/aoview_dev.c | 30 | 
1 files changed, 27 insertions, 3 deletions
diff --git a/aoview/aoview_dev.c b/aoview/aoview_dev.c index 2fabfe26..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 > 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;  | 
