diff --git a/zynq_7010_code/CuoZhiMotor.cpp b/zynq_7010_code/CuoZhiMotor.cpp index 9f6b548..c0d6226 100644 --- a/zynq_7010_code/CuoZhiMotor.cpp +++ b/zynq_7010_code/CuoZhiMotor.cpp @@ -110,7 +110,7 @@ void CuoZhiMotor::speedRecover() void CuoZhiMotor::speedConfig() { - printf("CuoZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ", + LOG("CuoZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ", m_cuoparamex.speed, m_cuoparamex.dpi, m_cuoparamex.colormode, diff --git a/zynq_7010_code/HCamDevice.cpp b/zynq_7010_code/HCamDevice.cpp index feb3dfd..4bd35b6 100644 --- a/zynq_7010_code/HCamDevice.cpp +++ b/zynq_7010_code/HCamDevice.cpp @@ -309,8 +309,6 @@ void HCamDevice::HtCamSetPeriod(double reg_value) printf("reg_value:%f\r\n",reg_value); double pr = reg_value == 0 ? 0x183C/2 :reg_value * 0x183C / 1; - printf("\r\n"); - if (virBaseAddr == NULL) { return ; @@ -322,7 +320,7 @@ void HCamDevice::HtCamSetPeriod(double reg_value) rgb.NShort[0] = 0x183C; //周期参数默认0x183C 不可修改 rgb.NShort[1] = pr; //占空比 = 百分比 / 0x183C *1 - printf("占空比:%d\r\n",rgb.NShort[1]); + printf("PWM占空比:%d\r\n",rgb.NShort[1]); HtCamWriteFpgaRegs(0x09,rgb.value); } int HCamDevice::HtCamEventWorkThread(void) @@ -476,8 +474,6 @@ int HCamDevice::HtCamReadCaptureFrame(void **pbuf, int timeout) *pbuf = captureBufers[0].start; else *pbuf = captureBufers[lastSucceedBufferIndex + 1].start; - - printf("timeout !!! captureBufers[lastSucceedBufferIndex].length :%d\r\n",captureBufers[lastSucceedBufferIndex].length); return -1; } struct v4l2_buffer buf; @@ -608,7 +604,6 @@ int HCamDevice::HtCamStartSampling() // This function is prohibited int HCamDevice::HtCamStopSampling() { - printf("调用了 HtCamStopSampling\r\n"); uint32_t *CamReg; if (virBaseAddr == NULL) return -1; @@ -742,8 +737,6 @@ int HCamDevice::init_video_buffer() req.memory = v4l2memtype; - printf("I GET THE drivertype %d\n",drivertype); - if (ioctl(videofd, VIDIOC_REQBUFS, &req) < 0) { camera_err(" VIDIOC_REQBUFS failed\n"); diff --git a/zynq_7010_code/MultiFrameCapture.cpp b/zynq_7010_code/MultiFrameCapture.cpp index 7a5ec0c..f36dc61 100644 --- a/zynq_7010_code/MultiFrameCapture.cpp +++ b/zynq_7010_code/MultiFrameCapture.cpp @@ -38,7 +38,8 @@ MultiFrameCapture::MultiFrameCapture(ScannerGlue glue) : color_mode_(GRAY), is_correct_(0), is_double_paper_(0), - is_remove_morr_(0) + is_remove_morr_(0), + m_cv_snap_is_scaning(false) { video.reset(new HCamDevice); video->HtCamSetdivder(true); @@ -86,7 +87,6 @@ void MultiFrameCapture::open() { i = video->HtCamReadCaptureFrame((void **)&buf, 10); } - printf("open_device\r\n"); } void MultiFrameCapture::snap() @@ -111,7 +111,6 @@ void MultiFrameCapture::snap() void MultiFrameCapture::stopsnap(bool autosize) { - printf("stop stop stop\r\n"); if (autosize) { video->HtCamStopSampling(); @@ -121,7 +120,6 @@ void MultiFrameCapture::stopsnap(bool autosize) void MultiFrameCapture::close() { - printf("close close close\r\n"); if (video.get()) video->close_device(); } @@ -164,7 +162,6 @@ SIZE MultiFrameCapture::GetPaperSize(PaperSize paper, int dpi) SIZE resize{2480,3507}; resize.cx = paper_map_[paper].cx * dpi / 25.4; resize.cy = paper_map_[paper].cy * dpi / 25.4; - printf("resize.cx:%d resize.cy:%d\r\n",resize.cx,resize.cy); return resize; } return SIZE{2338, 3307}; @@ -172,7 +169,7 @@ SIZE MultiFrameCapture::GetPaperSize(PaperSize paper, int dpi) void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config) { m_config = config; - printf("config.params.pageSize:%d\r\n",config.params.pageSize); + if(config.params.slow_moire && config.params.dpi != 3) { config.params.dpi = 2; @@ -193,7 +190,6 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config) is_remove_morr_ = config.params.slow_moire; //width_ = paper_size_ == PaperSize::G400_MAXSIZE || paper_size_ ==PaperSize::G400_MAXAUTO && - printf("config.params.dc;%d\r\n",config.params.dc); video->HtCamSetPeriod(config.params.dc); @@ -390,7 +386,7 @@ void MultiFrameCapture::snaprun() int t = resolution_ == DPI_600 ? sw.elapsed_ms() + 600 : sw.elapsed_ms() + 20; time_out = t; uint32_t sendLine = video->HtCamReadFpgaRegs(0x000e);////0x000e 取出来的实际行数 - printf("--------------fpga send line ------------:%d HtCamReadCaptureFrame =%0.2f \r\n",sendLine,sw.elapsed_ms()); + printf("--------------fpga send line ------------:%d\r\n",sendLine); if (data) { @@ -425,12 +421,12 @@ void MultiFrameCapture::snaprun() info.width = frame_info.width; info.height = frame_info.height; - printf("获取数据 width:%d height:%d is_first:%d is_last:%d DataLength:%d\r\n",frame_info.width,frame_info.height,info.first_frame,info.last_frame,info.DataLength); + //printf("获取数据 width:%d height:%d is_first:%d is_last:%d DataLength:%d\r\n",frame_info.width,frame_info.height,info.first_frame,info.last_frame,info.DataLength); m_glue.m_imageready(info); //m_frameinfos.Put(frame_info); - printf("采集图像耗时:%f\r\n",sw.elapsed_ms()); + //printf("采集图像耗时:%f\r\n",sw.elapsed_ms()); } return ret; }; @@ -439,8 +435,9 @@ void MultiFrameCapture::snaprun() while (b_snap_run) { std::unique_lock lock(m_mtx_snap); + m_cv_snap_is_scaning = false; m_cv_snap.wait(lock); - + m_cv_snap_is_scaning = true; V4L2_DATAINFO_Ex frame_info; frame_info.pixtype = color_mode_; frame_info.dpi = resolution_; @@ -454,7 +451,7 @@ void MultiFrameCapture::snaprun() int channels = color_mode_ == 1 ? 3 : 1; int color_mode = video->HtCamGetColorMode(); int func_sig = 0; - int time_out = resolution_ == DPI_600 ? 2000 : 600; ///这个时间是根据每帧的数据量来进行调测的 + int time_out = resolution_ == DPI_600 ? 2000 : 900; ///这个时间是根据每帧的数据量来进行调测的 if (is_remove_morr_) { diff --git a/zynq_7010_code/MultiFrameCapture.h b/zynq_7010_code/MultiFrameCapture.h index bb8741f..1bfd915 100644 --- a/zynq_7010_code/MultiFrameCapture.h +++ b/zynq_7010_code/MultiFrameCapture.h @@ -49,6 +49,7 @@ private: std::mutex m_mtx_snap; std::mutex m_mtx_snapdone; std::condition_variable m_cv_snap; + bool m_cv_snap_is_scaning; std::condition_variable m_cv_snapdone; std::shared_ptr m_snap_thread; std::shared_ptr m_imgproc_thread; diff --git a/zynq_7010_code/Scanner.cpp b/zynq_7010_code/Scanner.cpp index bbd9131..ca579ce 100644 --- a/zynq_7010_code/Scanner.cpp +++ b/zynq_7010_code/Scanner.cpp @@ -209,8 +209,10 @@ void Scanner::runScan() StopWatch sw; StopWatch sw1; StopWatch sw2; + isScaning = true; while (m_DstScannum > 0) { + isScaning = true; sw1.reset(); m_isDoublePaper = false; m_jamPaper = false; @@ -222,12 +224,14 @@ void Scanner::runScan() put(S_EVT_STOP_SCAN); LOG("STOP STOP STOP RUNSCAN \n"); } + isScaning = false; break; } sensor->enableDoubleSensor(m_config.params.doubleFeeded); if (m_DstScannum == 0) //被取消扫描了 { + isScaning = false; break; } @@ -236,6 +240,7 @@ void Scanner::runScan() { put(S_EVT_STOP_SCAN); isRested = false; + isScaning = false; break; } isRested = false; @@ -248,6 +253,7 @@ void Scanner::runScan() put(S_EVT_JAM_IN); m_scaninfo.JamInNum++; } + isScaning = false; break; } printf("检测到纸张的时间:%f\r\n",sw.elapsed_ms());//检测到纸张 @@ -278,6 +284,7 @@ void Scanner::runScan() if (!sensor->isPaperIn()) { LOG("paper 假卡纸了。。。。。\n"); + isScaning = false; break; } } @@ -301,6 +308,7 @@ void Scanner::runScan() capturer->stopsnap(b_autosize); capturer->waitsnapdone(1);//等待采集完成 this_thread::sleep_for(std::chrono::milliseconds(500));//200 80ms 600 260ms + isScaning = false; break; } //LOG("\nclose double sensor %s\n",GetCurrentTimeStamp(2).c_str()); @@ -340,6 +348,7 @@ void Scanner::runScan() capturer->waitsnapdone(1);//等待采集完成 capturer->stopsnap(b_autosize); + isScaning = false; break; } } @@ -355,6 +364,7 @@ void Scanner::runScan() this_thread::sleep_for(std::chrono::milliseconds(200)); put(S_EVT_STOP_SCAN); + isScaning = false; break; } sw.reset(); @@ -367,6 +377,7 @@ void Scanner::runScan() else { put(S_EVT_STOP_SCAN); + isScaning = false; break; } } @@ -375,7 +386,7 @@ void Scanner::runScan() if( m_config.params.dpi == 3) this_thread::sleep_for(std::chrono::milliseconds(3000)); } - + isScaning = false; m_DstScannum = 0; sensor->enableDoubleSensor(false); sensor->resetPaperPin(); diff --git a/zynq_7010_code/Scanner.h b/zynq_7010_code/Scanner.h index 217630d..a433c5c 100644 --- a/zynq_7010_code/Scanner.h +++ b/zynq_7010_code/Scanner.h @@ -29,6 +29,7 @@ public: public: bool isRested = false; + bool isScaning = false; void startScan(); void emergency_stop(int id) { @@ -40,20 +41,15 @@ public: motorCuozhi.stop(); motorZouzhi.stop(); - //capturer->close(); + put(S_EVT_SCAN_STOPPED); SaveScaninfo(m_scaninfo); start_enter_lowpwoer(); printf("emergency_stop capturer->close() \n"); - - - //sensor->enableDoubleSensor(false); } void stop_scan() { - printf("!!!!!!!!!!!!!!!!!!!!!stop_scan() waitting snap session done \n"); - sensor->cancelWaitPaper(); m_DstScannum = 0; if (threadRunScan.joinable()) @@ -78,7 +74,7 @@ public: motorCuozhi.reset(); isRested = true; isPaperInit = false; - printf("Scanner->motorCuozhi is reseted \n"); + LOG("Scanner->motorCuozhi is reseted \n"); } } void paperReady() @@ -91,9 +87,6 @@ public: bool isFeederLoaded() { return sensor->isPaperStandby(); } void ConfigScanParam(HG_ScanConfiguration config) { - // if (config.params.dpi == 0) - // config.params.dpi = 1; - m_config = config; LOG("m_config.params.dpi = %d \n \ m_config.params.isColor = %d \n \ diff --git a/zynq_7010_code/Sensor.cpp b/zynq_7010_code/Sensor.cpp index f414bd3..bb68a53 100644 --- a/zynq_7010_code/Sensor.cpp +++ b/zynq_7010_code/Sensor.cpp @@ -249,7 +249,7 @@ void Sensor::monitor2() if (i == 2) { double_1 = ret; - printf("2 double_1 :%d double_2:%d\r\n",double_1,double_2); + LOG("2 double_1 :%d double_2:%d\r\n",double_1,double_2); if (double_2 && double_1 && enbale_double_) { events.Put(ScanEvent(S_EVT_DOUBLEPAPER)); @@ -260,7 +260,7 @@ void Sensor::monitor2() if (i == 3) { double_2 = ret; - printf("3 double_1 :%d double_2:%d\r\n",double_1,double_2); + LOG("3 double_1 :%d double_2:%d\r\n",double_1,double_2); if (double_2 && double_1 && enbale_double_) { events.Put(ScanEvent(S_EVT_DOUBLEPAPER)); diff --git a/zynq_7010_code/ZouZhiMotor.cpp b/zynq_7010_code/ZouZhiMotor.cpp index 59e3888..d5e4948 100644 --- a/zynq_7010_code/ZouZhiMotor.cpp +++ b/zynq_7010_code/ZouZhiMotor.cpp @@ -32,7 +32,7 @@ void ZouZhiMotor::speedRecover() void ZouZhiMotor::speedConfig() { - printf("ZouZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ", + LOG("ZouZhiMotor speed=%d \n dpi=%d \n colormode=%d \n finalPeriod=%d \n Fmin=%d \n a=%.2f \n offset=%.2f \n stepnum=%.2f \n finalDelay=%.2f \n ", m_zouparamex.speed, m_zouparamex.dpi, m_zouparamex.colormode, diff --git a/zynq_7010_code/main.cpp b/zynq_7010_code/main.cpp index 465503d..ef1d17b 100644 --- a/zynq_7010_code/main.cpp +++ b/zynq_7010_code/main.cpp @@ -342,8 +342,7 @@ int main(int argc, char *argv[]) break; case USBCommand::GET_IMAGE: { - static int indx = 1; - + printf("传图中\r\n"); HG_JpegCompressInfo info = m_scanner->GetImage(); if (info.pJpegData != nullptr && info.DataLength != 0) { @@ -370,7 +369,6 @@ int main(int argc, char *argv[]) else index += tt; } - indx++; } } break; @@ -387,7 +385,6 @@ int main(int argc, char *argv[]) case USBCommand::GET_FW_VERSION: { m_scanner->write_bulk((void *)m_scanner->GetFWVersion().c_str(), m_scanner->GetFWVersion().length()); - // DEBUG("usb write bulk fwversion : %s length :%d", m_scanner->GetFWVersion().c_str(), m_scanner->GetFWVersion().length()); } break; case USBCommand::CONFIGURED_DATA: @@ -691,7 +688,7 @@ int main(int argc, char *argv[]) { int ret = get_devs_status(SLEEP_STATUS_PATH); - printf("sleep status :%d\r\n",ret); + printf("休眠状态:%s\r\n",ret == SCANNER_ERR_SLEEP?"设备休眠中...":"设备未休眠...") ; usbcb.Data = ret == SCANNER_ERR_SLEEP ? 0x100 : 0x10; m_scanner->write_bulk(&usbcb, sizeof(usbcb)); if (ret == SCANNER_ERR_SLEEP) diff --git a/zynq_7010_code/utilsfunc.cpp b/zynq_7010_code/utilsfunc.cpp index 1d9cdff..60b609a 100644 --- a/zynq_7010_code/utilsfunc.cpp +++ b/zynq_7010_code/utilsfunc.cpp @@ -360,31 +360,13 @@ std::string getmeminfo() void start_enter_lowpwoer() { #ifdef ENABLE_LOWPOWERMODE -// // stop_countdown(); -// int seconds=900; -// auto scaninfo= js_config.GetScanInfo(); -// if(scaninfo.SleepTime<0||scaninfo.SleepTime<180) -// seconds=180; -// else -// seconds=scaninfo.SleepTime; -// std::string str="sh /mnt/flash-disk/countdown.sh start 0 0 "+std::to_string(seconds) + " &"; -// printf("start_enter_lowpwoer %s \n",str.c_str()); - -// int ret = system(str.c_str()); -printf("system start_enter_lowpwoer :%d\r\n",true); - -write_sleep_fifo(true); + write_sleep_fifo(true); #endif } void stop_countdown() { #ifdef ENABLE_LOWPOWERMODE -// int ret = system("sh /mnt/flash-disk/killtimer.sh"); -// printf("system stop_countdown :%d\r\n",ret); - //sleep(2); - printf("stop_countdown :%d\r\n",false); - write_sleep_fifo(false); #endif } @@ -420,7 +402,7 @@ int write_sleep_fifo(int status) char buffer[12]; sprintf(buffer,"%d",status); - printf("status:%d\r\n",status); + //printf("status:%d\r\n",status); int ret = write(sleep_fd_,buffer,strlen(buffer)); return ret;