📄 init.c
字号:
/****************Portting Start *******************/
#include "string.h"
#include "vxworks.h"
#include "tylib.h"
int consoleFd;
void serial_init( )
{
consoleFd=open("/tyCo/0",O_RDWR,0666);
ioctl(consoleFd,FIOSETOPTIONS,OPT_RAW);
ioctl(consoleFd,FIOFLUSH,0);
}
/* Test if there's chars at serial port */
int sio_ischar()
{
int cnt;
ioctl (consoleFd, FIONREAD, (int) &cnt);
return cnt;
}
void Uart_SendKey(unsigned char trychar)
{
unsigned char keyout;
keyout = trychar;
write(consoleFd, &keyout, 1);
}
int Uart_GetKey(unsigned char * chp)
{
unsigned char ch;
/* last_error = 0; */
while ( !sio_ischar() )
{
taskDelay(4);
return -1;
}
read(consoleFd,&ch,1);
/* last_error = 1; */
*chp=ch;
/* printf("Uart_GetKey: Get the char %c .\n",ch);*/
return (int)ch;
}
/****************Portting End*******************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -