/* Set input parity option */
if (parity != 'n'){
options.c_iflag |= INPCK;
}
tcflush(fd,TCIFLUSH);
options.c_iflag &= ~(ICRNL | IXON | BRKINT | ISTRIP); //预防0D强制变0A 防止丢掉0x13
options.c_cc[VTIME] = 0; /* 设置超时15 seconds*/
options.c_cc[VMIN] = 1; /* define the minimum bytes data to be readed*/
if (tcsetattr(fd,TCSANOW,&options) != 0){
return (-1);
}
tcgetattr(fd, &opt);
return (0);