Skip to content

Make use of polling functionality in 16-ev3dev kernel #230

Closed

Description

@ddemidov

Kernel Release Cycle 16 restores support for polling the status attribute of the tacho motor class for EV3 (see ev3dev/ev3dev.github.io#284). This may be used to wait for changes in motor state efficiently, so we should provide an interface for this feature.

Activity

  1. ddemidov commented on Oct 15, 2016

    @ddemidov
    MemberAuthor

    Something like

    motor.wait_while('running') # wait while `'running'` is in the motor's `state`.
    motor.wait_until('holding') # wait until `'holding'` is in the motor's state

    should be doable.

  2. WasabiFan commented on Oct 15, 2016

    @WasabiFan
    Member

    Keep in mind that we'll need to account for race conditions. I don't believe we're guaranteed that the state will change to "running" immediately.

  3. ddemidov commented on Oct 15, 2016

    @ddemidov
    MemberAuthor

    I am not sure I understand. I was thinking of something along these lines:

    class Motor:
    
      def wait(self, is_done):
        while True:
          wait_for_polling_event()
          if is_done(self.state): break
    
      def wait_while(self, s):
        self.wait(lambda state: return s not in state)

    Would that be more error prone that what we have to do currently (while 'running' in m.state: sleep(0.01))? Or do you say that polling event could come later that that state has actually changed?

  4. WasabiFan commented on Oct 15, 2016

    @WasabiFan
    Member

    No, it's not more error-prone than the loops we currently use; however now that we are building it into the library itself we need to make sure it's not going to fail on edge cases.

  5. added 2 commits that reference this issue on Oct 28, 2016
    be8e149
    02187d4
  6. added a commit that references this issue on Oct 30, 2016
    61b5439
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    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