diff --git a/zynq_7010_code/CameraParams.h b/zynq_7010_code/CameraParams.h index 3d7b6ad..7480e6e 100644 --- a/zynq_7010_code/CameraParams.h +++ b/zynq_7010_code/CameraParams.h @@ -77,7 +77,7 @@ union CamZ_Reg_A_New unsigned int psen: 1; //使能相移 写低写高 unsigned int psincdec : 1; //相移动反向 unsigned int clr_psedon : 1;//清除相完成 写低写高 - unsigned int dpi: 1;//bit 12 //1: 300DPI 0: 600DPI + unsigned int dpi: 2;//bit 12 //1: 300DPI 0: 600DPI unsigned int dpi_200: 1; //dpi=1的时候 dpi_200=1 200dpi dpi=1的时候 dpi_200=0 300dpi dpi=0的时候 dpi_200=0 600dpi }; }; diff --git a/zynq_7010_code/CuoZhiMotor.cpp b/zynq_7010_code/CuoZhiMotor.cpp index 3a088b9..9f6b548 100644 --- a/zynq_7010_code/CuoZhiMotor.cpp +++ b/zynq_7010_code/CuoZhiMotor.cpp @@ -71,10 +71,8 @@ void CuoZhiMotor::reset() mspCuozhiBackward.offset, mspCuozhiBackward.finalDelay); setDirection(0); Motor::start(delays_backward, mspCuozhiBackward); - if(smbtype==SMBType::MB_DRV_8825) - std::this_thread::sleep_for(std::chrono::milliseconds(30)); - else - std::this_thread::sleep_for(std::chrono::milliseconds(150)); + + std::this_thread::sleep_for(std::chrono::milliseconds(150)); stop(); speedRecover(); diff --git a/zynq_7010_code/HCamDevice.cpp b/zynq_7010_code/HCamDevice.cpp index c54fe0b..feb3dfd 100644 --- a/zynq_7010_code/HCamDevice.cpp +++ b/zynq_7010_code/HCamDevice.cpp @@ -114,7 +114,7 @@ HCamDevice::HCamDevice() HtCamSetdivder(true); - HtCamSetPeriod(0.2); + HtCamSetPeriod(20); HtCamWriteFpgaRegs(17, 0x04ce99ff); //扫描传感器阈值 @@ -294,6 +294,7 @@ void HCamDevice::HtCamSetdivder(bool is_enble) // scan.bit.scan_pwm_enble_o = 1; // scan.bit.scan_pwm_input_clear = 0; // scan.bit.scan_pwm_reset =0; + printf("rgb.NShort[0]:%d\r\n",rgb.NShort[0]); uint32_t r = 0x0001001e; if (!is_enble) r=0x0001001F; @@ -304,9 +305,9 @@ void HCamDevice::HtCamSetdivder(bool is_enble) } void HCamDevice::HtCamSetPeriod(double reg_value) { - reg_value /= 10; + reg_value /= 100; printf("reg_value:%f\r\n",reg_value); - double pr = reg_value == 0 || reg_value > 10 ? 0x183C/2 :reg_value * 0x183C / 1; + double pr = reg_value == 0 ? 0x183C/2 :reg_value * 0x183C / 1; printf("\r\n"); diff --git a/zynq_7010_code/Keyboard.cpp b/zynq_7010_code/Keyboard.cpp index 6d23cb6..b08827d 100644 --- a/zynq_7010_code/Keyboard.cpp +++ b/zynq_7010_code/Keyboard.cpp @@ -137,7 +137,7 @@ namespace huagao if (n == sizeof(input_event)) { memcpy((void *)(&input_ev), buffer, sizeof(input_event)); - if (input_ev.type == 0) // 非按键不响应 + if (input_ev.type != 1) // 非按键不响应 { n = 0; continue; diff --git a/zynq_7010_code/MultiFrameCapture.cpp b/zynq_7010_code/MultiFrameCapture.cpp index 53c49c4..7a5ec0c 100644 --- a/zynq_7010_code/MultiFrameCapture.cpp +++ b/zynq_7010_code/MultiFrameCapture.cpp @@ -37,9 +37,11 @@ MultiFrameCapture::MultiFrameCapture(ScannerGlue glue) : paper_size_((unsigned int)PaperSize::G400_AUTO), color_mode_(GRAY), is_correct_(0), - is_double_paper_(0) + is_double_paper_(0), + is_remove_morr_(0) { video.reset(new HCamDevice); + video->HtCamSetdivder(true); m_snap_thread.reset(new std::thread(&MultiFrameCapture::snaprun, this)); m_imgproc_thread.reset(new std::thread(&MultiFrameCapture::procimage, this)); @@ -69,6 +71,7 @@ MultiFrameCapture::~MultiFrameCapture() void MultiFrameCapture::SetParent(void *scanner) { + video->HtCamSetdivder(true); } void MultiFrameCapture::open() @@ -187,11 +190,12 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config) is_correct_ = config.params.isCorrect; paper_size_ = config.params.pageSize; is_double_paper_ = config.params.doubleFeeded; + 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 < 0 || config.params.dc > 10 ? 5 : config.params.dc); + video->HtCamSetPeriod(config.params.dc); //int height = resolution_ == DPI_600 ? 342 : 900; int height = config.params.dpi == 3 ? 900 :(config.params.dpi == 2?999:300); @@ -229,11 +233,12 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config) printf("彩色sp = %d\r\n",sp * 3); } - if (paper_size_ == (unsigned int)PaperSize::G400_MAXSIZE && !config.params.slow_moire) //长文稿模式选择使用 600 dpi走纸速度 + //长文稿模式选择使用 600 dpi走纸速度 + if (paper_size_ == (unsigned int)PaperSize::G400_MAXSIZE && !config.params.slow_moire) { int sp = 0; if (color_mode_ == GRAY) - sp = resolution_ == 1 ? 22950 : 9000; //长文稿模式 这几组数据是在600dpi的走纸速度调测的 sptime + sp = resolution_ == 1 ? 22950 : 15450; //长文稿模式 这几组数据是在600dpi的走纸速度调测的 sptime else sp = resolution_ == 1 ? 7800 : 5210; @@ -450,6 +455,13 @@ void MultiFrameCapture::snaprun() int color_mode = video->HtCamGetColorMode(); int func_sig = 0; int time_out = resolution_ == DPI_600 ? 2000 : 600; ///这个时间是根据每帧的数据量来进行调测的 + + if (is_remove_morr_) + { + time_out = 2000; + } + + int time_out_cnt = 0; if (color_mode_) diff --git a/zynq_7010_code/MultiFrameCapture.h b/zynq_7010_code/MultiFrameCapture.h index f8c4c18..bb8741f 100644 --- a/zynq_7010_code/MultiFrameCapture.h +++ b/zynq_7010_code/MultiFrameCapture.h @@ -89,6 +89,7 @@ private: unsigned int color_mode_; // 颜色模式 unsigned int is_correct_; // 是否校正 unsigned int is_double_paper_; // 是否启动双张检测 + unsigned int is_remove_morr_; // 去除摩尔纹 cv::Mat lut; diff --git a/zynq_7010_code/Scanner.cpp b/zynq_7010_code/Scanner.cpp index 210a859..bbd9131 100644 --- a/zynq_7010_code/Scanner.cpp +++ b/zynq_7010_code/Scanner.cpp @@ -29,6 +29,7 @@ Scanner::Scanner(ScannerGlue glue) capturer.reset(new MultiFrameCapture(m_glue)); capturer->SetParent(this); + this_thread::sleep_for(std::chrono::milliseconds(50)); //固件版本 int version=7010; @@ -289,7 +290,7 @@ void Scanner::runScan() m_jamPaper = true; put(S_EVT_JAM_OUT); m_scaninfo.JamOutNum++; - LOG("paper 卡纸了。。。。。\n"); + printf("paper 卡纸了。。。。。\n"); } else { diff --git a/zynq_7010_code/Scanner.h b/zynq_7010_code/Scanner.h index 1e7b02e..217630d 100644 --- a/zynq_7010_code/Scanner.h +++ b/zynq_7010_code/Scanner.h @@ -78,7 +78,7 @@ public: motorCuozhi.reset(); isRested = true; isPaperInit = false; - LOG("Scanner->motorCuozhi is reseted \n"); + printf("Scanner->motorCuozhi is reseted \n"); } } void paperReady() diff --git a/zynq_7010_code/Sensor.cpp b/zynq_7010_code/Sensor.cpp index e8c474f..f414bd3 100644 --- a/zynq_7010_code/Sensor.cpp +++ b/zynq_7010_code/Sensor.cpp @@ -158,14 +158,29 @@ void Sensor::monitor() } if (pfd.revents & POLLPRI) { + if(sw.elapsed_ms() < 10) + { + printf("扫描传感器消抖。。。\r\n"); + sw.reset(); + ret = poll(&pfd, 1, 1); + if (ret > 0) + { + lseek(pfd.fd, 0, SEEK_SET); + num = read(pfd.fd, buf, 8); + buf[num - 1] = '\0'; + ret = atoi(buf); + } + continue; + } lseek(pfd.fd, 0, SEEK_SET); num = read(pfd.fd, buf, 8); buf[num - 1] = '\0'; ret = atoi(buf); - //ftt.append_log(ret?"in":"out"); + bool b = false; if (ret) { + b = true; printf("检测纸张进入 time:%f\r\n",sw2.elapsed_ms()); sw1.reset(); } @@ -173,19 +188,12 @@ void Sensor::monitor() { printf("检测纸张出去 time:%f\r\n",sw1.elapsed_ms()); sw2.reset(); + if (!b) //理论上来说 + continue; } edges[ret]->notify_all(); - while(sw.elapsed_ms() < 10) - { - ret = poll(&pfd, 1, 1); - if (ret > 0) - { - num = read(pfd.fd, buf, 8); - buf[num - 1] = '\0'; - ret = atoi(buf); - } - } + sw.reset(); } } diff --git a/zynq_7010_code/main.cpp b/zynq_7010_code/main.cpp index 30e65a3..465503d 100644 --- a/zynq_7010_code/main.cpp +++ b/zynq_7010_code/main.cpp @@ -497,7 +497,7 @@ int main(int argc, char *argv[]) // break; case USBCommand::PRE_UPGRADE: { - printf("start PRE_UPGRADE \n"); + printf("正在准备升级中... \n"); updatePkg.open("/home/root/update.zip", ios::out | ios::binary); m_scanner->SetLEDStatus(LedStatus::Updating); total_length = usbcb.Length; @@ -505,35 +505,69 @@ int main(int argc, char *argv[]) break; case USBCommand::START_UPGRADE: { - LOG("\n-----------START_UPGRADE----------------\n %d %d %d ", usbcb.Command, usbcb.Data, usbcb.Length); - USBCB tmpUpdate = {(unsigned int)(USBCommand::START_UPGRADE), 0, 0}; - if (usbcb.Length != 0) + if (!updatePkg.is_open()) { - LOG("\n-----------read_bulk----------------"); - uint ntoReadn = usbcb.Length; - char *bufferData = (char *)malloc(ntoReadn * sizeof(char)); - if (bufferData) - { - m_scanner->read_bulk(bufferData, ntoReadn); - updatePkg.write(bufferData, ntoReadn); - tmpUpdate.Length = ntoReadn; - free(bufferData); - } + printf("准备升级文件失败...\r\n"); + break; } + + printf("开始进行升级包下载...\r\n"); + int total = usbcb.Length, + block = 0, + indx = 0; + + char *bufferData = (char *)malloc(total * sizeof(char)); + while (total > 0) + { + block = 1024 * 1024; + if (total < block) + block = total; + + m_scanner->read_bulk(bufferData + indx, block); + + total -= block; + indx += block; + } + + updatePkg.write(bufferData, indx);//或者放上面分段写也是一样的,数据量太大的话 + + USBCB tmpUpdate = {(unsigned int)(USBCommand::START_UPGRADE), 0, 0}; + + tmpUpdate.Data = updatePkg.bad() ? 10 : 100; + m_scanner->write_bulk(&tmpUpdate, sizeof(tmpUpdate)); + if (bufferData) + { + free(bufferData); + } + + printf("升级包下载:%s...\r\n",tmpUpdate.Data == 10 ? "失败":"成功"); + + // LOG("\n-----------START_UPGRADE----------------\n %d %d %d ", usbcb.Command, usbcb.Data, usbcb.Length); + // USBCB tmpUpdate = {(unsigned int)(USBCommand::START_UPGRADE), 0, 0}; + // if (usbcb.Length != 0) + // { + // LOG("\n-----------read_bulk----------------"); + // uint ntoReadn = usbcb.Length; + // char *bufferData = (char *)malloc(ntoReadn * sizeof(char)); + // if (bufferData) + // { + // m_scanner->read_bulk(bufferData, ntoReadn); + // updatePkg.write(bufferData, ntoReadn); + // tmpUpdate.Length = ntoReadn; + // free(bufferData); + // } + // } + // m_scanner->write_bulk(&tmpUpdate, sizeof(tmpUpdate)); } break; case USBCommand::UPDATE_FINISHED: { + printf("开始进行升级... \n"); - printf("PRE_UPGRADE finished \n"); - if (total_length < (1024 * 1024 * 5)) - this_thread::sleep_for(std::chrono::seconds(10)); m_scanner->SetLEDStatus(LedStatus::UpdateDone); updatePkg.close(); - //system("sh /mnt/flash-disk/upgrade_firmware.sh &"); - printf("PRE_UPGRADE finished exit!!!!!!!!!!!!! \n"); - + system("sh /mnt/flash-disk/upgrade_firmware.sh &"); } break; case USBCommand::REBOOT: @@ -592,9 +626,8 @@ int main(int argc, char *argv[]) case USBCommand::GET_UPDATE_RESULT: { int ret = get_devs_status("/mnt/flash-disk/update_status.txt"); - printf("GET_UPDATE_RESULT !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n"); - printf("ret:%d\r\n",ret); - + printf("获取升级状态:%d\r\n",ret); + usbcb.Data = ret; if (ret == -1) { @@ -602,8 +635,11 @@ int main(int argc, char *argv[]) } m_scanner->write_bulk(&usbcb, sizeof(usbcb)); - if (usbcb.Data == 0) - system("reboot"); + if (ret == SCANNER_ERR_UPDATE_OK) + { + printf("升级成功。。。\r\n"); + } + //system("reboot"); } break; case USBCommand::CLEAR_LOG_FILES: diff --git a/zynq_7010_code/scanservices_utils.h b/zynq_7010_code/scanservices_utils.h index 7ec9db1..fc0e0d6 100644 --- a/zynq_7010_code/scanservices_utils.h +++ b/zynq_7010_code/scanservices_utils.h @@ -63,7 +63,7 @@ typedef struct static std::mapmapFradme_SP={ {1,{0x08ED1003,0x1ACC1002,CON(G34D,231027)}},//40 ppm - {2,{0x06DB1003,0x14A01002,CON(G35D,231027)}},//50 ppm + {2,{0x06DB1003,0x14A01002,CON(G3ZY,231102)}},//50 ppm {3,{0x05591003,0x100E1002,CON(G36D,231027)}},//60 ppm {4,{0x04421003,0x0CD11002,CON(G37D,231027)}},//70 ppm {5,{0x036c1003,0x0A421002,CON(G38D,231027)}},//80 ppm @@ -184,10 +184,10 @@ struct unsigned int enableSizeDetect : 1; unsigned int lutmode : 1 ; unsigned int slow_moire : 1; - unsigned int reversed1 : 3; + unsigned int reversed1 : 2; unsigned int isCorrect : 1; - unsigned int dc : 8; - unsigned int reversed2 : 6; + unsigned int dc : 7; //0 - 100 + unsigned int reversed2 : 8; } params; unsigned int value; };