diff --git a/huagao/Device/GScan.h b/huagao/Device/GScan.h index 40c98e28..be9aae91 100644 --- a/huagao/Device/GScan.h +++ b/huagao/Device/GScan.h @@ -87,6 +87,8 @@ typedef enum tagUsbSupported { V4L2_IMAGE_EMPTY = 80, //处于休眠中 SLEEPING = 81, + //检测到有折角 + HAVE_DOGEAR = 82, //USB 未连接 USB_DISCONNECTED = 200, //用户点击停止 @@ -119,6 +121,7 @@ static map msgs = { {UsbSupported::V4L2_AQULRE_ERROR,"扫描仪取图失败!"}, {UsbSupported::V4L2_IMAGE_EMPTY,"扫描仪图像处理异常!"}, {UsbSupported::SLEEPING,"设备处于休眠模式,请唤醒休眠后再扫描!"}, + {UsbSupported::HAVE_DOGEAR,"检测到有折角,停止扫描!"}, }; enum tagEventIndex diff --git a/huagao/Device/GScanO1003399.cpp b/huagao/Device/GScanO1003399.cpp index 551a31a5..829c3835 100644 --- a/huagao/Device/GScanO1003399.cpp +++ b/huagao/Device/GScanO1003399.cpp @@ -315,13 +315,13 @@ void GScanO1003399::Scanner_StartScan(UINT16 count) keeplastimg = true; reset(); devState = DEV_ISRUNNING; - if (scanner_read_reg(m_usb, SR_GET_SLEEP_STAUTUS) != 1) - { - devState = DEV_WRONG; - Set_ErrorCode(SLEEPING); - scanflag = false; - return; - } + //if (scanner_read_reg(m_usb, SR_GET_SLEEP_STAUTUS) != 1) + //{ + // devState = DEV_WRONG; + // Set_ErrorCode(SLEEPING); + // scanflag = false; + // return; + //} if (scan_mode()) { devState = DEV_WRONG; @@ -434,6 +434,7 @@ void GScanO1003399::usb_run() break; case V4L2: FileTools::writelog(log_ERROR, "Got V4L2 Error code = " + to_string(info.Code)); + stop(); break; case STOPSCAN: FileTools::writelog(log_INFO, "StopScan"); @@ -442,31 +443,33 @@ void GScanO1003399::usb_run() FileTools::writelog(log_ERROR, "Got Unkown error code ! From =" + to_string(info.From) + " Code = " + to_string(info.Code)); break; } - if ((codeconvter(info) != 0)) + if (codeconvter(info) > 0) { - if (info.Code == 0x10 || info.Code == 0x20 || info.Code == 0x40) - { - while (scanner_read_reg(m_usb, SR_STATUS) & 0x1) - this_thread::sleep_for(chrono::microseconds(10)); - if (m_param.is_duplex) - pop_dev_im(); - pop_dev_im(); - } + Set_ErrorCode(codeconvter(info)); + } + if ((codeconvter(info) == -1)) + { + if ((get_ErrorCode() != PAPER_JAM) && (get_ErrorCode() != DETECT_DOUBLE_FEED) && (get_ErrorCode() != DETECT_STAPLE)) { keeplastimg = false; im_rx(); } + else { + while (!scanner_read_reg(m_usb, SR_GET_IMAGEPROCESSDONE)) + this_thread::sleep_for(chrono::microseconds(30)); + if (m_param.is_duplex) + pop_dev_im(); + pop_dev_im(); + } scanflag = false; - if ((devState != DEV_WRONG) && (codeconvter(info) < 0)) + if ((devState != DEV_WRONG) && (get_ErrorCode()<=0)) devState = DEV_STOP; - else if ((devState != DEV_WRONG) && (codeconvter(info) > 0)) + else if ((devState != DEV_WRONG) && (get_ErrorCode() > 0)) devState = DEV_WRONG; } - if (codeconvter(info) > 0) - { - Set_ErrorCode(codeconvter(info)); - } + + this_thread::sleep_for(chrono::microseconds(10)); } @@ -589,7 +592,7 @@ int GScanO1003399::read_data(void* data, int length, int timeout) int readed = 0; int reading = 0; - const int buffer_size = 2 * 1024 * 1024; + const int buffer_size = 512 * 1024; StopWatch sw; FileTools::writelog(log_INFO, "read_data timeout =" + to_string(timeout)); while (readed < length) { @@ -604,7 +607,8 @@ int GScanO1003399::read_data(void* data, int length, int timeout) } else { - FileTools::writelog(log_INFO, "read usb image data time out ,time = "+std::to_string(sw.elapsed_ms())); + FileTools::writelog(log_INFO, "read usb image data time out ,time = " + std::to_string(sw.elapsed_ms())); + break; } } return readed; @@ -771,6 +775,16 @@ int GScanO1003399::codeconvter(HGEIntInfo code) break; } } + if (code.From == HGType::IMG) + { + switch (code.Code) + { + case 0: + return HAVE_DOGEAR; + default: + break; + } + } if (code.From == HGType::STOPSCAN) return -1; return 0; diff --git a/huagao/Device/IConfig.h b/huagao/Device/IConfig.h index 47afcd3b..8baa3a11 100644 --- a/huagao/Device/IConfig.h +++ b/huagao/Device/IConfig.h @@ -178,6 +178,7 @@ enum Scanner_Reg_Defs SR_SET_SLEEPTIME, SR_GET_SLEEPTIME, SR_GET_SLEEP_STAUTUS, + SR_GET_IMAGEPROCESSDONE, SR_GET_CUO_ERROR = 0x50, SR_GET_DOU_ERROR, SR_GET_JAM_ERROR, diff --git a/huagao/huagaotwds.rc b/huagao/huagaotwds.rc index 51e69179..0505be76 100644 Binary files a/huagao/huagaotwds.rc and b/huagao/huagaotwds.rc differ