佚名通过本文主要向大家介绍了arm开发板串口通信,arm开发板,arm嵌入式开发板,arm开发板哪,周立功arm开发板等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 急求!arm开发板串口读写
描述:
串口设置如下:
struct termios oldtio_data;
datafd=open("/dev/ttySAC2",O_RDWR|O_NOCTTY);
if(datafd<0)
{
printf("the sensors connect fail, check and restart.\n");
exit(1);
}
else printf("open the serial interface success\n");
tcgetattr(datafd,&oldtio_data);
oldtio_data.c_iflag &= ~(INLCR|ICRNL|IGNCR);
oldtio_data.c_oflag &= ~(ONLCR|OCRNL|ONOCR|ONLRET);
cfmakeraw(&oldtio_data);
cfsetispeed(&oldtio_data,B9600);
cfsetospeed(&oldtio_data,B9600);
tcsetattr(datafd,TCSANOW,&oldtio_data);
读写如下:
k1=write(dataspfd,acdemands,8);
printf("we write %d bytes.\n",k1);
k1=read(dataspfd,buf1,13);
描述:
arm数据Linux C#readdata
采用read、write函数完成串口读写。硬件采用mini6410开发板,通过串口向传感器发送8字节数据,传感器返回13字节。但read函数只能读到8个字节就返回了。如果分两次读,程序只能运行一次,第二回合就读不回任何参数串口设置如下:
struct termios oldtio_data;
datafd=open("/dev/ttySAC2",O_RDWR|O_NOCTTY);
if(datafd<0)
{
printf("the sensors connect fail, check and restart.\n");
exit(1);
}
else printf("open the serial interface success\n");
tcgetattr(datafd,&oldtio_data);
oldtio_data.c_iflag &= ~(INLCR|ICRNL|IGNCR);
oldtio_data.c_oflag &= ~(ONLCR|OCRNL|ONOCR|ONLRET);
cfmakeraw(&oldtio_data);
cfsetispeed(&oldtio_data,B9600);
cfsetospeed(&oldtio_data,B9600);
tcsetattr(datafd,TCSANOW,&oldtio_data);
读写如下:
k1=write(dataspfd,acdemands,8);
printf("we write %d bytes.\n",k1);
k1=read(dataspfd,buf1,13);