增加3399 折角检测 修复异常抛图问题

This commit is contained in:
masayume 2021-07-31 19:12:44 +08:00
parent df8bb0c795
commit 957c1925e6
4 changed files with 42 additions and 24 deletions

View File

@ -87,6 +87,8 @@ typedef enum tagUsbSupported {
V4L2_IMAGE_EMPTY = 80, V4L2_IMAGE_EMPTY = 80,
//处于休眠中 //处于休眠中
SLEEPING = 81, SLEEPING = 81,
//检测到有折角
HAVE_DOGEAR = 82,
//USB 未连接 //USB 未连接
USB_DISCONNECTED = 200, USB_DISCONNECTED = 200,
//用户点击停止 //用户点击停止
@ -119,6 +121,7 @@ static map<UsbSupported, string> msgs = {
{UsbSupported::V4L2_AQULRE_ERROR,"扫描仪取图失败!"}, {UsbSupported::V4L2_AQULRE_ERROR,"扫描仪取图失败!"},
{UsbSupported::V4L2_IMAGE_EMPTY,"扫描仪图像处理异常!"}, {UsbSupported::V4L2_IMAGE_EMPTY,"扫描仪图像处理异常!"},
{UsbSupported::SLEEPING,"设备处于休眠模式,请唤醒休眠后再扫描!"}, {UsbSupported::SLEEPING,"设备处于休眠模式,请唤醒休眠后再扫描!"},
{UsbSupported::HAVE_DOGEAR,"检测到有折角,停止扫描!"},
}; };
enum tagEventIndex enum tagEventIndex

View File

@ -315,13 +315,13 @@ void GScanO1003399::Scanner_StartScan(UINT16 count)
keeplastimg = true; keeplastimg = true;
reset(); reset();
devState = DEV_ISRUNNING; devState = DEV_ISRUNNING;
if (scanner_read_reg(m_usb, SR_GET_SLEEP_STAUTUS) != 1) //if (scanner_read_reg(m_usb, SR_GET_SLEEP_STAUTUS) != 1)
{ //{
devState = DEV_WRONG; // devState = DEV_WRONG;
Set_ErrorCode(SLEEPING); // Set_ErrorCode(SLEEPING);
scanflag = false; // scanflag = false;
return; // return;
} //}
if (scan_mode()) if (scan_mode())
{ {
devState = DEV_WRONG; devState = DEV_WRONG;
@ -434,6 +434,7 @@ void GScanO1003399::usb_run()
break; break;
case V4L2: case V4L2:
FileTools::writelog(log_ERROR, "Got V4L2 Error code = " + to_string(info.Code)); FileTools::writelog(log_ERROR, "Got V4L2 Error code = " + to_string(info.Code));
stop();
break; break;
case STOPSCAN: case STOPSCAN:
FileTools::writelog(log_INFO, "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)); FileTools::writelog(log_ERROR, "Got Unkown error code ! From =" + to_string(info.From) + " Code = " + to_string(info.Code));
break; break;
} }
if ((codeconvter(info) != 0)) if (codeconvter(info) > 0)
{ {
if (info.Code == 0x10 || info.Code == 0x20 || info.Code == 0x40) Set_ErrorCode(codeconvter(info));
{
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();
} }
if ((codeconvter(info) == -1))
{
if ((get_ErrorCode() != PAPER_JAM) && (get_ErrorCode() != DETECT_DOUBLE_FEED) && (get_ErrorCode() != DETECT_STAPLE)) if ((get_ErrorCode() != PAPER_JAM) && (get_ErrorCode() != DETECT_DOUBLE_FEED) && (get_ErrorCode() != DETECT_STAPLE))
{ {
keeplastimg = false; keeplastimg = false;
im_rx(); 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; scanflag = false;
if ((devState != DEV_WRONG) && (codeconvter(info) < 0)) if ((devState != DEV_WRONG) && (get_ErrorCode()<=0))
devState = DEV_STOP; devState = DEV_STOP;
else if ((devState != DEV_WRONG) && (codeconvter(info) > 0)) else if ((devState != DEV_WRONG) && (get_ErrorCode() > 0))
devState = DEV_WRONG; devState = DEV_WRONG;
} }
if (codeconvter(info) > 0)
{
Set_ErrorCode(codeconvter(info));
}
this_thread::sleep_for(chrono::microseconds(10)); 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 readed = 0;
int reading = 0; int reading = 0;
const int buffer_size = 2 * 1024 * 1024; const int buffer_size = 512 * 1024;
StopWatch sw; StopWatch sw;
FileTools::writelog(log_INFO, "read_data timeout =" + to_string(timeout)); FileTools::writelog(log_INFO, "read_data timeout =" + to_string(timeout));
while (readed < length) { while (readed < length) {
@ -605,6 +608,7 @@ int GScanO1003399::read_data(void* data, int length, int timeout)
else 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; return readed;
@ -771,6 +775,16 @@ int GScanO1003399::codeconvter(HGEIntInfo code)
break; break;
} }
} }
if (code.From == HGType::IMG)
{
switch (code.Code)
{
case 0:
return HAVE_DOGEAR;
default:
break;
}
}
if (code.From == HGType::STOPSCAN) if (code.From == HGType::STOPSCAN)
return -1; return -1;
return 0; return 0;

View File

@ -178,6 +178,7 @@ enum Scanner_Reg_Defs
SR_SET_SLEEPTIME, SR_SET_SLEEPTIME,
SR_GET_SLEEPTIME, SR_GET_SLEEPTIME,
SR_GET_SLEEP_STAUTUS, SR_GET_SLEEP_STAUTUS,
SR_GET_IMAGEPROCESSDONE,
SR_GET_CUO_ERROR = 0x50, SR_GET_CUO_ERROR = 0x50,
SR_GET_DOU_ERROR, SR_GET_DOU_ERROR,
SR_GET_JAM_ERROR, SR_GET_JAM_ERROR,

Binary file not shown.