CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 4.9k
make hwmon_response product line dependent #13444
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
make hwmon_response product line dependent #13444
Conversation
src/ds/d400/d400-device.h
Outdated
friend class d400_depth_sensor; | ||
|
||
std::shared_ptr<hw_monitor> _hw_monitor; | ||
std::shared_ptr<ds::d400_hwmon_response_handler> hw_monitor_response = std::make_shared<ds::d400_hwmon_response_handler>(); |
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.
Why here and not in the constructor?
@OhadMeir please review |
src/hw-monitor.h
Outdated
|
||
std::string hwmon_error_string( command const &, hwmon_response e ); | ||
typedef int32_t hwmon_response; | ||
class base_hwmon_response_handler { // base class for different product number to implement responses |
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.
We don't have product numbers, you probably meant product ID, which also does not sound correct here. Rephrase to products
or product lines
src/hw-monitor.h
Outdated
typedef int32_t hwmon_response; | ||
class base_hwmon_response_handler { // base class for different product number to implement responses | ||
public: | ||
inline virtual std::string hwmon_error2str(int e) const = 0; |
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.
Virtual can be inlined. Remove inline
keyword
src/hw-monitor.h
Outdated
class base_hwmon_response_handler { // base class for different product number to implement responses | ||
public: | ||
inline virtual std::string hwmon_error2str(int e) const = 0; | ||
virtual hwmon_response hwmon_Success() const = 0; |
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.
Meaning is ambiguous, can be understood as is_successful
or success_value
.
According to the rest of the code it's the later, please rename.
Note - naming convention, should not capitalize after underscore.
src/hw-monitor.h
Outdated
|
||
std::string hwmon_error_string( command const &, hwmon_response e ); | ||
typedef int32_t hwmon_response; | ||
class base_hwmon_response_handler { // base class for different product number to implement responses |
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.
On most places we name interfaces as XXX_interface
. Consider renaming hwmon_response_handler_interface
or hwmon_response_interface
(are we a "handler"?).
Also can wrap typedef int32_t hwmon_response
in the class namespace as hwmon_response_interface::type
src/hw-monitor.h
Outdated
explicit hw_monitor(std::shared_ptr<locked_transfer> locked_transfer) | ||
: _locked_transfer(std::move(locked_transfer)) | ||
explicit hw_monitor(std::shared_ptr<locked_transfer> locked_transfer, std::shared_ptr<base_hwmon_response_handler> hwmon_response_handler) | ||
: _locked_transfer(std::move(locked_transfer)), hwmon_response_handler(hwmon_response_handler) |
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.
Use _
as a prefix to member variables name
src/ds/d400/d400-private.h
Outdated
public: | ||
enum d400_hwmon_response_names : int32_t | ||
{ | ||
hwm_Success = 0, |
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.
As we discussed, can shorten the literal names because it's in a class namespace.
d400_hwmon_response::success
src/hw-monitor.h
Outdated
|
||
std::shared_ptr<base_hwmon_response_handler> hwmon_response_handler; | ||
|
||
std::string hwmon_error_string(command const&, int e) const; |
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.
Should be hwmon_response
not int
src/hdr-config.cpp
Outdated
hwmon_response response; | ||
auto res = _hwm.send( cmd, &response ); // avoid the throw | ||
switch( response ) | ||
if (response != _hwm.hwmon_response_handler->hwmon_Success()) // If no subpreset is streaming, the firmware returns "NO_DATA_TO_RETURN" error |
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.
This is not exactly equivalent to the former logic. Why was this changed?
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 think it's becasue now we get the success value from a virtual function. I'm getting an error when trying to use _hwm.hwmon_response_handler->hwmon_Success()
as a 'case' value ('this' can not be used in a constant expression
)
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, but now you don't have any reference to hwmon_response::hwm_NoDataToReturn
, is it not needed?
You can replace switch
with some else if
clauses, but here you have changed the logic. Just make sure its intended and works as expected.
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.
oh I see, thanks, I will add no_data_to_return_opcode
as a member to this class, like we did on alternating_emitter_option
src/ds/ds-options.h
Outdated
{ | ||
public: | ||
alternating_emitter_option(hw_monitor& hwm, bool is_fw_version_using_id); | ||
alternating_emitter_option(hw_monitor& hwm, bool is_fw_version_using_id, int no_data_to_return_opcode); |
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.
Use hwmon_response
type, not int
src/ds/d400/d400-private.h
Outdated
class d400_hwmon_response_handler : public base_hwmon_response_handler | ||
{ | ||
public: | ||
enum d400_hwmon_response_names : int32_t |
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.
Here too, use the defined hwmon_response
type
{ | ||
public: | ||
enum d400_hwmon_response_names : int32_t | ||
{ |
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.
Rename d400_hwmon_response_names
to opcodes
. It will be under the class namespace.
|
||
friend class d400_depth_sensor; | ||
|
||
std::shared_ptr<hw_monitor> _hw_monitor; |
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.
Member hw_monitor_response
is not needed, create the shared object as you directly pass it into _hw_monitor
.
Also, should be prefixed with _
src/ds/d500/d500-private.h
Outdated
class d500_hwmon_response_handler : public base_hwmon_response_handler | ||
{ | ||
public: | ||
enum d500_hwmon_response_names : int32_t |
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.
Same comments as d400
Tracked on: [LRS-1105]