增加从设备描述符iProduct域中判断通信协议版本的接口
This commit is contained in:
parent
7de2077960
commit
d5325e9a4c
|
@ -743,6 +743,11 @@ scanner_err hg_scanner_mgr::hg_scanner_open(scanner_handle* h, const char* name,
|
||||||
ret = (scanner_err)usb_manager::instance()->open(it->dev, &io, &hg_scanner_mgr::last_open_msg_);
|
ret = (scanner_err)usb_manager::instance()->open(it->dev, &io, &hg_scanner_mgr::last_open_msg_);
|
||||||
if (ret == SCANNER_ERR_OK)
|
if (ret == SCANNER_ERR_OK)
|
||||||
{
|
{
|
||||||
|
if (io->get_ver() > 1)
|
||||||
|
{
|
||||||
|
// new version ...
|
||||||
|
}
|
||||||
|
|
||||||
hg_scanner* scanner = g_supporting_devices[it->ind].create_scanner(it->display_name.c_str(), io, h);
|
hg_scanner* scanner = g_supporting_devices[it->ind].create_scanner(it->display_name.c_str(), io, h);
|
||||||
if (!scanner)
|
if (!scanner)
|
||||||
{
|
{
|
||||||
|
|
|
@ -769,6 +769,24 @@ void usb_io::init_after_open(void)
|
||||||
close();
|
close();
|
||||||
last_err_ = err;
|
last_err_ = err;
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
char str[128] = { 0 }, *ver = nullptr;
|
||||||
|
libusb_device_descriptor dd = { 0 };
|
||||||
|
|
||||||
|
libusb_get_device_descriptor(dev_info_.device, &dd);
|
||||||
|
libusb_get_string_descriptor_ascii(handle_, dd.iProduct, (unsigned char*)str, _countof(str) - 1);
|
||||||
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "Device Product: '%s'\n", str);
|
||||||
|
ver = strstr(str, "(V");
|
||||||
|
if (ver)
|
||||||
|
{
|
||||||
|
ver_ = (int)atof(ver + 2);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ver_ = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
void usb_io::open(void)
|
void usb_io::open(void)
|
||||||
{
|
{
|
||||||
|
@ -1107,6 +1125,10 @@ int usb_io::get_pid(void)
|
||||||
{
|
{
|
||||||
return dev_info_.pid;
|
return dev_info_.pid;
|
||||||
}
|
}
|
||||||
|
int usb_io::get_ver(void)
|
||||||
|
{
|
||||||
|
return ver_;
|
||||||
|
}
|
||||||
|
|
||||||
void usb_io::on_disconnected(void)
|
void usb_io::on_disconnected(void)
|
||||||
{
|
{
|
||||||
|
|
|
@ -152,6 +152,7 @@ class usb_io
|
||||||
int last_err_;
|
int last_err_;
|
||||||
std::string init_err_msg_;
|
std::string init_err_msg_;
|
||||||
libusb_device *ref_device_;
|
libusb_device *ref_device_;
|
||||||
|
unsigned int ver_ = 1;
|
||||||
|
|
||||||
// endpoint ports
|
// endpoint ports
|
||||||
usb_manager::USBTRANSENDP endpoints_;
|
usb_manager::USBTRANSENDP endpoints_;
|
||||||
|
@ -191,6 +192,7 @@ public:
|
||||||
libusb_device* get_usb_device(void); // 获取该USB对象
|
libusb_device* get_usb_device(void); // 获取该USB对象
|
||||||
int get_vid(void); // 获取连接到该USB端口上的设备VID
|
int get_vid(void); // 获取连接到该USB端口上的设备VID
|
||||||
int get_pid(void); // 获取连接到该USB端口上的设备PID
|
int get_pid(void); // 获取连接到该USB端口上的设备PID
|
||||||
|
int get_ver(void);
|
||||||
|
|
||||||
void on_disconnected(void);
|
void on_disconnected(void);
|
||||||
std::string init_error_msg(void);
|
std::string init_error_msg(void);
|
||||||
|
|
Loading…
Reference in New Issue