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

Migrate HC_SR04 class member variable initialization to declarations, augment code so that it compiles. #11857

Closed
wants to merge 1 commit into from

Conversation

mcsauder
Copy link
Contributor

@mcsauder mcsauder commented Apr 15, 2019

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

@mcsauder
Copy link
Contributor Author

@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.


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;
Copy link
Member

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.

@mcsauder mcsauder force-pushed the hc_sr04_work branch 2 times, most recently from 5c6d1b5 to a4205b9 Compare June 18, 2019 17:37
@mcsauder mcsauder force-pushed the hc_sr04_work branch 2 times, most recently from 980ff23 to d4a3487 Compare July 2, 2019 16:37
@mcsauder mcsauder force-pushed the hc_sr04_work branch 2 times, most recently from 83cf755 to 059bfb1 Compare July 16, 2019 18:50
… list to declarations, format whitespace, and organize var declaration order.
if (hc_sr04::g_dev != nullptr) {
hc_sr04::g_dev->interrupt(time);
}
// static int sonar_isr(int irq, void *context);
Copy link
Contributor

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
Copy link
Contributor

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.

@mcsauder
Copy link
Contributor Author

Closing in favor of #13021!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants