日期:2014-05-16  浏览次数:20719 次

在linux下用串口发送数据问题:
在linux下用如下程序通过串口发送数据
char sendbuffer[66];
if(nwrite = write(fd, sendbuffer,64))>0)
{
printf("send data to uart success! nwrite = %d\n",nwrite); 
}
else
{
printf("\nsend data to uart fail!\n");
}  

当sendbuffer[]中含有数据 0 时,会出现发送失败的问题,即nwrite<= 0;
当sendbuffer中含有数据13,17,19等数据时,对方收到的数据是错误的,
这是什么问题,高手指教,急等!谢谢!

输入输出模式
  options.c_cflag &= ~CSIZE; 
  options.c_lflag &= ~(ICANON | ECHO | ECHOE | ISIG); /*Input*/
  options.c_oflag &= ~OPOST; /*Output*/
   
  if (set_Parity(fd,8,1,'N') == FALSE) 
  {
  printf("Set Parity Error\n");
  //return -1;
  }

------解决方案--------------------
确认一下波特率设置是否正确