예제 #1
0
        /// <summary>
        /// 电动读卡器异常发送状态
        /// </summary>
        public static string SendCRT310State()
        {
            string        port = SysConfigHelper.readerNode("CRT310Port");
            StringBuilder info = new StringBuilder(1024);

            Thread.Sleep(1000 * 1);
            CRT310.TT_CloseDevice(info);
            CRT310.TT_CloseDevice(info);
            Thread.Sleep(1000 * 1);
            int handle = -1;

            for (int i = 1; i <= 2; i++)
            {
                handle = CRT310.TT_OpenDevice(new StringBuilder("COM" + port), new StringBuilder("9600"), info);
                if (handle == 0)
                {
                    break;
                }
            }
            int jubing = handle;

            if (handle == 0)
            {
                handle = CRT310.TT_GetDeviceStatus(info);
                CRT310.TT_CloseDevice(info);
                if (handle == 4101)
                {
                    return(null);
                }
                if (handle == 4104)
                {
                    return(null);
                }
                if (handle != 0)
                {
                    return("01" + handle.ToString());
                }
            }
            else
            {
                return("01" + handle.ToString());
            }
            return(null);
        }