Skip to content

Device is not connected exception #257

Closed

Description

@verytallrobot

Just getting one LargeMotor on outB to run from a file is throwing up this exception!
Code works from python3 prompt just not when in a .py file which is just crazy.
I'm going to try an older build of the kernel.
Any help greatly appreciated.

from ev3dev.ev3 import *
from time import sleep
m = LargeMotor('outB', stop_action="hold")
m.run_to_rel_pos(position_sp=360, speed_sp=900)
sleep(5)

Terminal message:

robot@ev3dev:~$ python3 m3.py
Traceback (most recent call last):
  File "m3.py", line 12, in <module>
    m.run_to_rel_pos(position_sp=360, speed_sp=900)
  File "/usr/lib/python3/dist-packages/ev3dev/core.py", line 774, in run_to_rel_pos
    setattr(self, key, kwargs[key])
  File "/usr/lib/python3/dist-packages/ev3dev/core.py", line 546, in speed_sp
    self._speed_sp = self.set_attr_int(self._speed_sp, 'speed_sp', value)
  File "/usr/lib/python3/dist-packages/ev3dev/core.py", line 215, in set_attr_int
    return self._set_attribute(attribute, name, str(int(value)))
  File "/usr/lib/python3/dist-packages/ev3dev/core.py", line 208, in _set_attribute
    raise Exception('Device is not connected')
Exception: Device is not connected

Activity

  1. ddemidov commented on Nov 8, 2016

    @ddemidov
    Member
    m = LargeMotor('outB', stop_action="hold")

    This is wrong. keyword arguments in motor constructor are for finding the correct motor, so you are trying to find a motor which has "hold" as a stop action. This may work from command prompt, because you set the stop action for the same motor earlier yourself, but is not very reliable in general.

    What you should do is

    m = LargeMotor('outB')
    m.stop_action="hold"
  2. WasabiFan commented on Nov 8, 2016

    @WasabiFan
    Member

    To expand on what @ddemidov said: When a device is "not connected", it means that no device could be found which satisfied the given requirements (e.g. port name, motor type).

  3. verytallrobot commented on Nov 8, 2016

    @verytallrobot
    Author

    Thanks ddemidov and wasabiFan. I thought I was initialising the motor not asking the brick to find that motor.
    Confused as to why it worked at all from the prompt.
    Cheers

  4. simoscream commented on Apr 8, 2018

    @simoscream

    I confirm that this may happen also because of a command called for incorrect device (ex LargeMotor(outB) where OUt B is connected to a small motor.

    Thanks :)

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