- int space_serial(int fd) //空校验
- {
- opt.c_cflag |= PARENB|CMSPAR|PARODD;
- if(tcsetattr(fd, TCSANOW, &opt) !=0) //配置立刻起作用
- {
- perror("serial error");
- return-1;
- }
- }
- int mark_serial(int fd) //置位校验
- {
- opt.c_cflag |= PARENB|CMSPAR;
- opt.c_cflag &= ~PARODD;
- if(tcsetattr(fd, TCSANOW, &opt) !=0) //配置立刻起作用
- {
- perror("serial error");
- return-1;
- }
- }
- int none_serial(int fd)
- {
- opt.c_cflag &=~PARENB; //关闭奇偶校验位
- opt.c_cflag &=~INPCK; //使奇偶校验不起作用
- if(tcsetattr(fd, TCSANOW, &opt) !=0) //配置立刻起作用
- {
- perror("serial error");
- return-1;
- }
- }
int odd_serial(int fd)
{
}
int even_serial(int fd)
{
}