Skip to content
Snippets Groups Projects
Verified Commit 4afe94d0 authored by Jakub Vaněk's avatar Jakub Vaněk
Browse files

Work around race condition when EV3 sensors are being reset

This works around an unexpected crash that would happen when you run the
following code:

```
cs = <EV3 color sensor instance>
# start sensor reset
cs.start_reset()
# wait for sensor reset and return new reading
cs.reflection()
```

The cs.reflection() call would raise SensorNotReadyError with the
message "Sensor has been unplugged". However, ideally, the call should
block up to 3 seconds until the sensor has rebooted.

It seems to me that the problem is caused by the fact that immediately
after cs.start_reset() is called, cs.is_ready() will still return true.
This confuses the waiting loop in read_raw_mode() - it will think that
the sensor has unexpectedly disappeared a ~millisecond later.

This commit fixes the issue by checking for the reset condition
in the is_ready() and similar functions.
parent e2345042
No related branches found
No related tags found
1 merge request!13Make the EV3 color sensor calibration applicable to the EV3 color sensor
Pipeline #110621 passed
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment