69,374
社区成员
发帖
与我相关
我的任务
分享
do{
state->fd = open(device,O_RDWR);
}while(state->fd<0 && errno == EINTR);
if(isatty(state->fd))
{
struct termios ios;
if(0!=tcgetattr(state->fd,,&ios))
{
perror("get ttyS1");
goto Fail;
}
cfsetispeed(&ios,B115200);
ios.c_cflag |= (CLOCAL | CREAD);
ios.c_lfag &= ~(ICANON | ECHO | ECHOE | ISIG);
ios.c_oflag &= ~OPOST;
ios.c_cc[VMIN] = 0;
ios.c_cc[VTIME] = 100;
if(0!=tcsetattr(state->fd,TCSANOW,&ios))
{
perror("setup ttyS1");
goto Fail;
}
}