-
Couldn't load subscription status.
- Fork 145
Description
ev3dev version: 4.14.117-ev3dev-2.3.5-ev3
- ev3dev-lang-python version:
||/ Name Version Architecture Description
+++-==================================-======================-======================-=========================================================================
ii micropython-ev3dev2 2.1.0 all Python language bindings for ev3dev for MicroPython
ii python3-ev3dev 1.2.0 all Python language bindings for ev3dev
ii python3-ev3dev2 2.1.0 all Python language bindings for ev3dev
I have certain programs that crash on EV3Dev2 when 2 parallel Threads may control the same Motor. The crashes have different error messages on MicroPython vs. Python3. I have reproduced the errors in the enclosed test scripts "BUG.SameMotor.Threading.EV3Dev2.MicroPython.py" and "BUG.SameMotor.Threading.EV3Dev2.Python3.py".
For comparison, I have also tried and enclosed below other variations (e.g. using ev3dev(1.2.0) or pybricks instead of ev3dev2, or using multiprocessing or PyBricks's run_parallel instead of threading) that run successfully.
All these programs do the following: turn the Motor clockwise when the Touch Sensor is pressed, or turn the same Motor counter-clockwise when any IR Remote Control button is pressed. The observations from all the coding variations are as follows:
threadingwithev3dev22.1.0 onmicropython: CRASHED after pressing the IR Remote Control buttons a few times (making the Motor turn counter-clockwise), even if the Touch Sensor is NOT pressed at all (i.e. that Touch-Sensor-triggeredThreadnever commands the Motor at all).
File "ev3dev2/motor.py", line 1048, in on_for_seconds
File "ev3dev2/motor.py", line 928, in wait_until_not_moving
File "ev3dev2/motor.py", line 908, in wait
OSError: 4
threadingwithev3dev22.1.0 onpython3: CRASHED when the Touch Sensor and an IR Remote Control button are pressed at the same time, i.e. bothThreadare trying to command the Motor at the same time. But the program runs ok when only 1 button is pressed.
File "/usr/lib/python3/dist-packages/ev3dev2/motor.py", line 1048, in on_for_seconds
self.wait_until_not_moving()
File "/usr/lib/python3/dist-packages/ev3dev2/motor.py", line 928, in wait_until_not_moving
return self.wait(lambda state: self.STATE_RUNNING not in state or self.STATE_STALLED in state, timeout)
File "/usr/lib/python3/dist-packages/ev3dev2/motor.py", line 908, in wait
self._poll.poll(poll_tm)
RuntimeError: concurrent poll() invocation
-
multiprocessingwithev3dev22.1.0 onmicropython: bothProcesses run successfully WITH mutual blocking, i.e. 1ProcessCANNOT interrupt/reverse the otherProcess's Motor movement mid-stream -
multiprocessingwithev3dev22.1.0 onpython3: bothProcesses run successfully WITH mutual blocking, i.e. 1ProcessCANNOT interrupt/reverse the otherProcess's Motor movement mid-stream -
threadingwithev3dev(1.2.0) onpython3: bothThreads run successfully WITHOUT mutual blocking, i.e. 1ThreadCAN interrupt/reverse the otherThread's Motor movement mid-stream -
multiprocessingwithev3dev(1.2.0) onpython3: bothProcesses run successfully WITHOUT mutual blocking, i.e. 1ProcessCAN interrupt/reverse the otherProcess's Motor movement mid-stream -
threadingwithpybricks(2.0.0) onpybricks-micropython: bothThreads run successfully WITH mutual blocking, i.e. 1ThreadCANNOT interrupt/reverse the otherThread's Motor movement mid-stream -
run_parallel(experimental PyBricks feature) withpybricks(2.0.0) onpybricks-micropython: bothThreads run successfully WITH mutual blocking, i.e. 1ThreadCANNOT interrupt/reverse the otherThread's Motor movement mid-stream