OpenRoberta / robertalab-ev3dev

roberta lab connector for ev3dev
Apache License 2.0
17 stars 14 forks source link

starting programs on the ev3dev with no motors/sensors connected throws #10

Closed ensonic closed 8 years ago

ensonic commented 8 years ago

When sending a program that does not use motors/sensors to an ev3 that has nothing connected, we still instantiate them in the robot config. This will throw an exception that we don't handle.

Exception AttributeError: "'MediumMotor' object has no attribute '_path'" in <bound method MediumMotor.del of <ev3dev.core.MediumMotor object at 0xb5dc9410>> ignored

ensonic commented 8 years ago

We have the same issue with sensors. For those we probably need to introduce factory methods in the hal too. This will need a server update though.

Jan 21 10:35:41 ev3dev openrobertalab[933]: File "/home/robot/NEPOprog.py", line 20, in <module>
Jan 21 10:35:41 ev3dev openrobertalab[933]: '1':ev3dev.TouchSensor(ev3dev.INPUT_1),
Jan 21 10:35:41 ev3dev openrobertalab[933]: File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 1664, in __init__
Jan 21 10:35:41 ev3dev openrobertalab[933]: Device.__init__(self, self.SYSTEM_CLASS_NAME, name_pattern, name_exact, driver_name=['lego-ev3-touch', 'lego-nxt-touch'], **kwargs)
Jan 21 10:35:41 ev3dev openrobertalab[933]: File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 180, in __init__
Jan 21 10:35:41 ev3dev openrobertalab[933]: name = next(list_device_names(classpath, name_pattern, **kwargs))
Jan 21 10:35:41 ev3dev openrobertalab[933]: File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 123, in list_device_names
Jan 21 10:35:41 ev3dev openrobertalab[933]: for f in os.listdir(class_path):
Jan 21 10:35:41 ev3dev openrobertalab[933]: OSError: [Errno 2] No such file or directory: '/sys/class/lego-sensor'
ensonic commented 8 years ago

Need to catch more exceptions. For Sensors we can also get an OSError:

ERROR:roberta.lab:Ooops:
Mar 04 09:27:55 ev3dev openrobertalab[313]: Traceback (most recent call last):
Mar 04 09:27:56 ev3dev openrobertalab[313]: File "/usr/lib/python2.7/dist-packages/roberta/lab.py", line 217, in _exec_code
Mar 04 09:27:56 ev3dev openrobertalab[313]: exec(compiled_code, scope)
Mar 04 09:27:56 ev3dev openrobertalab[313]: File "/home/robot/NEPOprog.py", line 19, in <module>
Mar 04 09:27:56 ev3dev openrobertalab[313]: '1':Hal.makeTouchSensor(ev3dev.INPUT_1),
Mar 04 09:27:56 ev3dev openrobertalab[313]: File "/usr/lib/python2.7/dist-packages/roberta/ev3.py", line 126, in makeTouchSensor
Mar 04 09:27:56 ev3dev openrobertalab[313]: s = ev3dev.TouchSensor(port)
Mar 04 09:27:56 ev3dev openrobertalab[313]: File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 1664, in __init__
Mar 04 09:27:56 ev3dev openrobertalab[313]: Device.__init__(self, self.SYSTEM_CLASS_NAME, name_pattern, name_exact, driver_name=['lego-ev3-touch', 'lego-nxt-touch'], **kwargs)
Mar 04 09:27:56 ev3dev openrobertalab[313]: File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 180, in __init__
Mar 04 09:27:56 ev3dev openrobertalab[313]: name = next(list_device_names(classpath, name_pattern, **kwargs))
Mar 04 09:27:56 ev3dev openrobertalab[313]: File "/usr/lib/python2.7/dist-packages/ev3dev/core.py", line 123, in list_device_names
Mar 04 09:27:56 ev3dev openrobertalab[313]: for f in os.listdir(class_path):
Mar 04 09:27:56 ev3dev openrobertalab[313]: OSError: [Errno 2] No such file or directory: '/sys/class/lego-sensor'