/// <summary> /// 防冲突的情况下选卡,并选择其中停车卡。返回值为0表示成功,-1表示防冲突函数失败,否则表示选卡不成功。 /// </summary> /// <param name="nCardSequenceNum">卡号</param> /// <returns>返回值为0表示成功,-1表示防冲突函数失败,否则表示选卡不成功。</returns> private int SelectCard(ref uint nCardSequenceNum) { //int nCardSequenceNum; //byte strtemp; int nback = -1; if (m_bIs64BitOperatingSystem) { //64位系统 if (USB_SWIPER == m_nComID) { nback = CQTCommonForUsb.rf_anticoll(m_nEquipDesc, 0, out nCardSequenceNum);//查找卡片 } else { nback = CQTCommon.rf_anticoll(m_nEquipDesc, 0, out nCardSequenceNum);//查找卡片 } } else { //其他位系统 if (USB_SWIPER == m_nComID) { nback = CQTCommonForUsb.rf_anticoll(m_nEquipDesc, 0, out nCardSequenceNum);//查找卡片 } else { nback = CQTCommon.rf_anticoll(m_nEquipDesc, 0, out nCardSequenceNum);//查找卡片 } } if (nback == 0) { if (m_bIs64BitOperatingSystem) { //64位系统 if (USB_SWIPER == m_nComID) { CQTCommonForUsb.rf_beep(m_nEquipDesc, 50); } else { CQTCommon.rf_beep(m_nEquipDesc, 50); } } else { //其他位系统 if (USB_SWIPER == m_nComID) { CQTCommonForUsb.rf_beep(m_nEquipDesc, 50); } else { //CLOGException.Trace(m_nEquipDesc + "beep"); CQTCommon.rf_beep(m_nEquipDesc, 50); } } //rf_halt(m_nEquipDesc); } return(nback); }
/// <summary> /// 向感应区内所选定卡的指定扇区(0~15)的指定数据块(0~3)写入数据(16字节或者6字节(密码)十六进制)。函数返回值,-1表示验证密码失败,0表示操作成功,其他表示读失败 /// </summary> /// <param name="nSector">指定扇区</param> /// <param name="nDBNum">指定扇区中的指定DB块</param> /// <param name="strWrite">写入的数据(16字节或6字节),十六进制数</param> /// <returns>函数返回值,-1表示验证密码失败,0表示操作成功,其他表示读失败</returns> public override int WriteDataIntoCard(Int16 nSector, Int16 nDBNum, string strWrite) { strWrite += "FF"; byte[] bBuff = new byte[32]; byte[] bWrite = new byte[16]; int nCounter = 0; for (nCounter = 0; nCounter < strWrite.Length; nCounter++) { if (strWrite[nCounter] >= '0' && strWrite[nCounter] <= '9') { continue; } if (strWrite[nCounter] <= 'a' && strWrite[nCounter] <= 'f') { continue; } if (strWrite[nCounter] <= 'A' && strWrite[nCounter] <= 'F') { continue; } } if (nCounter != strWrite.Length) { // lbResult.Text = "data is hex data!"; return(1); } bBuff = Encoding.ASCII.GetBytes(strWrite); if (m_bIs64BitOperatingSystem) { //64位系统 if (USB_SWIPER == m_nComID) { CQTCommonForUsb.a_hex(bBuff, bWrite, 32); } else { CQTCommon.a_hex(bBuff, bWrite, 32); } } else { //其他位系统 if (USB_SWIPER == m_nComID) { CQTCommonForUsb.a_hex(bBuff, bWrite, 32); } else { CQTCommon.a_hex(bBuff, bWrite, 32); } } int nBack = 1; int blocknum = nSector * 4 + nDBNum; if (m_bIs64BitOperatingSystem) { //64位系统 if (USB_SWIPER == m_nComID) { nBack = CQTCommonForUsb.rf_authentication(m_nEquipDesc, m_nAuthKeyMode, nSector); } else { nBack = CQTCommon.rf_authentication(m_nEquipDesc, m_nAuthKeyMode, nSector); } } else { //其他位系统 if (USB_SWIPER == m_nComID) { nBack = CQTCommonForUsb.rf_authentication(m_nEquipDesc, m_nAuthKeyMode, nSector); } else { nBack = CQTCommon.rf_authentication(m_nEquipDesc, m_nAuthKeyMode, nSector); } } if (nBack != 0) { return(-1); } if (m_bIs64BitOperatingSystem) { //64位系统 if (USB_SWIPER == m_nComID) { nBack = CQTCommonForUsb.rf_write(m_nEquipDesc, (short)blocknum, bWrite); CQTCommonForUsb.rf_beep(m_nEquipDesc, 50); } else { nBack = CQTCommon.rf_write(m_nEquipDesc, (short)blocknum, bWrite); CQTCommon.rf_beep(m_nEquipDesc, 50); } } else { //其他位系统 if (USB_SWIPER == m_nComID) { nBack = CQTCommonForUsb.rf_write(m_nEquipDesc, (short)blocknum, bWrite); CQTCommonForUsb.rf_beep(m_nEquipDesc, 50); } else { nBack = CQTCommon.rf_write(m_nEquipDesc, (short)blocknum, bWrite); CQTCommon.rf_beep(m_nEquipDesc, 50); } } return(nBack); }