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;
close(fd);
}
-int main()
+int main(int argc, char* argv[])
{
int fd;
cp2103_port_config_t config;
int ret;
int i;
- if ((fd = cpConnect()) < 0)
+ if (argc != 2) {
+ fprintf(stderr, "usage: %s <tty>\n", argv[0]);
+ return 1;
+ }
+
+ /* open */
+ if ((fd = cpConnect(argv[1])) < 0)
return 1;
/* Read the current port configuration */
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) {