-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Detect the new products in the SDK and Viewer: D435f, D435if, D455f, D456 #11399
Detect the new products in the SDK and Viewer: D435f, D435if, D455f, D456 #11399
Conversation
src/ds/ds-private.h
Outdated
camera_fw_version_offset = 12, | ||
is_camera_locked_offset = 25, | ||
module_serial_offset = 48, | ||
module_asic_serial_offset = 64, | ||
fisheye_sensor_lb = 112, | ||
fisheye_sensor_hb = 113, | ||
imu_acc_chip_id = 124, | ||
ip65_sealed_offset = 161, | ||
filter_sensor_offset = 164, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe it is not the correct name "filter_sensor_offset"? Actually, a filter is not a sensor.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree, please align to your previous name: ir_filter_exist
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry, what do you mean by previous name
? Do you mean the variable ir_filter_mask
?
In the struct, we have offsets of a memory.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Like discussed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done
src/ds/ds5/ds5-device.cpp
Outdated
@@ -692,6 +695,27 @@ namespace librealsense | |||
std::make_shared<thermal_compensation>(_thermal_monitor,thermal_compensation_toggle)); | |||
} | |||
|
|||
auto const CUR_GVD_VERSION = gvd_buff[gvd_version_offset]; | |||
auto const MIN_GVD_VERSION = 0x4; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets create a function for that, maybe inside ds5-private.h
This function will check once that MIN_GVD_VERSION <= CUR_GVD_VERSION
You also need to add comments for it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please inside the function add comments specificaly say how we change the name e.g. from D435i to D435IF
So when we search the code in the future for D435IF we will find it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Lets create a function for that, maybe inside ds5-private.h
This function will check once that
MIN_GVD_VERSION <= CUR_GVD_VERSION
You also need to add comments for it.
Due to multiple definitions, the project failed on the build with my function in *.h file.
What about creating a function in ds5-device.cpp?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Resolved together
We need to search all of the old device names, see if someone is the code used the specific camera name to add some logic. |
src/ds/ds5/ds5-device.cpp
Outdated
val_in_range(_pid, {RS435_RGB_PID, RS435I_PID, RS455_PID}) && | ||
(_device_capabilities & ir_filter_mask) == ir_filter_mask) | ||
{ | ||
device_name += "F"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please search a way to replace it with a regex substitute, maybe it will look better :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A regex use was added.
But I can find optimal logic for changing the name.
How much include <regex>
increase our .cpp file?
Meanwhile, I didn't find any used device by name only using a device by a pid. |
Please rebase and solve conflicts
|
I don't see the new changes, please push |
src/ds/ds5/ds5-device.cpp
Outdated
(_device_capabilities & ip65_mask) == ip65_mask) | ||
{ | ||
device_name = device_name.substr(0, device_name.size() - 1); | ||
device_name += "6"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The "F" is OK since it's the last character,
Here we replace so I wish for something more elegant..
Look at std::string function or std::regex variations
And like I said we are missing comments, hard to understand what is done here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I added some comments and left commented lines of code with the purpose to understand what looks good for us.
3c9f58a
to
1f7fb3c
Compare
src/ds/d400/d400-device.cpp
Outdated
switch (cap) | ||
{ | ||
case ds::d400_caps::CAP_IR_FILTER: | ||
if (is_capability_supports(cap, cur_gvd_version)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to check it inside every case,
Lets take it out and only call update_device_name
if it's true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The code is optimized.
src/ds/d400/d400-device.cpp
Outdated
if (is_capability_supports(cap, cur_gvd_version)) | ||
{ | ||
// device_name[device_name.size() - 1] = '6'; // Changing last digit name to "6" if device has IP65 standart. | ||
std::regex vowel_re("D455"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What does vowel_re
means?
Maybe better to use a more meaningful name
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The variable was renamed to old_name
src/ds/d400/d400-device.cpp
Outdated
std::regex vowel_re("D455"); | ||
std::regex_replace(device_name, device_name.begin(), device_name.end(), vowel_re, "D456"); | ||
} | ||
break; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please add a default case (always)
Here you can throw and say the required capability is not supported for name update (with adding the cap value)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The default case was added.
I implemented throw in the default case but can't find it in IDE after throwing an exception.
As a result, the viewer continues work after throwing an exception and NOT showing the device name.
Please advise, if we can leave it as is or improve it.
3b3e0ef
to
1f79659
Compare
src/ds/d400/d400-device.cpp
Outdated
break; | ||
|
||
default: | ||
auto wrong_cap = ds::d400_capabilities_names.find(cap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need for all of this:
default:
throw invalid_value_exception("capability '" + cap + "' is not supported for device name update");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cap
variable is not a string, so I can't connect it to another string.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
try this:
default:
throw invalid_value_exception("capability '" + d400_capabilities_names.at( cap ) + "' is not supported for device name update");
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok, thank you! I will move forward with your suggestion!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I will do next:
ds::d400_capabilities_names.find(cap)->second
Because d400_capabilities_names
is a map.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ds::d400_capabilities_names.find(cap)->second
this use can raise a null reference and crash the SW.
map api has .at()
which will throw if the input is not inside the map, which is good for us.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are right. The first time, IDE showed me a syntax error there.
Now it's OK, something flaky.
src/ds/d400/d400-device.cpp
Outdated
break; | ||
|
||
case ds::d400_caps::CAP_IP65: | ||
device_name = std::regex_replace(device_name, old_name_reg, "D456"); // Change device name from D455 to D456. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Notice you have alignment issues on several lines here.
Please use 'clang-format', (if you don't know how ask..)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May you send me a link to read about clang-format?
Because I found something but I think that is not was you meant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sent
src/ds/d400/d400-device.cpp
Outdated
break; | ||
|
||
case ds::d400_caps::CAP_IP65: | ||
device_name = std::regex_replace(device_name, old_name_reg, "D456"); // Change device name from D455 to D456. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we remove line 1109 and place here:
device_name = std::regex_replace(device_name, std::regex("D455"), "D456"); // Change device name from D455 to D456.
?
The parameter at line 1109 is only relevant on this case
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, you are absolutely right. I tried your solution and VS marked it like an error, so full of pain I moved it out of "switch".
But now it worked. It happens the second time. Maybe delay in IDE.
Changed according to your suggestion.
Tracked on [LRS-657]