Detect the new products in the SDK and Viewer: D435f, D435if, D455f, D456 - #11399
Conversation
| fisheye_sensor_hb = 113, | ||
| imu_acc_chip_id = 124, | ||
| ip65_sealed_offset = 161, | ||
| filter_sensor_offset = 164, |
There was a problem hiding this comment.
Maybe it is not the correct name "filter_sensor_offset"? Actually, a filter is not a sensor.
There was a problem hiding this comment.
I agree, please align to your previous name: ir_filter_exist
There was a problem hiding this comment.
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.
| } | ||
|
|
||
| auto const CUR_GVD_VERSION = gvd_buff[gvd_version_offset]; | ||
| auto const MIN_GVD_VERSION = 0x4; |
There was a problem hiding this comment.
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.
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.
Lets create a function for that, maybe inside ds5-private.h
This function will check once that
MIN_GVD_VERSION <= CUR_GVD_VERSIONYou 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?
|
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. |
| 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.
Please search a way to replace it with a regex substitute, maybe it will look better :)
There was a problem hiding this comment.
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 |
| (_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.
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.
I added some comments and left commented lines of code with the purpose to understand what looks good for us.
3c9f58a to
1f7fb3c
Compare
| switch (cap) | ||
| { | ||
| case ds::d400_caps::CAP_IR_FILTER: | ||
| if (is_capability_supports(cap, cur_gvd_version)) |
There was a problem hiding this comment.
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.
The code is optimized.
| 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.
What does vowel_re means?
Maybe better to use a more meaningful name
There was a problem hiding this comment.
The variable was renamed to old_name
| 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.
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.
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
| break; | ||
|
|
||
| default: | ||
| auto wrong_cap = ds::d400_capabilities_names.find(cap); |
There was a problem hiding this comment.
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.
cap variable is not a string, so I can't connect it to another string.
There was a problem hiding this comment.
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.
Ok, thank you! I will move forward with your suggestion!
There was a problem hiding this comment.
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.
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.
Yes, you are right. The first time, IDE showed me a syntax error there.
Now it's OK, something flaky.
| 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.
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.
May you send me a link to read about clang-format?
Because I found something but I think that is not was you meant.
| 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.
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.
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]