⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 command.c.bak

📁 mifarea卡程序mifarea卡程序mifarea卡程序
💻 BAK
字号:
/****************************************
 * command.c                            *
 * Designe by 刘俐训                    *
 * check and excute command from host   *
 * last update: 05-01-2007              *
 ****************************************/

#include "includes.h"
#include "MifarePro.h"

void Command(void)
{
    unsigned int len = 0;           // 通讯报文长度
    unsigned char buf[316];     // 通讯、操作用临时数据缓冲
    int limit;

    if((len = CommRead(buf, sizeof(buf)-1)) > 0)
    {
        limit = ParaRead(PARA_LIMIT);
        if(limit < 0)
            limit = ParaWrite(PARA_LIMIT, 1);
            
        if((limit <= 0) && (buf[0] != SEC))
        {
            buf[0] = ERRORCMD;
            buf[1] = 0xaa;
            len = 2;
        }
        else
        {
            switch(buf[0])  // buf[0]: cmd target
            {
                case SEC:
                    len = SecCommand(buf, len);
                    break;
                    
                case IC_M1:
                    len = M1Command(buf, len);
                    break;
				case IC_MPRO:
				    len = MifareProExcute(buf,len);
					break;	 
                    
                case IC_SAM1:
                case IC_SAM2:
                case IC_SAM3:
                case IC_USER:
                    len = TcCommand(buf, len);
                    break;
                
                case MCU:
                    len = SysCommand(buf, len);
                    break;
                    
                default:
                    break;
            }
        }
        
        if(len > 0)
            CommSend(buf, len);
    }
}

#if 0
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)	         //这里有一处疑问?
        {
            
        }
    }
}
#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -