Пример #1
0
        /// <summary>
        /// COM2
        /// </summary>
        /// <param name="com"></param>
        public bool OpenCom(string com)
        {
            var handle = DLL_CRT591M001_MR01.CRT591MROpen(com);

            if ((int)handle == 0)
            {
                return(false);
            }
            this.comHandler = handle;
            return(true);
        }
Пример #2
0
        /// <summary>
        /// COM2
        /// </summary>
        /// <param name="com"></param>
        public bool OpenCom(string com, string route)
        {
            var handle = DLL_CRT591M001_MR01.CRT591MROpenWithBaut(com, uint.Parse(route));

            if (handle.Equals(0))
            {
                return(false);
            }
            this.comHandler = handle;
            return(true);
        }
Пример #3
0
        /// <summary>
        /// 获取所有连接的读卡器状态,先初始化
        /// </summary>
        /// <returns></returns>
        public List <ReaderCardandState> GetSCardReaderStatus()
        {
            List <ReaderCardandState> list = new List <ReaderCardandState>();

            for (int i = 0; i < ReaderCount; i++)
            {
                ReaderCardandState reader = new ReaderCardandState();
                DLL_CRT591M001_MR01.GetSCardReaderStatus(i, ref reader.ReaderName, ref reader.ReaderNameLen, ref reader.CardState, ref reader.CardProtocol, reader.ATR_DATA, ref reader.ATR_DataLen);
                list.Add(reader);
            }
            return(list);
        }
Пример #4
0
        /// <summary>
        /// 断开只能读卡器
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public bool DisconnectSCardReader(int index)
        {
            int res = DLL_CRT591M001_MR01.DisconnectSCardReader(index);

            if (res.Equals(0))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #5
0
        /// <summary>
        /// 初始化读卡器环境
        /// </summary>
        public bool InitializeContext()
        {
            int count = 0;
            int res   = DLL_CRT591M001_MR01.InitializeContext(ref count);

            if (res.Equals(0))
            {
                ReaderCount = count;
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #6
0
        /// <summary>
        /// 读卡器复位
        /// </summary>
        /// <returns></returns>
        public bool Poll()
        {
            RxRes rxRes = new RxRes();

            byte[] vs  = "00".ToHex();
            int    res = DLL_CRT591M001_MR01.RS232_ExeCommand(comHandler, TxAddr, 0x31, 0x30, 0x00, vs, ref rxRes.RxReplyType, ref rxRes.RxStCode0, ref rxRes.RxStCode1, ref rxRes.RxStCode2, ref rxRes.RxDataLen, rxRes.RxData);

            rxRes.ToString().logThis();
            if (res.Equals(0))
            {
                if ((enum_RxReplyType)rxRes.RxReplyType == enum_RxReplyType.执行成功)
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #7
0
        internal byte[] ReadRFCard()
        {
            RxRes rxRes = new RxRes(15);

            byte[] vs  = "41 42".ToHex();
            int    res = DLL_CRT591M001_MR01.RS232_ExeCommand(comHandler, TxAddr, 0x60, 0x30, 0x02, vs, ref rxRes.RxReplyType, ref rxRes.RxStCode0, ref rxRes.RxStCode1, ref rxRes.RxStCode2, ref rxRes.RxDataLen, rxRes.RxData);

            rxRes.ToString().logThis();
            if (res.Equals(0))
            {
                if ((enum_RxReplyType)rxRes.RxReplyType == enum_RxReplyType.执行成功)
                {
                    byte[] bt = null;
                    switch ((enum_RF_Rtype)rxRes.RxData[0])
                    {
                    case enum_RF_Rtype.MifareOneCard:
                        int a = rxRes.RxData[3];
                        bt = new byte[a];
                        for (int i = 0; i < a; i++)
                        {
                            bt[i] = rxRes.RxData[4 + i];
                        }
                        break;

                    case enum_RF_Rtype.TypeA:
                        break;

                    case enum_RF_Rtype.TypeB:
                        break;

                    default:
                        break;
                    }
                    return(bt);
                }
            }
            return(null);
        }
Пример #8
0
        public bool CloseCom()
        {
            int a = DLL_CRT591M001_MR01.CRT591MRClose(comHandler);

            return(a == 0 ? true : false);
        }
Пример #9
0
        /// <summary>
        /// 释放资源
        /// </summary>
        /// <returns></returns>
        internal bool ReleaseContext()
        {
            int a = DLL_CRT591M001_MR01.ReleaseContext();

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