linux: tcgetattr 함수 기능 및 사용 장면
10111 단어 의문 처리 기록
/* termios */
struct termios options;
/* */
tcgetattr(fd,&options);
/* */
cfsetispeed(&options,B4800);
cfsetospeed(&options,B4800);
options.c_cflag |= CLOCAL;//
options.c_cflag |= CREAD;//
options.c_cflag &= ~CRTSCTS;//
options.c_cflag |= CRTSCTS;//
options.c_cflag |= IXON|IXOFF|IXANY;//
options.c_cflag &= ~CSIZE;//
options.c_cflag |= CS5;
options.c_cflag &= ~CSIZE;//
options.c_cflag |= CS6;
options.c_cflag &= ~CSIZE;//
options.c_cflag |= CS7;
options.c_cflag &= ~CSIZE;//
options.c_cflag |= CS8;
options.c_cflag &= ~PARENB;//PARENB: ,
options.c_cflag &= ~INPCK;//INPCK:
/* , 2 */
options.c_cflag &= ~PARENB;//PARENB: ,
options.c_cflag &= ~CSTOPB;//CSTOPB:
/* */
options.c_cflag |= PARENB;//PARENB: ,
options.c_cflag |= PARODD;//PARODD: ,
options.c_cflag |= INPCK;//INPCK:
options.c_cflag |= ISTRIP;//ISTRIP: 7 , 8
/* */
options.c_cflag |= PARENB;//PARENB: ,
options.c_cflag &= ~PARODD;//PARODD: ,
options.c_cflag |= INPCK;//INPCK:
options.c_cflag |= ISTRIP;//ISTRIP: 7 , 8
/* */
options.c_cflag &= ~CSTOPB;//CSTOPB:
options.c_cflag |= CSTOPB;//CSTOPB:
/* */
options.c_oflag &= ~OPOST;//OPOST: , c_oflag
/* */
options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG);
/*
*ICANON:
*ECHO:
*ECHOE: EPASE Backspace,Space,Backspace
*ISIG:
*/
/* */
options.c_cc[VTIME] = 0;// select
options.c_cc[VMIN] = 1;//
/* , , */
tcflush(fd,TCIFLUSH);
/* , */
tcsetattr(fd,TCSANOW,&options)
urt 직렬 통신 초기 화 설정 예제 코드https://blog.csdn.net/u010360266/article/details/107084561