调整第一次打开设备的时候,需要处理的事件(测试版,不一定可行)

This commit is contained in:
13038267101 2023-04-27 18:00:37 +08:00
parent 42f428483f
commit ee537730a0
3 changed files with 29 additions and 9 deletions

View File

@ -356,9 +356,13 @@ void hg_scanner::thread_read_int(void)
} }
void hg_scanner::thread_handle_usb(void) void hg_scanner::thread_handle_usb(void)
{ {
int cnt = 0;
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "[thread_handle_usb 'START' !!!]:[%d]\n", cnt);
while (run_) while (run_)
{ {
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "[thread_handle_usb 'WAIT' !!!]:[%d]\n", cnt);
wait_usb_.wait(); wait_usb_.wait();
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "[thread_handle_usb 'NOTIFY' !!!]:[%d]\n", cnt);
if (!run_) if (!run_)
break; break;
@ -367,7 +371,7 @@ void hg_scanner::thread_handle_usb(void)
std::this_thread::sleep_for(std::chrono::milliseconds(3000)); std::this_thread::sleep_for(std::chrono::milliseconds(3000));
if (scan_life_) if (scan_life_)
{ {
LOG_INFO(LOG_LEVEL_FATAL, "image process is still running!\n"); VLOG_MINI_1(LOG_LEVEL_FATAL, "[thread_handle_usb image process is still running!]:[%d]\n", cnt);
continue; continue;
} }
} }
@ -377,7 +381,11 @@ void hg_scanner::thread_handle_usb(void)
thread_handle_usb_read(); thread_handle_usb_read();
if (scan_life_->release() == 0) if (scan_life_->release() == 0)
scan_life_ = NULL; scan_life_ = NULL;
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "[thread_handle_usb_read 'GET IMAGE END'!!!]:[%d]\n", cnt);
cnt++;
} }
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "[thread_handle_usb EXIT !!!]:[%d]\n", cnt);
} }
void hg_scanner::thread_image_handle(void) void hg_scanner::thread_image_handle(void)
{ {

View File

@ -1323,10 +1323,14 @@ void hg_scanner_239::thread_handle_usb_read(void)
int hg_scanner_239::start(void) int hg_scanner_239::start(void)
{ {
if (is_read_int) StopWatch sw;
while (is_read_int)
{ {
VLOG_MINI_1(LOG_LEVEL_WARNING, "device status is(%s)\n", hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_BUSY)); if (sw.elapsed_s() > 10)
return SCANNER_ERR_DEVICE_DEVS_BOOTING; {
break;
}
VLOG_MINI_1(LOG_LEVEL_WARNING, "device status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING);
} }
bool handled = false; bool handled = false;
int ret = try_third_app_handle_start(handled), int ret = try_third_app_handle_start(handled),

View File

@ -127,7 +127,7 @@ void hg_scanner_300::thread_handle_usb_read(void)
status_ = ret = SCANNER_ERR_USER_CANCELED; status_ = ret = SCANNER_ERR_USER_CANCELED;
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s:%s\n", hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_USER_CANCEL_SCAN), hg_scanner_err_name(status_)); VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s:%s\n", hg_log::lang_load(ID_STATU_DESC_SCANNER_ERR_DEVICE_GET_USER_CANCEL_SCAN), hg_scanner_err_name(status_));
} }
VLOG_MINI_2(LOG_LEVEL_DEBUG_INFO, "%s:%s\n", "'STOPSCAN' message in usb thread\n" , hg_scanner_err_name(status_)); VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "'STOPSCAN' message in usb thread:%s\n" , hg_scanner_err_name(status_));
break; break;
} }
@ -269,7 +269,7 @@ int hg_scanner_300::discard_all_images(void)
std::lock_guard<std::mutex> lock(io_lock_); std::lock_guard<std::mutex> lock(io_lock_);
int ret = io_->read_bulk(&str[0], &block); int ret = io_->read_bulk(&str[0], &block);
} }
while (ret != SCANNER_ERR_TIMEOUT) while (ret == SCANNER_ERR_OK)
{ {
cnt++; cnt++;
{ {
@ -292,12 +292,20 @@ int hg_scanner_300::discard_all_images(void)
} }
int hg_scanner_300::start(void) int hg_scanner_300::start(void)
{ {
if (is_read_int) //if (is_read_int)
//{
// VLOG_MINI_1(LOG_LEVEL_WARNING, "device status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING);
// return SCANNER_ERR_DEVICE_DEVS_BOOTING;
//}
StopWatch sw;
while (is_read_int)
{ {
VLOG_MINI_1(LOG_LEVEL_WARNING, "device status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING); if (sw.elapsed_s() > 10)
return SCANNER_ERR_DEVICE_DEVS_BOOTING; {
break;
}
VLOG_MINI_1(LOG_LEVEL_WARNING, "device status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_DEVS_BOOTING);
} }
//discard_all_images(); //discard_all_images();
bool handled = false; bool handled = false;
int ret = try_third_app_handle_start(handled), int ret = try_third_app_handle_start(handled),