Permalink
Browse files

accept devices in form of "/dev/ttyUSB0" and "ttyUSB0"

  • Loading branch information...
pyrovski committed Oct 8, 2015
1 parent fae037b commit 9bee5066cc5bf6e33a381f6879c7bbc3ce8ef3ce
Showing with 8 additions and 1 deletion.
  1. +8 −1 util.c
View
9 util.c
@@ -177,6 +177,13 @@ int open_device(char * device_name, int * dev_fd)
return ret;
}
// check for leading /dev/
char * lastSlash = rindex(device_name, '/');
if(lastSlash && !strncmp(device_name, "/dev", lastSlash - device_name)){
device_name = lastSlash + 1;
}
/*
* First, check if /sys/class/tty/<name>/ exists.
*/
@@ -190,7 +197,7 @@ int open_device(char * device_name, int * dev_fd)
}
if (!S_ISDIR(s.st_mode)) {
errno = -ENOTDIR;
ret = errno = -ENODEV;
err("%s is not a TTY device.", device_name);
goto Done;
}

0 comments on commit 9bee506

Please sign in to comment.