?? comreceive.c
字號:
#include "vxWorks.h" /*for vxworks OS*/
#include "stdioLib.h"
#include "ioLib.h"
#include "stdio.h"
#include "ioctl.h"
#include "selectLib.h"
#include "types/vxTypesOld.h"
#include "strLib.h"
#include "string.h"
#include "sioLib.h"
#include "drv\hdisk\ataDrv.h"
void CreatHardDrive();
void Comreceive(void);
void Portinit(void);
int fdd;
FILE *fpp;
int num;
int len;
char accept_buf[1000];
int width;
fd_set fds_data;
void Comreceive(void)
{
/*CreatHardDrive();*/
fdd=open("/tyCo/0",O_RDWR,0);
Portinit();
if(fdd==ERROR) /*如果不能打開串口1則打印出錯信息*/
printf("You can’t open port com1 !");
fpp=fopen("/ata0a/com.txt","a+b");
if(fpp==NULL)printf("openfile erorr");
while(1)
{
FD_ZERO(&fds_data);
FD_SET(fdd,&fds_data);
width=fdd+1;
if(select(width,&fds_data,NULL,NULL,NULL)==ERROR)printf("ERROR");
num=read(fdd,accept_buf,sizeof(accept_buf));
printf("accept message is : %s \n\n", accept_buf);
len=fwrite(accept_buf,num,1,fpp);
printf("num=%d\n",num);
printf("len=%d\n",len);
}
}
/*void CreatHardDrive()
{
BLK_DEV *pBlkDev;
pBlkDev = ataDevCreate(0, 0, 0, 0);
usrAtaConfig(0, 0, "/ata0");
}*/
void Portinit(void)
{ioctl(fdd,FIOSETOPTIONS,OPT_LINE);
ioctl(fdd,FIOBAUDRATE,9600);
ioctl(fdd,FIOFLUSH,0);
ioctl(fdd,SIO_HW_OPTS_SET,CS8|STOPB|PARENB|PARODD);
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -