Beispiel #1
0
        public void ConnectToCard()
        {
            try
            {
                acr1281UC1.connect(readerList[0].ToString());


                //Initialize Mifare classic class
                mifareClassic = new MifareClassic(acr1281UC1.pcscConnection);

                currentChipType = acr1281UC1.getChipType();


                if (currentChipType != CHIP_TYPE.MIFARE_1K && currentChipType != CHIP_TYPE.MIFARE_4K)
                {
                    // MessageBox.Show("Card is not supported.\r\nPlease present Mifare Classic card");
                    return;
                }
            }
            catch (PcscException pcscException)
            {
                //MessageBox.Show(pcscException.Message, "PCSC Exception");
            }
            catch (Exception generalException)
            {
                // MessageBox.Show(generalException.Message, "Exception");
            }
        }
Beispiel #2
0
        // Constructor
        public NetworkBackgammonChip(CHIP_TYPE chipType)
        {
            // Load the icon directly from the manifest resource
            Icon blackChipIcon = new Icon(this.GetType(),
                                          (chipType == CHIP_TYPE.OPPONENT_1 ? "Resources.BlackChip.ico" : "Resources.WhipChip.ico"));

            // Set the chip bitmap
            m_chipBitmap = new Bitmap(blackChipIcon.ToBitmap());
            // Set the chip size based on the image size
            ChipSize = new Size(blackChipIcon.ToBitmap().Width, blackChipIcon.ToBitmap().Height);
        }
Beispiel #3
0
        public CHIP_TYPE getChipType()
        {
            int rdrLen = 0, retCode, protocol = pcscConnection.activeProtocol;
            int pdwSate = 0, atrLen = 33;

            byte[]    atr      = new byte[100];
            CHIP_TYPE cardType = CHIP_TYPE.UNKNOWN;


            retCode = PcscProvider.SCardStatus(pcscConnection.cardHandle, pcscConnection.readerName, ref rdrLen, ref pdwSate,
                                               ref protocol, atr, ref atrLen);

            if (retCode != PcscProvider.SCARD_S_SUCCESS)
            {
                throw new PcscException(retCode);
            }

            pcscConnection.activeProtocol = protocol;

            if (atr.Length < 33)
            {
                return(CHIP_TYPE.UNKNOWN);
            }

            Array.Resize(ref atr, atrLen);

            if (atr[13] == 0x00 && atr[14] == 0x01)
            {
                cardType = CHIP_TYPE.MIFARE_1K;
            }
            else if (atr[13] == 0x00 && atr[14] == 0x02)
            {
                cardType = CHIP_TYPE.MIFARE_4K;
            }
            else if (atr[13] == 0x00 && atr[14] == 0x03)
            {
                cardType = CHIP_TYPE.MIFARE_ULTRALIGHT;
            }
            else
            {
                cardType = CHIP_TYPE.UNKNOWN;
            }

            return(cardType);
        }