X-Git-Url: https://oss.titaniummirror.com/gitweb?p=cp210x.git;a=blobdiff_plain;f=src%2Fexamples%2Fcpio.c;h=a4f2f7ad24868f1dd1dd759f5aeb89427dba0cb9;hp=f0f6f388ad0d25f469e852c446942fe98beb4a44;hb=8d1631bf2749ff43914cf6fb3fc136b691432e0b;hpb=4124804857a4525ccf77906b3faeb6df65dc9fb3 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 */