From 234937a14f3602f8234c1822aa90fb105f42171b Mon Sep 17 00:00:00 2001 From: modehua Date: Wed, 14 Dec 2022 14:18:17 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4scanimg=20=E5=9C=A829?= =?UTF-8?q?=E7=89=88=E6=9C=AC=E4=B8=8D=E8=83=BD=E4=BD=BF=E7=94=A8=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/hg_scanner_239.cpp | 2 ++ hgdriver/hgdev/scanner_manager.cpp | 16 ++++++++++++++-- hgdriver/wrapper/hg_log.cpp | 23 ++++++++++++++++++++++- hgdriver/wrapper/hg_log.h | 1 + 4 files changed, 39 insertions(+), 3 deletions(-) diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index 1c338fc..136a391 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -163,6 +163,8 @@ hg_scanner_239::hg_scanner_239(const char* dev_name, int pid,usb_io* io) : hg_sc //if (init_settings(0x239)) //init_settings((jsontext1 + jsontext2).c_str()); //writedown_device_configuration(); // initialize the hardware settings + std::string str = hg_log::get_scanimage_ver(); + printf("str:%s\r\n",str.c_str()); init_version(); hg_version_init_handle(); wait_devsislock_.notify(); diff --git a/hgdriver/hgdev/scanner_manager.cpp b/hgdriver/hgdev/scanner_manager.cpp index d24d376..da1722b 100644 --- a/hgdriver/hgdev/scanner_manager.cpp +++ b/hgdriver/hgdev/scanner_manager.cpp @@ -153,12 +153,24 @@ void hg_scanner_mgr::set_exe_name(const char* path, const char* name) { hg_scanner_mgr::pe_path_ = path ? path : ""; hg_scanner_mgr::pe_name_ = name ? name : ""; + std::string str = hg_log::get_scanimage_ver(); + bool is_scanimg =false; + if(str >= "1.0.29" ) + is_scanimg =true; + else + is_scanimg =false; + VLOG_MINI_2(LOG_LEVEL_ALL, "imgascan ver is: %s is_scanimg is:%d\n", str.c_str(),is_scanimg); if (name && *name) { - int ret = system("scanimage -V"); + // int ret = system("scanimage -V"); std::string eof(hg_log::ini_get("read_eof", name)); if (eof.empty()) - hg_scanner_mgr::read_over_with_eof_ = STRICMP(name, "simple-scan") != 0 && STRICMP(name, "scanimage") != 0 ; + { + if(is_scanimg) + hg_scanner_mgr::read_over_with_eof_ = STRICMP(name, "simple-scan") != 0; + else + hg_scanner_mgr::read_over_with_eof_ = STRICMP(name, "simple-scan") != 0 && (!is_scanimg? (STRICMP(name, "scanimage") != 0) : 1); + } else hg_scanner_mgr::read_over_with_eof_ = eof != "0"; } diff --git a/hgdriver/wrapper/hg_log.cpp b/hgdriver/wrapper/hg_log.cpp index d48ffef..d367027 100644 --- a/hgdriver/wrapper/hg_log.cpp +++ b/hgdriver/wrapper/hg_log.cpp @@ -99,6 +99,7 @@ class log_cls } } + protected: log_cls() : path_file_(""), file_(0), log_(&log_cls::log_consonle), level_(LOG_LEVEL_ALL), lcb_(NULL) {} @@ -341,8 +342,28 @@ extern "C" return ret; } -#endif +#endif + std::string get_scanimage_ver() + { + #if defined(WIN32) || defined(_WIN64) + return ""; + #else + FILE* fp = NULL; + char buf[128] = { 0 }; + fp = popen("scanimage -V", "r"); + if (!fp) + return ""; + + int ret = fread(buf, 1, sizeof(buf) - 1, fp); + if(ret<1) + return ""; + + pclose(fp); + std::string str = buf; + return str.substr(str.size()-7); + #endif + } //static std::string get_scanimage_ver() //{ // FILE* fp = popen("scanimage -V","r"); diff --git a/hgdriver/wrapper/hg_log.h b/hgdriver/wrapper/hg_log.h index 5f9ca38..132f371 100644 --- a/hgdriver/wrapper/hg_log.h +++ b/hgdriver/wrapper/hg_log.h @@ -55,6 +55,7 @@ extern "C" std::string local_data_path(void); std::string temporary_path(void); std::string log_file_path(void); + std::string get_scanimage_ver(); float GetMemoryUsage(int pid); float GetAppMemoryUsage(); unsigned int get_page_size(unsigned int* map_unit = nullptr);