Merge branch 'master' of http://192.168.100.140:8099/sane/code_device
This commit is contained in:
commit
be2b831795
|
@ -98,10 +98,15 @@ hg_scanner::hg_scanner(ScannerSerial serial
|
||||||
, double_paper_handle_(0), keep_watermark_(false), save_feedmode_type_(false), feedmode_(1), sleeptime_(-1),split3399_(0)
|
, double_paper_handle_(0), keep_watermark_(false), save_feedmode_type_(false), feedmode_(1), sleeptime_(-1),split3399_(0)
|
||||||
, async_io_(false), is_white_0_(true), isremove_left_hole(false), isremove_right_hole(false), isremove_top_hole(false), isremove_low_hole(false)
|
, async_io_(false), is_white_0_(true), isremove_left_hole(false), isremove_right_hole(false), isremove_top_hole(false), isremove_low_hole(false)
|
||||||
, isremove_left_hole_threshold(0), isremove_right_hole_threshold(0), isremove_top_hole_threshold(0), isremove_low_hole_threshold(0)
|
, isremove_left_hole_threshold(0), isremove_right_hole_threshold(0), isremove_top_hole_threshold(0), isremove_low_hole_threshold(0)
|
||||||
|
, dump_usb_path_("")
|
||||||
{
|
{
|
||||||
final_path_ = hg_log::ini_get("paths", "final_img");
|
final_path_ = hg_log::ini_get("paths", "final_img");
|
||||||
if(final_path_.empty())
|
if(final_path_.empty())
|
||||||
final_path_ = hg_log::local_data_path() + PATH_SEPARATOR + "imgs";
|
final_path_ = hg_log::local_data_path() + PATH_SEPARATOR + "imgs";
|
||||||
|
if (hg_log::ini_get("dump", "dumpusb") == "1")
|
||||||
|
{
|
||||||
|
dump_usb_path_ = hg_log::ini_get("dump", "usb_path");
|
||||||
|
}
|
||||||
if (hg_log::create_folder(final_path_.c_str()))
|
if (hg_log::create_folder(final_path_.c_str()))
|
||||||
{
|
{
|
||||||
VLOG_MINI_1(LOG_LEVEL_WARNING, "temporary image folder: %s\n", final_path_.c_str());
|
VLOG_MINI_1(LOG_LEVEL_WARNING, "temporary image folder: %s\n", final_path_.c_str());
|
||||||
|
@ -2270,9 +2275,32 @@ void hg_scanner::copy_to_sane_image_header(SANE_Parameters* header, int w, int h
|
||||||
int hg_scanner::save_usb_data(std::shared_ptr<tiny_buffer> data)
|
int hg_scanner::save_usb_data(std::shared_ptr<tiny_buffer> data)
|
||||||
{
|
{
|
||||||
int ret = SCANNER_ERR_OK;
|
int ret = SCANNER_ERR_OK;
|
||||||
|
unsigned int bytes = data->size();
|
||||||
|
|
||||||
usb_img_index_++;
|
usb_img_index_++;
|
||||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "USB read one picture with %u bytes\n", data->size());
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "USB read one picture with %u bytes\n", data->size());
|
||||||
|
if (dump_usb_path_.length())
|
||||||
|
{
|
||||||
|
char name[80] = { 0 };
|
||||||
|
FILE* dst = nullptr;
|
||||||
|
|
||||||
|
sprintf(name, "%susb_img_%03u.jpg", PATH_SEPARATOR, usb_img_index_);
|
||||||
|
if ((dst = fopen((dump_usb_path_ + name).c_str(), "wb")))
|
||||||
|
{
|
||||||
|
unsigned int off = 0, len = bytes;
|
||||||
|
unsigned char* buf = data->data(off, &len);
|
||||||
|
while (buf)
|
||||||
|
{
|
||||||
|
fwrite(buf, 1, len, dst);
|
||||||
|
off += len;
|
||||||
|
if (off >= bytes)
|
||||||
|
break;
|
||||||
|
len = bytes - off;
|
||||||
|
buf = data->data(off, &len);
|
||||||
|
}
|
||||||
|
fclose(dst);
|
||||||
|
}
|
||||||
|
}
|
||||||
if (!data->swap())
|
if (!data->swap())
|
||||||
{
|
{
|
||||||
ret = SCANNER_ERR_OPEN_FILE_FAILED;
|
ret = SCANNER_ERR_OPEN_FILE_FAILED;
|
||||||
|
@ -2283,10 +2311,7 @@ int hg_scanner::save_usb_data(std::shared_ptr<tiny_buffer> data)
|
||||||
if (wait_img_.is_waiting())
|
if (wait_img_.is_waiting())
|
||||||
wait_img_.notify();
|
wait_img_.notify();
|
||||||
}
|
}
|
||||||
unsigned int bytes = data->size();
|
|
||||||
//int type = io_->get_pid() & 0x0ff;
|
|
||||||
|
|
||||||
//if(type != 0x39 || (usb_img_index_ & 1))
|
|
||||||
if((serial_ != G10039Serial && serial_ != G20039Serial) || (usb_img_index_ & 1))
|
if((serial_ != G10039Serial && serial_ != G20039Serial) || (usb_img_index_ & 1))
|
||||||
ui_ev_cb_((scanner_handle)this, SANE_EVENT_USB_DATA_RECEIVED, NULL, &bytes, NULL);
|
ui_ev_cb_((scanner_handle)this, SANE_EVENT_USB_DATA_RECEIVED, NULL, &bytes, NULL);
|
||||||
|
|
||||||
|
|
|
@ -256,6 +256,7 @@ protected:
|
||||||
SCANCONF img_conf_; //此参数外部不做任何改变,请在writedown_image_configuration做修改
|
SCANCONF img_conf_; //此参数外部不做任何改变,请在writedown_image_configuration做修改
|
||||||
std::string img_type_;
|
std::string img_type_;
|
||||||
|
|
||||||
|
std::string dump_usb_path_; // 诊断模式,输出USB原始图像
|
||||||
final_img_queue final_imgs_; // JPG ...
|
final_img_queue final_imgs_; // JPG ...
|
||||||
unsigned int usb_img_index_;
|
unsigned int usb_img_index_;
|
||||||
unsigned int final_img_index_;
|
unsigned int final_img_index_;
|
||||||
|
|
|
@ -533,7 +533,7 @@ extern "C"
|
||||||
}
|
}
|
||||||
static int get_log_config(const std::string& root, hg_log_type* type, std::string* path)
|
static int get_log_config(const std::string& root, hg_log_type* type, std::string* path)
|
||||||
{
|
{
|
||||||
std::string me(root + PATH_SEPARATOR + "Cfg" + PATH_SEPARATOR + " scanner.conf");
|
std::string me(root + PATH_SEPARATOR + "config" + PATH_SEPARATOR + "debug.cfg");
|
||||||
int lv = LOG_LEVEL_ALL;
|
int lv = LOG_LEVEL_ALL;
|
||||||
hg_log_type tp = LOG_TYPE_FILE;
|
hg_log_type tp = LOG_TYPE_FILE;
|
||||||
|
|
||||||
|
@ -564,7 +564,7 @@ extern "C"
|
||||||
lv = LOG_LEVEL_FATAL;
|
lv = LOG_LEVEL_FATAL;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
create_folder((root + PATH_SEPARATOR + "Cfg").c_str());
|
create_folder((root + PATH_SEPARATOR + "config").c_str());
|
||||||
|
|
||||||
return lv;
|
return lv;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue