VxWorks串口发送

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/bolvtin/article/details/51029152
#include "stdio.h"
#include "vxworks.h"




#include "unistd.h"
#include "logLib.h"


#include "ioLib.h"
#include "sioLib.h"

#include "selectLib.h"

struct fd_set fds_data;
int width;
int numFds;
int test_serial()
{
	char *send_buf="test";
	//printf("hello !\n");
	//logMsg("hello !\n",0,0,0,0,0,0);
	
	
	uartFd[UART_RADIO] = open("/tyCo/0",O_RDWR,0);
	
	ioctl(uartFd[UART_RADIO],FIOFLUSH,0);  //清空输入输出缓冲	
	
	FD_SET(uartFd[UART_RADIO],&fds_data);
	width=uartFd[UART_RADIO];
	width++;
	
	if(select(width,NULL,&fds_data,NULL,NULL))
			;//logMsg("hello !\n",0,0,0,0,0,0);
	
	if(FD_ISSET(uartFd[UART_RADIO],&fds_data))
	{
		//logMsg(" FD_ISSET hello asv!\n",0,0,0,0,0,0);
		
		//ioctl(uartFd[UART_RADIO],FIOFLUSH,0);  //清空输入输出缓冲
		write(uartFd[UART_RADIO],send_buf,sizeof(send_buf));
		
	}
	return 0;
}
因为调试串口和输出串口是同一个,所以在write的同时,一定不要logMsg,这样会被阻塞,导致无法正确输出

猜你喜欢

转载自blog.csdn.net/bolvtin/article/details/51029152