Beispiel #1
0
        /// <summary>
        /// Recherche en mode Iso15693
        /// </summary>
        /// <param name="read"></param>
        /// <returns></returns>
        private bool SearISO15693(out byte[] read)
        {
            Int32 ret   = -1;
            Int32 lnRet = 0;

            byte[] bufferIN;
            byte[] bufferOut;

            bufferIN  = new byte[] { 0x80, 0x04, 0x15, 0x01, 0x26, 0x00, 0x00, 0x00, 0x00 };
            bufferOut = new byte[50];
            Int32 len = bufferIN.Length - 2;

            if ((ret = CSC.AddCRC(bufferIN, ref len)) == CSC.RCSC_Ok)
            {
                ret = CSC.SendReceive(2000, bufferIN, bufferIN.Length, bufferOut, ref lnRet);
                if (ret == CSC.RCSC_Ok && lnRet > 9)
                {
                    read = new byte[lnRet];
                    Array.Copy(bufferOut, read, lnRet - 1);
                    return(true);
                }
            }
            bufferIN  = null;
            bufferOut = null;
            System.GC.Collect();
            IsOnline = true;
            read     = new byte[0];
            return(false);
        }
Beispiel #2
0
        /// <summary>
        /// Recherche en mode Mifare
        /// </summary>
        /// <param name="lecture"></param>
        /// <returns></returns>
        private Int32 searchMifare(out byte[] lecture)
        /*****************************************************************************/
        {
            lecture = new byte[20];
            CSC.sCARD_SearchExtTag cardSearch = new CSC.sCARD_SearchExtTag();                 // config. structure of card research mode
            int   com        = 15693;                                                         // comm mode found
            Int32 respLength = 0;                                                             // response length

            byte[] response = { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 }; // response of the card
            Int32  retAct;
            Int32  ret;


            cardSearch.ISOA   = 2;
            cardSearch.ISOB   = 2;
            cardSearch.TICK   = 1;
            cardSearch.MV4k   = 1;
            cardSearch.MV5k   = 1;
            cardSearch.MIFARE = 1;
            cardSearch.CONT   = 1;
            cardSearch.MONO   = 0;
            cardSearch.INNO   = 1;


            retAct = CSC.SearchCardExt(ref cardSearch,
                                       CSC.SEARCH_MASK_ISOA | CSC.SEARCH_MASK_ISOB | CSC.SEARCH_MASK_MIFARE | CSC.SEARCH_MASK_MV4K | CSC.SEARCH_MASK_INNO,
                                       CSC.FORG,
                                       CSC.TIMEOUT,
                                       ref com,
                                       ref respLength,
                                       response);                               //activate Mifare


            Console.WriteLine(com.ToString());
            if ((retAct == CSC.RCSC_Ok) && (com == 0x08))
            {
                lecture = (byte[])response.Clone();

                ret = CSC.SUCCESS;
            }
            else
            {
                lecture = (byte[])response.Clone();
                ret     = CSC.FAILURE;
            }
            return(ret);
        }
Beispiel #3
0
        /// <summary>
        /// Constructeur du Wrapper
        /// </summary>
        /// <param name="delegationRead">Méthode déléguée appellé si lecture</param>
        /// <param name="ISO15693">Mode d'utilisation Iso15693 si true</param>
        public RDReaderWrapperNET(CSC.ReadCard delegationRead, bool ISO15693)
        {
            /// Recherche d'un lecteur ASK

            if (CSC.SearchCSC() != CSC.RCSC_Ok)
            {
                this._isOnline = false;
                return;
            }

            try
            {
                if (delegationRead != null)
                {
                    this.onReadCard = delegationRead;
                }

                byte[] version = new byte[CSC.VERSIONLENGTH];
                CSC.VersionDLL(version);
                this._version = UnicodeEncoding.ASCII.GetString(version);


                this._isOnline = true;

                //Initilialisation de la méthode ISO15693
                if (ISO15693)
                {
                    IsOnline       = false;
                    this._Iso15693 = true;
                    Int32 ret   = -1;
                    Int32 lnRet = 0;


                    byte[] bufferOut = new byte[50];

                    #region  Initialisation du champON
                    byte[] bufferIN = { 0x80, 0x05, 0x01, 0x0E, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00 };
                    Int32  len      = bufferIN.Length - 2;
                    if ((ret = CSC.AddCRC(bufferIN, ref len)) == CSC.RCSC_Ok)
                    {
                        ret = CSC.SendReceive(2000, bufferIN, bufferIN.Length, bufferOut, ref lnRet);
                        if (ret != CSC.RCSC_Ok)
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                    #endregion

                    #region  Initialisation du mode ISO15693
                    bufferIN  = null;
                    bufferOut = null;
                    System.GC.Collect();

                    bufferIN  = new byte[] { 0x80, 0x05, 0x10, 0x01, 0x02, 0x0C, 0x02, 0x00, 0x00, 0x00 };
                    bufferOut = new byte[50];
                    if ((ret = CSC.AddCRC(bufferIN, ref len)) == CSC.RCSC_Ok)
                    {
                        ret = CSC.SendReceive(2000, bufferIN, bufferIN.Length, bufferOut, ref lnRet);
                        if (ret != CSC.RCSC_Ok)
                        {
                            return;
                        }
                    }
                    else
                    {
                        return;
                    }
                    bufferIN  = null;
                    bufferOut = null;
                    System.GC.Collect();
                    IsOnline = true;

                    #endregion
                }
            }
            catch (Exception ex)
            {
                this._version = ex.Message;
            }
        }