fix bug when set option value

This commit is contained in:
gb 2023-12-26 13:52:16 +08:00
parent 0b445be68f
commit 403092a2bf
9 changed files with 191 additions and 60 deletions

View File

@ -612,8 +612,8 @@ int usb_device::open(libusb_device_handle** dev_handle)
}
if (DeviceIoControl(h, IOCTL_GET_PIPE_CONFIGURATION, NULL, 0, &upc, sizeof(upc), &cbr, NULL))
{
int type = PIPE_TYPE::WRITE_DATA_PIPE;
DeviceIoControl(h, IOCTL_RESET_PIPE, &type, sizeof(type), NULL, NULL, &cbr, NULL);
int type = PIPE_TYPE::ALL_PIPE;
DeviceIoControl(h, IOCTL_RESET_PIPE, &type, sizeof(type), NULL, NULL, &cbr, NULL); // will send URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL to device
for (int i = 0; i < upc.NumberOfPipes; ++i)
{
USBPIPE up = { 0 };
@ -895,12 +895,18 @@ int usb_monitor::enum_usb_device(bool(__stdcall* found_usb)(LPUSBDEV dev, void*
GUID hid = hub ? GUID_DEVINTERFACE_USB_HUB : GUID_DEVINTERFACE_USB_DEVICE;
HDEVINFO dev_info = NULL;
int ind = 0;
bool usr_cancel = false;
SP_DEVICE_INTERFACE_DATA id = { 0 };
SP_DEVINFO_DATA sdd = { 0 };
dev_info = SetupDiGetClassDevsW(&hid, NULL, NULL, DIGCF_PRESENT | DIGCF_DEVICEINTERFACE);
if (!dev_info)
return GetLastError();
{
DWORD err = GetLastError();
utils::to_log(LOG_LEVEL_WARNING, "enum usb device failed in get class: %d\r\n", err);
return err;
}
id.cbSize = sizeof(id);
while (SetupDiEnumDeviceInterfaces(dev_info, NULL, &hid, ind++, &id))
@ -934,6 +940,7 @@ int usb_monitor::enum_usb_device(bool(__stdcall* found_usb)(LPUSBDEV dev, void*
if (!found_usb(&dev, param))
{
delete[](char*)buf;
usr_cancel = true;
break;
}
}
@ -941,6 +948,11 @@ int usb_monitor::enum_usb_device(bool(__stdcall* found_usb)(LPUSBDEV dev, void*
}
id.cbSize = sizeof(id);
}
if (ind == 1 && !usr_cancel)
{
DWORD err = GetLastError();
utils::to_log(LOG_LEVEL_WARNING, "enum usb device interface: %d\r\n", err);
}
SetupDiDestroyDeviceInfoList(dev_info);
return ERROR_SUCCESS;
@ -1159,6 +1171,7 @@ void usb_monitor::find_usb_and_trigger_event(void)
found_usb_devs_.clear();
usb_monitor::enum_usb_device(&usb_monitor::find_all_usb_devices, &found_usb_devs_);
utils::to_log(LOG_LEVEL_DEBUG, "Found %u USB device(s).\r\n", found_usb_devs_.size());
for (size_t i = 0; i < found_usb_devs_.size(); ++i)
{
if (!usb_monitor::is_desired_usb_device(found_usb_devs_[i].vid, found_usb_devs_[i].pid))

View File

@ -10,6 +10,9 @@
#include <file/file_util.h>
#include <json/gb_json.h>
#include <sane_opt_json/device_opt.h>
#include <huagao/hgscanner_error.h>
#include <sane_opts.h>
#define TIMER_ID_REFRESH_BULK 1001
@ -19,8 +22,9 @@ namespace sane
{
#define ALIGN_INTEGER(v) ALIGN_INT(v, sizeof(int))
static std::vector<SANE_Option_Descriptor*> g_opts;
//static std::vector<SANE_Option_Descriptor*> g_opts;
SANE_Option_Descriptor g_opt0;
sane_options* opts_ = nullptr;
namespace local_utility
{
@ -441,9 +445,13 @@ namespace sane
void reset_opts(const char* json_txt)
{
for (auto& v : g_opts)
delete[] v;
g_opts.clear();
if (opts_)
delete opts_;
opts_ = new sane_options();
opts_->init_from(json_txt, nullptr, true);
//for (auto& v : g_opts)
// delete[] v;
//g_opts.clear();
g_opt0.cap = CAPABILITY_READONLY;
g_opt0.name = "option-count";
@ -452,26 +460,26 @@ namespace sane
g_opt0.type = SANE_TYPE_INT;
g_opt0.size = sizeof(SANE_TYPE_INT);
if (json_txt)
{
gb_json* jsn = new gb_json(), * child = NULL;
if (jsn->attach_text((char*)json_txt))
{
child = jsn->first_child();
if (child)
{
child->release();
while ((child = jsn->next_child()))
{
SANE_Option_Descriptor* desc = trans_json_to_opt_desc(child);
if (desc)
g_opts.push_back(desc);
child->release();
}
}
}
jsn->release();
}
//if (json_txt)
//{
// gb_json* jsn = new gb_json(), * child = NULL;
// if (jsn->attach_text((char*)json_txt))
// {
// child = jsn->first_child();
// if (child)
// {
// child->release();
// while ((child = jsn->next_child()))
// {
// SANE_Option_Descriptor* desc = trans_json_to_opt_desc(child);
// if (desc)
// g_opts.push_back(desc);
// child->release();
// }
// }
// }
// jsn->release();
//}
}
SANE_Status sane_get_devices_api(const SANE_Device*** device_list, SANE_Bool local_only)
@ -488,41 +496,42 @@ namespace sane
{
if (option == 0)
return &g_opt0;
else if (option <= g_opts.size())
return g_opts[option - 1];
else if (option <= opts_->get_option_count())
return opts_->get_opt_descriptor((void*)option);
else
return NULL;
}
SANE_Status sane_control_option_api(SANE_Handle handle, SANE_Int option, SANE_Action action, void* value, SANE_Int* info)
{
CDlgScanner* dlg = (CDlgScanner*)handle;
SANE_Option_Descriptor* desc = opts_->get_opt_descriptor((void*)option);
if (action == SANE_ACTION_GET_VALUE && option > 0 && option <= g_opts.size())
if (action == SANE_ACTION_GET_VALUE && option > 0 && option <= opts_->get_option_count())
{
if (g_opts[option - 1]->type == SANE_TYPE_FIXED)
if (desc->type == SANE_TYPE_FIXED)
{
double val = .0f;
dlg->get_option(g_opts[option - 1]->name, &val, sizeof(val));
dlg->get_option(desc->name, &val, sizeof(val));
*(SANE_Fixed*)value = SANE_FIX(val);
}
else
{
dlg->get_option(g_opts[option - 1]->name, value, g_opts[option - 1]->size);
dlg->get_option(desc->name, value, desc->size);
}
return SANE_STATUS_GOOD;
}
else if(action == SANE_ACTION_SET_VALUE && option > 0 && option <= g_opts.size())
else if(action == SANE_ACTION_SET_VALUE && option > 0 && option <= opts_->get_option_count())
{
size_t val_size = 0;
double val = .0f;
void* buf = value;
if (g_opts[option - 1]->type == SANE_TYPE_BOOL)
if (desc->type == SANE_TYPE_BOOL)
val_size = sizeof(bool);
else if (g_opts[option - 1]->type == SANE_TYPE_INT)
else if (desc->type == SANE_TYPE_INT)
val_size = sizeof(int);
else if (g_opts[option - 1]->type == SANE_TYPE_FIXED)
else if (desc->type == SANE_TYPE_FIXED)
{
val_size = sizeof(val);
val = SANE_UNFIX(*(SANE_Int*)value);
@ -532,7 +541,7 @@ namespace sane
val_size = strlen((char*)value);
SANE_Int after = 0;
SANE_Status ret = (SANE_Status)dlg->set_option(g_opts[option - 1]->name, buf, g_opts[option - 1]->type, val_size, g_opts[option - 1]->size, (int*)&after);
SANE_Status ret = (SANE_Status)dlg->set_option(desc->name, buf, desc->type, val_size, desc->size, (int*)&after);
if (info)
*info = after;
@ -592,6 +601,12 @@ namespace sane
}
void sane_exit_api(void)
{}
void clear(void)
{
if (opts_)
delete opts_;
opts_ = nullptr;
}
};
#define RETURN_EQUAL(v, e) \
@ -732,6 +747,7 @@ void CDlgScanner::DoDataExchange(CDataExchange* pDX)
// DDX_Control(pDX, IDC_TAB_OPT, tab_opt_);
DDX_Control(pDX, IDC_TAB_OPER, tab_oper_);
DDX_Control(pDX, IDC_COMBO_BUF_SIZE, buf_);
DDX_Control(pDX, IDC_PROGRESS1, tx_prog_);
}
typedef struct _prog_data
@ -745,6 +761,7 @@ void CDlgScanner::set_device(ONLNSCANNER* pnp)
{
auto_tx_ = false;
SetEvent(auto_wait_);
sane::clear();
}
((CButton*)GetDlgItem(IDC_CHECK_REPEAT))->SetCheck(BST_UNCHECKED);
@ -767,7 +784,8 @@ void CDlgScanner::set_device(ONLNSCANNER* pnp)
max_cmd_ = max_sent_ = 0;
buf_.SetCurSel(0);
buf_.EnableWindow(pnp != NULL);
//buf_.EnableWindow(pnp != NULL);
buf_.EnableWindow(FALSE);
if (pnp)
{
int err = 0;
@ -787,18 +805,18 @@ void CDlgScanner::set_device(ONLNSCANNER* pnp)
else
{
wchar_t buf[128] = { 0 };
uint16_t ver = PROTOCOL_VER;
PEERCFG prcfg = { 0 };
swprintf_s(buf, _countof(buf) - 1, L"%04X:%04X", pnp->vid, pnp->pid);
::SetWindowTextW(m_hWnd, buf);
//err = scanner_->get_protocol_version(&ver);
if (err || ver != PROTOCOL_VER)
err = scanner_->get_peer_config(&prcfg);
if (err || prcfg.ver != PROTOCOL_VER)
{
if(err)
msg_box(m_hWnd, MB_OK, L"Unsupported Scanner", L"Failed to get protocol version with error %d.", err);
else
msg_box(m_hWnd, MB_OK, L"Unsupported Scanner", L"Protocol version is mismatch: expect %u.%u but return %u.%u", HIBYTE(PROTOCOL_VER), LOBYTE(PROTOCOL_VER), HIBYTE(ver), LOBYTE(ver));
msg_box(m_hWnd, MB_OK, L"Unsupported Scanner", L"Protocol version is mismatch: expect %u.%u but return %u.%u", HIBYTE(PROTOCOL_VER), LOBYTE(PROTOCOL_VER), HIBYTE(prcfg.ver), LOBYTE(prcfg.ver));
if (scanner_)
{
scanner_->release();
@ -810,9 +828,12 @@ void CDlgScanner::set_device(ONLNSCANNER* pnp)
}
else
{
swprintf_s(buf, _countof(buf) - 1, L"%u.%u", HIBYTE(ver), LOBYTE(ver));
swprintf_s(buf, _countof(buf) - 1, L"%u.%u", HIBYTE(prcfg.ver), LOBYTE(prcfg.ver));
SetDlgItemTextW(IDC_EDIT_PROTOCOL_VER, buf);
swprintf_s(buf, _countof(buf) - 1, L"%u", prcfg.io_size);
buf_.SetCurSel(buf_.FindStringExact(-1, buf));
refresh_bulk_status();
//SetTimer(TIMER_ID_REFRESH_BULK, 1000, NULL);
RECT r = { 0 };
@ -851,7 +872,7 @@ bool CDlgScanner::is_online(void)
void CDlgScanner::get_option(const char* name, void* value, size_t size)
{
size_t len = 0;
char* cont = scanner_->get_value(name, value, &len);
char* cont = scanner_->get_option_value(name, nullptr, &len, nullptr);
if (cont)
{
@ -872,27 +893,52 @@ int CDlgScanner::get_all_option(std::string& opts_json)
}
int CDlgScanner::set_option(const char* name, void* value, int type, size_t len, size_t max_len, int* after)
{
return scanner_->set_value(name, value);
device_option* opt = scanner_->get_device_opt();
bool inexact = opt->refine_data(name, value);
int err = opt->update_data(name, value),
ef = inexact ? SANE_INFO_INEXACT : 0;
opt->release();
if (err == SCANNER_ERR_RELOAD_IMAGE_PARAM)
{
ef |= SANE_INFO_RELOAD_PARAMS;
err = SCANNER_ERR_OK;
}
else if (err == SCANNER_ERR_CONFIGURATION_CHANGED)
{
ef |= SANE_INFO_RELOAD_OPTIONS;
err = SCANNER_ERR_OK;
}
else if (err == SCANNER_ERR_RELOAD_OPT_PARAM)
{
ef |= SANE_INFO_RELOAD_OPTIONS | SANE_INFO_RELOAD_PARAMS;
err = SCANNER_ERR_OK;
}
int CDlgScanner::refresh_bulk_status(void)
if (after)
*after = ef;
return 0;
}
int CDlgScanner::refresh_bulk_status(bool en_dev_log)
{
EP0REPLYSTATUS s = { 0 };
wchar_t buf[128] = { 0 };
int err = scanner_->status(&s);
wchar_t buf[128] = { 0 }, tmp[40] = { 0 };
int err = scanner_->status(&s, en_dev_log);
if (err == 0)
{
SetDlgItemTextW(IDC_EDIT_BUILK_IN, peer_bulk_status(s.in_status, buf));
SetDlgItemTextW(IDC_EDIT_BUILK_IN, peer_bulk_status(s.in_status, tmp));
if (s.in_status == WORKER_STATUS_BUSY)
{
swprintf_s(buf, _countof(buf) - 1, L"WORKER_STATUS_BUSY(Want: %x)", s.bytes_to_sent);
SetDlgItemTextW(IDC_EDIT_BUILK_IN, buf);
}
SetDlgItemTextW(IDC_EDIT_BULK_OUT, peer_bulk_status(s.out_status, buf));
if (s.out_status == WORKER_STATUS_BUSY)
//SetDlgItemTextW(IDC_EDIT_BULK_OUT, peer_bulk_status(s.out_status, tmp));
//if (s.out_status == WORKER_STATUS_BUSY)
{
swprintf_s(buf, _countof(buf) - 1, L"WORKER_STATUS_BUSY(Need: %x)", s.task_required_bytes);
swprintf_s(buf, _countof(buf) - 1, L"%s(Need: %x)", peer_bulk_status(s.out_status, tmp), s.task_required_bytes);
SetDlgItemTextW(IDC_EDIT_BULK_OUT, buf);
}
@ -942,6 +988,7 @@ void CDlgScanner::thread_auto_tx_file(void)
ResetEvent(auto_wait_);
if (auto_tx_ & FILE_TX_SEND)
{
PostMessage(WM_TX_DIRECTION, 0, 1);
oper = L"Send file";
err = scanner_->file_transfer(file.c_str(), remt, true);
if (err)
@ -952,6 +999,7 @@ void CDlgScanner::thread_auto_tx_file(void)
{
double val = *prog;
free(prog);
PostMessage(WM_TX_PROGRESS, (WPARAM)((DWORD*)&val)[1], (WPARAM)((DWORD*)&val)[0]);
if (IS_DOUBLE_EQUAL(val, prevg))
{
if (IS_DOUBLE_EQUAL(val, 1.0f))
@ -980,6 +1028,7 @@ void CDlgScanner::thread_auto_tx_file(void)
if (auto_tx_ & FILE_TX_RECEIVE)
{
PostMessage(WM_TX_DIRECTION, 0, 0);
file = prev + std::to_string(++ind) + ext;
oper = L"Receive file";
err = scanner_->file_transfer(file.c_str(), remt, false);
@ -991,6 +1040,7 @@ void CDlgScanner::thread_auto_tx_file(void)
{
double val = *prog;
free(prog);
PostMessage(WM_TX_PROGRESS, (WPARAM)((DWORD*)&val)[1], (WPARAM)((DWORD*)&val)[0]);
if (IS_DOUBLE_EQUAL(val, prevg))
{
if (IS_DOUBLE_EQUAL(val, 1.0f))
@ -1090,6 +1140,8 @@ BEGIN_MESSAGE_MAP(CDlgScanner, CDialogEx)
ON_MESSAGE(WM_SET_BUTTON_CHECK, &CDlgScanner::OnSetButtonChecked)
ON_MESSAGE(WM_ENABLE_CTRLS, &CDlgScanner::OnEnableCtrls)
ON_MESSAGE(WM_DEVICE_STATTUS, &CDlgScanner::OnDeviceStatus)
ON_MESSAGE(WM_TX_DIRECTION, &CDlgScanner::OnTransDiretion)
ON_MESSAGE(WM_TX_PROGRESS, &CDlgScanner::OnTransProgress)
ON_CBN_SELCHANGE(IDC_COMBO_BUF_SIZE, &CDlgScanner::OnCbnSelchangeComboBufSize)
ON_WM_DESTROY()
END_MESSAGE_MAP()
@ -1152,6 +1204,7 @@ BOOL CDlgScanner::OnInitDialog()
img_root_ += L"\\";
::SetDlgItemTextW(m_hWnd, IDC_EDIT_IMG_PATH, img_root_.c_str());
buf_.SetCurSel(0);
tx_prog_.SetRange(0, 1000);
return FALSE; // 除非将焦点设置到控件,否则返回 TRUE
}
@ -1173,7 +1226,7 @@ void CDlgScanner::OnTcnSelchangeTabOper(NMHDR* pNMHDR, LRESULT* pResult)
scan[] = {IDC_STATIC_IMG_PATH, IDC_STATIC_COUNT, IDC_EDIT_IMG_PATH, IDC_EDIT_COUNT, IDC_BUTTON_BROWSE_IMG_PATH
, IDC_CHECK_AUTO_OPEN_IMG, IDC_BUTTON_SCAN},
file[] = {IDC_STATIC_LOCAL, IDC_STATIC_REMOTE, IDC_EDIT_LOCAL, IDC_EDIT_REMOTE, IDC_BUTTON_BROWSE_LOCAL
, IDC_BUTTON_SEND, IDC_BUTTON_RECEIVE, IDC_CHECK_REPEAT},
, IDC_BUTTON_SEND, IDC_BUTTON_RECEIVE, IDC_CHECK_REPEAT, IDC_PROGRESS1, IDC_EDIT_PROGRESS},
prog[] = {IDC_STATIC_CMD, IDC_STATIC_PARAM, IDC_EDIT_CMD, IDC_EDIT_PARAM, IDC_BUTTON_START_PROG},
ctrl[] = {IDC_STATIC_TYPE, IDC_STATIC_REQ, IDC_STATIC_IND, IDC_STATIC_VAL, IDC_STATIC_LEN, IDC_STATIC_DATA
, IDC_EDIT_TYPE, IDC_EDIT_REQ, IDC_EDIT_IND, IDC_EDIT_VAL, IDC_EDIT_LEN, IDC_EDIT_DATA
@ -1358,7 +1411,12 @@ void CDlgScanner::OnTimer(UINT_PTR nIDEvent)
{
// TODO: 在此添加消息处理程序代码和/或调用默认值
if (nIDEvent == TIMER_ID_REFRESH_BULK)
refresh_bulk_status();
{
bulk_statu_tick_++;
refresh_bulk_status(bulk_statu_tick_ <= 1);
if (bulk_statu_tick_ >= 3600)
bulk_statu_tick_ = 0;
}
CDialogEx::OnTimer(nIDEvent);
}
@ -1370,6 +1428,7 @@ void CDlgScanner::OnBnClickedCheckAuto()
bool checked = ((CButton*)GetDlgItem(IDC_CHECK_AUTO))->GetCheck() == BST_CHECKED;
GetDlgItem(IDC_BUTTON_REFRESH)->EnableWindow(!checked);
bulk_statu_tick_ = 0;
if (checked)
SetTimer(TIMER_ID_REFRESH_BULK, 1000, NULL);
else
@ -1452,6 +1511,43 @@ LRESULT CDlgScanner::OnDeviceStatus(WPARAM wp, LPARAM lp)
return 0;
}
LRESULT CDlgScanner::OnTransDiretion(WPARAM wp, LPARAM lp)
{
RECT t = { 0 }, s = { 0 };
int dx = 0;
GetDlgItem(lp ? IDC_BUTTON_SEND : IDC_BUTTON_RECEIVE)->GetWindowRect(&t);
GetDlgItem(IDC_PROGRESS1)->GetWindowRect(&s);
dx = t.right - s.left + 3;
GetDlgItem(IDC_EDIT_PROGRESS)->GetWindowRect(&t);
OffsetRect(&s, dx, 0);
OffsetRect(&t, dx, 0);
ScreenToClient(&s);
ScreenToClient(&t);
GetDlgItem(IDC_EDIT_PROGRESS)->MoveWindow(&t);
GetDlgItem(IDC_PROGRESS1)->MoveWindow(&s);
tx_prog_.SetPos(0);
return 0;
}
LRESULT CDlgScanner::OnTransProgress(WPARAM wp, LPARAM lp)
{
double prog = .0f;
DWORD* i32 = (DWORD*)&prog;
wchar_t txt[40] = { 0 };
int l = 0, u = 0;
i32[0] = lp;
i32[1] = wp;
tx_prog_.GetRange(l, u);
tx_prog_.SetPos(prog * (u - l) + l + .5f);
swprintf_s(txt, _countof(txt) - 1, L"%.2f%%", prog * 100);
::SetDlgItemTextW(m_hWnd, IDC_EDIT_PROGRESS, txt);
return 0;
}
void CDlgScanner::OnCbnSelchangeComboBufSize()

View File

@ -69,6 +69,7 @@ class CDlgScanner : public CDialogEx
uint32_t paper_cnt_;
uint32_t max_sent_;
uint32_t max_cmd_;
uint32_t bulk_statu_tick_ = 0;
safe_thread threads_;
public:
@ -87,7 +88,7 @@ protected:
DECLARE_MESSAGE_MAP()
int refresh_bulk_status(void);
int refresh_bulk_status(bool en_dev_log = false);
void thread_auto_tx_file(void);
void enable_buttons(bool enable);
@ -126,7 +127,10 @@ public:
afx_msg LRESULT OnSetButtonChecked(WPARAM wp, LPARAM lp);
afx_msg LRESULT OnEnableCtrls(WPARAM wp, LPARAM lp);
afx_msg LRESULT OnDeviceStatus(WPARAM wp, LPARAM lp);
afx_msg LRESULT OnTransDiretion(WPARAM wp, LPARAM lp);
afx_msg LRESULT OnTransProgress(WPARAM wp, LPARAM lp);
afx_msg void OnCbnSelchangeComboBufSize();
CComboBox buf_;
afx_msg void OnDestroy();
CProgressCtrl tx_prog_;
};

View File

@ -32,6 +32,8 @@
#define WM_SET_BUTTON_CHECK WM_USER + 322 // WPARAM: id; LPARAM: bool
#define WM_ENABLE_CTRLS WM_USER + 323 // WPARAM: id (0 is click repeat button); LPARAM: bool
#define WM_DEVICE_STATTUS WM_USER + 324 // WPARAM: unused; LPARAM: scanner_status
#define WM_TX_DIRECTION WM_USER + 325 // WPARAM: unused; LPARAM: bool - true: send; false - receive
#define WM_TX_PROGRESS WM_USER + 326 // WPARAM: high of double; LPARAM: low of double
extern HMODULE g_my_inst;

View File

@ -93,6 +93,9 @@
#define IDC_EDIT_LOG_FILE 1065
#define IDC_COMBO1 1066
#define IDC_COMBO_BUF_SIZE 1066
#define IDC_PROGRESS1 1067
#define IDC_EDIT1 1068
#define IDC_EDIT_PROGRESS 1068
#define ID_TRAY_EXIT 32771
// Next default values for new objects
@ -101,7 +104,7 @@
#ifndef APSTUDIO_READONLY_SYMBOLS
#define _APS_NEXT_RESOURCE_VALUE 138
#define _APS_NEXT_COMMAND_VALUE 32772
#define _APS_NEXT_CONTROL_VALUE 1067
#define _APS_NEXT_CONTROL_VALUE 1069
#define _APS_NEXT_SYMED_VALUE 101
#endif
#endif

View File

@ -76,7 +76,7 @@
<PropertyGroup Label="UserMacros" />
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
<LinkIncremental>true</LinkIncremental>
<IncludePath>$(ProjectDir)..\..\..\code_device\sdk;$(ProjectDir)..\sdk\include;$(ProjectDir)..\..\..\sdk\include;$(ProjectDir)..\..\device;$(ProjectDir)..\..\..\code_device\hgdriver\3rdparty\opencv\include;$(IncludePath);</IncludePath>
<IncludePath>$(ProjectDir)..\..\..\code_device\sdk;$(ProjectDir)..\sdk\include;$(ProjectDir)..\..\..\sdk\include;$(ProjectDir)..\..\device;$(ProjectDir)..\..\..\code_device\hgdriver\3rdparty\opencv\include;$(ProjectDir)..\..\..\code_device\hgsane\sane_opt;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\sdk\lib\$(Configuration);$(ProjectDir)..\..\..\sdk\lib\win\x86\oem\huagao;$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
@ -86,7 +86,7 @@
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<LinkIncremental>false</LinkIncremental>
<IncludePath>$(ProjectDir)..\..\..\code_device\sdk;$(ProjectDir)..\sdk\include;$(ProjectDir)..\..\..\sdk\include;$(ProjectDir)..\..\device;$(ProjectDir)..\..\..\code_device\hgdriver\3rdparty\opencv\include;$(IncludePath);</IncludePath>
<IncludePath>$(ProjectDir)..\..\..\code_device\sdk;$(ProjectDir)..\sdk\include;$(ProjectDir)..\..\..\sdk\include;$(ProjectDir)..\..\device;$(ProjectDir)..\..\..\code_device\hgdriver\3rdparty\opencv\include;$(ProjectDir)..\..\..\code_device\hgsane\sane_opt;$(IncludePath)</IncludePath>
<LibraryPath>$(ProjectDir)..\sdk\lib\$(Configuration);$(LibraryPath)</LibraryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
@ -201,6 +201,7 @@
<ClInclude Include="..\..\..\code_device\hgdriver\hgdev\scanner\scanner_handler.h" />
<ClInclude Include="..\..\..\code_device\hgdriver\hgdev\usb_manager.h" />
<ClInclude Include="..\..\..\code_device\hgdriver\hgdev\user-opt\user.h" />
<ClInclude Include="..\..\..\code_device\hgsane\sane_opt\sane_opts.h" />
<ClInclude Include="..\..\..\code_device\sdk\base\data.h" />
<ClInclude Include="..\..\..\code_device\sdk\base\encrypt.h" />
<ClInclude Include="..\..\..\code_device\sdk\base\huagaoxxx_warraper_ex.h" />
@ -251,6 +252,10 @@
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\code_device\hgsane\sane_opt\sane_opts.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
</ClCompile>
<ClCompile Include="..\..\..\code_device\sdk\base\data.cpp">
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>

View File

@ -129,6 +129,9 @@
<ClInclude Include="..\..\..\code_device\hgdriver\hgdev\user-opt\user.h">
<Filter>Imports\scanner</Filter>
</ClInclude>
<ClInclude Include="..\..\..\code_device\hgsane\sane_opt\sane_opts.h">
<Filter>opt-ui</Filter>
</ClInclude>
</ItemGroup>
<ItemGroup>
<ClCompile Include="usb_tools.cpp">
@ -209,6 +212,9 @@
<ClCompile Include="..\..\..\code_device\hgdriver\hgdev\user-opt\user.cpp">
<Filter>Imports\scanner</Filter>
</ClCompile>
<ClCompile Include="..\..\..\code_device\hgsane\sane_opt\sane_opts.cpp">
<Filter>opt-ui</Filter>
</ClCompile>
</ItemGroup>
<ItemGroup>
<ResourceCompile Include="usbtools.rc">

View File

@ -141,6 +141,7 @@ namespace usb
libusb_get_device_descriptor(pnp->dev, &desc);
pnp->vid = desc.idVendor;
pnp->pid = desc.idProduct;
pnp->addr = 0;
pnp->scanner = NULL;
pnp->family = pnp->display_name = "";
if (!PostMessage(owner, WM_USB_PNP, event == LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED, (LPARAM)pnp))
@ -625,6 +626,7 @@ void CusbtoolsDlg::open_usb(SCANNER& pnp, bool from_list)
pnp.dlg = new CDlgScanner(this); // new CDlgOpenning(this);
pnp.dlg->Create(IDD_SCANNER); // (IDD_OPENNING);
}
pnp.usb.addr = libusb_get_device_address(pnp.usb.dev);
pnp.dlg->set_device(&pnp.usb);
pnp.dlg->ShowWindow(SW_SHOW);

Binary file not shown.