📄 serial_xx_x.c
字号:
/*vxCom.c - serial interface communication programme between host and target machine */
/*description:baud rate is 9600bps;8 data bit,1 1 stop bit,no verify */
/*author: faliang zhou date: February 13,2009 */
#include "vxWorks.h"
#include "stdio.h"
#include "stdlib.h"
#include "ioLib.h"
#include "taskLib.h"
int receive(int);
int send(int);
char buff[]="www.lygzb.com.cn\n";
int main()
{
int handle;
handle = open("/tyCo/0",2, 0);/*warning:the name is tyCo not is tyco !*/
taskSpawn("rec",60,0,0x2000,(FUNCPTR)receive,handle,0,0,0,0,0,0,0,0,0);/*creat and activation accive task*/
taskSpawn("send",80,0,0x2000,(FUNCPTR)send,handle,0,0,0,0,0,0,0,0,0);/*creat and activation send task*/
}
int receive(int fd)
{
char buffer[20];
/*char rword;
int i=0;*/
if(fd!=ERROR)
while(1)
{
read(fd, buffer,10);
/*read(fd, &buffer1[i++],1);*/
/*printf("%c",rword);*/
/*if(rword!='\0')*/
/*buffer1[i++]=rword;*/
printf("%s\n",buffer);
/*printf("zhongguo\n");*/
/*printf("the worlds=%c",rword);*/
/*else /*it don't execute this part,maybe the reason is havn't '\0'*/
/*{
printf("123456");
}*/
taskDelay(200);
}
else
printf("error!\n");
}
int send(int fd)
{
int i=0;
if(fd!=ERROR)
while(i<3)
{
write(fd,buff,strlen(buff));/*buff containing bytes to be written*/
printf("you have send '%s' %d times to host com.\n",buff,i+1);
i++;
taskDelay(50);
}
else
printf("error!\n");
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -