From: smckown Date: Mon, 2 Nov 2009 20:21:31 +0000 (+0000) Subject: cptwiddle now accepts a device argument on its command line. X-Git-Tag: debian/0.11.2-5.2tmi~15 X-Git-Url: https://oss.titaniummirror.com/gitweb?p=cp210x.git;a=commitdiff_plain;h=f7c370bb62213bde2d52ec4816401fb3778773a5 cptwiddle now accepts a device argument on its command line. --- 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) {