Last active
April 17, 2017 10:50
-
-
Save lategoodbye/dd0d30af27b6f101b03d5923b279dbaa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//usb_test.c | |
//compile: gcc usb_test.c -o usb_test | |
#include <fcntl.h> /* O_RDWR */ | |
#include <stdio.h> | |
#include <unistd.h> | |
#include <string.h> | |
void open_port(char * portname) { | |
int fd; | |
printf("opening [%s]\n", portname); | |
fd = open(portname, O_RDWR); | |
if(fd == -1) { | |
printf("failed\n"); | |
return; | |
} | |
printf("ok\n"); | |
sleep(5); | |
} | |
int main() { | |
printf("idle \n"); | |
open_port("/dev/ttyUSB0"); | |
open_port("/dev/ttyUSB1"); | |
open_port("/dev/ttyUSB2"); | |
open_port("/dev/ttyUSB3"); | |
open_port("/dev/ttyUSB4"); | |
open_port("/dev/ttyUSB5"); | |
open_port("/dev/ttyUSB6"); | |
open_port("/dev/ttyUSB7"); | |
open_port("/dev/ttyUSB8"); | |
printf("idle 2\n"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment