Serial Port Program (C 언어)


Serial Port Program (C 언어)

C언어로 작성한 serial port 제어 프로그램이다. 먼저 serial port를 구성에 맞는 형식으로 open 을 하여야 한다. 매개 변수로는 디바이스의 파일 링크와 serial port의 속도를 전달한다. #include <termios.h> #include <unistd.h> #include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #include <string.h> int open_serial_device(char *path, int baudrate) { int fd; int ret; speed_t speed; /* Check Baudrate */ { speed = get_baudrate(baudrate); if (speed == INVALID_BAUD) { printf("Invalid baudrate %d\n", baudrate); return -1; } } /* open seri...


#blocking #c #program #serial #시리얼

원문링크 : Serial Port Program (C 언어)