|
请教下大牛们一个设置串口波特率的问题 int openGPRSdev(void) { int fd; struct termios options; char dev[]="/dev/modem0"; fd = open(dev, O_RDWR | O_NOCTTY | O_NDELAY); if(fd < 0) { printf("================================\n"); perror("open dev fail!"); return fd; } tcgetattr(fd, &options); cfsetospeed(&options, B9600); cfsetispeed(&options, B9600); printf("speed==========="); // cfgetispeed(&options); //cfgetospeed(&options); // Enable the receiver and set local mode... options.c_cflag |= (CLOCAL | CREAD); // No parity (8N1): options.c_cflag &= ~PARENB; options.c_cflag &= ~CSTOPB; options.c_cflag &= ~CSIZE; options.c_cflag |= CS8; // enable hardware flow control (CNEW_RTCCTS) // options.c_cflag |= CRTSCTS; // set raw input options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); options.c_iflag &= ~(INLCR | ICRNL | IGNCR | IXON | IXOFF); // set raw output options.c_oflag &= ~OPOST; options.c_oflag &= ~OLCUC; options.c_oflag &= ~ONLRET; options.c_oflag &= ~ONOCR; options.c_oflag &= ~OCRNL; // Set the new options for the port... tcsetattr(fd, TCSANOW, &options); return fd; } 为什么我的串口不能改成9600
|
|