diff --git a/sane/scanner.cpp b/sane/scanner.cpp index 7b4ddda..e16fe95 100644 --- a/sane/scanner.cpp +++ b/sane/scanner.cpp @@ -1605,22 +1605,22 @@ int scanner::thread_start(void) scan_over_ = false; double_handle_ = DOUBLE_FEED_NEED_UI; + unsigned int l = sizeof(img_fmt_); + SANE_CompressionType cmprsn = img_fmt_.compress.compression; + if (hg_sane_middleware::instance()->io_control(handle_, IO_CTRL_CODE_GET_FINAL_IMAGE_FORMAT, &img_fmt_, &l)) + img_fmt_.img_format = SANE_IMAGE_TYPE_BMP; + img_fmt_.compress.compression = cmprsn; + int ret = hg_sane_middleware::instance()->start(handle_, NULL); // the third-APPs in linux will call 'stop' after every start, but it not happens in windows-apps, so we handle this as following ... - if (ret == SANE_STATUS_NO_DOCS && prev_start_result_ == SANE_STATUS_GOOD) - ret = hg_sane_middleware::instance()->start(handle_, NULL); + //if (ret == SANE_STATUS_NO_DOCS && prev_start_result_ == SANE_STATUS_GOOD) + // ret = hg_sane_middleware::instance()->start(handle_, NULL); - if (ret == SANE_STATUS_GOOD) + if (ret == SANE_STATUS_GOOD || ret == SCANNER_ERR_DEVICE_DOUBLE_FEEDING) { /*if (indicator_.get() && !IsWindowVisible(indicator_->hwnd())) indicator_->show(true);*/ - - unsigned int l = sizeof(img_fmt_); - SANE_CompressionType cmprsn = img_fmt_.compress.compression; - if (hg_sane_middleware::instance()->io_control(handle_, IO_CTRL_CODE_GET_FINAL_IMAGE_FORMAT, &img_fmt_, &l)) - img_fmt_.img_format = SANE_IMAGE_TYPE_BMP; - img_fmt_.compress.compression = cmprsn; } //else if (indicator_.get()) //{ @@ -3600,7 +3600,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) img_ind_ = 0; if (prog) prog->notify_working(); - else if (callback::show_progress_ui && is_bIndicator) + else if (callback::show_progress_ui && is_bIndicator && ui_notify) ui_notify(ev_code, data, *len); on_ui_event(ev_code, (void*)ev_code); log_info(L"Scanning ...\r\n", 1); @@ -3675,7 +3675,7 @@ int scanner::handle_device_event(int ev_code, void* data, unsigned int* len) { wchar_t msg[128] = { 0 }; - swprintf_s(msg, _countof(msg) - 1, L"New image(%u) received with %u bytes\r\n", img_ind_, simg->bytes); + swprintf_s(msg, _countof(msg) - 1, L"New image(%u) received with %u bytes (status: %d)\r\n", img_ind_, simg->bytes, simg->flag.statu); log_info(msg, 1); } } @@ -3839,11 +3839,16 @@ void close_log(void) } void log(const wchar_t* info) { + wchar_t clock[40] = { 0 }; + + hg_get_current_time_w(clock); if (g_file_) { std::lock_guard lock(g_lock_); + std::wstring text(clock); - fwrite(info, 2, lstrlenW(info), g_file_); + text += info; + fwrite(text.c_str(), 2, text.length(), g_file_); fflush(g_file_); if (ftell(g_file_) > 10 * 1024 * 1024) {