arm linux 调试绝缘监测模块串口配置
int OpenDev(char *Dev,int baudrate)
{
speed_t speed;
int i=0;
int fdt,c=0,num;
struct termios oldtio,newtio;
speed = getBaudrate(baudrate);
fdt=open(Dev,O_RDWR | O_NONBLOCK| O_NOCTTY | O_NDELAY);
if(fdt<0)
{
perror(Dev);
exit(1);
} //save to oldtio
tcgetattr(fdt,&oldtio); //clear newtio
bzero(&newtio,sizeof(newtio));
//newtio.c_cflag = speed|CS8|CLOCAL|CREAD|CRTSCTS;
newtio.c_cflag = speed|CS8|CLOCAL|CREAD|PARENB;
newtio.c_iflag = IGNPAR;
newtio.c_oflag = 0;
//printf("newtio.c_cflag=%x\n",newtio.c_cflag);
tcflush(fdt,TCIFLUSH);
tcsetattr(fdt,TCSANOW,&newtio);
tcgetattr(fdt,&oldtio); //printf("oldtio.c_cflag=%x\n",oldtio.c_cflag);
return fdt;
}
由于使用的是泰兴的 ,按说明需要加上偶校验。