diff --git a/CImageMerge.cpp b/CImageMerge.cpp index e345753..0580ac8 100644 --- a/CImageMerge.cpp +++ b/CImageMerge.cpp @@ -12,7 +12,6 @@ cv::Mat CImageMerge::MergeImage(cv::Mat &srcMat, int dstwidth, int dstheight, in { if (b7010) { - //printf("7010 7010 10 7010 7010 7010 7010 7010 7010!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!\r\n"); cv::Mat matdst; if (!mode) // gray mode { diff --git a/CuoZhiMotor.cpp b/CuoZhiMotor.cpp index 3a088b9..07e7206 100644 --- a/CuoZhiMotor.cpp +++ b/CuoZhiMotor.cpp @@ -112,16 +112,16 @@ 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 ", - m_cuoparamex.speed, - m_cuoparamex.dpi, - m_cuoparamex.colormode, - m_cuoparamex.mt_param.finalPeriod, - m_cuoparamex.mt_param.Fmin, - m_cuoparamex.mt_param.a, - m_cuoparamex.mt_param.offset, - m_cuoparamex.mt_param.stepnum, - m_cuoparamex.mt_param.finalDelay); + // 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 ", + // m_cuoparamex.speed, + // m_cuoparamex.dpi, + // m_cuoparamex.colormode, + // m_cuoparamex.mt_param.finalPeriod, + // m_cuoparamex.mt_param.Fmin, + // m_cuoparamex.mt_param.a, + // m_cuoparamex.mt_param.offset, + // m_cuoparamex.mt_param.stepnum, + // m_cuoparamex.mt_param.finalDelay); delays_forward.clear(); delays_forward = speedup_cfg(m_cuoparamex.mt_param.finalPeriod, m_cuoparamex.mt_param.Fmin, m_cuoparamex.mt_param.stepnum, m_cuoparamex.mt_param.a, diff --git a/HCamDevice.cpp b/HCamDevice.cpp index c010428..61be07a 100644 --- a/HCamDevice.cpp +++ b/HCamDevice.cpp @@ -240,7 +240,6 @@ int HCamDevice::open_device(int width , int height) } int HCamDevice::close_device() { - printf("videofd:%d subDevicefd:%d\r\n",videofd,subDevicefd); if (videofd == -1 || subDevicefd == -1) { return 0; @@ -1230,7 +1229,7 @@ void HCamDevice::HtCamSetDpi(int dpi) { CamZ_Reg_A_New rega; rega.value = HtCamReadFpgaRegs(0x0A); - printf("dpi:%d\r\n",dpi); + if (dpi == 1 ) { rega.dpi_200 = 1; diff --git a/IScanner.h b/IScanner.h index 644f048..99d351b 100644 --- a/IScanner.h +++ b/IScanner.h @@ -43,4 +43,6 @@ protected: BlockingQueue m_scannerEvents; std::string m_serial; std::string m_fwversion; + int vid_; + int pid_; }; diff --git a/JsonConfig.cpp b/JsonConfig.cpp index cac627f..b43c775 100644 --- a/JsonConfig.cpp +++ b/JsonConfig.cpp @@ -121,12 +121,9 @@ ScannerScanInfo JsonConfig::CreateDefaultScanInfo() info.SpeedMode = 4; l_it = mapFradme_SP.find(info.SpeedMode); info.FWVersion = l_it->second.FWVERSIO; + info.VID = 0x3072; - #ifdef G400 - info.PID = 0x0400; - #else - info.PID = 0x0300; - #endif + info.PID = 0x0300; return info; } @@ -136,7 +133,7 @@ ScannerScanInfo JsonConfig::GetScanInfo() ScannerScanInfo info; if (access(SCANNER_SCAN_INFO_PATH, F_OK) != 0) { - printf("/usr/local/huago/jsonconfig.json do not exist!\n"); + printf("/mnt/flash-disk/huago/jsonconfig.json do not exist!\n"); info = CreateDefaultScanInfo(); SaveScanInfo(info); return info; @@ -146,7 +143,7 @@ ScannerScanInfo JsonConfig::GetScanInfo() i.seekg(0, ios::end); if(i.tellg()<=2) { - printf("/usr/local/huago/jsonconfig.json file size < 2!\n"); + printf("/mnt/flash-disk/huago/jsonconfig.json file size < 2!\n"); info = CreateDefaultScanInfo(); SaveScanInfo(info); return info; diff --git a/MultiFrameCapture.cpp b/MultiFrameCapture.cpp index 72593c9..c271113 100644 --- a/MultiFrameCapture.cpp +++ b/MultiFrameCapture.cpp @@ -47,7 +47,6 @@ MultiFrameCapture::MultiFrameCapture(ScannerGlue glue, CISVendor vendor) #endif { video.reset(new HCamDevice); - reset_fpga(); m_snap_thread.reset(new std::thread(&MultiFrameCapture::snaprun, this)); m_imgproc_thread.reset(new std::thread(&MultiFrameCapture::procimage, this)); @@ -127,7 +126,7 @@ void MultiFrameCapture::stopsnap(bool autosize) void MultiFrameCapture::close() { printf("close close close\r\n"); - if (video.get()) + if (video.get()) video->close_device(); } @@ -222,16 +221,14 @@ void MultiFrameCapture::UpdateScanParam(HG_ScanConfiguration config) printf(" -----------------------设置帧数:%d------------------\r\n",cnt); } - printf("颜色模式:%s\r\n",color_mode_== COLOR ? "彩色":"灰色"); printf("分辨率:%d\r\n",resolution_); - printf("V4L2宽:%d 高:%d\r\n",v4l2_width_,v4l2_height_); + printf("V4L2宽: %d 高:%d\r\n",v4l2_width_,v4l2_height_); printf("像素宽:%d 高: %d\r\n",pixels_width_,pixels_height_); printf("fpga_height_:%d\r\n", fpga_height_); printf("color_mode_:%d\r\n", color_mode_); printf("paper_size_:%d\r\n", paper_size_); - printf("paper_size_:%d\r\n", paper_size_); } void MultiFrameCapture::createCorrect(int correctmode) @@ -310,17 +307,6 @@ void MultiFrameCapture::setScanFlag(bool brun) bScanning = brun; } -void MultiFrameCapture::reset_fpga() -{ - -} - -void MultiFrameCapture::reload_fpga() -{ - -} - - void MultiFrameCapture::configFPGAParam(int mode, int dpi) { FPGAConfigParam fpgaparam = GetFpgaparam(dpi, mode); @@ -342,14 +328,6 @@ void MultiFrameCapture::configFPGAParam(int mode, int dpi) // //video->HtCamReadADCReg_ALL(i); // } }; -int MultiFrameCapture::width() -{ - return 0;//dpi == 0x02 ? 864 * channel : (dpi == 0x03 ? (1728 * channel) : (864 * channel)); // we only sup dunnancis now -} - -int MultiFrameCapture::color() -{ -} #include "bmp.h" @@ -1003,8 +981,6 @@ void MultiFrameCapture::correctcolor(int correctmode) void MultiFrameCapture::openDevice(int dpi, int mode) { - printf("openDevice dpi:%d mode:%d \r\n",dpi,mode); - reset_fpga(); bool dunnancis = true; int channelwidth = dpi == 0x02 ? 864 : (dpi == 0x03 ? 1728 : 576); // 1296 2592 864 int channels = mode == 0x01 ? 3 : 1; diff --git a/MultiFrameCapture.h b/MultiFrameCapture.h index 1a3d244..1ef4a45 100644 --- a/MultiFrameCapture.h +++ b/MultiFrameCapture.h @@ -67,12 +67,7 @@ private: #endif CamZ_Reg_4 reg_; private: - void reset_fpga(); - void reload_fpga(); - void configFPGAParam(int mode,int dpi); - int color(); - int width(); void snaprun(); void updatesnapstatus(int papertype); void procimage(); @@ -81,7 +76,7 @@ private: void creatcorrectconfig(int dpi,int mode); void correctcolor(int correctmode); void openDevice(int dpi,int mode); - //void myFloodFill(cv::Mat& image, bool isTwoSide); + private: unsigned int resolution_; // 分辨率 //3:600dpi 2:300dpi 1:200dpi diff --git a/Scanner.cpp b/Scanner.cpp index 4b8c86a..403ad25 100644 --- a/Scanner.cpp +++ b/Scanner.cpp @@ -105,7 +105,7 @@ void Scanner::updateSpeedMode(int speed) m_scaninfo = GetScanInfoFromJson(); if(m_scaninfo.SpeedMode==0) m_scaninfo.SpeedMode=3; - printf("速度模式:%d dpi:%d 颜色:%d \n",m_scaninfo.SpeedMode,m_config.params.dpi,m_config.params.isColor); + unsigned int t_dpi = m_config.params.dpi; if(typeid(*capturer)==typeid(MultiFrameCapture)) diff --git a/SysInforTool.cpp b/SysInforTool.cpp index c48174e..4ef6bb8 100644 --- a/SysInforTool.cpp +++ b/SysInforTool.cpp @@ -94,20 +94,13 @@ int SysInforTool::get_fileSystem_info(const char *fileSystem_name, struct fileSy break; } - // bzero(&fi->fileSystem_total_capacity,sizeof(fi->fileSystem_total_capacity)); - // bzero(&fi->fileSystem_free_capacity,sizeof(fi->fileSystem_free_capacity)); - printf("blocks %ld\n", buf.f_blocks); - printf("bfree %ld\n", buf.f_bfree); - printf("bsize %ld\n", buf.f_bsize); fileSystem_total_size = (float)(kscale(buf.f_blocks, buf.f_bsize)); fileSystem_free_size = (float)(kscale(buf.f_bfree, buf.f_bsize)); - printf("total %f\n", fileSystem_total_size); - printf("free %f\n", fileSystem_free_size); fi->fileSystem_total_capacity = fileSystem_total_size; fi->fileSystem_free_capacity = fileSystem_free_size; @@ -159,28 +152,28 @@ std::string SysInforTool::GetSysInfo() if (uname(&t_uname) != 0) perror("uname doesn't return 0, so there is an error"); - printf("System Name = %s\n", t_uname.sysname); - printf("Node Name = %s\n", t_uname.nodename); - printf("Version = %s\n", t_uname.version); - printf("Release = %s\n", t_uname.release); - printf("Machine = %s\n", t_uname.machine); + // printf("System Name = %s\n", t_uname.sysname); + // printf("Node Name = %s\n", t_uname.nodename); + // printf("Version = %s\n", t_uname.version); + // printf("Release = %s\n", t_uname.release); + // printf("Machine = %s\n", t_uname.machine); if (strcmp(t_uname.nodename, "linaro-alip") == 0 && strcmp(t_uname.machine, "armv7l") == 0) { m_sysinfo.Systype = SysType::Sys_Linux_Debian; m_sysinfo.CPU = SCPU::CPU_3288; - printf("Machine = %s CPU = %s \n", "Sys_Linux_Debian", "CPU_3288"); + //printf("Machine = %s CPU = %s \n", "Sys_Linux_Debian", "CPU_3288"); } else if (strcmp(t_uname.nodename, "linaro-alip") == 0 && strcmp(t_uname.machine, "aarch64") == 0) { m_sysinfo.Systype = SysType::Sys_Linux_Debian; m_sysinfo.CPU = SCPU::CPU_3399; - printf("Machine = %s CPU = %s \n", "Sys_Linux_Debian", "CPU_3399"); + //printf("Machine = %s CPU = %s \n", "Sys_Linux_Debian", "CPU_3399"); } char output[512]; get_system_output("uname -a", output, sizeof(output)); std::string ver(output); m_sysinfo.KernelVersion = ver; - printf("system version = %s \n", ver.c_str()); + //printf("system version = %s \n", ver.c_str()); json j; struct2json(j, m_sysinfo); std::ofstream o("/usr/local/huago/sysinfo.json"); diff --git a/UsbScanner.cpp b/UsbScanner.cpp index e6e5601..423009e 100644 --- a/UsbScanner.cpp +++ b/UsbScanner.cpp @@ -4,6 +4,7 @@ #include "USBProtocol.h" #include "filetools.h" #include "logs_out.h" +#include "JsonConfig.h" #define USB_REQ_GET_FPGA_REGS 0x40 #define USB_REQ_SET_FPGA_REGS 0x41 @@ -20,10 +21,6 @@ #define USB_REQ_GET_DEV_LOG 0x65 #define USB_REQ_SET_DEV_LOG 0x66 -static int enqueueindex = 0; - - - const int SPEED_MODE_MAX = 5; UsbScanner::UsbScanner() : m_startscan(false), @@ -31,8 +28,18 @@ UsbScanner::UsbScanner() : m_startscan(false), eventsramain(0) { DeviceExport(); - m_serial = ("G20018000298OO"); - m_fwversion = ("1234561300"); + JsonConfig js; + ScannerScanInfo info = js.GetScanInfo(); + + pid_ = info.PID; + vid_ = info.VID; + m_serial = info.SerialNum; + m_fwversion = info.FWVersion; + + printf("VID:%0x\r\n",vid_); + printf("PID:%0x\r\n",pid_); + printf("SerialNum:%s\r\n",m_serial.c_str()); + printf("FWVersion:%s\r\n",m_fwversion.c_str()); mount_usb_device(); auto ctrl_req_handler = [&](int fd, struct usb_ctrlrequest *setup, unsigned char *buffer) -> bool { @@ -121,19 +128,17 @@ UsbScanner::UsbScanner() : m_startscan(false), std::this_thread::sleep_for(std::chrono::milliseconds(2)); } - PRINT_MSG("!!!!!!!!!!time eplased :%.2f ",sw.elapsed_ms()); + auto imageready = [this](const HG_JpegCompressInfo &imageinfo) { imageremain++; m_images.Put(imageinfo); printf("队列缓存张数 :%d\r\n",m_images.Size()); - // LOG("Enqueue image index :%d ptr:%p length:%d\n", ++enqueueindex,imageinfo.pJpegData, imageinfo.DataLength); }; auto deviceevent = [this](const int eventID, std::string capmsg) { { - LOG("\n 222222222 Enqueue event %d \n", eventID); eventsramain++; m_scannerEvents.Put({eventID, capmsg}); if (eventID == (int)HG_ScannerStatus::STOP_SCAN) @@ -173,20 +178,14 @@ UsbScanner::~UsbScanner() void UsbScanner::StartScan(int scancount) { ClearImages(); - LOG("m_scannerEvents size %d\n", m_scannerEvents.Size()); ClearErrorEvents(); - LOG("m_images size %d\n", m_images.Size()); m_hgScanner->SetDstScanNum(9999);//scancount <= 0 ? 1 : scancount); - printf("1111111111111111111 %d \r\n", scancount); m_hgScanner->put(S_EVT_START_SCAN); - // m_hgScanner->startScan(); - LOG("Put Event S_EVT_START_SCAN\n"); } void UsbScanner::StopScan() { m_hgScanner->put(S_EVT_STOP_SCAN); - LOG("Put Event S_EVT_STOP_SCAN\n"); } void UsbScanner::ConfigScanParam(HG_ScanConfiguration config) @@ -480,10 +479,21 @@ bool UsbScanner::is_connect() void UsbScanner::mount_usb_device() { + /////没用到 if ((access("/dev/ffs-camtp/ep0", F_OK)) != -1) - return; - - int result = system("modprobe libcomposite\n \ + { + printf("exit mount_usb_device !!!\r\n"); + return; + } + + char p[12]; + sprintf(p,"%0x",pid_); + char v[12]; + sprintf(v,"%0x",vid_); + std::string pid = p; + std::string vid = v; + + std::string str = "modprobe libcomposite\n \ mkdir /var/cfg\n \ mount none /var/cfg -t configfs\n \ mkdir /var/cfg/usb_gadget/g1\n \ @@ -492,8 +502,8 @@ void UsbScanner::mount_usb_device() mkdir functions/ffs.camtp\n \ mkdir strings/0x409\n \ mkdir configs/c.1/strings/0x409\n \ - echo 0x0300 > idProduct\n \ - echo 0x3072 > idVendor\n \ + echo" + pid +"> idProduct\n \ + echo" + vid +"> idVendor\n \ echo \"01234567AABBCCDDEE\" > strings/0x409/serialnumber\n \ echo \"Holdtecs Technologies\" > strings/0x409/manufacturer\n \ echo \"The Holdtecs Product !\" > strings/0x409/product\n \ @@ -501,7 +511,6 @@ void UsbScanner::mount_usb_device() echo 120 > configs/c.1/MaxPower\n \ ln -s functions/ffs.camtp configs/c.1\n \ mkdir /dev/ffs-camtp\n \ - mount -t functionfs camtp /dev/ffs-camtp"); - - //printf("!!!!!!!!!!!!!!!!!!!modprobe libcomposite done \n"); + mount -t functionfs camtp /dev/ffs-camtp"; + int result = system(str.c_str()); } \ No newline at end of file diff --git a/ZouZhiMotor.cpp b/ZouZhiMotor.cpp index 59e3888..495f19d 100644 --- a/ZouZhiMotor.cpp +++ b/ZouZhiMotor.cpp @@ -32,16 +32,16 @@ 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 ", - m_zouparamex.speed, - m_zouparamex.dpi, - m_zouparamex.colormode, - m_zouparamex.mt_param.finalPeriod, - m_zouparamex.mt_param.Fmin, - m_zouparamex.mt_param.a, - m_zouparamex.mt_param.offset, - m_zouparamex.mt_param.stepnum, - m_zouparamex.mt_param.finalDelay); + // 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 ", + // m_zouparamex.speed, + // m_zouparamex.dpi, + // m_zouparamex.colormode, + // m_zouparamex.mt_param.finalPeriod, + // m_zouparamex.mt_param.Fmin, + // m_zouparamex.mt_param.a, + // m_zouparamex.mt_param.offset, + // m_zouparamex.mt_param.stepnum, + // m_zouparamex.mt_param.finalDelay); delays.clear(); diff --git a/main.cpp b/main.cpp index 21cb08e..f0c690e 100644 --- a/main.cpp +++ b/main.cpp @@ -299,9 +299,7 @@ int main(int argc, char *argv[]) int evt = m_scanner->GetEventFront().code; if (evt != (int)HG_ScannerStatus::NORMAL && evt != (int)HG_ScannerStatus::STOP_SCAN) { - sts.Data = m_scanner->GetEvent().code; // 扫描中途的事件能够被通知 - // printf("关闭V4L2 333\r\n"); - // m_scanner->close_v4l2(); + sts.Data = m_scanner->GetEvent().code; // 扫描中途的事件能够被通知 } else { @@ -338,8 +336,7 @@ int main(int argc, char *argv[]) m_scanner->write_bulk(&sts, sizeof(sts)); auto msg = data.msg; m_scanner->write_bulk(&msg[0], msg.length()); - //printf("关闭V4L2 111\r\n"); - //m_scanner->close_v4l2(); + break; } } @@ -401,7 +398,6 @@ int main(int argc, char *argv[]) //LOG("Free info.pJpegData done\n"); if (info.dpi) { - //printf("111111111111111111111111111111111\r\n"); free(info.pJpegData); } diff --git a/usbdevice.cpp b/usbdevice.cpp index 78d745d..63197fa 100755 --- a/usbdevice.cpp +++ b/usbdevice.cpp @@ -51,6 +51,8 @@ const int UsbDevice::cacheSize = 3*1024*1024; int camtp_load_config_file(camtp_ctx * context, const char * conffile) { + JsonConfig js; + ScannerScanInfo info = js.GetScanInfo(); int err = 0; FILE * f; char line[MAX_CFG_STRING_SIZE]; @@ -68,8 +70,8 @@ int camtp_load_config_file(camtp_ctx * context, const char * conffile) strncpy(context->usb_cfg.usb_string_version, "Rev A", MAX_CFG_STRING_SIZE); strncpy(context->usb_cfg.usb_string_interface, "Ht UsbCam", MAX_CFG_STRING_SIZE); - context->usb_cfg.usb_vendor_id = USB_DEV_VENDOR_ID; - context->usb_cfg.usb_product_id = USB_DEV_PRODUCT_ID; + context->usb_cfg.usb_vendor_id = info.VID; + context->usb_cfg.usb_product_id = info.PID; context->usb_cfg.usb_class = USB_DEV_CLASS; context->usb_cfg.usb_subclass = USB_DEV_SUBCLASS; context->usb_cfg.usb_protocol = USB_DEV_PROTOCOL; diff --git a/usbdevice.h b/usbdevice.h index 3825d9e..d1d3f18 100755 --- a/usbdevice.h +++ b/usbdevice.h @@ -14,7 +14,7 @@ #include "camtp.h" #include "buildconf.h" #include "usb_gadget.h" - +#include "JsonConfig.h" //#define AIO_BULK_TRANSFER #ifdef AIO_BULK_TRANSFER @@ -86,6 +86,8 @@ private: std::shared_ptr intPointPool ; int loop_continue = 0 ; + int vid_; + int pid_; #ifdef AIO_BULK_TRANSFER // int handle_ffs_aio_ep0(usb_gadget * ctx); io_context_t aio_ctx = 0; @@ -94,5 +96,6 @@ private: std::thread aio_event_thread; int aio_event_poll(); std::mutex mx; + #endif }; \ No newline at end of file