From 443e4938d184d44757e84bca9c1dcda48bb5b6ee Mon Sep 17 00:00:00 2001 From: 13038267101 Date: Fri, 11 Nov 2022 17:59:08 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4=20io=20ctrl=20=E5=9C=A8?= =?UTF-8?q?=E6=81=A2=E5=A4=8D=E9=BB=98=E8=AE=A4=E5=80=BC=E6=97=B6=E5=AF=BC?= =?UTF-8?q?=E8=87=B4=E5=A5=94=E6=BA=83=EF=BC=8C=E6=96=B0=E5=A2=9E=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=89=AB=E6=8F=8F=E5=BC=A0=E6=95=B0=20=E8=B0=83?= =?UTF-8?q?=E6=95=B4long=E5=9C=A864=E4=BD=8D=E4=B8=8B=E5=9B=A0=E4=B8=BA?= =?UTF-8?q?=E6=98=AF32=E4=BD=8D=E5=AF=BC=E8=87=B4=E5=A5=94=E6=BA=83?= =?UTF-8?q?=E4=B8=BA=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hgdriver/hgdev/common_setting.h | 2 +- hgdriver/hgdev/hg_scanner.cpp | 35 +++---- hgdriver/hgdev/hg_scanner.h | 27 +++--- hgdriver/hgdev/hg_scanner_239.cpp | 147 ++++++----------------------- hgdriver/hgdev/hg_scanner_239.h | 132 +++++++++++--------------- hgdriver/hgdev/hg_scanner_302.cpp | 2 +- hgdriver/hgdev/scanner_manager.cpp | 10 +- hgsane/sane_hg_mdw.cpp | 15 +-- hgsane/sane_hg_mdw.h | 4 +- 9 files changed, 133 insertions(+), 241 deletions(-) diff --git a/hgdriver/hgdev/common_setting.h b/hgdriver/hgdev/common_setting.h index 5c0cfc6..45fc9ec 100644 --- a/hgdriver/hgdev/common_setting.h +++ b/hgdriver/hgdev/common_setting.h @@ -855,7 +855,7 @@ namespace setting3399 SR_SET_COLOR_SP, SR_SET_SLEEPTIME, SR_GET_SLEEPTIME, - SR_GET_SLEEP_STAUTUS, + SR_GET_SLEEP_STAUTUS, //返回1不在睡眠状态 0反之 SR_GET_IMAGEPROCESSDONE, SR_GET_KEEP_LAST_PAPER, SR_GET_PAPERON, diff --git a/hgdriver/hgdev/hg_scanner.cpp b/hgdriver/hgdev/hg_scanner.cpp index 3197f31..5fc18ca 100644 --- a/hgdriver/hgdev/hg_scanner.cpp +++ b/hgdriver/hgdev/hg_scanner.cpp @@ -3068,9 +3068,9 @@ int hg_scanner::device_io_control(unsigned long code, void* data, unsigned* len) { return SCANNER_ERR_OUT_OF_RANGE; } - else if((setting_jsn_.begin() + *len)->contains("default")) + else if(*len < jsn_children_.size()) { - if (get_default_value(data, &*(setting_jsn_.begin() + *len))) + if (get_default_value(data, &setting_jsn_.at(jsn_children_[*len]))) return SCANNER_ERR_OK; else return SCANNER_ERR_DATA_DAMAGED; @@ -3082,10 +3082,11 @@ int hg_scanner::device_io_control(unsigned long code, void* data, unsigned* len) } else if (code == IO_CTRL_CODE_CLEAR_ROLLER_COUNT) { - int count = get_roller_num(); + + int val = 0, ret = get_roller_num(val); if (len) - *len = count; + *len = val; return clear_roller_num(); } @@ -3336,10 +3337,10 @@ int hg_scanner::device_io_control(unsigned long code, void* data, unsigned* len) string str = (char*)data; return firmware_upgrade(str); } - else if (code == IO_CTRL_CODE_GET_HISTORY_NUM) + else if (code == IO_CTRL_CODE_GET_HISTORY_ROLLER_NUM) { int num = 0; - int ret = get_history_count(num); + int ret = get_history_roller_count(num); (*(int*)data) = num; return ret; } @@ -3361,9 +3362,9 @@ std::string hg_scanner::get_ip(void) { return BRAND_DEVICE_NOT_SUPPORT; } -int hg_scanner::get_roller_num(void) +int hg_scanner::get_roller_num(int &val) { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::get_device_log(string &log) { @@ -3371,39 +3372,39 @@ int hg_scanner::get_device_log(string &log) } int hg_scanner::set_devreboot() { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::set_devshtudown() { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::clear_roller_num(void) { return SCANNER_ERR_DEVICE_NOT_SUPPORT; } -int hg_scanner::get_history_count(int &num) +int hg_scanner::get_history_roller_count(int &num) { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::set_scan_islock(SANE_Bool set_islock) { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::get_scan_islock(SANE_Bool* islock) { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::set_scan_lock_check_val(string check_str) { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::firmware_upgrade(std::string filename) { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner::clean_paper_road() { - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } ////////////////////////////////////////////////////////////////////////////////////////////////////// int hg_scanner::set_leaflet_scan(void) diff --git a/hgdriver/hgdev/hg_scanner.h b/hgdriver/hgdev/hg_scanner.h index fb1ff91..6288ad3 100644 --- a/hgdriver/hgdev/hg_scanner.h +++ b/hgdriver/hgdev/hg_scanner.h @@ -359,17 +359,20 @@ public: public: - virtual int set_leaflet_scan(void); //单张扫描 - virtual int get_abuot_info(void); //获取软件关于信息 (基类实现) + virtual std::string get_firmware_version(void); + virtual std::string get_serial_num(void); + virtual std::string get_ip(void); + /// + /// retuen scanner_err + /// + virtual int set_leaflet_scan(void) = 0; //单张扫描 + virtual int get_abuot_info(void) = 0; //获取软件关于信息 (基类实现) virtual int restore_default_setting(void); //恢复默认设置 (基类实现) virtual int set_final_image_format(SANE_FinalImgFormat* fmt);//设置图像处理最终输出(final())的图像数据格式 (基类实现) *** virtual int get_compression_format(void); //获取支持的压缩格式 功能不支持 virtual int clear_roller_num(void); // 清除滚轴计数 virtual int set_compression_format(void); //设置图像数据最终输出的压缩格式 virtual int set_auto_color_type(void); //设置自动匹配颜色模式 (基类实现) *** - virtual std::string get_firmware_version(void); - virtual std::string get_serial_num(void); - virtual std::string get_ip(void); virtual int get_device_code(void); //获取设备编码 virtual int get_dogear_distance(void); //获取折角检测最小距离阈值 virtual int set_dogear_distance(void); // 设置折角检测最小距离阈值 @@ -381,17 +384,17 @@ public: virtual int get_scan_is_sleep(void); //获取设备是否休眠当中 virtual int get_sleep_time(int& getsleepime); //获取功耗模式(休眠) virtual int set_sleep_time(int sleeptime); //设置功耗模式(休眠) - virtual int get_history_count(int &num); //获取历史扫描张数 -2:设备不支持该功能;-1:与设备通信失败;其它大于等于0的为正常 - virtual int get_roller_num(void); //获取滚轮张数 -2:设备不支持该功能;-1:与设备通信失败;其它大于等于0的为正常 + virtual int get_history_roller_count(int &num); //获取历史扫描张数 + virtual int get_roller_num(int &val); //获取滚轮张数 virtual int notify_sleep(void); //唤醒设备 virtual int get_device_log(string &log); //获取设备日志 virtual int set_devreboot(); //设置设备重启 virtual int set_devshtudown(); //设置设备关机 - virtual int set_scan_islock(SANE_Bool set_islock); //设置设备是否锁定 - 2:设备不支持该功能;它大于等于0的为正常 - virtual int get_scan_islock(SANE_Bool* islock); //获取设备是否锁定 -2:设备不支持该功能;它大于等于0的为正常 - virtual int set_scan_lock_check_val(string check_str); //获取设备是否锁定 -2:设备不支持该功能;它大于等于0的为正常 - virtual int firmware_upgrade(std::string filename); //固件升级 -2:设备不支持该功能;它大于等于0的为正常 - virtual int clean_paper_road(); //清理纸道 -2:设备不支持该功能;它大于等于0的为正常 + virtual int set_scan_islock(SANE_Bool set_islock); //设置设备是否锁定 + virtual int get_scan_islock(SANE_Bool* islock); //获取设备是否锁定 + virtual int set_scan_lock_check_val(string check_str); //获取设备是否锁定 + virtual int firmware_upgrade(std::string filename); //固件升级 + virtual int clean_paper_road(); //清理纸道 }; #ifdef UOS diff --git a/hgdriver/hgdev/hg_scanner_239.cpp b/hgdriver/hgdev/hg_scanner_239.cpp index 48df82f..0a1d44f 100644 --- a/hgdriver/hgdev/hg_scanner_239.cpp +++ b/hgdriver/hgdev/hg_scanner_239.cpp @@ -321,32 +321,7 @@ std::string hg_scanner_239::get_fpga(void) return fpga; } -int hg_scanner_239::clr_roller_num(void) -{ - int val = 0, - ret = read_register(setting3399::SR_CLR_ROLLER_NUM, &val); - if (ret == SCANNER_ERR_OK) - return val; - else - { - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "clr_roller_num = %s\n", hg_scanner_err_name(ret)); - return -1; - } -} -int hg_scanner_239::get_sleep_time(void) -{ - int val = 0, - ret = read_register(setting3399::SR_GET_SLEEPTIME, &val); - - if (ret == SCANNER_ERR_OK) - return val; - else - { - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_sleep_time = %s\n", hg_scanner_err_name(ret)); - return -1; - } -} int hg_scanner_239::get_scan_mode(void) { int val = 0, @@ -377,21 +352,7 @@ int hg_scanner_239::get_status(void) else return val; } -bool hg_scanner_239::is_dev_tx(void) -{ - int val = 0, - ret = read_register(setting3399::SR_STATUS, &val); - if (ret) - { - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "is_dev_tx() error: %s\n", hg_scanner_err_name(ret)); - status_ = ret; - - return false; - } - else - return val; -} bool hg_scanner_239::is_dev_image_process_done(void) { int val = 0, @@ -423,19 +384,7 @@ bool hg_scanner_239::is_dev_image_keep_last_paper(void) else return val; } -int hg_scanner_239::get_scanned_count(void) -{ - int val = 0, - ret = read_register(setting3399::SR_GET_SCANN_NUM, &val); - if (ret == SCANNER_ERR_OK) - return val; - else - { - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_scanned_count = %s\n", hg_scanner_err_name(ret)); - return -1; - } -} int hg_scanner_239::get_image_count(void) { int val = 0, @@ -478,22 +427,6 @@ void hg_scanner_239::init_version(void) else is_kernelsnap_220830_ = false; } - - -int hg_scanner_239::get_device_sleep_stautus() -{ - int val = 0, - ret = 0; - - ret = read_register(setting3399::SR_GET_SLEEP_STAUTUS,&val); - return val; -} - -int hg_scanner_239::get_device_paperon_stautus(void) -{ - int ret =read_register(setting3399::SR_GET_PAPERON,0); - return ret; -} int hg_scanner_239::writedown_device_configuration(setting_hardware::HGSCANCONF_3399 *dev_conf) { @@ -1454,26 +1387,25 @@ int hg_scanner_239::start(void) notify_ui_working_status(STATU_DESC_PREPARE_START); reset(); - get_roller_num(); - val = get_device_sleep_stautus();//211220固件版本不支持返回 - if (val == 0) + ret = get_roller_num(val); + ret = get_scan_is_sleep(val);//211220固件版本不支持返回 + if (ret == SCANNER_ERR_DEVICE_SLEEPING) { - status_ = SCANNER_ERR_DEVICE_SLEEPING;; + status_ = ret;; VLOG_MINI_1(LOG_LEVEL_WARNING, "device start status is(%s)\n", STATU_DESC_SCANNER_ERR_DEVICE_SLEEPING); if(is_kernelsnap_220830_) - val = notify_sleep(); + ret = notify_sleep(); notify_ui_working_status(STATU_DESC_SCANNER_ERR_DEVICE_NOTIFY_SLEEP, SANE_EVENT_ERROR, status_); return status_; } - - val = get_scan_mode(); + ret = get_scan_mode(); if (status_ == SCANNER_ERR_DEVICE_NOT_FOUND) return status_; - if (val == -1) + if (ret == -1) return status_; - if (val & 1) + if (ret & 1) { status_ = SCANNER_ERR_DEVICE_COUNT_MODE; @@ -1579,18 +1511,10 @@ std::string hg_scanner_239::get_ip(void) { return control_fetch(setting3399::SR_GET_IPADDR, 0, 40); } -int hg_scanner_239::get_roller_num(void) +int hg_scanner_239::get_roller_num(int &val) { - int val = 0, - ret = read_register(setting3399::SR_GET_ROLLER_NUM, &val); - - if (ret == SCANNER_ERR_OK) - return val; - else - { - VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_roller_num = %s\n", hg_scanner_err_name(ret)); - return -1; - } + int ret = read_register(setting3399::SR_GET_SCANN_NUM, &val); + return ret; } int hg_scanner_239::clear_roller_num(void) { @@ -1614,7 +1538,6 @@ int hg_scanner_239::set_leaflet_scan(void) } int hg_scanner_239::get_abuot_info(void) { - return SCANNER_ERR_DEVICE_NOT_SUPPORT; } int hg_scanner_239::restore_default_setting(void) @@ -1677,31 +1600,13 @@ int hg_scanner_239::get_scanner_paperon(SANE_Bool* paperon) { int val = 0, ret = read_register(setting3399::SR_GET_PAPERON, &val); - - if (ret == SCANNER_ERR_OK) - { - if (!val) - { - ret = SCANNER_ERR_DEVICE_NO_PAPER; - if (paperon) - { - *paperon = false; - } - } - else - { - ret = SCANNER_ERR_OK; - if (paperon) - { - *paperon = true; - } - } - } - else + if (ret != SCANNER_ERR_OK) { VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_scanner_paperon = %s\n", hg_scanner_err_name(ret)); - return -1; + return ret; } + ret = val ? SCANNER_ERR_OK : SCANNER_ERR_DEVICE_NO_PAPER; + *paperon = val; return ret; } int hg_scanner_239::set_scan_when_paper_on(void) @@ -1720,9 +1625,12 @@ int hg_scanner_239::set_scan_with_hole(void) { return SCANNER_ERR_DEVICE_NOT_SUPPORT; } -int hg_scanner_239::get_scan_is_sleep() +int hg_scanner_239::get_scan_is_sleep(int& status) { - return SCANNER_ERR_DEVICE_NOT_SUPPORT; + int ret = 0; + + ret = read_register(setting3399::SR_GET_SLEEP_STAUTUS, &status); + return ret = status ? SCANNER_ERR_OK : SCANNER_ERR_DEVICE_SLEEPING; } int hg_scanner_239::notify_sleep() { @@ -1734,7 +1642,7 @@ int hg_scanner_239::notify_sleep() } return ret; } -int hg_scanner_239::get_history_count(int &num) +int hg_scanner_239::get_history_roller_count(int &num) { int ret = read_register(setting3399::SR_GET_ROLLER_NUM, &num); return ret; @@ -1813,7 +1721,7 @@ int hg_scanner_239::set_scan_islock(SANE_Bool set_islock) if (ret != SCANNER_ERR_OK) return ret; } -int hg_scanner_239::get_scan_islock(SANE_Bool* islock) +int hg_scanner_239::get_scan_islock(SANE_Bool& islock) { if (!is_kernelsnap_220830_) return SCANNER_ERR_DEVICE_NOT_SUPPORT; @@ -1821,12 +1729,11 @@ int hg_scanner_239::get_scan_islock(SANE_Bool* islock) int val = 0, ret = read_register(setting3399::SR_GET_LOCK_STATES, &val); - if (ret == SCANNER_ERR_OK) - *islock = val; - - if ( val == 1) - ret = SCANNER_ERR_DEVICE_ISLOCK; + if (ret != SCANNER_ERR_OK) + return ret; + ret = islock ? SCANNER_ERR_DEVICE_ISLOCK : SCANNER_ERR_OK; + islock = val; return ret; } @@ -1851,7 +1758,7 @@ int hg_scanner_239::set_scan_lock_check_val(string check_str) int ret = SCANNER_ERR_OK; std::uint8_t key[CryptoPP::AES::DEFAULT_KEYLENGTH] = { 0 }; - ret = get_scan_islock(&islock); + ret = get_scan_islock(islock); if (ret == SCANNER_ERR_DEVICE_ISLOCK) return ret; diff --git a/hgdriver/hgdev/hg_scanner_239.h b/hgdriver/hgdev/hg_scanner_239.h index bfdb6b2..4977e59 100644 --- a/hgdriver/hgdev/hg_scanner_239.h +++ b/hgdriver/hgdev/hg_scanner_239.h @@ -28,52 +28,39 @@ class hg_scanner_239 : public hg_scanner bool reset_; bool is_start_status; - int read_register(int addr, int* val); - int write_register(int addr, int val); - int write_command(int cmd); std::string control_fetch(int addr, int val, int size); - std::string get_fpga(void); - int clr_roller_num(void); - int get_sleep_time(void); - int get_scan_mode(void); - int get_status(void); - bool is_dev_tx(void); + int get_scan_mode(void); + int get_status(void); + int get_image_count(void); + int get_front_data_size(void); + int read_register(int addr, int* val); + int write_register(int addr, int val); + int write_command(int cmd); + int writedown_device_configuration(setting_hardware::HGSCANCONF_3399* dev_conf = NULL); + int writedown_image_configuration(void); + int pop_first_image(void); + int read_one_image_from_usb(SANE_Image_Statu statu = SANE_Image_Statu_OK); bool is_dev_image_process_done(void); bool is_dev_image_keep_last_paper(void); - int get_scanned_count(void); - int get_image_count(void); - int get_front_data_size(void); - void init_version(void); - int get_device_sleep_stautus(); - int get_device_paperon_stautus(void); - - int writedown_device_configuration(setting_hardware::HGSCANCONF_3399* dev_conf = NULL); - int writedown_image_configuration(void); - int pop_first_image(void); - - int read_one_image_from_usb(SANE_Image_Statu statu = SANE_Image_Statu_OK); void discard_all_images(void); - + void init_version(void +); protected: - int on_color_mode_changed(int& color_mode) override; - virtual int on_paper_changed(int& paper) override; - virtual int on_paper_check_changed(bool& check) override; - virtual int on_resolution_changed(int& dpi) override; - - virtual int on_ultrasonic_check_changed(bool& check) override; - virtual int on_staple_check_changed(bool& check) override; - virtual int on_skew_check_changed(bool& check) override; - virtual int on_skew_check_level_changed(int& check) override; - - virtual int on_get_feedmode(int& feedmode) override;//获取分纸强度 - virtual int on_set_feedmode(int feedmode) override;//设置分纸强度 - virtual int on_pic_type(bool& pic);//照片模式或者文本模式 - virtual int on_pick_paper(bool autostrength); - - virtual int on_pick_paper_threshold(double threshold); - virtual int on_is_auto_paper(bool isautopaper);//待纸扫描 - + int on_color_mode_changed(int& color_mode) override; + virtual int on_paper_changed(int& paper) override; + virtual int on_paper_check_changed(bool& check) override; + virtual int on_resolution_changed(int& dpi) override; + virtual int on_ultrasonic_check_changed(bool& check) override; + virtual int on_staple_check_changed(bool& check) override; + virtual int on_skew_check_changed(bool& check) override; + virtual int on_skew_check_level_changed(int& check) override; + virtual int on_get_feedmode(int& feedmode) override;//获取分纸强度 + virtual int on_set_feedmode(int feedmode) override;//设置分纸强度 + virtual int on_pic_type(bool& pic);//照片模式或者文本模式 + virtual int on_pick_paper(bool autostrength); + virtual int on_pick_paper_threshold(double threshold); + virtual int on_is_auto_paper(bool isautopaper);//待纸扫描 virtual void on_device_reconnected(void) override; virtual int on_scanner_closing(bool force) override; virtual void thread_handle_usb_read(void) override; @@ -83,53 +70,46 @@ public: ~hg_scanner_239(); public: - virtual int start(void) override; //virtual int get_image_info(IMG_PARAM* ii) override; //virtual int read_image_data(unsigned char* buf, int* len) override; + virtual int start(void) override; virtual int stop(void) override; virtual int reset(void) override; virtual int device_io_control(unsigned long code, void* data, unsigned* len) override; public: - virtual int set_leaflet_scan(void);//单张扫描 - virtual int get_abuot_info(void);//获取软件关于信息 (基类实现) - virtual int restore_default_setting(void);//恢复默认设置 (基类实现) + virtual std::string get_firmware_version(void); + virtual std::string get_serial_num(void); + virtual std::string get_ip(void); + virtual int set_leaflet_scan(void); //单张扫描 + virtual int get_abuot_info(void); //获取软件关于信息 (基类实现) + virtual int restore_default_setting(void); //恢复默认设置 (基类实现) virtual int set_final_image_format(SANE_FinalImgFormat* fmt); // 设置图像处理最终输出(final())的图像数据格式 (基类实现) *** - virtual int get_compression_format(void);//获取支持的压缩格式 ***功能不支持 - - virtual int get_roller_num(void); //获取滚轮张数 ***完成 - virtual int clear_roller_num(void); // 清除滚轴计数 ***完成 - - virtual int set_compression_format(void);//设置图像数据最终输出的压缩格式 ***功能不支持 - virtual int set_auto_color_type(void);// 设置自动匹配颜色模式 (基类实现) ***完成 - - virtual std::string get_firmware_version(void); - virtual std::string get_serial_num(void); - virtual std::string get_ip(void); - - virtual int get_device_code(void);//获取设备编码 - virtual int get_sleep_time(int& getime);//获取功耗模式(休眠) - virtual int set_sleep_time(int setsleepime);//设置功耗模式(休眠) - - virtual int get_dogear_distance(void);//获取折角检测最小距离阈值 - virtual int set_dogear_distance(void);// 设置折角检测最小距离阈值 + virtual int get_compression_format(void); //获取支持的压缩格式 + virtual int get_roller_num(int &val); //获取滚轮张数 + virtual int clear_roller_num(void); //清除滚轴计数 + virtual int set_compression_format(void); //设置图像数据最终输出的压缩格式 ***功能不支持 + virtual int set_auto_color_type(void); //设置自动匹配颜色模式 (基类实现) ***完成 + virtual int get_device_code(void); //获取设备编码 + virtual int get_sleep_time(int& getime); //获取功耗模式(休眠) + virtual int set_sleep_time(int setsleepime); //设置功耗模式(休眠) + virtual int get_dogear_distance(void); //获取折角检测最小距离阈值 + virtual int set_dogear_distance(void); //设置折角检测最小距离阈值 virtual int get_scanner_paperon(SANE_Bool* paperon = NULL);//获取设备有无纸张 - virtual int set_scan_when_paper_on(void);//获取是否为检测到进纸盘上有纸即开始扫描 - virtual int get_scan_when_paper_on(void);//设置是否为检测到进纸盘上有纸即开始扫描 - virtual int get_scan_with_hole(void);// 获取是否为带孔扫描 - virtual int set_scan_with_hole(void);// 设置是否为带孔扫描 - - virtual int get_scan_is_sleep(void);//获取设备是否休眠当中 - - virtual int notify_sleep(void);//唤醒设备 - virtual int get_history_count(int &num);//获取历史扫描张数 -2:设备不支持该功能;-1:与设备通信失败;其它大于等于0的为正常 为实现 - virtual int get_device_log(string &get_device_log);//获取设备日志 - virtual int set_devreboot();//设置设备重启 - virtual int set_devshtudown();//设置设备关机 + virtual int set_scan_when_paper_on(void); //获取是否为检测到进纸盘上有纸即开始扫描 + virtual int get_scan_when_paper_on(void); //设置是否为检测到进纸盘上有纸即开始扫描 + virtual int get_scan_with_hole(void); //获取是否为带孔扫描 + virtual int set_scan_with_hole(void); //设置是否为带孔扫描 + virtual int get_scan_is_sleep(int &status); //获取设备是否休眠当中 + virtual int notify_sleep(void); //唤醒设备 + virtual int get_history_roller_count(int &num); //获取历史扫描张数 + virtual int get_device_log(string &get_device_log); //获取设备日志 + virtual int set_devreboot(); //设置设备重启 + virtual int set_devshtudown(); //设置设备关机 virtual int set_scan_islock(SANE_Bool set_islock); - virtual int get_scan_islock(SANE_Bool* islock); + virtual int get_scan_islock(SANE_Bool& islock); virtual int set_scan_lock_check_val(string check_str); virtual int firmware_upgrade(std::string filename); - virtual int clean_paper_road(); //清理纸道 -2:设备不支持该功能;它大于等于0的为正常 + virtual int clean_paper_road(); //清理纸道 }; diff --git a/hgdriver/hgdev/hg_scanner_302.cpp b/hgdriver/hgdev/hg_scanner_302.cpp index c23cd00..e71a027 100644 --- a/hgdriver/hgdev/hg_scanner_302.cpp +++ b/hgdriver/hgdev/hg_scanner_302.cpp @@ -1571,7 +1571,7 @@ int hg_scanner_302::get_roller_num(void) else { VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "get_roller_num = %s\n", hg_scanner_err_name(ret)); - return -2; + return SCANNER_ERR_DEVICE_NOT_SUPPORT; } // return -2; } diff --git a/hgdriver/hgdev/scanner_manager.cpp b/hgdriver/hgdev/scanner_manager.cpp index 4bc392c..7d92f30 100644 --- a/hgdriver/hgdev/scanner_manager.cpp +++ b/hgdriver/hgdev/scanner_manager.cpp @@ -484,7 +484,7 @@ scanner_err hg_scanner_mgr::get_about_info(scanner_handle h, void* data, unsigne memcpy(ptr, g_logo, about->logo_bytes); ptr += about->logo_bytes + 1; - int count = 0, rolls = 0; + int count = 0, rolls = 0, ret = SCANNER_ERR_OK; set_appendix_info_for_about(about, ptr, count, BRAND_TITE_MANUFACTOR, g_vendor.c_str(), NULL); set_appendix_info_for_about(about, ptr, count, BRAND_TITLE_URL, BRAND_COMPANY_URL, BRAND_URL_COMPANY_URL); @@ -499,8 +499,8 @@ scanner_err hg_scanner_mgr::get_about_info(scanner_handle h, void* data, unsigne info = scanner->get_ip(); if(info.length()) set_appendix_info_for_about(about, ptr, count, BRAND_TITLE_IP, info.c_str(), NULL); - rolls = scanner->get_roller_num(); - if (rolls >= 0) + ret = scanner->get_roller_num(rolls); + if (ret == SCANNER_ERR_OK) { char buf[40]; sprintf(buf, "%u", rolls); @@ -511,8 +511,8 @@ scanner_err hg_scanner_mgr::get_about_info(scanner_handle h, void* data, unsigne set_appendix_info_for_about(about, ptr, count, BRAND_TITLE_ROLLER_COUNT, rolls == -1 ? BRAND_COMMUNICATION_FAIL : BRAND_DEVICE_NOT_SUPPORT, NULL); #endif - rolls = scanner->get_history_count(); - if (rolls >= 0) + ret = scanner->get_history_roller_count(rolls); + if (ret == SCANNER_ERR_OK) { char buf[40]; sprintf(buf, "%u", rolls); diff --git a/hgsane/sane_hg_mdw.cpp b/hgsane/sane_hg_mdw.cpp index 1353359..5e16b79 100644 --- a/hgsane/sane_hg_mdw.cpp +++ b/hgsane/sane_hg_mdw.cpp @@ -951,7 +951,7 @@ SANE_Option_Descriptor* hg_sane_middleware::from_json(scanner_handle h, const st // initializing status ... if (so.master.size()) { - std::string master(get_option_json(h, (unsigned long)so.master[0].name.c_str())); + std::string master(get_option_json(h, (void *)so.master[0].name.c_str())); json* m = new json(); if (m->attach_text(&master[0])) { @@ -993,7 +993,7 @@ scanner_handle hg_sane_middleware::find_openning_device(SANE_Handle h, bool rmv, return handle; } -std::string hg_sane_middleware::get_option_json(scanner_handle handle, unsigned long opt, std::string* key) +std::string hg_sane_middleware::get_option_json(scanner_handle handle, void *opt, std::string* key) { char* json_txt = NULL; long length = 0; @@ -1036,6 +1036,7 @@ std::string hg_sane_middleware::get_option_json(scanner_handle handle, unsigned } SANE_Option_Descriptor* hg_sane_middleware::find_stored_descriptor(const char* name, unsigned long option) { + if (IS_PTR_NUMBER(option)) { for (const auto& v : opts_) @@ -1076,7 +1077,7 @@ void hg_sane_middleware::reload_current_value(scanner_handle handle, std::vector for (int i = 1; i < count; ++i) { std::string key(""), - val(get_option_json(handle, i, &key)); + val(get_option_json(handle, (void *)i, &key)); json* jsn = new json(); if (jsn->attach_text(&val[0]) && jsn->get_value("type", val)) @@ -1090,7 +1091,7 @@ void hg_sane_middleware::reload_current_value(scanner_handle handle, std::vector bool hg_sane_middleware::get_current_value(scanner_handle handle, int option, void* value, SANE_Value_Type* type) { std::string name(""), - val(get_option_json(handle, option, &name)); + val(get_option_json(handle, (void *)option, &name)); json* jsn = new json(); int estimate = 20; bool ret = false; @@ -1145,7 +1146,7 @@ bool hg_sane_middleware::get_current_value(scanner_handle handle, int option, vo } void* hg_sane_middleware::get_default_value(scanner_handle handle, int option, int* bytes, bool log) { - std::string val(get_option_json(handle, option)); + std::string val(get_option_json(handle, (void *)option)); void* data = nullptr; json* jsn = new json(); @@ -1373,11 +1374,11 @@ SANE_Option_Descriptor* hg_sane_middleware::get_option_descriptor(SANE_Handle h, return opt_0_; } - ret = find_stored_descriptor(dev.dev_name.c_str(), option); + ret = find_stored_descriptor(dev.dev_name.c_str(),option); if (!ret) { std::string key(""), - json_txt(get_option_json(handle, option, &key)); + json_txt(get_option_json(handle, (SANE_Int*)option, &key)); if (json_txt.length()) { diff --git a/hgsane/sane_hg_mdw.h b/hgsane/sane_hg_mdw.h index 1cebd70..1dafea1 100644 --- a/hgsane/sane_hg_mdw.h +++ b/hgsane/sane_hg_mdw.h @@ -77,7 +77,7 @@ class hg_sane_middleware SANE_Status open(SANE_String_Const devicename, SANE_Handle* handle, const char* name, const char* pwd, const char* method, char* rsc); SANE_Option_Descriptor* from_json(scanner_handle h, const std::string& name, json* jsn, int opt_no); scanner_handle find_openning_device(SANE_Handle h, bool rmv = false, OPENDEV* dev = NULL); - std::string get_option_json(scanner_handle handle, unsigned long opt, std::string* key = nullptr); + std::string get_option_json(scanner_handle handle, void* opt, std::string* key = nullptr); SANE_Option_Descriptor* find_stored_descriptor(const char* name, unsigned long option); SANE_Option_Descriptor* find_stored_descriptor(SANE_Handle handle, unsigned long option); @@ -192,7 +192,7 @@ public: void* get_def_value(SANE_Handle handle, int option, int* bytes = nullptr, bool log = false); // caller should call local_utility::free_memory to free the returned value, SANE_type // extension ... - SANE_Status io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len); + SANE_Status io_control(SANE_Handle h, unsigned long code, void* data, unsigned* len); public: };