Skip to content

Commit 7587d84

Browse files
committed
Trying to fix problem that interface handle becomes invalid
1 parent 07624fb commit 7587d84

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

rc_genicam_api/interface.cc

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,26 @@ std::vector<std::shared_ptr<Device> > Interface::getDevices()
160160
// update available interfaces
161161

162162
GenTL::GC_ERROR err=gentl->IFUpdateDeviceList(ifh, 0, 100);
163+
164+
if (err == GenTL::GC_ERR_INVALID_HANDLE)
165+
{
166+
// the interface handle is invalid, try to reopen the interface
167+
168+
if (gentl->TLUpdateInterfaceList(parent->getHandle(), 0, 10) != GenTL::GC_ERR_SUCCESS)
169+
{
170+
throw GenTLException(std::string("Interface::getDevices() (recovery 1) ")+id, gentl);
171+
}
172+
173+
if (gentl->TLOpenInterface(parent->getHandle(), id.c_str(), &ifh) != GenTL::GC_ERR_SUCCESS)
174+
{
175+
throw GenTLException(std::string("Interface::getDevices() (recovery 2) ")+id, gentl);
176+
}
177+
178+
// try to repeat discovery of devices
179+
180+
err=gentl->IFUpdateDeviceList(ifh, 0, 100);
181+
}
182+
163183
if (err != GenTL::GC_ERR_SUCCESS)
164184
{
165185
throw GenTLException(std::string("Interface::getDevices() (1) ")+id+" "+std::to_string(err), gentl);

0 commit comments

Comments
 (0)