脱机属性已经在驱动中包含在打开的设备中,有设备句柄时,不再在SANE协议层单独添加;缩短清空上次端口数据的时间

This commit is contained in:
gb 2023-11-14 14:38:06 +08:00
parent 02abb23198
commit 1f65d4d014
3 changed files with 25 additions and 41 deletions

View File

@ -801,7 +801,7 @@ int hg_scanner_239::discard_all_images(void)
str.resize(block); str.resize(block);
{ {
char buf[64]; char buf[64];
int size = sizeof(buf); int size = sizeof(buf), to = io_->set_timeout(50);
ret = SCANNER_ERR_OK; ret = SCANNER_ERR_OK;
setting3399::HGEIntInfo* info = (setting3399::HGEIntInfo*)buf; setting3399::HGEIntInfo* info = (setting3399::HGEIntInfo*)buf;
{ {
@ -826,8 +826,9 @@ int hg_scanner_239::discard_all_images(void)
ret = io_->read_interrupt(buf, &size); ret = io_->read_interrupt(buf, &size);
} }
} }
io_->set_timeout(to);
} }
std::this_thread::sleep_for(std::chrono::milliseconds(1000)); std::this_thread::sleep_for(std::chrono::milliseconds(100));
if (pre_int) if (pre_int)
utils::to_log(LOG_LEVEL_DEBUG, "prev-connection has left %d interrupt packet(s) && %d image(s).\n", pre_int, pre_img); utils::to_log(LOG_LEVEL_DEBUG, "prev-connection has left %d interrupt packet(s) && %d image(s).\n", pre_int, pre_img);

View File

@ -504,7 +504,7 @@ SANE_Status hg_sane_middleware::get_current_value(LPDEVINST inst, const void* op
std::string val(""); std::string val("");
SANE_Option_Descriptor* desc = inst->opts->get_opt_descriptor(opt); SANE_Option_Descriptor* desc = inst->opts->get_opt_descriptor(opt);
if (!desc && inst != offline_) /*if (!desc && inst != offline_)
{ {
desc = offline_->opts->get_opt_descriptor(opt, nullptr, inst->opts->get_option_count()); desc = offline_->opts->get_opt_descriptor(opt, nullptr, inst->opts->get_option_count());
if (desc) if (desc)
@ -512,7 +512,7 @@ SANE_Status hg_sane_middleware::get_current_value(LPDEVINST inst, const void* op
else else
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
else if (!desc) else*/ if (!desc)
{ {
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
@ -533,7 +533,7 @@ SANE_Status hg_sane_middleware::set_value(LPDEVINST inst, const void* opt, void*
bool empty_value = false; bool empty_value = false;
SANE_Option_Descriptor* desc = inst->opts->get_opt_descriptor(opt); SANE_Option_Descriptor* desc = inst->opts->get_opt_descriptor(opt);
if (!desc && inst != offline_) /*if (!desc && inst != offline_)
{ {
desc = offline_->opts->get_opt_descriptor(opt, nullptr, inst->opts->get_option_count()); desc = offline_->opts->get_opt_descriptor(opt, nullptr, inst->opts->get_option_count());
if (desc) if (desc)
@ -541,7 +541,7 @@ SANE_Status hg_sane_middleware::set_value(LPDEVINST inst, const void* opt, void*
else else
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
else if (!desc) else*/ if (!desc)
{ {
return SANE_STATUS_INVAL; return SANE_STATUS_INVAL;
} }
@ -568,10 +568,11 @@ SANE_Status hg_sane_middleware::get_option_fixed_id(LPDEVINST inst, const void*
{ {
int fix_id = 0; int fix_id = 0;
if (!inst->opts->get_opt_descriptor(opt, &fix_id) && inst != offline_) inst->opts->get_opt_descriptor(opt, &fix_id);
{ //if (!inst->opts->get_opt_descriptor(opt, &fix_id) && inst != offline_)
offline_->opts->get_opt_descriptor(opt, &fix_id, inst->opts->get_option_count()); //{
} // offline_->opts->get_opt_descriptor(opt, &fix_id, inst->opts->get_option_count());
//}
*(SANE_Int*)value = fix_id; *(SANE_Int*)value = fix_id;
return fix_id <= 0 ? SANE_STATUS_INVAL : SANE_STATUS_GOOD; return fix_id <= 0 ? SANE_STATUS_INVAL : SANE_STATUS_GOOD;
@ -761,8 +762,8 @@ SANE_Option_Descriptor* hg_sane_middleware::get_option_descriptor(SANE_Handle h,
base_ind = dev->opts->get_option_count(); base_ind = dev->opts->get_option_count();
ret = dev->opts->get_opt_descriptor(option); ret = dev->opts->get_opt_descriptor(option);
} }
else
if (!ret) //if (!ret)
ret = offline_->opts->get_opt_descriptor(option, nullptr, base_ind); ret = offline_->opts->get_opt_descriptor(option, nullptr, base_ind);
return ret; return ret;
@ -784,7 +785,7 @@ SANE_Status hg_sane_middleware::control_option(SANE_Handle h, const void* option
{ {
if (!option) if (!option)
{ {
*(SANE_Int*)value = inst->opts->get_option_count() + offline_->opts->get_option_count(); *(SANE_Int*)value = inst->opts->get_option_count(); // +offline_->opts->get_option_count();
err = SANE_STATUS_GOOD; err = SANE_STATUS_GOOD;
} }
else else
@ -827,8 +828,9 @@ SANE_Status hg_sane_middleware::control_option(SANE_Handle h, const void* option
else if (action == SANE_ACTION_ENUM_INVISIBLE_FIX_ID) else if (action == SANE_ACTION_ENUM_INVISIBLE_FIX_ID)
{ {
struct _fix_id_cb* fcb = (struct _fix_id_cb*)value; struct _fix_id_cb* fcb = (struct _fix_id_cb*)value;
if (!inst->opts->enum_invisible_fix_ids(fcb) && inst != offline_) inst->opts->enum_invisible_fix_ids(fcb);
offline_->opts->enum_invisible_fix_ids(fcb); //if (!inst->opts->enum_invisible_fix_ids(fcb) && inst != offline_)
// offline_->opts->enum_invisible_fix_ids(fcb);
err = SANE_STATUS_GOOD; err = SANE_STATUS_GOOD;
} }

View File

@ -939,36 +939,17 @@ COM_API_IMPLEMENT(scanner, int, get_scanned_images(DWORD milliseconds))
is_ui_wait_img_ = true; is_ui_wait_img_ = true;
while (is_scanning_ && count == 0 && milliseconds) while (is_scanning_ && count == 0 && milliseconds)
{ {
// MSG msg = { 0 }; MSG msg = { 0 };
// if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE))
// { {
// TranslateMessage(&msg); TranslateMessage(&msg);
// DispatchMessageW(&msg); DispatchMessageW(&msg);
// } }
// else else
Sleep(elapse); Sleep(elapse);
count = images_.count(); count = images_.count();
//int ev = get_event();
//
//if (ev == SANE_EVENT_SCAN_FINISHED)
//{
// ui_hide();
// break;
//}
//else if (ev == SANE_EVENT_UI_CLOSE_CANCEL)
//{
// stop();
// ui_hide();
// break;
//}
//else if (ev == SANE_EVENT_UI_CLOSE_NORMAL)
//{
// ui_hide();
// break;
//}
if (milliseconds != -1) if (milliseconds != -1)
{ {
if (milliseconds <= elapse) if (milliseconds <= elapse)