]> oss.titaniummirror.com Git - cp210x.git/commitdiff
Update cpio (cp210x io test program) to accept device on command line like cpmfg
authorsmckown <smckown@986fd584-583e-0410-b54d-b9fe63dff8e5>
Mon, 2 Nov 2009 20:21:28 +0000 (20:21 +0000)
committersmckown <smckown@986fd584-583e-0410-b54d-b9fe63dff8e5>
Mon, 2 Nov 2009 20:21:28 +0000 (20:21 +0000)
src/examples/cpio.c

index f0f6f388ad0d25f469e852c446942fe98beb4a44..a4f2f7ad24868f1dd1dd759f5aeb89427dba0cb9 100644 (file)
@@ -28,10 +28,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;
@@ -46,14 +46,19 @@ void cpDisconnect(int fd)
        close(fd);
 }
 
-int main()
+int main(int argc, char* argv[])
 {
     int fd;
     cp2103_port_config_t config;
     int ret;
 
+    if (argc != 2) {
+       fprintf(stderr, "usage: %s <tty>\n", argv[0]);
+       return 1;
+    }
+
     /* open */
-    if ((fd = cpConnect()) < 0)
+    if ((fd = cpConnect(argv[1])) < 0)
        return 1;
 
     /* Read the current port configuration */