Skip to content

python-ev3dev v2 program freezes if go to current position #505

Closed

Description

@ndward

ev3dev version: 4.14.61-ev3dev-2.2.2-ev3
ev3dev-lang-python version:
ii python3-ev3dev 1.2.0 all Python language bindings for ev3dev
ii python3-ev3dev2 2.0.0~beta1 all Python language bindings for ev3dev

If the script instructs the motor to go to a position that it is already in then this freezes the program! For example, this will freeze the program (i.e. the program will not terminate):

!/usr/bin/env python3
from ev3dev2.motor import LargeMotor, OUTPUT_B
from time import sleep
large_motor = LargeMotor(OUTPUT_B)
large_motor.on_to_position(speed_pct=10, position=-120)
sleep(2)
large_motor.on_to_position(speed_pct=10, position=-120) 

Activity

  1. self-assigned this
    on Sep 8, 2018
  2. matskew commented on Sep 8, 2018

    @matskew

    I put this comment in one of your other issues, but the point still stands:

    motor.py's wait(self, cond, timeout=None) method polls the motor waiting for a change. It assumes that when it is called the motor is running, and it is waiting for a change to either 'stalled' or 'not running'. Unfortunately if you ask the motor to move zero, then it never was running in the first place. Thus the polling will block forever.

    You can narrow the race condition by moving the poll to the end of wait()'s while loop, and therefore checking the condition before blocking.

  3. WasabiFan commented on Sep 24, 2018

    @WasabiFan
    Member

    Fix released in 2.0.0~beta2. To upgrade:

    sudo apt-get update
    sudo apt-get install --only-upgrade python3-ev3dev2
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions