调整部分日志;修复WIN平台枚举模块BUG

This commit is contained in:
gb 2022-06-01 16:11:51 +08:00
parent 7b2a89f3a1
commit eb83eec0d5
6 changed files with 31 additions and 24 deletions

View File

@ -250,7 +250,7 @@ char* shared_memory::get_buf(void)
#else #else
int* h = (int*)&obj_; int* h = (int*)&obj_;
char* buf = (char*)shmat(*h, 0, 0); char* buf = (char*)shmat(*h, 0, 0);
VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "shared memory %d tiny_buffer = %s, error = %d\n", *h, hg_log::format_ptr(buf).c_str(), errno); VLOG_MINI_3(LOG_LEVEL_DEBUG_INFO, "shared memory %d buffer = %s, error = %d\n", *h, hg_log::format_ptr(buf).c_str(), errno);
#endif #endif
return buf; return buf;

View File

@ -604,11 +604,11 @@ void hg_scanner_200::image_process(std::shared_ptr<tiny_buffer>& buffer)
param.double_side = img_conf_.is_duplex; param.double_side = img_conf_.is_duplex;
param.dpi = img_conf_.resolution_dst; param.dpi = img_conf_.resolution_dst;
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white); //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.black_white :%d\r\n",param.black_white);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels); //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.channels :%d\r\n",param.channels);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode); //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.color_mode :%d\r\n",param.color_mode);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side); //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.double_side :%d\r\n",param.double_side);
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.dpi :%d\r\n",param.dpi); //VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO,"param.dpi :%d\r\n",param.dpi);
handle = hg_imgproc::init(&img_conf_,&param,pid_); handle = hg_imgproc::init(&img_conf_,&param,pid_);

View File

@ -890,13 +890,19 @@ int usb_io::read_bulk(void* buf, int* len)
int total = 0, int total = 0,
err = libusb_bulk_transfer(handle_, endpoints_.bulk.in.port, (unsigned char*)buf, *len, &total, to_); err = libusb_bulk_transfer(handle_, endpoints_.bulk.in.port, (unsigned char*)buf, *len, &total, to_);
*len = total;
last_err_ = usb_manager::usb_error_2_hg_err(err);
if (err) if (err)
{ {
VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "libusb_bulk_transfer(%x, %d/%d) = %s\n", endpoints_.bulk.in.port, *len, total, libusb_error_name(err)); VLOG_MINI_4(LOG_LEVEL_DEBUG_INFO, "read_bulk(%x, %d/%d) = %s\n", endpoints_.bulk.in.port, total, *len, libusb_error_name(err));
if (err == LIBUSB_ERROR_TIMEOUT && *len == total)
{
int old = to_;
to_ *= 1.5f;
err = LIBUSB_SUCCESS;
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, " Read full length, we consider it as success, and increament timeout from %d to %d\n", old, to_);
}
} }
*len = total;
last_err_ = usb_manager::usb_error_2_hg_err(err);
return last_err_; return last_err_;
} }

View File

@ -167,11 +167,7 @@ extern "C"
static bool on_found(const char* file, void* param) static bool on_found(const char* file, void* param)
{ {
LPFF lpff = (LPFF)param; LPFF lpff = (LPFF)param;
#ifdef WIN32 char pth = PATH_SEPARATOR[0];
char pth = '\\';
#else
char pth = '/';
#endif
const char* name = strrchr(file, pth); const char* name = strrchr(file, pth);
if (name++ == nullptr) if (name++ == nullptr)
@ -217,13 +213,17 @@ extern "C"
ret = GetLastError(); ret = GetLastError();
else else
{ {
do pei.dwSize = sizeof(pei);
if (Module32FirstW(h, &pei))
{ {
std::string ansi(u2a(pei.szExePath)); do
if (!found_file(ansi.c_str(), param)) {
break; std::string ansi(u2a(pei.szExePath));
} while (Module32NextW(h, &pei)); if (!found_file(ansi.c_str(), param))
break;
pei.dwSize = sizeof(pei);
} while (Module32NextW(h, &pei));
}
CloseHandle(h); CloseHandle(h);
} }

View File

@ -11,8 +11,10 @@
#ifdef WIN32 #ifdef WIN32
#define bzero(a, l) memset(a, 0, l) #define bzero(a, l) memset(a, 0, l)
#define PATH_SEPARATOR "\\" #define PATH_SEPARATOR "\\"
#define DLL_EXTESION ".dll"
#else #else
#define PATH_SEPARATOR "/" #define PATH_SEPARATOR "/"
#define DLL_EXTESION ".so"
#endif #endif
#ifdef OEM_HANWANG #ifdef OEM_HANWANG

View File

@ -34,9 +34,9 @@ extern "C"
{ {
std::string name(""), std::string name(""),
pe(hg_log::pe_path(&name)), pe(hg_log::pe_path(&name)),
path("\\"), path(PATH_SEPARATOR),
scanner(g_scanner_path), scanner(g_scanner_path),
sane(hg_log::get_module_full_path((g_sane_name + ".so").c_str())); sane(hg_log::get_module_full_path((g_sane_name + DLL_EXTESION).c_str()));
#ifdef WIN32 #ifdef WIN32
size_t pos = g_scanner_path.rfind('\\'); size_t pos = g_scanner_path.rfind('\\');
if (pos++ != std::string::npos) if (pos++ != std::string::npos)
@ -45,7 +45,6 @@ extern "C"
size_t pos = 0; size_t pos = 0;
g_scanner_path = hg_log::get_module_full_path((std::string(GET_BACKEND_NAME) + ".so").c_str()); g_scanner_path = hg_log::get_module_full_path((std::string(GET_BACKEND_NAME) + ".so").c_str());
scanner = g_scanner_path; scanner = g_scanner_path;
path = "/";
pos = g_scanner_path.rfind('/'); pos = g_scanner_path.rfind('/');
if (pos++ != std::string::npos) if (pos++ != std::string::npos)
g_scanner_path.erase(pos); g_scanner_path.erase(pos);