修复PNP BUG
This commit is contained in:
parent
202579a4cd
commit
6deaffbb21
|
@ -545,6 +545,8 @@ bool usb_device::is_online(void)
|
||||||
void usb_device::set_online(bool online)
|
void usb_device::set_online(bool online)
|
||||||
{
|
{
|
||||||
online_ = online;
|
online_ = online;
|
||||||
|
if (!online_)
|
||||||
|
reg_key_ = "";
|
||||||
}
|
}
|
||||||
uint8_t usb_device::port(void)
|
uint8_t usb_device::port(void)
|
||||||
{
|
{
|
||||||
|
@ -552,6 +554,10 @@ uint8_t usb_device::port(void)
|
||||||
init();
|
init();
|
||||||
return port_;
|
return port_;
|
||||||
}
|
}
|
||||||
|
std::string usb_device::reg_path(void)
|
||||||
|
{
|
||||||
|
return reg_key_;
|
||||||
|
}
|
||||||
|
|
||||||
bool usb_device::init(void)
|
bool usb_device::init(void)
|
||||||
{
|
{
|
||||||
|
@ -1068,7 +1074,7 @@ void usb_monitor::notify_usb_event(usb_device*& dev, bool arrive)
|
||||||
if (devices_[i]->is_online())
|
if (devices_[i]->is_online())
|
||||||
{
|
{
|
||||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s is already in device queue and received ARRIVE again, discard this event.\n", dev->name().c_str());
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s is already in device queue and received ARRIVE again, discard this event.\n", dev->name().c_str());
|
||||||
dev->release();
|
// dev->release();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1090,33 +1096,45 @@ void usb_monitor::notify_usb_event(usb_device*& dev, bool arrive)
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
bool discard = false;
|
||||||
for (size_t i = 0; i < devices_.size(); ++i)
|
for (size_t i = 0; i < devices_.size(); ++i)
|
||||||
{
|
{
|
||||||
if (!(devices_[i]->id() == id))
|
if (devices_[i]->id().vid != id.vid || devices_[i]->id().pid != id.pid)
|
||||||
continue;
|
continue;
|
||||||
|
if (devices_[i]->reg_path().empty() || usb_device::usb_scan_name(devices_[i]->reg_path().c_str()).empty())
|
||||||
|
{
|
||||||
dev->release();
|
dev->release();
|
||||||
dev = devices_[i];
|
dev = devices_[i];
|
||||||
dev->add_ref();
|
dev->add_ref();
|
||||||
if (dev->is_open())
|
// if (dev->is_open())
|
||||||
{
|
{
|
||||||
if (dev->is_online())
|
if (dev->is_online())
|
||||||
|
{
|
||||||
dev->set_online(false);
|
dev->set_online(false);
|
||||||
|
discard = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
// VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s is already offline and received LEAVE again, discard this event.\n", dev->name().c_str());
|
||||||
|
// dev->release();
|
||||||
|
// return;
|
||||||
|
discard = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//else
|
||||||
|
//{
|
||||||
|
// devices_.erase(devices_.begin() + i);
|
||||||
|
// dev->release();
|
||||||
|
//}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (discard)
|
||||||
|
{
|
||||||
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s is already offline and received LEAVE again, discard this event.\n", dev->name().c_str());
|
VLOG_MINI_1(LOG_LEVEL_DEBUG_INFO, "%s is already offline and received LEAVE again, discard this event.\n", dev->name().c_str());
|
||||||
dev->release();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
devices_.erase(devices_.begin() + i);
|
|
||||||
dev->release();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
for (size_t i = 0; i < cbs_.size(); ++i)
|
for (size_t i = 0; i < cbs_.size(); ++i)
|
||||||
cbs_[i]->notify((libusb_context*)this, dev, ev);
|
cbs_[i]->notify((libusb_context*)this, dev, ev);
|
||||||
|
|
|
@ -140,6 +140,7 @@ public:
|
||||||
bool is_online(void);
|
bool is_online(void);
|
||||||
void set_online(bool online);
|
void set_online(bool online);
|
||||||
uint8_t port(void);
|
uint8_t port(void);
|
||||||
|
std::string reg_path(void);
|
||||||
|
|
||||||
bool init(void);
|
bool init(void);
|
||||||
void clear(void);
|
void clear(void);
|
||||||
|
|
Loading…
Reference in New Issue