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

📄 at125lib.h

📁 附件采用EM4095 读头IC来读取Atmel的Tag芯片T5557
💻 H
字号:

#ifndef AT125Lib_h
#define AT125Lib_h

#include "GinUtility_TComm.h"
#include "GinThread.h"

#include <vector>
using namespace std;


#define COMMAND 0x01
#define RESPONSE_BEGIN 0x02
#define RESPONSE_DATA 0x03
#define RESPONSE_END 0x04


#define CMD_GENERAL	 0x01
#define CMD_GENERAL_READ_REG 0x01
#define CMD_GENERAL_WRITE_REG 0x02

#define CMD_T5557  0x02
#define CMD_T5557_REGULAR_READ 0x01
#define CMD_T5557_READ_TID 0x02
#define CMD_T5557_READ_BLOCK 0x03
#define CMD_T5557_WRITE_BLOCK 0x04
#define CMD_T5557_WRITE_CONFIG 0x05
#define CMD_T5557_WRITE_PASSWORD 0x06



class AT125Lib:public TComm
{
public:
        AT125Lib();
        ~AT125Lib();
        bool OpenComPort(int port);
        void CloseComPort();

        int T5557RegularRead(unsigned char *ptr,int len);
        int T5557ReadTID(unsigned char *ptr);
        int T5557ReadBlock(unsigned char *ptr,int addr);
        int T5557WriteBlock(unsigned char *data,int addr);
        int T5557WriteConfig(unsigned char *config);
        int T5557WritePassword(unsigned char *password);

protected:
        int AccessControlLayer(unsigned char *data,unsigned char len,int to=0);

private:
        unsigned char GetChecksum(unsigned char *data,int len);

        int SendData(unsigned char *data,int len,int to=0);
        int ReadData(unsigned char *data,int len,int to=0);
        int CheckResponse(unsigned char *data,unsigned char *len,int to=0);
        int CheckResponseStatus(unsigned char &status,int to=0);
        int CheckResponseT5557RegularRead(unsigned char *ptr,int length,int to);
        int CheckT5557ReadTID(unsigned char *ptr,int to);
        int CheckT5557ReadBlock(unsigned char *ptr,int addr,int to);


        int timeout;
        GinMutex mutex;

        #define UART_IN_BUFFER_SIZE  128
  
        unsigned char temp_buffer[UART_IN_BUFFER_SIZE];
        unsigned char uart_state;
        unsigned char uart_in_buffer[UART_IN_BUFFER_SIZE]; // input cyclic buffer
        unsigned short uart_in_read;                        // input read index
        unsigned short uart_in_end;                         // input message read index
        unsigned short uart_in_write;                       // input write index
        unsigned char uart_in_overflow;                    // input buffer overflow
        unsigned char uart_in_error;                       // input buffer parity error, ...
        unsigned char uart_read_bytes;       // number of bytes to read before parsing
        unsigned char uart_read_msg_bytes;   // actual number of bytes (msg position no.2)
};

#endif
 

⌨️ 快捷键说明

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