-
Notifications
You must be signed in to change notification settings - Fork 13.6k
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
Migrate HC_SR04 class member variable initialization to declarations, augment code so that it compiles. #11857
Conversation
b59e7d7
to
3498919
Compare
e192e97
to
1893af3
Compare
29b9d4d
to
83d2a1b
Compare
@teapethu , could you advise me on this driver? It is currently in a broken state. I've added code in this PR so that it compiles, but it appears to have been broken for at least the past year and a half. |
4f15bd5
to
9c0f013
Compare
e81d19c
to
8c756d4
Compare
|
||
virtual ssize_t read(device::file_t *filp, char *buffer, size_t buflen); | ||
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg); | ||
virtual int ioctl(device::file_t *filp, int cmd, unsigned long arg) override; |
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.
Things like the ioctl, read, and ringbuffers can usually be gutted entirely. These were used historically to read directly from the device (eg ::open("/dev/distance_sensor0")
), but all of that has moved entirely to orb.
5c6d1b5
to
a4205b9
Compare
980ff23
to
d4a3487
Compare
83cf755
to
059bfb1
Compare
6f7ee54
to
1414c8a
Compare
… list to declarations, format whitespace, and organize var declaration order.
1414c8a
to
e27efe8
Compare
if (hc_sr04::g_dev != nullptr) { | ||
hc_sr04::g_dev->interrupt(time); | ||
} | ||
// static int sonar_isr(int irq, void *context); |
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 is this commented out? Can it be removed?
{ | ||
int ret = PX4_ERROR; | ||
int ret = -EIO; | ||
#if 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.
Why is this disabled? I would at least add a comment in code to explain why.
Closing in favor of #13021! |
Describe problem solved by the proposed pull request
This PR migrates HC_SR04 class member variable initialization to their respective declarations, formats whitespace, organizes variable ordering, and modifies the code so that it at least compiles, (it is very much still broken, however).
NOTE the hc_sr04 driver has been in a disfunctional state since prior to January 2018. This PR aims to align the driver with other distance sensor drivers, however it could easily be argued that this PR should be modified to deprecate the hc_sr04 driver entirely.
Describe your preferred solution
Ultimately all distance sensor drivers should inherit from a common base class, and this PR makes incremental steps toward that objective.
Describe possible alternatives
Deprecate this particular driver entirely.
Additional context
See Issue #9279.
NOTE: This driver is badly broken... A decision should be made about whether or not it should be fixed or deprecated.
https://www.mouser.com/ds/2/813/HCSR04-1022824.pdf
Please let me know if you have any questions on this PR. Thanks!
-Mark