public string ReadData(int sector, int block) { int ret = -1; InitCard(sector); ret = MwRfSDK.rf_read_hex(_icdev, 4 * sector + block, _buff32); return(HexToStr(System.Text.Encoding.ASCII.GetString(_buff32))); }
public bool StopCard() { int ret = MwRfSDK.rf_halt(_icdev); if (ret != 0) { return(false); } return(true); }
protected string InitCard(int sector) { int ret = -1; ret = MwRfSDK.rf_reset(_icdev, 3); ret = MwRfSDK.rf_card(_icdev, (byte)Mode.CARD, ref _snr); _guid = _snr.ToString("X"); ret = MwRfSDK.rf_load_key(_icdev, (byte)Mode.LOAD, sector, _key); ret = MwRfSDK.rf_authentication(_icdev, (byte)Mode.LOAD, sector); return(_guid); }
/// <summary> /// 关闭通讯口 /// </summary> /// <returns></returns> public bool Close() { int ret = -1; ret = MwRfSDK.rf_exit(_icdev); _icdev = 0; if (ret < 0) { return(false); } Status = DeviceStatus.CLOSE; return(true); }
public bool WriteData(string strData, int sector, int block) { int ret = -1; if (strData.Length > 16) { return(false); } string strTemp = StrToHex(strData).PadLeft(32, '0'); _buff32 = Encoding.ASCII.GetBytes(strTemp); InitCard(sector); ret = MwRfSDK.rf_write_hex(_icdev, sector * 4 + block, _buff32); if (ret != 0) { return(false); } return(true); }
/// <summary> /// 打开设备 /// </summary> /// <returns></returns> public bool Open() { int ret = -1; string hexKey = "ffffffffffff"; byte[] bytesKey = new byte[17]; // _key2 = new byte[6] { 0xff, 0xff, 0xff, 0xff, 0xff, 0xff }; _key = new byte[7]; _buff32 = new byte[32]; _icdev = MwRfSDK.rf_init(_port, _baud); ret = _icdev; if (ret < 0) { return(false); } bytesKey = Encoding.ASCII.GetBytes(hexKey); MwRfSDK.a_hex(bytesKey, _key, 12); Status = DeviceStatus.OPEN; return(true); }
public void Beep(int msec) { MwRfSDK.rf_beep(_icdev, msec); }