void init_ttyS(int fd)
{
struct termios options;
bzero(&options,sizeof(options));
//set baud rate
cfsetispeed(&options,B9600);
cfsetospeed(&options,B9600);
options.c_cflag=(B9600 | CS8 |CLOCAL | CREAD); //control mode flag:baud rate,8 bits,local link,can read
options.c_iflag=IGNPAR; // input mode flag
options.c_oflag=0;
options.c_lflag=ICANON;
tcflush(fd,TCIFLUSH);
tcsetattr(fd,TCSANOW,&options); //new set take into practise right now
printf("init %s success, DEVICE_TTYS");
}
做的项目需要用串口1来发送数据,(串口0进行调试)
程序写好之后,编绎成功,在板上运行时提示“segmentation fault”,调试发现问题出在inin_ttyS(int fd)( 因为我把它//inin_ttyS(int fd)( ),程序能顺利调通
但这段段码我仔细看了N遍,没发现有什么错误呀,望达人解答