/// <summary> /// /// </summary> /// <param name="bank"></param> /// <param name="offset"></param> /// <param name="count"></param> /// <param name="data"></param> /// <param name="password"></param> /// <param name="retry"></param> /// <param name="flags"></param> /// <returns></returns> private CSLibrary.Constants.Result CUST_18K6CTagWrite( CSLibrary.Constants.MemoryBank bank, UInt32 offset, UInt32 count, UInt16[] data, UInt32 password, CSLibrary.Constants.SelectFlags flags ) { if (count > MAX_WR_CNT) { return(CSLibrary.Constants.Result.DEVICE_NOT_SUPPORT); // too many data } MacWriteRegister(MACREGISTER.HST_TAGACC_ACCPWD, password); Start18K6CRequest(1, flags); MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG /*0xA01*/, (31 << 1) | 0x01); // Enable write verify and set retry count //MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG /*0xA01*/, 0x1ff); // Enable write verify and set retry count Setup18K6CWriteRegisters(bank, offset, count, data, 0); _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.WRITE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation); return(CSLibrary.Constants.Result.OK); }
} // Start18K6CRead bool CUST_18K6CTagRead(CSLibrary.Constants.MemoryBank bank, int offset, int count, UInt16[] data, UInt32 password, /*UInt32 retry, */ CSLibrary.Constants.SelectFlags flags) { const int MAX_RD_CNT = 0x20; if (count > MAX_RD_CNT) { return(false); // too many data } Start18K6CRead((uint)bank, (uint)(offset), (uint)count, data, password, 1, flags); return(true); }
} // Start18K6CRead bool CUST_18K6CTagRead(CSLibrary.Constants.MemoryBank bank, int offset, int count, UInt16[] data, UInt32 password, /*UInt32 retry, */ CSLibrary.Constants.SelectFlags flags) { const int MAX_RD_CNT = 0x20; int rdCycle = count / MAX_RD_CNT; int rdReminder = count % MAX_RD_CNT; int index = 0, i; //if (retry > 7) // retry = 7; if (rdCycle > 0) { return(false); // too many data } /* * for (index = 0; index < rdCycle; index++) * { * for (i = 0; i < retry; i++) * if (Start18K6CRead(bank, (uint)(offset + index * MAX_RD_CNT), MAX_RD_CNT, tagreadbuf, password, 1, flags) == true) * { * if (m_TagAccessStatus == 2) * { * Array.Copy(tagreadbuf, 0, data, index * MAX_RD_CNT, MAX_RD_CNT); * break; * } * } * if (i == retry) * return false; * } */ if (rdReminder > 0) { Start18K6CRead((uint)bank, (uint)(offset + index * MAX_RD_CNT), (uint)rdReminder, data, password, 1, flags); /* * if (Start18K6CRead(bank, (uint)(offset + index * MAX_RD_CNT), (uint)rdReminder, tagreadbuf, password, 1, flags) == true) * { * if (m_TagAccessStatus == 2) * { * Array.Copy(tagreadbuf, 0, data, index * MAX_RD_CNT, rdReminder); * break; * } * }*/ } return(true); }
public int Start18K6CRead(uint bank, uint offset, uint count, UInt16[] data, uint accessPassword, uint retry, CSLibrary.Constants.SelectFlags flags) { // Perform the common 18K6C tag operation setup Start18K6CRequest(retry, flags); Setup18K6CReadRegisters(bank, offset, count); // Set up the access password register MacWriteRegister(MACREGISTER.HST_TAGACC_ACCPWD, accessPassword); // Issue the read command _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.READ), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation); return(0); } // Start18K6CRead
/// <summary> /// /// </summary> /// <param name="bank"></param> /// <param name="offset"></param> /// <param name="count"></param> /// <param name="data"></param> /// <param name="password"></param> /// <param name="retry"></param> /// <param name="flags"></param> /// <returns></returns> private CSLibrary.Constants.Result CUST_18K6CTagWrite( CSLibrary.Constants.MemoryBank bank, UInt32 offset, UInt32 count, UInt16[] data, UInt32 password, //UInt32 retry, //UInt32 writeretry, CSLibrary.Constants.SelectFlags flags ) { int index; uint wrCycle = (uint)(count / MAX_WR_CNT); uint wrReminder = (uint)(count % MAX_WR_CNT); CSLibrary.Constants.Result status; UInt32 i; if (wrCycle > 0) { return(CSLibrary.Constants.Result.DEVICE_NOT_SUPPORT); } //MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG, 0x1ff); MacWriteRegister(MACREGISTER.HST_TAGACC_ACCPWD, password); Start18K6CRequest(1, flags); //ReadReaderRegister((UInt16)MACREGISTER.HST_TAGACC_DESC_CFG); MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG /*0xA01*/, (31 << 1) | 0x01); // Enable write verify and set retry count //MacWriteRegister(MACREGISTER.HST_TAGACC_DESC_CFG /*0xA01*/, 0x1ff); // Enable write verify and set retry count /* for (index = 0; index < wrCycle; index++) * { * Setup18K6CWriteRegisters(bank, (uint)(offset + index * MAX_WR_CNT), MAX_WR_CNT, data, (uint)(index * MAX_WR_CNT)); * * for (i = retry; i > 0; i--) * { * // Issue the write command to the MAC * status = COMM_HostCommand(HST_CMD.WRITE); * * if (status != Result.OK) * return status; * * //MacClearError(); * * if (m_TagAccessStatus == 2) * break; * * System.Threading.Thread.Sleep(100); * } * * if (i == 0) * return Result.MAX_RETRY_EXIT; * }*/ index = 0; if (wrReminder > 0) { Setup18K6CWriteRegisters(bank, (uint)(offset + index * MAX_WR_CNT), wrReminder, data, (uint)(index * MAX_WR_CNT)); //for (i = retry; i > 0; i--) { // Issue the write command to the MAC //status = COMM_HostCommand(HST_CMD.WRITE); _deviceHandler.SendAsync(0, 0, DOWNLINKCMD.RFIDCMD, PacketData(0xf000, (UInt32)HST_CMD.WRITE), HighLevelInterface.BTWAITCOMMANDRESPONSETYPE.WAIT_BTAPIRESPONSE_COMMANDENDRESPONSE, (UInt32)CurrentOperation); //if (status != Result.OK) //return status; //MacClearError(); //if (m_TagAccessStatus == 2) //break; //System.Threading.Thread.Sleep(100); } //if (i == 0) //return Result.MAX_RETRY_EXIT; } return(CSLibrary.Constants.Result.OK); }