diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index 062c6f2..b8ec5d0 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -801,7 +801,7 @@ int hg_scanner_239::discard_all_images(void) str.resize(block); { char buf[64]; - int size = sizeof(buf); + int size = sizeof(buf), to = io_->set_timeout(50); ret = SCANNER_ERR_OK; setting3399::HGEIntInfo* info = (setting3399::HGEIntInfo*)buf; { @@ -826,8 +826,9 @@ int hg_scanner_239::discard_all_images(void) 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) utils::to_log(LOG_LEVEL_DEBUG, "prev-connection has left %d interrupt packet(s) && %d image(s).\n", pre_int, pre_img); diff --git a/hgsane/sane_hg_mdw.cpp b/hgsane/sane_hg_mdw.cpp index b8477a5..9ae166a 100644 --- a/hgsane/sane_hg_mdw.cpp +++ b/hgsane/sane_hg_mdw.cpp @@ -504,7 +504,7 @@ SANE_Status hg_sane_middleware::get_current_value(LPDEVINST inst, const void* op std::string val(""); 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()); if (desc) @@ -512,7 +512,7 @@ SANE_Status hg_sane_middleware::get_current_value(LPDEVINST inst, const void* op else return SANE_STATUS_INVAL; } - else if (!desc) + else*/ if (!desc) { 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; 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()); if (desc) @@ -541,7 +541,7 @@ SANE_Status hg_sane_middleware::set_value(LPDEVINST inst, const void* opt, void* else return SANE_STATUS_INVAL; } - else if (!desc) + else*/ if (!desc) { 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; - if (!inst->opts->get_opt_descriptor(opt, &fix_id) && inst != offline_) - { - offline_->opts->get_opt_descriptor(opt, &fix_id, inst->opts->get_option_count()); - } + 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()); + //} *(SANE_Int*)value = fix_id; 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(); ret = dev->opts->get_opt_descriptor(option); } - - if (!ret) + else + //if (!ret) ret = offline_->opts->get_opt_descriptor(option, nullptr, base_ind); return ret; @@ -784,7 +785,7 @@ SANE_Status hg_sane_middleware::control_option(SANE_Handle h, const void* 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; } 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) { struct _fix_id_cb* fcb = (struct _fix_id_cb*)value; - if (!inst->opts->enum_invisible_fix_ids(fcb) && inst != offline_) - offline_->opts->enum_invisible_fix_ids(fcb); + inst->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; } diff --git a/twain/ds/scanner.cpp b/twain/ds/scanner.cpp index 97b226a..e7cb8f6 100644 --- a/twain/ds/scanner.cpp +++ b/twain/ds/scanner.cpp @@ -939,36 +939,17 @@ COM_API_IMPLEMENT(scanner, int, get_scanned_images(DWORD milliseconds)) is_ui_wait_img_ = true; while (is_scanning_ && count == 0 && milliseconds) { - // MSG msg = { 0 }; - // if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) - // { - // TranslateMessage(&msg); - // DispatchMessageW(&msg); - // } - // else + MSG msg = { 0 }; + if (PeekMessage(&msg, nullptr, 0, 0, PM_REMOVE)) + { + TranslateMessage(&msg); + DispatchMessageW(&msg); + } + else Sleep(elapse); 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 <= elapse)