From e3e218f086c0b43cbe3b8df87d05521f3462f0f0 Mon Sep 17 00:00:00 2001 From: gb <741021719@qq.com> Date: Sat, 9 Mar 2024 17:47:57 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=89=AB=E6=8F=8F=E6=B5=81?= =?UTF-8?q?=E7=A8=8B=EF=BC=9B=E5=A4=9A=E6=B5=81=E8=BE=93=E5=87=BA=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E4=BD=BF=E8=83=BD=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hardware/hardware.cpp | 29 ++++++++++++++++++++++------- hardware/motor/motorboard.cpp | 4 ++-- imgproc/algs/multi_out.cpp | 2 +- 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/hardware/hardware.cpp b/hardware/hardware.cpp index 36e539d..474a4b1 100644 --- a/hardware/hardware.cpp +++ b/hardware/hardware.cpp @@ -531,6 +531,7 @@ int scanner_hw::scan_one_turn(LPPACKIMAGE img, safe_fifo* cism, int* cism_c DBG_PRINT("\n\t%d: to rebuild spend %ums.\n", ++oper_index, chronograph::from_process_born() - bgn); mem->release(); mem = nullptr; + retrieve_v4l2_mem(cism, cism_cnt); } #endif int fatal = 0; @@ -564,11 +565,7 @@ int scanner_hw::scan_one_turn(LPPACKIMAGE img, safe_fifo* cism, int* cism_c pass = watch.elapse_ms(); img->pos.paper_ind++; - if(count_mode_) - { - devui::send_message(devui::UI_STATUS_PAPER_CNT, (uint8_t*)&pass, sizeof(pass)); - } - else + if(!count_mode_) { img->height = get_image_real_height(minh); DBG_PRINT("\t%d: to get_image_real_height spend %ums.\n", ++oper_index, chronograph::from_process_born() - bgn); @@ -607,6 +604,7 @@ int scanner_hw::scan_one_turn(LPPACKIMAGE img, safe_fifo* cism, int* cism_c break; } +#ifndef REBUILD_IN_CIS_THREAD // retrieve V4L2 memory ... retrieve_v4l2_mem(cism, cism_cnt); DBG_PRINT("\t%d: to retrieve_v4l2_mem spend %ums.\n", ++oper_index, chronograph::from_process_born() - bgn); @@ -617,6 +615,11 @@ int scanner_hw::scan_one_turn(LPPACKIMAGE img, safe_fifo* cism, int* cism_c utils::to_log(LOG_LEVEL_FATAL, "Scanning stopped for that V4L2 is out of memory!\n"); break; } +#endif + } + else + { + devui::send_message(devui::UI_STATUS_PAPER_CNT, (uint8_t*)&pass, sizeof(pass)); } if(ret || fatal == MOTOR_BORD_EVENT_SCAN_DONE) @@ -666,10 +669,20 @@ int scanner_hw::get_image_real_height(int minh) while(h < minh && watch.elapse_ms() < 500) { - std::this_thread::sleep_for(std::chrono::milliseconds(3)); + std::this_thread::sleep_for(std::chrono::milliseconds(1)); img_controller_->read(14, h); } - h = img_controller_->get_real_height(); + if(h >= minh) + { + unsigned int v8 = 0; + + img_controller_->read(8, v8); + img_controller_->write(8, v8 & ~8); + std::this_thread::sleep_for(std::chrono::milliseconds(5)); + img_controller_->read(8, v8); + img_controller_->write(8, v8 | 8); + } + // h = img_controller_->get_real_height(); return h; } @@ -678,6 +691,7 @@ void scanner_hw::retrieve_v4l2_mem(safe_fifo* mem, int* used) int u = *used, ind = 0; +#ifndef REBUILD_IN_CIS_THREAD while(u >= camera_->get_mem_count() - 2) { if(mem->size()) @@ -693,6 +707,7 @@ void scanner_hw::retrieve_v4l2_mem(safe_fifo* mem, int* used) break; std::this_thread::sleep_for(std::chrono::milliseconds(3)); } +#endif while(mem->take(ind, false)) { u--; diff --git a/hardware/motor/motorboard.cpp b/hardware/motor/motorboard.cpp index 2d6d384..09c6743 100644 --- a/hardware/motor/motorboard.cpp +++ b/hardware/motor/motorboard.cpp @@ -993,8 +993,8 @@ bool MotorBoard::wait_event(int event, int *evdata, int to_ms, int* fatal_ev, in } } - printf("\twait event %d = %s: evdata = %d, fatal_ev = %d\n", event, waited ? "true" : "false" - , *evdata, *fatal_ev); + // printf("\twait event %d = %s: evdata = %d, fatal_ev = %d\n", event, waited ? "true" : "false" + // , *evdata, *fatal_ev); return waited; } \ No newline at end of file diff --git a/imgproc/algs/multi_out.cpp b/imgproc/algs/multi_out.cpp index 2820e18..3f82eb9 100644 --- a/imgproc/algs/multi_out.cpp +++ b/imgproc/algs/multi_out.cpp @@ -80,7 +80,7 @@ int multi_out::set_value(const char* name/*nullptr for all options*/, void* val/ if(strcmp(name, SANE_OPT_NAME(IS_MULTI_OUT)) == 0) { - multi_ = *(bool*)val; + enabled_ = multi_ = *(bool*)val; refresh_final_mode(); } else if(strcmp(name, SANE_OPT_NAME(MULTI_OUT_TYPE)) == 0)