Beispiel #1
0
        //Use a key group to read the card
        public byte[] ReadData(ReadWriteTypeModeEnum rm, KeyModeEnum km, byte blockNo, byte keyGroupIndex, out byte[] cardSerialData)
        {
            //byte readModel = (byte)rm;
            byte keyModel = (byte)km;

            cardSerialData = SelectCard();
            if (cardSerialData == null)
            {
                return(null);
            }
            if (CheckReaderKey(keyModel, blockNo, keyGroupIndex))
            {
                byte[] pData    = new byte[100];
                ulong  pDataLen = 0;
                int    r        = MasterRDImprot.rf_M1_read(0, blockNo, pData, ref pDataLen);
                if (r == 0)
                {
                    byte[] resultData = new byte[pDataLen];
                    for (int i = 0; i < (int)pDataLen; i++)
                    {
                        resultData[i] = pData[i];
                    }
                    return(resultData);
                }
            }
            return(null);
        }
Beispiel #2
0
        public bool OpenLed(LightColor lc)
        {
            byte color = (byte)lc;
            int  r     = MasterRDImprot.rf_light(0, color);

            return(r == 0 ? true : false);
        }
Beispiel #3
0
        public byte[] ReadData(KeyModeEnum km, byte blokNo, string keyStr, out byte[] cardSerialData)
        {
            // byte readModel = (byte)rm;
            byte keyModel = (byte)km;

            byte[] key      = GetKeyData(keyStr);
            byte[] pData    = new byte[100];
            ulong  pdataLen = 0;

            //Reading card serial number
            cardSerialData = SelectCard();
            if (cardSerialData == null)
            {
                return(null);
            }
            int r;

            //check key
            r = MasterRDImprot.rf_M1_authentication2(0, keyModel, blokNo, key);

            r = MasterRDImprot.rf_M1_read(0, blokNo, pData, ref pdataLen);
            if (r == 0)
            {
                byte[] rData = new byte[pdataLen];
                for (int i = 0; i < (int)pdataLen; i++)
                {
                    rData[i] = pData[i];
                }
                return(rData);
            }
            return(null);
        }
Beispiel #4
0
        public bool DownloadKeyToReader(byte blockNo, string keystr)
        {
            byte[] key = GetKeyData(keystr);
            int    r   = MasterRDImprot.rf_M1_WriteKeyToEE2(0, blockNo, key);

            if (r == 0)
            {
                return(true);
            }
            return(false);
        }
Beispiel #5
0
 public bool OpenCom(ushort comNo, ushort baud)
 {
     try
     {
         int r = MasterRDImprot.rf_init_com(comNo, baud);
         return(r == 0 ? true : false);
     }
     catch
     {
         throw new Exception("loi5");
     }
 }
Beispiel #6
0
 public bool CloseCom()
 {
     try
     {
         int r = MasterRDImprot.rf_ClosePort();
         return(r == 0 ? true : false);
     }
     catch
     {
         throw new Exception("loi6");
     }
 }
Beispiel #7
0
        //Use key groups to write data
        public bool WriteData(ReadWriteTypeModeEnum rm, KeyModeEnum km, byte blockNo, byte keyGroupIndex, string pDataStr)
        {
            byte readModel = (byte)rm;
            byte keyModel  = (byte)km;

            SelectCard();
            if (CheckReaderKey(keyModel, blockNo, keyGroupIndex))
            {
                byte[] pData = GetWriteData(pDataStr);
                int    r     = MasterRDImprot.rf_M1_write(0, blockNo, pData);
                return(r == 0 ? true : false);
            }
            return(false);
        }
Beispiel #8
0
        public byte[] SelectCard()
        {
            byte[] pData    = new byte[10];
            byte   pdataLen = 0;
            int    r        = MasterRDImprot.rf_s70_select(0, pData, ref pdataLen);

            if (r == 0)
            {
                byte[] rData = new byte[pdataLen];
                for (int i = 0; i < pdataLen; i++)
                {
                    rData[i] = pData[i];
                }
                return(rData);
            }
            return(null);
        }
Beispiel #9
0
        //Use key to write data
        public bool WriteData(KeyModeEnum km, byte blockNo, string keyStr, string pDataStr)
        {
            //byte readModel = (byte)rm;
            byte keyModel = (byte)km;

            byte[] key   = GetKeyData(keyStr);
            byte[] pData = GetBlockData(pDataStr);
            ulong  pLen  = (ulong)pData.Length;

            SelectCard();
            int r;

            //Check key
            r = MasterRDImprot.rf_M1_authentication2(0, keyModel, blockNo, key);

            r = MasterRDImprot.rf_M1_write(0, blockNo, pData);
            return(r == 0 ? true : false);
        }
Beispiel #10
0
        public bool Beep(int msec)
        {
            int r = MasterRDImprot.rf_beep(0, msec);

            return(r == 0 ? true : false);
        }
Beispiel #11
0
        public bool CheckReaderKey(byte keyModel, byte blockNo, byte keyGroupIndex)
        {
            int r = MasterRDImprot.rf_M1_authentication1(0, keyModel, blockNo, keyGroupIndex);

            return(r == 0 ? true : false);
        }