From 8d1631bf2749ff43914cf6fb3fc136b691432e0b Mon Sep 17 00:00:00 2001 From: smckown Date: Mon, 2 Nov 2009 20:21:28 +0000 Subject: [PATCH] Update cpio (cp210x io test program) to accept device on command line like cpmfg --- src/examples/cpio.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/examples/cpio.c b/src/examples/cpio.c index f0f6f38..a4f2f7a 100644 --- a/src/examples/cpio.c +++ b/src/examples/cpio.c @@ -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 \n", argv[0]); + return 1; + } + /* open */ - if ((fd = cpConnect()) < 0) + if ((fd = cpConnect(argv[1])) < 0) return 1; /* Read the current port configuration */ -- 2.39.2