请教虚拟机vmware下串口通信的问题
请教虚拟机vmware下串口通信的问题     
 我在虚拟机vmware下安了linux,用了串口,    
 arm写了一个写串口程序,linux下写了一个读串口程序,能成功的运行;    
 但在linux下写一个写串口程序,arm下写了一个读串口程序,就读不出数据来,怎么回事,是虚拟机有问题吗,只能写不能读? 
 程序: 
 //writetest.c 
 #include    <stdio.h>  
 #include    <string.h>  
 #include    <stdlib.h>  
 #include    <malloc.h>  
 #include    <sys/types.h>  
 #include    <sys/stat.h>  
 #include    <fcntl.h>  
 #include    <unistd.h>  
 #include    <termios.h>  
 #include    <errno.h>  
 #include    <math.h>    
 int   spfd; 
 int   main() 
 { 
 char   fname[16],*sbuf; 
 int   retv,i,ncount=0; 
 struct   termios   oldtio; 
 int   realdata=0; 
 spfd=open( "/dev/ttyS0 ",O_RDWR|O_NOCTTY|O_NONBLOCK); 
 //spfd=open( "/dev/ttyS0 ",O_RDWR|O_NOCTTY); 
 if(spfd <0) 
 { 
 perror( "open/dev/ttyS0 "); 
 return   -1; 
 } 
 tcgetattr(spfd,&oldtio); 
 cfmakeraw(&oldtio); 
 cfsetispeed(&oldtio,B57600); 
 cfsetospeed(&oldtio,B57600); 
 tcsetattr(spfd,TCSANOW,&oldtio); 
 printf( "ready   for   sending   data...\n "); 
 fname[0]= '1 '; 
 fname[1]= '2 '; 
 fname[2]= '3 '; 
 fname[3]= '\0 ';   
 retv=write(spfd,fname,4); 
 if(retv==-1) 
 perror( "write "); 
 printf( "the   number   sent   is   %d\n ",retv); 
 close(spfd); 
 return   0; 
 }   
 //readtest.c   
 #include    <stdio.h>  
 #include    <string.h>  
 #include    <malloc.h>  
 #include    <sys/types.h>  
 #include    <sys/stat.h>  
 #include    <fcntl.h>  
 #include    <unistd.h>  
 #include    <termios.h>  
 #include    <errno.h>  
 #include    <math.h>    
 int   spfd; 
 int   main() 
 { 
 char   hd[4]; 
 int   retv,i,ncount=0; 
 struct   termios   oldtio; 
 int   realdata=0; 
 spfd=open( "/dev/ttyS0 ",O_RDWR|O_NOCTTY|O_NONBLOCK); 
 //spfd=open( "/dev/ttyS0 ",O_RDWR|O_NOCTTY); 
 if(spfd <0) 
 { 
 perror( "open/dev/ttyS0 "); 
 return   -1; 
 } 
 printf( "spfd%d\n ",spfd); 
 tcgetattr(spfd,&oldtio); 
 cfmakeraw(&oldtio); 
 cfsetispeed(&oldtio,B57600); 
 cfsetospeed(&oldtio,B57600); 
 tcsetattr(spfd,TCSANOW,&oldtio);   
 printf( "ready   for   receiving   data...\n "); 
 retv=read(spfd,hd,4); 
 /* 
 if(retv==-1) 
 { 
 perror( "read "); 
 return   -1; 
 } 
 */   
 printf( "%d\n ",retv); 
 printf( "%s\n ",hd);   
 close(spfd); 
 return   0; 
 } 
 arm开发板和主机是通过串口通信,arm发出的数据,主机能读,主机发出的数据,arm就不能读,郁闷! 
 哪位高手指点指点我,不胜感谢 
------解决方案--------------------我老用vmware串口,没问题啊 
 你用minicom测试一下吧,看你的程序有没问题。   
 vmware添加串口的时候,也没啥特别要注意的,在菜单里指定物理串口就可以了