|  | 
 
| 本帖最后由 fanyundemuzi 于 2013-3-3 17:39 编辑 
 fd = open("/dev/tq2440_serial1", O_RDWR|O_NOCTTY|O_NDELAY    //TQ2440开发板+TTL串口拓展模块
 
 串口初始化:
 struct termios options;
 tcgetattr(fd, &options);             //得到当前串口参数
 options.c_cflag |= (CLOCAL | CREAD); //使能接收、使能本地状态
 options.c_cflag &= ~CRTSCTS;         //取消硬件流控制
 options.c_cflag &= ~CSIZE;           //设置字符大小
 options.c_cflag |= CS8;              //数据为8位
 options.c_cflag &= ~CSTOPB;          //一个停止位
 options.c_cflag |= IGNPAR;           //忽略奇偶校验错误
 options.c_oflag = 0;                 //指定终端控制信息
 options.c_lflag = 0;                 //本地模式设置
 
 
 cfsetispeed(&options, B9600);        //设置输入波特率为9600
 cfsetospeed(&options, B9600);        //设置输出波特率为9600
 tcsetattr(fd, TCSANOW, &options);    //激活新配置
 
 
 
 往串口里写入数据:
 unsigned char temp[LEN];                           //假设temp[]大于4160的数组
 nwrite = write(fd, temp, sizeof(temp));     //往串口里面写入temp[]数据
 printf ("nwrite:%d\n");                  //为什么输出始终都是显示“nwrite:4160”,如果temp[]数组的长度3160(小于4160),nwrite就显示3160(显示正常)
 是不是因为tq2440_serial1驱动问题,限制了缓冲区的大小?具体怎么改?怎么解决?
 
 | 
 |