调整scanimg 在29版本不能使用的问题

This commit is contained in:
modehua 2022-12-14 14:18:17 +08:00
parent 9bcea02769
commit 234937a14f
4 changed files with 39 additions and 3 deletions

View File

@ -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();

View File

@ -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";
}

View File

@ -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");

View File

@ -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);