📄 command.h.bak
字号:
#ifndef COMMAND_H
#define COMMAND_H
/*
// PACKAGE:
STX - LEN1 - LEN2 - CMDTARGET - CMDCODE - UDP - ETX - LRC
for commands with fixed length and same target, we can send
multi-command in one command package.
// STX LEN CMD1 CMDDATA1 CMD2 CMDDATA2 ... ETX LRC
// in this case, once a command has been excuted, a result
// will be sent to the host.
*/
//CMDTARGET
#ifndef IC_TYPE
#define IC_TYPE
#define IC_SAM1 0
#define IC_SAM2 1
#define IC_SAM3 2
#define IC_SAMMAX 2 // the last sam card
#define IC_USER 3
#define IC_M1 10 // M1卡
#define IC_MPRO 11 // Mpro卡(特指射频接口)
#define MCU 20 // 单片机
#define SEC 21
#endif
//########################################################################################
// SEC
#define CMD_RDSEC 0
#define CMD_WRSEC 1
#define CMD_RDMEM 2
//########################################################################################
// MCU
#define CMD_EJECTCARD 0 // UDP: NULL
#define CMD_SETRFRXGAIN 1 // UDP: RECEIVE GAIN, 1 BYTE, (0 ~ 3, 0 FOR MIN AND 3 FOR MAX)
#define CMD_SETMODE 2 // UDP: MODE, one byte, defined follow
#define CMD_GETVER 3 // UDP: NULL
#define CMD_GETSYSINFO 4 // UDP: NULL
#define CMD_SYSRESET 5 // UDP: NULL
#define CMD_TESTCARD 6 // UDP: NULL
#define CMD_SETICCBRATE 7 // UDP: ETU(0: 9600, 1: 38400, 2: 19200, 3: ICC-9600)
#define CMD_USEDEBUG 8 // UDP: USEDEBUG(0 for not use, 1 for use)
#define CMD_BEEP 9 // UDP: beeptimes + interval
#define CMD_INV_PACK 10 // UDP: 0: normal pack, 1: inv pack
#define CMD_RFRESET 11 // UDP: NULL, return: SUCCESS/NOT
#define CMD_GETHDINFO 12 // UDP: NULL, return: HDINFO
#define CMD_GETMODE 13 // UDP: NULL, return: MODE, see setmode command
#define CMD_SETTOCRF 14 // UDP: time, 1 means 0.1 sec. set time of comfirm a rfcard
#define CMD_USERPOWER 15 // UDP: ON/OFF(0: OFF, else: ON)
#define CMD_SETLED 16 // UDP: LORC + LOTC + LOBC + LONC
#define CMD_CTRLLED 17 // UDP: LED_VALUE
#define CMD_SETBAUD 18 // UDP: BAUD(4800, 9600, 19200, 38400, 57600, 115200) + FMT.
#define CMD_CONNECT 0xEF
#define CMD_STARTISP 0x5a
///mode for mcu, = one or more of the following value OR tegather
#define AUTO_SEARCH_RFCARD 0x01
#define BEEP_ON_CARD_INOUT 0x02
#define NOTIFY_ON_CARD_INOUT 0x04
#define OFTEN_RESET_RF_IC 0x08 // reset rf ic once an hour when idle
//########################################################################################
// SMARTCARD / MPROCARD
//////////////////////////////////////////
// MifarePro Card Instruction
#define CMD_RESET 0 // UDP: NULL
#define CMD_PACKEDCMD 1 // UDP: CLA + INS + P1 + P2 + [[LC + DATA(LC BYTES)] + LE]
// 以上两条专用于MifarePro Card 的命令操作.
//////////////////////////////////////////
#define CMD_SYNC_RESET 2 // UDP: NULL
#define CMD_SYNC_START 3 // UDP: NULL
#define CMD_SYNC_STOP 4 // UDP: NULL
#define CMD_SYNC_PUTCHAR_ACK 5 // UDP: A CHAR
#define CMD_SYNC_GETCHAR_ACK 6 // UDP: ACK/NAK, 0: ACK, else: NAK
#define CMD_SYNC_WR_ACK 7 // UDP: DATA_TO_WRITE + LEN_TO_READ
#define CMD_SYNC_PUTCHAR 8 // UDP: A CHAR
#define CMD_SYNC_GETCHAR 9 // UDP: ACK/NAK, 0: ACK, else: NAK
#define CMD_SYNC_WR 10 // UDP: DATA_TO_WRITE + LEN_TO_READ
#define CMD_153_WR_EEPROM 0x6F // UDP: ZONE + ADDR + DATA(len-4)
#define CMD_153_RD_EEPROM 0x6E // UDP: ZONE + ADDR + LEN_TO_READ
#define CMD_153_VRF_PSWD 0x6D // UDP: RP + DATA(3 bytes)
#define CMD_153_INIT_AUTH 0x6C // UDP: DATA(8 bytes)
#define CMD_153_VRF_AUTH 0x6B // UDP: DATA(8 bytes)
#define CMD_153_WR_FUSE 0x6A // UDP: 1 byte value
#define CMD_153_RD_FUSE 0x69 // UDP: NULL
#define CMD_SLE_RD_MMEM 0x4F // UDP: Address
#define CMD_SLE_UPD_MMEM 0x4E // UDP: address + data
#define CMD_SLE_WR_MMEM 0x4E // UDP: address + data
#define CMD_SLE_RD_PMEM 0x4D // UDP: NULL
#define CMD_SLE_UPD_PMEM 0x4C // UDP: address + data
#define CMD_SLE_WR_PMEM 0x4C // UDP: address + data
#define CMD_SLE_RD_SMEM 0x4B // UDP: NULL
#define CMD_SLE_UPD_SMEM 0x4A // UDP: address + data
#define CMD_SLE_VERIFY 0x49 // UDP: address + data
#define CMD_SLE_CMD 0x40 // UDP: to be defined
/*
#define CMD_GET_ISAM_KEY 2 //UDP: SAM card SN--4 byte
#define CMD_INIT_POS 4
#define CMD_DO_POS 5
*/
//########################################################################################
// MEMERYCARD
//#define CMD_RESET 0
//########################################################################################
// M1
#define CMD_GETSNR 0 // UDP: NULL
#define CMD_AUTH 1 // UDP: SECTOR + AUTHFLAG + KEYAB(6 BYTES), AUTHFLAG: 0: A, OTHER: B
#define CMD_READ 2 // UDP: SECTOR + BLOCK
#define CMD_WRITE 3 // UDP: SECTOR + BLOCK + DATA(16 BYTES)
#define CMD_DECEP 4 // UDP: SECTOR + BLOCK + BAKBLOCK + eptype(0: lsb first) + value(4 bytes)
#define CMD_INCEP 5 // UDP: SECTOR + BLOCK + BAKBLOCK + eptype(0: lsb first) + value(4 bytes)
#define CMD_RDEP 6 // UDP: SECTOR + BLOCK + BAKBLOCK + eptype(0: lsb first)
#define CMD_WREP 7 // UDP: SECTOR + BLOCK + BAKBLOCK + eptype(0: lsb first) + value(4 bytes)
// #define CMD_LDMKEY 8 // UDP: SECTOR1 + A/BFLAG1 + KEY1 + ... SECTORn + FLAGn + KEYn
#define CMD_LDKEY 11 // UDP: SECTOR1 + A/BFLAG1 + KEY1 + ... SECTORn + FLAGn + KEYn
// n(max) = 16;
// 以下命令使用philips的加减钱包命令
#define CMD_PDECEP 9 // UDP: SECTOR + BLOCK + BAKBLOCK + eptype(0: lsb first) + value(4 bytes, msb first)
#define CMD_PINCEP 10 // UDP: SECTOR + BLOCK + BAKBLOCK + eptype(0: lsb first) + value(4 bytes, msb first)
// 070207新增块复制命令
#define CMD_BLOCKCOPY 12 // UDP: SECTOR + SRCBLOCK + DESTBLOCK
#define ALLBLOCK 0xFF
// 读取的数字以8086的格式排列,低位在前,高位在后
#ifndef MI_ERRCODE
#define MI_ERRCODE
#define MI_OK 0 /* 正确 */
#define MI_NOTAGERR 1 /* 无卡 */
#define MI_CRCERR 2 /* CRC校验错误 */
#define MI_AUTHERR 3 /* 认证错 */
#define MI_PARITYERR 4 /* 奇偶校验错 */
#define MI_CODEERR 5 /* 给卡的命令代码错 */
#define MI_SERNRERR 6 /* 卡序列号错 */
#define MI_KEYERR 7 /* 密钥错 */
#define MI_NOTAUTHERR 8 /* 没有认证 */
#define MI_BITCOUNTERR 9 /* 位计数错 */
#define MI_BYTECOUNTERR 10 /* 字节计数错 */
#define MI_WRITEERR 11 /* 写错误 */
#define MI_VALERR 12 /* 值错误 */
#define MI_OVFLERR 13 /* FIFO溢出 */
#define MI_FRAMINGERR 14 /* 桢错误 */
#define MI_UNKNOWN_COMMAND 15 /* 不支持的命令 */
#define MI_COLLERR 16 /* 卡冲突 */
#define MI_RESETERR 17 /* 复位错 */
#define MI_INTERFACEERR 18 /* 接口错 */
#define MI_ACCESSTIMEOUT 19 /* 操作超时 */
#define MI_NY_IMPLEMENTED 20 /* 其他错误 */
#define MI_EPBAKERR 21 /* 写钱包备份错误 */
#endif
//#####################################################################//
// 返回信息
// onsuccess: stx - len1 - len2 - result(=success) - data - [sw for smartcard] - etx - lrc
// onfail: stx - len1 - len2 - result(=fail) - [cmd_return_value] - etx - lrc
// on card in/out: stx - len1 - len2 - HASCARD - 行程开关状态 - 射频状态 - etx - lrc
// 其中”行程开关状态“和”射频状态“:1表示有,0表示无。
#define SUCCESS 0
#define FAIL 1
#define ERRORCMD 2
#define ERRORCMDLEN 3
#define TCARD 0xff
#define RFCARD 0xfe
#define TCOVERLOAD 0xfd
// execute host commands
void Command(void);
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -