mifarea卡程序mifarea卡程序mifarea卡程序

源代码在线查看: command.c.bak

软件大小: 1887 K
上传用户: haowoainime
关键词: mifarea 程序
下载地址: 免注册下载 普通下载 VIP

相关代码

				/****************************************
				 * 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 				        {
				            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			

相关资源