示例#1
0
        public bool USB_DownImage(byte[] pBuf, int nBufLen)
        {
            byte[] tPCCmd = new byte[6];
            int    w_nDataCnt;

            byte[] w_pImgBuf = new byte[ONCE_UP_IMAGE_UINT];
            int    w_nI;

            if (m_hHandle.IsInvalid)
            {
                return(false);
            }

            w_nDataCnt = nBufLen;
            w_nI       = 0;

            while (w_nDataCnt > ONCE_UP_IMAGE_UINT)
            {
                tPCCmd[0] = 0xEF;
                tPCCmd[1] = 0x17;
                tPCCmd[3] = (byte)w_nI;
                tPCCmd[4] = CommandProc.LOBYTE((ushort)(ONCE_UP_IMAGE_UINT & 0xFFFF));
                tPCCmd[5] = CommandProc.HIBYTE((ushort)(ONCE_UP_IMAGE_UINT & 0xFFFF));

                Array.Copy(pBuf, w_nI * ONCE_UP_IMAGE_UINT, w_pImgBuf, 0, ONCE_UP_IMAGE_UINT);

                if (!USBSCSIWrite(tPCCmd, 6, w_pImgBuf, ONCE_UP_IMAGE_UINT, SCSI_TIMEOUT))
                {
                    return(false);
                }

                w_nDataCnt -= (int)ONCE_UP_IMAGE_UINT;
                w_nI++;
            }

            tPCCmd[0] = 0xEF;
            tPCCmd[1] = 0x17;
            tPCCmd[3] = (byte)w_nI;
            tPCCmd[4] = CommandProc.LOBYTE((ushort)(w_nDataCnt & 0xFFFF));
            tPCCmd[5] = CommandProc.HIBYTE((ushort)(w_nDataCnt & 0xFFFF));

            Array.Copy(pBuf, w_nI * ONCE_UP_IMAGE_UINT, w_pImgBuf, 0, w_nDataCnt);

            if (!USBSCSIWrite(tPCCmd, 6, w_pImgBuf, (uint)w_nDataCnt, SCSI_TIMEOUT))
            {
                return(false);
            }

            return(true);
        }
示例#2
0
        public void DisplayResponsePacket(ushort p_nCode)
        {
            checkOK = false;
            goToAdd = false;
            saveID  = "";

            int    w_nRet;
            ushort w_nData   = 0;
            ushort w_nData2  = 0;
            ushort w_nRcvCks = 0;
            ushort w_nSize   = 0;

            //ClearResponseInfo();

            if (CommandProc.GET_PACKET_PREFIX(false) == CommonDefine.RCM_PREFIX_CODE)
            {
                w_nRcvCks = (ushort)((CommandProc.m_pPacketBuffer[CommonDefine.ST_COM_PACKET_LEN + 1] << 8) + CommandProc.m_pPacketBuffer[CommonDefine.ST_COM_PACKET_LEN]);
            }
            else if (CommandProc.GET_PACKET_PREFIX(false) == CommonDefine.RCM_DATA_PREFIX_CODE)
            {
                w_nRcvCks = (ushort)((CommandProc.m_pPacketBuffer[CommandProc.GET_DATAPACKET_LEN(false) + 1] << 8) + CommandProc.m_pPacketBuffer[CommandProc.GET_DATAPACKET_LEN(false)]);
            }

            w_nRet   = (int)CommandProc.GET_PACKET_RETURN(false);
            w_nData  = CommandProc.GET_PACKET_RCMDATA(0, false); // MAKEWORD(g_Packet[8], g_Packet[9]);
            w_nData2 = CommandProc.GET_PACKET_RCMDATA(2, false); //MAKEWORD(g_Packet[10], g_Packet[11]);
            w_nSize  = CommandProc.GET_PACKET_LEN(false);

            string strMsg = "";

            switch (p_nCode)
            {
            case CommonDefine.CMD_CLEAR_TEMPLATE_CODE:
                //指定删除
                if (w_nRet == CommonDefine.ERR_SUCCESS)
                {
                    //strMsg = string.Format("结果 : 成功\r\n指纹编号 : {0}", w_nData);
                }
                else
                {
                    // strMsg = string.Format("结果 : 错误\r\n{0}", GetErrorMsg(w_nData));
                }
                break;

            case CommonDefine.CMD_WRITE_TEMPLATE_CODE:
                //指定录入
                if (w_nRet == CommonDefine.ERR_SUCCESS)
                {
                    strMsg = string.Format("结果 : 成功\r\n指纹编号 : {0}", w_nData);
                }
                else
                {
                    strMsg = string.Format("结果 : 错误\r\n{0}", GetErrorMsg(w_nData));

                    if (w_nData == CommonDefine.ERR_DUPLICATION_ID)
                    {
                        strMsg += string.Format(" {0}.", w_nData2);
                    }
                }

                break;

            case CommonDefine.CMD_GET_EMPTY_ID_CODE:
                //获取最小ID
                if (w_nRet == CommonDefine.ERR_SUCCESS)
                {
                    strMsg = string.Format("结果 : 成功\r\n可以编号 : {0}", w_nData);
                    strID  = w_nData.ToString();
                }
                else
                {
                    strMsg = string.Format("结果 : 错误\r\n{0}", GetErrorMsg(w_nData));
                    strID  = "";
                }
                break;

            case CommonDefine.CMD_GET_ENROLL_COUNT_CODE:
                //已经注册个数
                if (w_nRet == CommonDefine.ERR_SUCCESS)
                {
                    strMsg = string.Format("结果 : 成功\r\n指纹数量 : {0}", w_nData);
                }
                else
                {
                    strMsg = string.Format("结果 : 错误\r\n{0}", GetErrorMsg(w_nData));
                }

                break;

            case CommonDefine.CMD_VERIFY_WITH_DOWN_TMPL_CODE:
            case CommonDefine.CMD_IDENTIFY_WITH_DOWN_TMPL_CODE:
            case CommonDefine.CMD_VERIFY_CODE:
            case CommonDefine.CMD_IDENTIFY_CODE:
            case CommonDefine.CMD_IDENTIFY_FREE_CODE:
            case CommonDefine.CMD_ENROLL_CODE:
            case CommonDefine.CMD_ENROLL_ONETIME_CODE:
            case CommonDefine.CMD_CHANGE_TEMPLATE_CODE:
            case CommonDefine.CMD_IDENTIFY_WITH_IMAGE_CODE:
            case CommonDefine.CMD_VERIFY_WITH_IMAGE_CODE:
                if (w_nRet == CommonDefine.ERR_SUCCESS)
                {
                    switch (w_nData)
                    {
                    case CommonDefine.GD_NEED_RELEASE_FINGER:
                        strMsg = "请离开手指";
                        break;

                    case CommonDefine.GD_NEED_FIRST_SWEEP:
                        strMsg = "请按手指";
                        break;

                    case CommonDefine.GD_NEED_SECOND_SWEEP:
                        strMsg = "请再按一次";
                        break;

                    case CommonDefine.GD_NEED_THIRD_SWEEP:
                        strMsg = "请再按一次";
                        break;

                    case CommonDefine.CMD_CLEAR_TEMPLATE_CODE:
                        strMsg = "请按手指";
                        break;

                    default:

                        strMsg = string.Format("结果 : 成功\r\n指纹编号 : {0}", w_nData);
                        strID  = "";

                        checkOK = p_nCode == CommonDefine.CMD_IDENTIFY_FREE_CODE;
                        loginID = p_nCode == CommonDefine.CMD_IDENTIFY_FREE_CODE ? w_nData.ToString() : "";
                        saveID  = p_nCode == CommonDefine.CMD_ENROLL_ONETIME_CODE ? w_nData.ToString() : "";

                        break;
                    }
                }
                else
                {
                    strMsg = string.Format("结果 : 错误\r\n{0}", GetErrorMsg(w_nData));
                    if (CommandProc.LOBYTE(w_nData) == CommonDefine.ERR_BAD_QUALITY)
                    {
                        strMsg += "\r\nAgain... !";
                    }
                    else
                    {
                        goToAdd = p_nCode == CommonDefine.CMD_IDENTIFY_FREE_CODE;
                        if (w_nData == CommonDefine.ERR_DUPLICATION_ID)
                        {
                            strMsg += string.Format(" {0}.", w_nData2);
                        }
                    }
                }

                break;

            case CommonDefine.CMD_FINGER_DETECT_CODE:

                if (w_nRet == CommonDefine.ERR_SUCCESS)
                {
                    if (w_nData == CommonDefine.GD_DETECT_FINGER)
                    {
                        strMsg = string.Format("检测到指纹");
                    }
                    else if (w_nData == CommonDefine.GD_NO_DETECT_FINGER)
                    {
                        strMsg = string.Format("没有检测到指纹");
                    }
                    else
                    {
                        strMsg = string.Format("通讯错误.");
                    }
                }
                else
                {
                    strMsg = string.Format("结果 : 错误\r\n{0}", GetErrorMsg(w_nData));
                }

                break;

            case CommonDefine.CMD_FP_CANCEL_CODE:

                /* if (w_nRet == CommonDefine.ERR_SUCCESS)
                 *   strMsg = string.Format("结果 : 取消命令成功");
                 * else
                 *   strMsg = string.Format("结果 : 错误\r\n{0}", GetErrorMsg(w_nData));
                 */
                break;

            default:
                break;
            }

            edtRC_Result.Text = strMsg;

            if ((p_nCode == CommonDefine.CMD_IDENTIFY_FREE_CODE))
            {
                if (w_nRet == CommonDefine.ERR_SUCCESS ||
                    CommandProc.LOBYTE(w_nData) != CommonDefine.ERR_NOT_AUTHORIZED &&
                    CommandProc.LOBYTE(w_nData) != CommonDefine.ERR_FP_CANCEL &&
                    CommandProc.LOBYTE(w_nData) != CommonDefine.ERR_INVALID_OPERATION_MODE &&
                    CommandProc.LOBYTE(w_nData) != CommonDefine.ERR_ALL_TMPL_EMPTY)
                {
                    Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);

                    if (checkOK)
                    {
                        Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);
                        m_clsCmdProc.m_bCmdDone = true;

                        Login(loginID);

                        return;
                    }

                    if (goToAdd)
                    {
                        if (MessageBox.Show("当前指纹未识别到身份证信息,是否手动登录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
                        {
                            Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);
                            m_clsCmdProc.m_bCmdDone = true;

                            AddLogin();
                        }
                    }

                    m_clsCmdProc.StartSendThread();
                    return;
                }

                if (goToAdd)
                {
                    if (MessageBox.Show("当前指纹未识别到身份证信息,是否手动登录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
                    {
                        Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);
                        m_clsCmdProc.m_bCmdDone = true;

                        AddLogin();
                    }
                }
            }

            if ((p_nCode == CommonDefine.CMD_ENROLL_CODE) ||
                (p_nCode == CommonDefine.CMD_CHANGE_TEMPLATE_CODE))
            {
                switch (w_nData)
                {
                case CommonDefine.GD_NEED_RELEASE_FINGER:
                case CommonDefine.GD_NEED_FIRST_SWEEP:
                case CommonDefine.GD_NEED_SECOND_SWEEP:
                case CommonDefine.GD_NEED_THIRD_SWEEP:
                case CommonDefine.ERR_BAD_QUALITY:
                    Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);
                    m_clsCmdProc.StartSendThread();
                    return;

                default:
                    break;
                }
            }
            if ((p_nCode == CommonDefine.CMD_ENROLL_ONETIME_CODE) ||
                (p_nCode == CommonDefine.CMD_VERIFY_CODE) ||
                (p_nCode == CommonDefine.CMD_IDENTIFY_CODE) ||
                (p_nCode == CommonDefine.CMD_IDENTIFY_FREE_CODE))
            {
                switch (w_nData)
                {
                case CommonDefine.GD_NEED_RELEASE_FINGER:
                    Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);
                    m_clsCmdProc.StartSendThread();
                    return;

                default:
                    break;
                }
            }

            Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);
            m_clsCmdProc.m_bCmdDone = true;

            if (!string.IsNullOrEmpty(saveID))
            {
                SaveID(saveID);
            }

            if (p_nCode == CommonDefine.CMD_CLEAR_TEMPLATE_CODE)
            {
                if (MessageBox.Show("当前指纹未识别到身份证信息,是否手动登录?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.OK)
                {
                    Array.Clear(CommandProc.m_pPacketBuffer, 0, CommonDefine.MAX_DATA_LEN + 10);
                    m_clsCmdProc.m_bCmdDone = true;

                    AddLogin();

                    return;
                }

                Run_IdentifyFree();
            }
        }
示例#3
0
        public string GetErrorMsg(ushort p_nErrorCode)
        {
            string w_ErrMsg;

            switch (CommandProc.LOBYTE(p_nErrorCode))
            {
            case CommonDefine.ERR_VERIFY:
                w_ErrMsg = "1:1失败";
                break;

            case CommonDefine.ERR_IDENTIFY:
                //w_ErrMsg = "1:N失败";
                w_ErrMsg = "验证失败";
                break;

            case CommonDefine.ERR_EMPTY_ID_NOEXIST:
                w_ErrMsg = "没有可用编号";
                break;

            case CommonDefine.ERR_BROKEN_ID_NOEXIST:
                w_ErrMsg = "没有损坏的模板";
                break;

            case CommonDefine.ERR_TMPL_NOT_EMPTY:
                w_ErrMsg = "指纹已经存在";
                break;

            case CommonDefine.ERR_TMPL_EMPTY:
                w_ErrMsg = "没有此指纹";
                break;

            case CommonDefine.ERR_INVALID_TMPL_NO:
                w_ErrMsg = "错误的指纹编号";
                break;

            case CommonDefine.ERR_ALL_TMPL_EMPTY:
                w_ErrMsg = "指纹为空";
                break;

            case CommonDefine.ERR_INVALID_TMPL_DATA:
                w_ErrMsg = "错误的指纹数据";
                break;

            case CommonDefine.ERR_DUPLICATION_ID:
                w_ErrMsg = "重复指纹 : ";
                break;

            case CommonDefine.ERR_BAD_QUALITY:
                w_ErrMsg = "图像质量差";
                break;

            case CommonDefine.ERR_SMALL_LINES:
                w_ErrMsg = "图像太小";
                break;

            case CommonDefine.ERR_TOO_FAST:
                w_ErrMsg = "手指离开太快";
                break;

            case CommonDefine.ERR_TIME_OUT:
                w_ErrMsg = "超时";
                break;

            case CommonDefine.ERR_GENERALIZE:
                w_ErrMsg = "创建失败";
                break;

            case CommonDefine.ERR_NOT_AUTHORIZED:
                w_ErrMsg = "通讯被加密";
                break;

            case CommonDefine.ERR_EXCEPTION:
                w_ErrMsg = "出现异常 ";
                break;

            case CommonDefine.ERR_MEMORY:
                w_ErrMsg = "内存出错 ";
                break;

            case CommonDefine.ERR_INVALID_PARAM:
                w_ErrMsg = "无效参数";
                break;

            case CommonDefine.ERR_NO_RELEASE:
                w_ErrMsg = "请离开手指";
                break;

            case CommonDefine.ERR_INTERNAL:
                w_ErrMsg = "内部错误";
                break;

            case CommonDefine.ERR_FP_CANCEL:
                w_ErrMsg = "已取消";
                break;

            case CommonDefine.ERR_INVALID_OPERATION_MODE:
                w_ErrMsg = "无效的工作模式";
                break;

            case CommonDefine.ERR_NOT_SET_PWD:
                w_ErrMsg = "没有设置通讯密码";
                break;

            case CommonDefine.ERR_FP_NOT_DETECTED:
                w_ErrMsg = "没有检测到指纹";
                break;

            case CommonDefine.ERR_ADJUST_SENSOR:
                w_ErrMsg = "校准传感器失败";
                break;

            default:
                w_ErrMsg = "错误";
                break;
            }

            // Return
            return(w_ErrMsg);
        }