X-Git-Url: https://oss.titaniummirror.com/gitweb?a=blobdiff_plain;f=src%2Fexamples%2Fcptwiddle.c;h=54171752fe318f3d5585e41512925a38f2a32d2b;hb=f7c370bb62213bde2d52ec4816401fb3778773a5;hp=068809eae917818631ba261d8d55f9a2eb538901;hpb=db657625822bb2d96ee0ee8117f3cf81f0d9af08;p=cp210x.git diff --git a/src/examples/cptwiddle.c b/src/examples/cptwiddle.c index 068809e..5417175 100644 --- a/src/examples/cptwiddle.c +++ b/src/examples/cptwiddle.c @@ -53,10 +53,10 @@ typedef struct { uint8_t enhancedFxn; } cp2103_port_config_t; -int cpConnect() +int cpConnect(char* device) { int ret, ioval; - int fd = open("/dev/usb/tts/0", O_RDWR); + int fd = open(device, O_RDWR); if (fd < 0) { fprintf(stderr, "cannot open tty\n"); return -1; @@ -71,7 +71,7 @@ void cpDisconnect(int fd) close(fd); } -int main() +int main(int argc, char* argv[]) { int fd; cp2103_port_config_t config; @@ -80,7 +80,13 @@ int main() int ret; int i; - if ((fd = cpConnect()) < 0) + if (argc != 2) { + fprintf(stderr, "usage: %s \n", argv[0]); + return 1; + } + + /* open */ + if ((fd = cpConnect(argv[1])) < 0) return 1; /* Read the current port configuration */ @@ -121,7 +127,7 @@ int main() printf("disconnected\n"); for (i = 0; i < 10; i++) { sleep(1); - if ((fd = cpConnect()) >= 0) + if ((fd = cpConnect(argv[1])) >= 0) break; } if (i == 100) {