diff --git a/hardware/hardware.cpp b/hardware/hardware.cpp index 8c5a0b2..ebc3d2b 100644 --- a/hardware/hardware.cpp +++ b/hardware/hardware.cpp @@ -390,9 +390,14 @@ void scanner_hw::thread_image_capture(bool paper_ready) err = start_and_wait_lifter(to_lifter_, &over_msg_id); if(err) break; - + + uint64_t bgn = chronograph::from_process_born(); + uint32_t cnt0 = img.pos.paper_ind; motor_->pick_paper(); err = scan_one_turn(&img, &avail_mem, &used_v4l2_mem, &over_msg_id, &over); + bgn = chronograph::from_process_born() - bgn; + cnt0 = img.pos.paper_ind - cnt0; + utils::to_log(LOG_LEVEL_DEBUG, "Scanned %d papers in %dms.\n", cnt0, (int)bgn); if((over && !auto_scan_) || err || !auto_scan_ || !scanning_) break; { @@ -493,7 +498,7 @@ int scanner_hw::start_and_wait_lifter(int to_ms, int* ui_words_id) } int scanner_hw::scan_one_turn(LPPACKIMAGE img, safe_fifo* cism, int* cism_cnt, int* ui_words, bool* mbstopped) { - int ret = SCANNER_ERR_OK, minh = 210 * dpi_ / 25.4, + int ret = SCANNER_ERR_OK, minh = 210 * dpi_y_ / 25.4, words = 0; uint32_t pass = 0; chronograph watch; @@ -565,15 +570,15 @@ int scanner_hw::scan_one_turn(LPPACKIMAGE img, safe_fifo* cism, int* cism_c words = ID_WORDS_STATUS_CAPTURE_FAILED; break; } + cism_cnt[0]++; devui::send_message(devui::UI_STATUS_PAPER_CNT, (uint8_t*)&pass, sizeof(pass)); img->prc_time = watch.elapse_ms(); mem = new dyn_mem_shared(frame, size, put_v4l2_mem); mem->set_param(cism, 0); mem->set_param((void*)(long)ind, 1); - cism_cnt[0]++; img->pos.status = hg_err_2_image_status(ret); - img_handler_(mem, true, img); + img_handler_(mem, true, img); // (frame, ind, LPPACKIMAGE, cism, ret, pass, bool) mem->release(); if(!scan_cntless_ && img->pos.paper_ind == scan_count_) @@ -621,7 +626,7 @@ int scanner_hw::get_image_real_height(int minh) while(h < minh && watch.elapse_ms() < 500) { - std::this_thread::sleep_for(std::chrono::milliseconds(10)); + std::this_thread::sleep_for(std::chrono::milliseconds(3)); img_controller_->read(14, h); } h = img_controller_->get_real_height(); @@ -898,7 +903,11 @@ int scanner_hw::open(std::function image_handler, CHK_RES_F motor_->set_staple_inpect(staple_chk_); motor_->set_screw_inpect(screw_chk_); motor_->set_screw_level(screw_chk_level_); - motor_->set_speed_mode(motor_speed_); + motor_->set_slowmoire(false); + if(1 || count_mode_) + motor_->set_speed_mode(SPEED_PPM_BASE_20); + else + motor_->set_speed_mode(motor_speed_); motor_->set_auto_paper(auto_scan_, true); unsigned int val = 0; diff --git a/imgproc/imgprc_mgr.cpp b/imgproc/imgprc_mgr.cpp index 45375e0..768c75f 100644 --- a/imgproc/imgprc_mgr.cpp +++ b/imgproc/imgprc_mgr.cpp @@ -263,8 +263,25 @@ void imgproc_mgr::send_image(LPPACKIMAGE head, cv::Mat& mat, void* info, size_t } void imgproc_mgr::send_image(std::vector& imgs, bool last) { + // if(last && imgs.size()) + // { + // bool first = true; + // while(imgs[0].info.pos.paper_ind != sent_ind_) + // { + // if(first) + // { + // first = false; + // utils::to_log(LOG_LEVEL_DEBUG, "Wait paper %d sent before sending paper %d ...\n", sent_ind_, imgs[0].info.pos.paper_ind); + // } + // std::this_thread::sleep_for(std::chrono::milliseconds(3)); + // } + // } + for(auto& v: imgs) send_image(&v.info, v.img, v.ext_info.empty() ? nullptr : &v.ext_info[0], v.ext_info.length(), last); + + if(last) + sent_ind_++; } int imgproc_mgr::set_value(const char* name, void* val) @@ -366,6 +383,6 @@ bool imgproc_mgr::is_busy(void) void imgproc_mgr::start_new_turn(uint32_t scanid, uint32_t sessionid) { scan_id_ = scanid; - sent_ind_ = 0; + sent_ind_ = 1; session_id_ = sessionid; } diff --git a/imgproc/imgprc_mgr.h b/imgproc/imgprc_mgr.h index 3cff085..e6f1e4f 100644 --- a/imgproc/imgprc_mgr.h +++ b/imgproc/imgprc_mgr.h @@ -33,9 +33,9 @@ class imgproc_mgr : public sane_opt_provider image_processor* stretcher_ = nullptr; bool do_rebuild_ = true; volatile bool run_ = true; + volatile uint32_t sent_ind_ = 1; bool dump_img_ = false; uint32_t scan_id_ = 0; - uint32_t sent_ind_ = 0; uint32_t session_id_ = 0; MUTEX working_cnt_lock_; uint32_t working_cnt_ = 0; diff --git a/sdk/base/data.h b/sdk/base/data.h index d25a6c4..db6fd79 100644 --- a/sdk/base/data.h +++ b/sdk/base/data.h @@ -376,6 +376,7 @@ public: uint32_t take_pos(void); }; + // callback proto // // parameters: usb_functionfs_event* - the function event ptr diff --git a/sdk/base/utils.h b/sdk/base/utils.h index a39ce64..bc9bc3f 100644 --- a/sdk/base/utils.h +++ b/sdk/base/utils.h @@ -317,8 +317,8 @@ public: static bool now(TIMEV* tv); static bool now(uint64_t* seconds, uint64_t* u_seconds); static std::string now(bool with_ms = true/*whether with milliseconds*/); // return '2022-11-30 10:38:42.123', no '.123' if with_ms was false - static uint64_t from_process_born(void); - + static uint64_t from_process_born(void); // return the time in milliseconds that has passed since the process started + public: uint64_t elapse_s(void); uint64_t elapse_ms(void); diff --git a/xmake.lua b/xmake.lua index 4ace7ee..30abab0 100644 --- a/xmake.lua +++ b/xmake.lua @@ -60,8 +60,8 @@ add_packagedirs("sdk") add_defines("BUILD_AS_DEVICE") add_defines("VER_MAIN=2") add_defines("VER_FAMILY=200") -add_defines("VER_DATE=20240228") -add_defines("VER_BUILD=2") +add_defines("VER_DATE=20240301") +add_defines("VER_BUILD=20") target("conf") set_kind("phony")