300d8设备日志,固件0430之后的直接从片上读取文件,不用协议

This commit is contained in:
yangjiaxuan 2023-11-03 09:44:27 +08:00
parent 5c19147246
commit 8aebb9c4eb
3 changed files with 93 additions and 45 deletions

View File

@ -159,7 +159,7 @@ hg_scanner::hg_scanner(ScannerSerial serial, const char* dev_name, usb_io* io, i
, is_dpi_color_check(false), save_dpi_color_check_val(0.0f), is_auto_falt(false), HGVersion_mgr_(NULL), HGVersion_Init_(NULL)
, HGVersion_Islock_(NULL), HGVersion_Postlog_(NULL), HGVersion_Free_(NULL), Dynamicopen_HGVersion_pHandle_(NULL), pid_(pid), fetching_id_(-1), color_correction_(false)
, is_auto_paper_scan_exit_time(60), is_read_int(true), is_auto_feedmode_(false)
, firmware_sup_wait_paper_(false),firmware_sup_pick_strength_(false),firmware_sup_log_export_(false),firmware_sup_color_corr_(false),firmware_sup_wake_device_(false)
, firmware_sup_wait_paper_(false),firmware_sup_pick_strength_(false),firmware_sup_log_export_(false), firmware_sup_log_export_G300_(false),firmware_sup_color_corr_(false),firmware_sup_wake_device_(false)
, firmware_sup_double_img(false),firmware_sup_devs_lock_(false),firmware_sup_dpi_300(false),firmware_sup_dpi_600(false),firmware_sup_auto_speed_(false),firmware_sup_morr_(false)
, firmware_sup_color_fill_(false),firmware_sup_history_cnt(false), have_max_size(false), is_discardblank(false),firmware_sup_device_7010(false), firmware_sup_double_check(false)
, firmware_sup_dirty_check(false)

View File

@ -383,6 +383,7 @@ protected:
bool firmware_sup_wait_paper_; //固件支持 待纸扫描 139 239-3B0431, 439-3B0629
bool firmware_sup_pick_strength_; //固件支持 分纸强度 139 239-3B0830
bool firmware_sup_log_export_; //固件支持 日志导出 139 239-3B0429
bool firmware_sup_log_export_G300_; //固件支持 不用协议,直接读片上文件,设备日志导出 300 - 0430
bool firmware_sup_color_corr_; //固件支持 偏色校正 139 239 439-3C
bool firmware_sup_wake_device_; //固件支持 唤醒设备 139 239-3B0830
bool firmware_sup_double_img; //固件支持 双张保留 139 239-3C

View File

@ -111,6 +111,7 @@ hg_scanner_300::hg_scanner_300(const char* dev_name,int pid, usb_io* io) :
firmware_sup_backup_restore = year_date.compare("231021") >= 0 ? true : false;
firmware_sup_boardTime = year_date.compare("231021") >= 0 ? true : false;
firmware_sup_double_img = year_date.compare("231027") >= 0 ? true : false;
firmware_sup_log_export_G300_ = year_date.compare("230430") >= 0 ? true : false;
#ifndef MAPPING_FUNCTION_IN_BASE
init_setting_map(setting_map_, ARRAY_SIZE(setting_map_));//优先初始化
@ -1253,6 +1254,51 @@ int hg_scanner_300::on_get_feedmode(int &feedmode)
}
int hg_scanner_300::get_device_log(string &log)
{
if (firmware_sup_log_export_G300_)
{
std::string src_name = "/var/log/syslog";
std::string save_path = hg_log::temporary_path() + PATH_SEPARATOR + "device.log";
USBCB usbcb = { 0 };
usbcb.u32_CMD = 0x301;
usbcb.u32_Count = src_name.length();
int len = src_name.length();
int size = sizeof(usbcb);
int ret = io_->write_bulk(&usbcb, &size);
ret = io_->write_bulk(&src_name[0], &len);
usbcb.u32_CMD = 0x300;
ret = io_->write_bulk(&usbcb, &size);
ret = io_->read_bulk(&usbcb, &size);
ofstream out(save_path);
usbcb.u32_CMD = 0x302;
ret = io_->write_bulk(&usbcb, &size);
int touch = 0;
std::string buff;
int bufsize = usbcb.u32_Count < 512 * 1024 ? usbcb.u32_Count : 512 * 1024;
buff.resize(bufsize);
while (touch < usbcb.u32_Count)
{
ret = io_->read_bulk(&buff[0], &bufsize);
if (SCANNER_ERR_OK != ret)
return ret;
out.write(&buff[0], bufsize);
touch += bufsize;
bufsize = bufsize > usbcb.u32_Count - touch ? usbcb.u32_Count - touch : bufsize;
}
out.close();
ofstream f;
f.open(save_path, ios::out | ios::trunc);
if (!f.is_open())
return SCANNER_ERR_CREATE_FILE_FAILED;
f << buff << endl;
f.close();
log = save_path;
}
else
{
int ret = SCANNER_ERR_OK,
len = 0;
string save_path = hg_log::temporary_path() + PATH_SEPARATOR + "device.log";
@ -1307,6 +1353,7 @@ int hg_scanner_300::get_device_log(string &log)
f << str << endl;
f.close();
log = save_path;
}
return SCANNER_ERR_OK;
}