Esempio n. 1
0
        bool USB_ReceiveDataAck(ushort p_wCMD)
        {
            byte[] btCDB       = new byte[8];
            int[]  nLen        = new int[1];
            int    w_dwTimeOut = CommonDefine.COMM_TIMEOUT;

            byte[] w_WaitPacket = new byte[8];
            byte[] w_pTmpBuf;

            if (p_wCMD == CommonDefine.CMD_VERIFY_CODE ||
                p_wCMD == CommonDefine.CMD_IDENTIFY_CODE ||
                p_wCMD == CommonDefine.CMD_IDENTIFY_FREE_CODE ||
                p_wCMD == CommonDefine.CMD_ENROLL_CODE ||
                p_wCMD == CommonDefine.CMD_ENROLL_ONETIME_CODE)
            {
                w_dwTimeOut = (CommonDefine.GD_MAX_FP_TIME_OUT + 1) * (1000);
            }

            CommandProc.memset(w_WaitPacket, 0xAF, 0, 8);
            CommandProc.memset(btCDB, 0, 0, 8);

            do
            {
                btCDB[0] = 0xEF; btCDB[1] = 0x15;
                nLen[0]  = 6;
                if (!USBSCSIRead(btCDB, 8, CommandProc.m_pPacketBuffer, nLen, (uint)w_dwTimeOut))
                {
                    return(false);
                }
                Thread.Sleep(100);
                if (!CommandProc.DoEvents())
                {
                    return(false);
                }
            } while (CommandProc.memcmp(CommandProc.m_pPacketBuffer, w_WaitPacket, 6) == true);

            nLen[0]   = CommandProc.GET_PACKET_LEN(false) + 2;
            w_pTmpBuf = new byte[nLen[0] + 10];
            do
            {
                Array.Copy(CommandProc.m_pPacketBuffer, 6, w_pTmpBuf, 0, nLen[0]);
                if (!USB_ReceiveRawData(w_pTmpBuf, (uint)nLen[0]))
                {
                    return(false);
                }
                Array.Copy(w_pTmpBuf, 0, CommandProc.m_pPacketBuffer, 6, nLen[0]);
                Thread.Sleep(5);
                if (!CommandProc.DoEvents())
                {
                    return(false);
                }
            } while (CommandProc.memcmp(CommandProc.m_pPacketBuffer, w_WaitPacket, 4) == true);

            return(MainWindow.m_clsCmdProc.CheckReceive(CommonDefine.RCM_DATA_PREFIX_CODE, p_wCMD));
        }
Esempio n. 2
0
        public bool USB_ReceiveAck(ushort p_wCMD, bool p_bCmdData)
        {
            byte[] btCDB        = new byte[8];
            byte[] w_WaitPacket = new byte[24];
            int[]  nLen         = new int[1];
            int    w_dwTimeOut  = (int)SCSI_TIMEOUT;

            if (p_wCMD == CommonDefine.CMD_VERIFY_CODE ||
                p_wCMD == CommonDefine.CMD_IDENTIFY_CODE ||
                p_wCMD == CommonDefine.CMD_IDENTIFY_FREE_CODE ||
                p_wCMD == CommonDefine.CMD_ENROLL_CODE ||
                p_wCMD == CommonDefine.CMD_ENROLL_ONETIME_CODE)
            {
                w_dwTimeOut = (CommonDefine.GD_MAX_FP_TIME_OUT + 1) * (1000);
            }

            CommandProc.memset(w_WaitPacket, 0xAF, 0, CommonDefine.ST_COM_PACKET_LEN + 2);
            CommandProc.memset(btCDB, 0, 0, 8);

            do
            {
                CommandProc.memset(CommandProc.m_pPacketBuffer, 0, 0, CommonDefine.MAX_DATA_LEN + 10);
                btCDB[0] = 0xEF; btCDB[1] = 0x12;
                nLen[0]  = CommonDefine.ST_COM_PACKET_LEN + 2;
                if (!USBSCSIRead(btCDB, 8, CommandProc.m_pPacketBuffer, nLen, (uint)w_dwTimeOut))
                {
                    return(false);
                }
                Thread.Sleep(100);
                if (!CommandProc.DoEvents())
                {
                    return(false);
                }
            } while (CommandProc.memcmp(CommandProc.m_pPacketBuffer, w_WaitPacket, CommonDefine.ST_COM_PACKET_LEN + 2) == true);

            if (p_bCmdData)
            {
                return(MainWindow.m_clsCmdProc.CheckReceive(CommonDefine.RCM_PREFIX_CODE, p_wCMD));
            }
            else
            {
                return(MainWindow.m_clsCmdProc.CheckReceive(CommonDefine.RCM_DATA_PREFIX_CODE, p_wCMD));
            }
        }