command.c
来自「mifarea卡程序mifarea卡程序mifarea卡程序」· C语言 代码 · 共 69 行
C
69 行
/****************************************
* command.c *
* Designe by 刘俐训 *
* check and excute command from host *
* last update: 04-07-2007 *
****************************************/
void command(void)
{
unsigned char i;
unsigned int len; // 通讯报文长度
unsigned char buf[316]; // 通讯、操作用临时数据缓冲
unsigned int rsplen;
if((len = CommRead(buf, sizeof(buf)-1)) > 0)
{
switch(buf[0]) // buf[0]: cmd target
{
case IC_M1:
M1Command(buf+1, len-1);
break;
case IC_SAM1:
case IC_SAM2:
case IC_SAM3:
case IC_USER:
TcCommand(buf, len);
break;
case SYSTEM:
SysCommand(buf+1, len-1);
default:
}
}
}
void Connect(unsigned int time)
{
unsigned int starttime;
unsigned char ch;
int i;
unsigned char tar;
bit freading = 0;
starttime = GetTickCount();
while(GetTickCount() - starttime < time)
{
// check serial port
if(ComIBufBytesTell() > 0)
{
// restart timer
starttime = GetTickCount();
// read
ComRead(&ch, 1);
// if ch is a command, do it
// else write ch to tar
}
if(freading && // ch = read from tar > 0)
{
}
}
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?