Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix resolveDeviceURI: <bus>@<devicenr> format, don't connect if invalid #47

Merged
merged 2 commits into from
Apr 29, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions src/openni2_driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -652,7 +652,7 @@ std::string OpenNI2Driver::resolveDeviceURI(const std::string& device_id) throw(
if (index >= device_id.size() - 1)
{
THROW_OPENNI_EXCEPTION(
"%s is not a valid device URI, you must give a number after the @, specify 0 for first device",
"%s is not a valid device URI, you must give the device number after the @, specify 0 for any device on this bus",
device_id.c_str());
}

Expand All @@ -671,8 +671,9 @@ std::string OpenNI2Driver::resolveDeviceURI(const std::string& device_id) throw(
if (s.find(bus) != std::string::npos)
{
// this matches our bus, check device number
--device_number;
if (device_number <= 0)
std::ostringstream ss;
ss << bus << '/' << device_number;
if (device_number == 0 || s.find(ss.str()) != std::string::npos)
return s;
}
}
Expand Down Expand Up @@ -716,10 +717,11 @@ std::string OpenNI2Driver::resolveDeviceURI(const std::string& device_id) throw(
}
}
}
return matched_uri;
if (match_found)
return matched_uri;
else
return "INVALID";
}

return "INVALID";
}

void OpenNI2Driver::initDevice()
Expand Down