添加memory hook
This commit is contained in:
parent
79942f5b4c
commit
6104c9dcdd
|
@ -1164,5 +1164,39 @@
|
||||||
"max": 200,
|
"max": 200,
|
||||||
"step": 1
|
"step": 1
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
"phase-f": {
|
||||||
|
"cat": "none",
|
||||||
|
"group": "CIS",
|
||||||
|
"title": "正面相位",
|
||||||
|
"desc": "CIS正面分段之间的相位差",
|
||||||
|
"type": "int",
|
||||||
|
"ui-pos": 26,
|
||||||
|
"auth": 0,
|
||||||
|
"size": 4,
|
||||||
|
"cur": 66,
|
||||||
|
"default": 66,
|
||||||
|
"range": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 256,
|
||||||
|
"step": 1
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"phase-b": {
|
||||||
|
"cat": "none",
|
||||||
|
"group": "CIS",
|
||||||
|
"title": "背面相位",
|
||||||
|
"desc": "CIS背面分段之间的相位差",
|
||||||
|
"type": "int",
|
||||||
|
"ui-pos": 27,
|
||||||
|
"auth": 0,
|
||||||
|
"size": 4,
|
||||||
|
"cur": 67,
|
||||||
|
"default": 67,
|
||||||
|
"range": {
|
||||||
|
"min": 0,
|
||||||
|
"max": 256,
|
||||||
|
"step": 1
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -165,7 +165,7 @@ void* GVideoISP1::read_frame(int timeout, size_t& size, int& ind) {
|
||||||
// }
|
// }
|
||||||
ind = buf.index;
|
ind = buf.index;
|
||||||
size = buffers[ind].length;
|
size = buffers[ind].length;
|
||||||
utils::to_log(LOG_LEVEL_DEBUG, "\tvideo buf[%d] = %d\n", ind, size);
|
utils::to_log(LOG_LEVEL_DEBUG, "\tvideo buf[%d] = %p + %d\n", ind, buffers[ind].start, size);
|
||||||
|
|
||||||
return buffers[ind].start;
|
return buffers[ind].start;
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because one or more lines are too long
|
@ -72,6 +72,8 @@ class scanner_hw : public sane_opt_provider
|
||||||
int frame_h_ = 12;
|
int frame_h_ = 12;
|
||||||
int sample_ = 201; // 256;
|
int sample_ = 201; // 256;
|
||||||
int sp_ = 816;
|
int sp_ = 816;
|
||||||
|
int vsp_a_ = 66;
|
||||||
|
int vsp_b_ = 67;
|
||||||
int exposure_[SIDE_COUNT][COLOR_IND_COUNT];
|
int exposure_[SIDE_COUNT][COLOR_IND_COUNT];
|
||||||
int gain_[SIDE_COUNT][CIS_SECTOR_COUNT];
|
int gain_[SIDE_COUNT][CIS_SECTOR_COUNT];
|
||||||
int off_[SIDE_COUNT][CIS_SECTOR_COUNT];
|
int off_[SIDE_COUNT][CIS_SECTOR_COUNT];
|
||||||
|
@ -120,5 +122,7 @@ public:
|
||||||
int start_scan(void);
|
int start_scan(void);
|
||||||
int stop_scan(void);
|
int stop_scan(void);
|
||||||
int close(bool from_worker = false);
|
int close(bool from_worker = false);
|
||||||
|
int trans_motorboard_err_2_hg_error(int mberr);
|
||||||
|
int hg_err_2_image_status(int hgerr);
|
||||||
bool is_scanning(void);
|
bool is_scanning(void);
|
||||||
};
|
};
|
||||||
|
|
|
@ -437,15 +437,15 @@ namespace hg
|
||||||
long total = dataFile.total();
|
long total = dataFile.total();
|
||||||
int step = total / 256;
|
int step = total / 256;
|
||||||
|
|
||||||
int channel = 1;
|
int channel = 408; // 1;
|
||||||
#ifndef USE_NEWFLAT
|
// #ifndef USE_NEWFLAT
|
||||||
if (step == 4896 || step == 7344 )
|
// if (step == 4896 || step == 7344 )
|
||||||
channel = 408;
|
// channel = 408;
|
||||||
else if (step == 14688 ||step== 22032 || step == 44064)
|
// else if (step == 14688 ||step== 22032 || step == 44064)
|
||||||
channel = 432; //486
|
// channel = 432; //486
|
||||||
#else
|
// #else
|
||||||
channel = 408;
|
// channel = 408;
|
||||||
#endif
|
// #endif
|
||||||
cv::Mat lut(step / channel, 256, CV_8UC(channel));
|
cv::Mat lut(step / channel, 256, CV_8UC(channel));
|
||||||
memcpy(lut.data, dataFile.data, total);
|
memcpy(lut.data, dataFile.data, total);
|
||||||
return lut;
|
return lut;
|
||||||
|
|
|
@ -68,7 +68,7 @@ void auto_crop::init(void)
|
||||||
{
|
{
|
||||||
OPTION_FUNC(deskew)
|
OPTION_FUNC(deskew)
|
||||||
{
|
{
|
||||||
deskew_ = *(bool*)val;
|
enabled_ = deskew_ = *(bool*)val;
|
||||||
};
|
};
|
||||||
OPTION_FUNC(bg)
|
OPTION_FUNC(bg)
|
||||||
{
|
{
|
||||||
|
|
|
@ -35,16 +35,22 @@ int color_correct::set_value(const char* name/*nullptr for all options*/, void*
|
||||||
int ret = SCANNER_ERR_OK;
|
int ret = SCANNER_ERR_OK;
|
||||||
|
|
||||||
if(strcmp(name, SANE_FULL_NAME(COLOR_CORRECT)) == 0)
|
if(strcmp(name, SANE_FULL_NAME(COLOR_CORRECT)) == 0)
|
||||||
correct_ = *(bool*)val;
|
enabled_ = correct_ = *(bool*)val;
|
||||||
else if(strcmp(name, SANE_FULL_NAME(LUT_FILE)) == 0)
|
else if(strcmp(name, SANE_FULL_NAME(LUT_FILE)) == 0)
|
||||||
{
|
{
|
||||||
lut_path_ = (char*)val;
|
if(lut_path_ != (char*)val)
|
||||||
hg::initLut(lut_path_.c_str(), clr_);
|
{
|
||||||
|
lut_path_ = (char*)val;
|
||||||
|
hg::initLut(lut_path_.c_str(), clr_);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if(strcmp(name, SANE_FULL_NAME(CIS_MODE)) == 0)
|
else if(strcmp(name, SANE_FULL_NAME(CIS_MODE)) == 0)
|
||||||
{
|
{
|
||||||
|
bool pre = clr_;
|
||||||
|
|
||||||
clr_ = strcmp((char*)val, WORDS_COLOR_COLOR) == 0;
|
clr_ = strcmp((char*)val, WORDS_COLOR_COLOR) == 0;
|
||||||
hg::initLut(lut_path_.c_str(), clr_);
|
if(pre != clr_)
|
||||||
|
hg::initLut(lut_path_.c_str(), clr_);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
ret = SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
ret = SCANNER_ERR_DEVICE_NOT_SUPPORT;
|
||||||
|
|
|
@ -123,7 +123,7 @@ void imgproc_mgr::process(RAWIMG* img)
|
||||||
{
|
{
|
||||||
if(img->img)
|
if(img->img)
|
||||||
{
|
{
|
||||||
std::vector<PROCIMGINFO> in, out;
|
std::vector<PROCIMGINFO> in, out, *src = &in, *dst = &out, *swp = nullptr;
|
||||||
chronograph watch;
|
chronograph watch;
|
||||||
|
|
||||||
rebuild_->do_rebuild(&img->info, img->data->ptr(), in);
|
rebuild_->do_rebuild(&img->info, img->data->ptr(), in);
|
||||||
|
@ -133,13 +133,17 @@ void imgproc_mgr::process(RAWIMG* img)
|
||||||
{
|
{
|
||||||
send_image(&img->info, img->data->ptr(), img->info.width * img->info.height);
|
send_image(&img->info, img->data->ptr(), img->info.width * img->info.height);
|
||||||
img->data->release();
|
img->data->release();
|
||||||
|
|
||||||
for(auto& v: processors_)
|
for(auto& v: processors_)
|
||||||
{
|
{
|
||||||
send_image(in, false);
|
send_image(*src, false);
|
||||||
if(v->is_enable())
|
if(v->is_enable())
|
||||||
{
|
{
|
||||||
v->process(in, out);
|
v->process(*src, *dst);
|
||||||
in = std::move(out);
|
src->clear();
|
||||||
|
swp = src;
|
||||||
|
src = dst;
|
||||||
|
dst = swp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -150,8 +154,11 @@ void imgproc_mgr::process(RAWIMG* img)
|
||||||
{
|
{
|
||||||
if(v->is_enable())
|
if(v->is_enable())
|
||||||
{
|
{
|
||||||
v->process(in, out);
|
v->process(*src, *dst);
|
||||||
in = std::move(out);
|
src->clear();
|
||||||
|
swp = src;
|
||||||
|
src = dst;
|
||||||
|
dst = swp;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
uint32_t t = watch.elapse_ms();
|
uint32_t t = watch.elapse_ms();
|
||||||
|
@ -159,7 +166,7 @@ void imgproc_mgr::process(RAWIMG* img)
|
||||||
v.info.prc_time = t;
|
v.info.prc_time = t;
|
||||||
}
|
}
|
||||||
|
|
||||||
send_image(in, true);
|
send_image(*src, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -180,11 +187,23 @@ void imgproc_mgr::process(RAWIMG* img)
|
||||||
}
|
}
|
||||||
void imgproc_mgr::send_image(LPPACKIMAGE head, uint8_t* data, size_t size, void* info, size_t info_l)
|
void imgproc_mgr::send_image(LPPACKIMAGE head, uint8_t* data, size_t size, void* info, size_t info_l)
|
||||||
{
|
{
|
||||||
|
auto ovr = [&](uint64_t total, uint64_t cur_size, uint32_t err, void* user_data) -> int
|
||||||
|
{
|
||||||
|
if(total == FINAL_NOTIFY && cur_size == FINAL_NOTIFY)
|
||||||
|
printf("~%p\n", user_data);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
};
|
||||||
|
|
||||||
dyn_mem_ptr mem(dyn_mem::memory(size));
|
dyn_mem_ptr mem(dyn_mem::memory(size));
|
||||||
image_packet_ptr ptr = nullptr;
|
image_packet_ptr ptr = nullptr;
|
||||||
|
|
||||||
|
// mem->set_progress_notify(ovr, mem);
|
||||||
mem->put(data, size);
|
mem->put(data, size);
|
||||||
ptr = imgproc_mgr::image_sent_packet(head, mem, scan_id_, info, info_l);
|
ptr = imgproc_mgr::image_sent_packet(head, mem, scan_id_, info, info_l);
|
||||||
|
// ptr->set_progress_notify(ovr, ptr);
|
||||||
|
// printf("+dyn_mem(%p)\n+image_packet(%p)\n", mem, ptr);
|
||||||
|
|
||||||
mem->release();
|
mem->release();
|
||||||
ptr->set_session_id(session_id_);
|
ptr->set_session_id(session_id_);
|
||||||
img_sender_(ptr);
|
img_sender_(ptr);
|
||||||
|
@ -194,10 +213,12 @@ void imgproc_mgr::send_image(std::vector<PROCIMGINFO>& imgs, bool clear_after_se
|
||||||
{
|
{
|
||||||
for(auto& v: imgs)
|
for(auto& v: imgs)
|
||||||
{
|
{
|
||||||
|
if(clear_after_send)
|
||||||
|
v.info.prc_stage = -1;
|
||||||
send_image(&v.info, v.img.ptr(), v.img.total() * v.img.channels()
|
send_image(&v.info, v.img.ptr(), v.img.total() * v.img.channels()
|
||||||
, v.ext_info.empty() ? nullptr : &v.ext_info[0], v.ext_info.length());
|
, v.ext_info.empty() ? nullptr : &v.ext_info[0], v.ext_info.length());
|
||||||
if(clear_after_send)
|
// if(clear_after_send)
|
||||||
v.img.release();
|
// v.img.release();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,84 @@
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
|
#include <malloc.h>
|
||||||
|
|
||||||
|
static void *(*old_malloc_hook)(size_t, const void *) = nullptr;
|
||||||
|
static void (*old_free_hook)(void *ptr, const void *caller) = nullptr;
|
||||||
|
static FILE* g_mem_file = nullptr;
|
||||||
|
static uint64_t total_size = 0;
|
||||||
|
static void * my_malloc_hook(size_t size, const void *caller)
|
||||||
|
{
|
||||||
|
void *result;
|
||||||
|
/* Restore all old hooks */
|
||||||
|
__malloc_hook = old_malloc_hook;
|
||||||
|
/* Call recursively */
|
||||||
|
result = malloc(size);
|
||||||
|
/* Save underlying hooks */
|
||||||
|
old_malloc_hook = __malloc_hook;
|
||||||
|
/* printf() might call malloc(), so protect it too. */
|
||||||
|
if(g_mem_file)
|
||||||
|
{
|
||||||
|
char buf[128] = {0};
|
||||||
|
sprintf(buf, "+%p from %p (size = %u)\n", result, caller, size);
|
||||||
|
fwrite(buf, 1, strlen(buf), g_mem_file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("+%p from %p (size = %u)\n", result, caller, size);
|
||||||
|
/* Restore our own hooks */
|
||||||
|
__malloc_hook = my_malloc_hook;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
static void my_free_hook(void *ptr, const void *caller)
|
||||||
|
{
|
||||||
|
__free_hook = old_free_hook;
|
||||||
|
if(ptr)
|
||||||
|
free(ptr);
|
||||||
|
if(g_mem_file)
|
||||||
|
{
|
||||||
|
char buf[128] = {0};
|
||||||
|
sprintf(buf, "-%p from %p\n", ptr, caller);
|
||||||
|
fwrite(buf, 1, strlen(buf), g_mem_file);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf("-%p from %p\n", ptr, caller);
|
||||||
|
old_free_hook = __free_hook;
|
||||||
|
__free_hook = my_free_hook;
|
||||||
|
}
|
||||||
|
static void record_malloc(bool enable)
|
||||||
|
{
|
||||||
|
if(enable)
|
||||||
|
{
|
||||||
|
printf("my_malloc_hook = %p, my_free_hook = %p\n", (void*)my_malloc_hook, (void*)my_free_hook);
|
||||||
|
if(g_mem_file)
|
||||||
|
fclose(g_mem_file);
|
||||||
|
g_mem_file = fopen("/tmp/memlog.txt", "wb");
|
||||||
|
std::string log(utils::format_current_time() + "\n");
|
||||||
|
fwrite(log.c_str(), 1, log.length(), g_mem_file);
|
||||||
|
|
||||||
|
old_free_hook = __free_hook;
|
||||||
|
__free_hook = my_free_hook;
|
||||||
|
|
||||||
|
old_malloc_hook = __malloc_hook;
|
||||||
|
__malloc_hook = my_malloc_hook;
|
||||||
|
}
|
||||||
|
else // if(old_malloc_hook)
|
||||||
|
{
|
||||||
|
if(g_mem_file)
|
||||||
|
{
|
||||||
|
std::string log(utils::format_current_time() + "\n");
|
||||||
|
fwrite(log.c_str(), 1, log.length(), g_mem_file);
|
||||||
|
fclose(g_mem_file);
|
||||||
|
}
|
||||||
|
g_mem_file = nullptr;
|
||||||
|
|
||||||
|
__malloc_hook = old_malloc_hook;
|
||||||
|
old_malloc_hook = nullptr;
|
||||||
|
|
||||||
|
__free_hook = old_free_hook;
|
||||||
|
old_free_hook = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||||
//
|
//
|
||||||
async_scanner::async_scanner() : usb_(nullptr), cfg_mgr_(nullptr), scan_id_(0)
|
async_scanner::async_scanner() : usb_(nullptr), cfg_mgr_(nullptr), scan_id_(0)
|
||||||
|
@ -539,3 +615,4 @@ int async_scanner::last_error(void)
|
||||||
{
|
{
|
||||||
return last_err_;
|
return last_err_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,94 @@ static std::string get_command(void)
|
||||||
return std::move(cmd);
|
return std::move(cmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace test_cmd
|
||||||
|
{
|
||||||
|
static void skip_space(const char*& ptr)
|
||||||
|
{
|
||||||
|
while(*ptr == ' ')
|
||||||
|
ptr++;
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* free_cmd = "free ";
|
||||||
|
static void free_memory(const char* cmd)
|
||||||
|
{
|
||||||
|
uint64_t addr = 0;
|
||||||
|
if(strstr(cmd, " 0x"))
|
||||||
|
{
|
||||||
|
cmd = strstr(cmd, " 0x") + 3;
|
||||||
|
utils::from_hex_string(cmd, &addr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd += strlen(free_cmd);
|
||||||
|
addr = atoll(cmd);
|
||||||
|
}
|
||||||
|
printf("\t free %p? ", addr);
|
||||||
|
if(getchar() == 'y')
|
||||||
|
free((void*)addr);
|
||||||
|
}
|
||||||
|
|
||||||
|
static const char* rdm_cmd = "rdmem ";
|
||||||
|
static void read_memory(const char* cmd)
|
||||||
|
{
|
||||||
|
uint64_t addr = 0;
|
||||||
|
if(strstr(cmd, " 0x"))
|
||||||
|
{
|
||||||
|
cmd = strstr(cmd, " 0x") + 3;
|
||||||
|
utils::from_hex_string(cmd, &addr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cmd += strlen(free_cmd);
|
||||||
|
addr = atoll(cmd);
|
||||||
|
}
|
||||||
|
printf("\t read memory %p? ", addr);
|
||||||
|
if(getchar() == 'y')
|
||||||
|
{
|
||||||
|
int len = 128, off = 0;
|
||||||
|
skip_space(cmd);
|
||||||
|
cmd = strstr(cmd, " ");
|
||||||
|
if(cmd)
|
||||||
|
{
|
||||||
|
skip_space(cmd);
|
||||||
|
len = atoi(cmd);
|
||||||
|
}
|
||||||
|
|
||||||
|
uint8_t *ptr = (uint8_t*)addr;
|
||||||
|
std::string str("");
|
||||||
|
char buf[2] = {0};
|
||||||
|
for(; off < len; )
|
||||||
|
{
|
||||||
|
printf("%p: ", ptr + off);
|
||||||
|
for(int c = 0; off < len && c < 16; ++c, ++off)
|
||||||
|
{
|
||||||
|
printf("%02X ", ptr[off]);
|
||||||
|
if(ptr[off] >= ' ' && ptr[off] < 0x7f)
|
||||||
|
{
|
||||||
|
buf[0] = ptr[off];
|
||||||
|
str += buf;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
str += ".";
|
||||||
|
|
||||||
|
if((c + 1) % 16 == 0)
|
||||||
|
{
|
||||||
|
printf(" %s\n", str.c_str());
|
||||||
|
str = "";
|
||||||
|
}
|
||||||
|
else if((c + 1) % 8 == 0)
|
||||||
|
{
|
||||||
|
printf(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(str.length())
|
||||||
|
printf(" %s\n", str.c_str());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
int main()
|
int main()
|
||||||
{
|
{
|
||||||
/* Ctrl + C */
|
/* Ctrl + C */
|
||||||
|
@ -68,6 +156,10 @@ int main()
|
||||||
break;
|
break;
|
||||||
if(cmd == "mem")
|
if(cmd == "mem")
|
||||||
utils::print_memory_usage(" Memory usage", false);
|
utils::print_memory_usage(" Memory usage", false);
|
||||||
|
if(cmd.find(test_cmd::free_cmd) == 0)
|
||||||
|
test_cmd::free_memory(cmd.c_str());
|
||||||
|
if(cmd.find(test_cmd::rdm_cmd) == 0)
|
||||||
|
test_cmd::read_memory(cmd.c_str());
|
||||||
}
|
}
|
||||||
|
|
||||||
async_scanner* tmp = scanner;
|
async_scanner* tmp = scanner;
|
||||||
|
|
|
@ -18,7 +18,9 @@ packet_data_base::packet_data_base() : pack_cmd_(0), pack_id_(0)
|
||||||
set_progress_notify();
|
set_progress_notify();
|
||||||
}
|
}
|
||||||
packet_data_base::~packet_data_base()
|
packet_data_base::~packet_data_base()
|
||||||
{}
|
{
|
||||||
|
notify_progress(FINAL_NOTIFY, FINAL_NOTIFY, 0);
|
||||||
|
}
|
||||||
|
|
||||||
void packet_data_base::set_packet_param(uint32_t cmd, uint32_t id)
|
void packet_data_base::set_packet_param(uint32_t cmd, uint32_t id)
|
||||||
{
|
{
|
||||||
|
@ -183,6 +185,7 @@ int image_holder::save_2_file(const char* root_dir, const char* alg)
|
||||||
|
|
||||||
if (dst)
|
if (dst)
|
||||||
fclose(dst);
|
fclose(dst);
|
||||||
|
utils::to_log(LOG_LEVEL_ALL, "Image-Process of file '%s' is %ums.\n", file.c_str(), head_.prc_time);
|
||||||
|
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
@ -398,7 +401,6 @@ dyn_mem::dyn_mem(void* buf, size_t size)
|
||||||
|
|
||||||
dyn_mem::~dyn_mem()
|
dyn_mem::~dyn_mem()
|
||||||
{
|
{
|
||||||
notify_progress(space_, len_, 0);
|
|
||||||
if (buf_)
|
if (buf_)
|
||||||
{
|
{
|
||||||
free(buf_);
|
free(buf_);
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
//
|
//
|
||||||
/* packet parameter keeper, parameter of corresponding packet
|
/* packet parameter keeper, parameter of corresponding packet
|
||||||
*/
|
*/
|
||||||
|
static const uint64_t FINAL_NOTIFY = -1;
|
||||||
#define PROGRESS_NOTIFYER std::function<int(uint64_t/*total*/, uint64_t/*cur-size*/, uint32_t/*err*/, void* /*user data*/)>
|
#define PROGRESS_NOTIFYER std::function<int(uint64_t/*total*/, uint64_t/*cur-size*/, uint32_t/*err*/, void* /*user data*/)>
|
||||||
|
|
||||||
class packet_data_base : public refer
|
class packet_data_base : public refer
|
||||||
|
|
|
@ -861,69 +861,75 @@ namespace utils
|
||||||
return str.c_str();
|
return str.c_str();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool from_hex_string(const char* hex, uint8_t* val)
|
static bool hex_str_2_num(char hex, uint8_t* v)
|
||||||
{
|
{
|
||||||
*val = 0;
|
*v = 0;
|
||||||
if(*hex >= '0' && *hex <= '9')
|
if(hex >= '0' && hex <= '9')
|
||||||
*val = *hex - '0';
|
*v = hex - '0';
|
||||||
else if(*hex >= 'a' && *hex <= 'f')
|
else if(hex >= 'a' && hex <= 'f')
|
||||||
*val = *hex - 'a' + 10;
|
*v = hex - 'a' + 10;
|
||||||
else if(*hex >= 'A' && *hex <= 'F')
|
else if(hex >= 'A' && hex <= 'F')
|
||||||
*val = *hex - 'A' + 10;
|
*v = hex - 'A' + 10;
|
||||||
else
|
else
|
||||||
return *hex == 0;
|
return hex == 0;
|
||||||
|
|
||||||
hex++;
|
|
||||||
if(*hex)
|
|
||||||
{
|
|
||||||
*val <<= 4;
|
|
||||||
if(*hex >= '0' && *hex <= '9')
|
|
||||||
*val += *hex - '0';
|
|
||||||
else if(*hex >= 'a' && *hex <= 'f')
|
|
||||||
*val += *hex - 'a' + 10;
|
|
||||||
else if(*hex >= 'A' && *hex <= 'F')
|
|
||||||
*val += *hex - 'A' + 10;
|
|
||||||
else
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
bool from_hex_string(const char* hex, uint8_t* val)
|
||||||
|
{
|
||||||
|
uint8_t t = 0;
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
*val = 0;
|
||||||
|
for(int i = 0; i < 2 && *hex && (ret = hex_str_2_num(*hex++, &t)); ++i)
|
||||||
|
{
|
||||||
|
*val <<= 4;
|
||||||
|
*val += t;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
bool from_hex_string(const char* hex, uint16_t* val)
|
bool from_hex_string(const char* hex, uint16_t* val)
|
||||||
{
|
{
|
||||||
if(from_hex_string(hex, (uint8_t*)val))
|
uint8_t t = 0;
|
||||||
{
|
bool ret = true;
|
||||||
hex += 2;
|
|
||||||
*val = swap_half(*val);
|
|
||||||
|
|
||||||
return from_hex_string(hex, (uint8_t*)val);
|
*val = 0;
|
||||||
|
for(int i = 0; i < 4 && *hex && (ret = hex_str_2_num(*hex++, &t)); ++i)
|
||||||
|
{
|
||||||
|
*val <<= 4;
|
||||||
|
*val += t;
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
return ret;
|
||||||
}
|
}
|
||||||
bool from_hex_string(const char* hex, uint32_t* val)
|
bool from_hex_string(const char* hex, uint32_t* val)
|
||||||
{
|
{
|
||||||
if(from_hex_string(hex, (uint16_t*)val))
|
uint8_t t = 0;
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
*val = 0;
|
||||||
|
for(int i = 0; i < 8 && *hex && (ret = hex_str_2_num(*hex++, &t)); ++i)
|
||||||
{
|
{
|
||||||
hex += 4;
|
*val <<= 4;
|
||||||
*val = swap_half(*val);
|
*val += t;
|
||||||
|
|
||||||
return from_hex_string(hex, (uint16_t*)val);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
return ret;
|
||||||
}
|
}
|
||||||
bool from_hex_string(const char* hex, uint64_t* val)
|
bool from_hex_string(const char* hex, uint64_t* val)
|
||||||
{
|
{
|
||||||
if(from_hex_string(hex, (uint32_t*)val))
|
uint8_t t = 0;
|
||||||
|
bool ret = true;
|
||||||
|
|
||||||
|
*val = 0;
|
||||||
|
for(int i = 0; i < 16 && *hex && (ret = hex_str_2_num(*hex++, &t)); ++i)
|
||||||
{
|
{
|
||||||
hex += 8;
|
*val <<= 4;
|
||||||
*val = swap_half(*val);
|
*val += t;
|
||||||
|
|
||||||
return from_hex_string(hex, (uint32_t*)val);
|
|
||||||
}
|
}
|
||||||
else
|
|
||||||
return false;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -396,6 +396,16 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
T front(void)
|
||||||
|
{
|
||||||
|
SIMPLE_LOCK(lock_);
|
||||||
|
return que_.front();
|
||||||
|
}
|
||||||
|
void pop_front(void)
|
||||||
|
{
|
||||||
|
SIMPLE_LOCK(lock_);
|
||||||
|
que_.pop_front();
|
||||||
|
}
|
||||||
size_t size(void)
|
size_t size(void)
|
||||||
{
|
{
|
||||||
SIMPLE_LOCK(lock_);
|
SIMPLE_LOCK(lock_);
|
||||||
|
|
|
@ -253,6 +253,7 @@ enum opt_visible_level // "visible" field
|
||||||
#define SANE_STD_OPT_NAME_CIS_FRAME_H "frame-h"
|
#define SANE_STD_OPT_NAME_CIS_FRAME_H "frame-h"
|
||||||
#define SANE_STD_OPT_NAME_CIS_SAMPLE "sample"
|
#define SANE_STD_OPT_NAME_CIS_SAMPLE "sample"
|
||||||
#define SANE_STD_OPT_NAME_CIS_SP "cis-sp"
|
#define SANE_STD_OPT_NAME_CIS_SP "cis-sp"
|
||||||
|
#define SANE_STD_OPT_NAME_CIS_LED "cis-led"
|
||||||
#define SANE_STD_OPT_NAME_CIS_EXPO_FB "expo-fb"
|
#define SANE_STD_OPT_NAME_CIS_EXPO_FB "expo-fb"
|
||||||
#define SANE_STD_OPT_NAME_CIS_EXPO_FG "expo-fg"
|
#define SANE_STD_OPT_NAME_CIS_EXPO_FG "expo-fg"
|
||||||
#define SANE_STD_OPT_NAME_CIS_EXPO_FR "expo-fr"
|
#define SANE_STD_OPT_NAME_CIS_EXPO_FR "expo-fr"
|
||||||
|
@ -268,6 +269,8 @@ enum opt_visible_level // "visible" field
|
||||||
#define SANE_STD_OPT_NAME_MOTOR_SPEED "motor-speed"
|
#define SANE_STD_OPT_NAME_MOTOR_SPEED "motor-speed"
|
||||||
#define SANE_STD_OPT_NAME_COLOR_CORRECT "clr-correct"
|
#define SANE_STD_OPT_NAME_COLOR_CORRECT "clr-correct"
|
||||||
#define SANE_STD_OPT_NAME_LUT_FILE "lut-file"
|
#define SANE_STD_OPT_NAME_LUT_FILE "lut-file"
|
||||||
|
#define SANE_STD_OPT_NAME_PHASE_FRONT "phase-f"
|
||||||
|
#define SANE_STD_OPT_NAME_PHASE_BACK "phase-b"
|
||||||
|
|
||||||
//
|
//
|
||||||
// 借鉴TWAIN协议固定ID的做法,定义SANE属性的固定ID - 这里与TWAIN中的ID保持一致,以方便TWAIN的调用
|
// 借鉴TWAIN协议固定ID的做法,定义SANE属性的固定ID - 这里与TWAIN中的ID保持一致,以方便TWAIN的调用
|
||||||
|
|
|
@ -60,8 +60,8 @@ add_packagedirs("sdk")
|
||||||
add_defines("BUILD_AS_DEVICE")
|
add_defines("BUILD_AS_DEVICE")
|
||||||
add_defines("VER_MAIN=2")
|
add_defines("VER_MAIN=2")
|
||||||
add_defines("VER_FAMILY=200")
|
add_defines("VER_FAMILY=200")
|
||||||
add_defines("VER_DATE=20240125")
|
add_defines("VER_DATE=20240127")
|
||||||
add_defines("VER_BUILD=21")
|
add_defines("VER_BUILD=27")
|
||||||
|
|
||||||
target("conf")
|
target("conf")
|
||||||
set_kind("phony")
|
set_kind("phony")
|
||||||
|
|
Loading…
Reference in New Issue