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

Add data "age" attribute to sensor sysfs #81

Open
wants to merge 1 commit into
base: ev3dev-buster
Choose a base branch
from

Conversation

JakubVanek
Copy link
Contributor

I would like to propose a workaround for ev3dev/ev3dev#1401 . A new sysfs attribute is exported: bin_data_age. It contains the number of milliseconds elapsed since the raw data received from given sensor last changed. This enables userspace to detect conditions like ultrasonic sensor not being able to measure distance at the current position. Thanks to mode_info separation present in current drivers, this also works across mode switches - if the same stale data are received after switch, the timestamp of last data update is not reset.

I think the naming (bin_data_age) is a bit unfortunate, but I don't know a better alternative. "Age" implies that the sensor did not send any new data during this time, but this may not be true. Sensor may still be sending data, but if they are the same as the old values, "age" is not reset to zero. I would like bin_data_msec_since_last_change more, but that is likely too long.

This patch also can't report age of individual values. One use I currently see is for detecting freezes on individual EV3 IR seeker channels. This would mean exporting age for each value separately, which may (or may not) be what is best for ev3dev.

The EV3 color sensor needs a different workaround - here the sensor sends new data, but they aren't accurate yet.

@JakubVanek
Copy link
Contributor Author

I have tested this only on x86_64 Linux laptop, but as the changes affect port code, I have to test it on the EV3 too. However, I would like to ask for help with testing on other platforms (brickpi, pistorms, wedo) to which I don't have access currently.

@JakubVanek JakubVanek force-pushed the feature/data-change branch 4 times, most recently from b8fc328 to f9c4a10 Compare August 9, 2020 21:17
@JakubVanek
Copy link
Contributor Author

I have to test it tomorrow against ev3dev-stretch, I cannot get UART sensors to work even on stock ev3dev-buster.

@JakubVanek
Copy link
Contributor Author

The https://github.com/JakubVanek/ev3devdrv-private-dev/tree/feature/dataage-stretch branch (just ev3dev-stretch with this PR cherry-picked) appears to work well under EV3 with gyro, color, sonic and touch sensors.

@JakubVanek JakubVanek force-pushed the feature/data-change branch from f9c4a10 to 5c1fa55 Compare August 10, 2020 13:07
@dlech
Copy link
Member

dlech commented Aug 10, 2020

This is an interesting idea. I will have to think about it for a while (both the specific change and the bigger future of ev3dev in general).

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.

2 participants