调整G402流程
This commit is contained in:
parent
24f057d15f
commit
0e51486c14
|
@ -726,7 +726,28 @@ bool tiny_buffer::swap(void)
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
int tiny_buffer::to_file(const char* file)
|
||||||
|
{
|
||||||
|
FILE* dst = fopen(file, "wb");
|
||||||
|
|
||||||
|
if (!dst)
|
||||||
|
return errno;
|
||||||
|
|
||||||
|
unsigned int off = 0, len = size_;
|
||||||
|
unsigned char* buf = data(off, &len);
|
||||||
|
while (buf)
|
||||||
|
{
|
||||||
|
fwrite(buf, 1, len, dst);
|
||||||
|
off += len;
|
||||||
|
if (off >= size_)
|
||||||
|
break;
|
||||||
|
len = size_ - off;
|
||||||
|
buf = data(off, &len);
|
||||||
|
}
|
||||||
|
fclose(dst);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
// final_img_queue
|
// final_img_queue
|
||||||
|
|
|
@ -199,6 +199,7 @@ public:
|
||||||
|
|
||||||
// mapping if unmapped; or unmapping if mapped
|
// mapping if unmapped; or unmapping if mapped
|
||||||
bool swap(void);
|
bool swap(void);
|
||||||
|
int to_file(const char* file);
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _img_header
|
typedef struct _img_header
|
||||||
|
|
|
@ -1195,6 +1195,11 @@ int hg_scanner_402::read_one_image_from_usb(void)
|
||||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Read image from USB = %s\n", hg_scanner_err_name(ret));
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Read image from USB = %s\n", hg_scanner_err_name(ret));
|
||||||
if (ret == SCANNER_ERR_OK)
|
if (ret == SCANNER_ERR_OK)
|
||||||
{
|
{
|
||||||
|
//{
|
||||||
|
// char f[128] = { 0 };
|
||||||
|
// sprintf(f, "/tmp/usb_%02d.jpg", usb_img_index_);
|
||||||
|
// buf->to_file(f);
|
||||||
|
//}
|
||||||
ret = save_usb_data(buf);
|
ret = save_usb_data(buf);
|
||||||
if (ret == SCANNER_ERR_OK)
|
if (ret == SCANNER_ERR_OK)
|
||||||
{
|
{
|
||||||
|
@ -1516,6 +1521,7 @@ void hg_scanner_402::thread_handle_usb_read(void)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
size = sizeof(buf);
|
size = sizeof(buf);
|
||||||
|
memset(buf, 0, size);
|
||||||
{
|
{
|
||||||
std::lock_guard<std::mutex> lock(io_lock_);
|
std::lock_guard<std::mutex> lock(io_lock_);
|
||||||
|
|
||||||
|
@ -1626,11 +1632,18 @@ int hg_scanner_402::start(void)
|
||||||
|
|
||||||
reset();
|
reset();
|
||||||
get_roller_num();
|
get_roller_num();
|
||||||
|
read_register(SR_GET_PAPERON, &val);
|
||||||
|
if (!val)
|
||||||
|
{
|
||||||
|
VLOG_MINI_1(LOG_LEVEL_WARNING, "start failed: %s\n", hg_scanner_err_name(SCANNER_ERR_DEVICE_NO_PAPER));
|
||||||
|
return SCANNER_ERR_DEVICE_NO_PAPER;
|
||||||
|
}
|
||||||
notify_ui_working_status(STATU_DESC_REWRITE_CONFIGURATION);
|
notify_ui_working_status(STATU_DESC_REWRITE_CONFIGURATION);
|
||||||
writedown_device_configuration();
|
writedown_device_configuration();
|
||||||
writedown_image_configuration();
|
writedown_image_configuration();
|
||||||
|
val = 0;
|
||||||
ret = read_register(/*SR_GET_ANDROID_STATE*/0x1001, &val);
|
ret = read_register(/*SR_GET_ANDROID_STATE*/0x1001, &val);
|
||||||
if (val)
|
while (val)
|
||||||
{
|
{
|
||||||
if (val == 1)
|
if (val == 1)
|
||||||
ret = status_ = SCANNER_ERR_DEVICE_COVER_OPENNED;
|
ret = status_ = SCANNER_ERR_DEVICE_COVER_OPENNED;
|
||||||
|
@ -1639,9 +1652,12 @@ int hg_scanner_402::start(void)
|
||||||
else if (val == 3)
|
else if (val == 3)
|
||||||
ret = status_ = SCANNER_ERR_DEVICE_NO_PAPER;
|
ret = status_ = SCANNER_ERR_DEVICE_NO_PAPER;
|
||||||
else
|
else
|
||||||
ret = status_ = SCANNER_ERR_IO;
|
{
|
||||||
|
VLOG_MINI_2(LOG_LEVEL_WARNING, "consider as success on SR_GET_ANDROID_STATE(%d) result: %s\n", val, hg_scanner_err_name(ret));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
VLOG_MINI_1(LOG_LEVEL_WARNING, "SR_GET_ANDROID_STATE result: %s\n", hg_scanner_err_name(ret));
|
VLOG_MINI_2(LOG_LEVEL_WARNING, "failed on SR_GET_ANDROID_STATE(%d) result: %s\n", val, hg_scanner_err_name(ret));
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
write_register(0x1000, scan_count_);
|
write_register(0x1000, scan_count_);
|
||||||
|
@ -1678,7 +1694,7 @@ int hg_scanner_402::stop(void)
|
||||||
int hg_scanner_402::reset(void)
|
int hg_scanner_402::reset(void)
|
||||||
{
|
{
|
||||||
final_imgs_.clear();
|
final_imgs_.clear();
|
||||||
//discard_all_images();
|
discard_all_images();
|
||||||
|
|
||||||
return status_;
|
return status_;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue