📄 cmmcom.c
字号:
#include <vxWorks.h>
#include <ioLib.h>
#include <stdio.h>
#include <string.h>
#include <sockLib.h>
#include <socket.h>
#include <ioLib.h>
#include <time.h>
#include "fioLib.h"
#include "CmmCom.h"
#include "stdio.h"
#include "s3c2410.h"
#include "taskLib.h"
#include "semLib.h"
#include "sysLib.h"
char CMM_Readuart1();
char CMM_Readuart2();
void cxp(void);
int main(void)
{
printf("run status start\n");
testcominit();
taskSpawn ("tUART", 200, 0, 2000,
(FUNCPTR)cxp,0,0,0,0,0,0,0,0,0,0);
}
void cxp(void)
{
char temp=0;
char temp1=0;
while(1)
{
temp=CMM_Readuart1();
if(temp!=0xff)
{
printf("uart1 receive:%0x\n",temp);
}
temp=0;
temp1=CMM_Readuart2();
if(temp1!=0xff)
{
printf("uart2 receive:%0x\n",temp1);
}
temp1=0;
/* taskDelay(sysClkRateGet()/2);*/
}
}
char CMM_Readuart1()
{
char key;
int bytesRead = 0xff;
bytesRead = read (consoleFd1, &key, 1);
if(bytesRead != 1)
return 0xff;
return (key);
}
char CMM_Readuart2()
{
char key;
int bytesRead = 0xff;
bytesRead = read (consoleFd2, &key, 1);
if(bytesRead != 1)
return 0xff;
return (key);
}
/****************************************************************
description: Add all command to the command structure one by one
InPut: Non
OutPut: Non
Return: The result of add all command
****************************************************************/
int CMM_Writeuart1(char *key,int len)
{
int bytesWrite = 0;
bytesWrite = write(consoleFd1, key, len);
return (bytesWrite);
}
/*************this is for test *****************/
#if 1
int testcominit()
{
consoleFd1 = open ("/tyCo/1", O_RDWR, 0);
if(ERROR == consoleFd1)
{
printf("open /tyCo/1 error errno =%d\n",errno);
return;
}
(void) ioctl (consoleFd1, FIOBAUDRATE, 9600);
(void) ioctl (consoleFd1, FIOSETOPTIONS,
OPT_CRMOD | OPT_TANDEM );
consoleFd2 = open ("/tyCo/2", O_RDWR, 0);
if(ERROR == consoleFd2)
{
printf("open /tyCo/2 error errno =%d\n",errno);
return;
}
(void) ioctl (consoleFd2, FIOBAUDRATE, 9600);
(void) ioctl (consoleFd2, FIOSETOPTIONS,
OPT_CRMOD | OPT_TANDEM );
}
char CMM_Readcom(int comx)
{
char key;
int bytesRead = -1;
bytesRead = read (comx, &key, 1);
if(bytesRead != 1)
return 0xff;
printf("get from %d :%c\n",comx,key);
return (key);
}
int CMM_Writecom(char *key,int len,int comx)
{
int bytesWrite = 0;
bytesWrite = write(comx, key, len);
if(bytesWrite > 0)
printf("write to %d:%c\n",comx,*key);
return (bytesWrite);
}
void uart1(char *s)
{
int len;
for(len=0;len<strlen(s);len++)
{
CMM_Writecom(&s[len],1,consoleFd1);
}
}
void uart2(char *s)
{
int len;
for(len=0;len<strlen(s);len++)
{
CMM_Writecom(&s[len],1,consoleFd2);
}
}
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -