Replies: 9 comments 4 replies
-
|
Hi vascolp, Maybe you now need to change the use of center button? In the beta examples I see this: # Using the stop button during your program
from pybricks.hubs import TechnicHub
from pybricks.parameters import Color, Button
from pybricks.tools import wait, StopWatch
# Initialize the hub.
hub = TechnicHub()
# Disable the stop button.
hub.system.set_stop_button(None)
# Check the button for 5 seconds.
watch = StopWatch()
while watch.time() < 5000:
# Set light to green if pressed, else red.
if hub.button.pressed():
hub.light.on(Color.GREEN)
else:
hub.light.on(Color.RED)
# Enable the stop button again.
hub.system.set_stop_button(Button.CENTER)
# Now you can press the stop button as usual.
wait(5000) |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your answer, I am aware of the set_stop_button method. In fact that was the last thing I removed from my test program. Ah! Just found out that it only happens with Motor, it does not happen with DCMotor! |
Beta Was this translation helpful? Give feedback.
-
|
This is the expected behavior for this release. When you unplug a motor while it is running, the System Exit exception is raised. This also happens if you press the stop button, and there’s only one generic ‘stop button was pressed’ message right now. We did this to make sure the hub would cleanly turn off all the motors in case of unhandled problems, like unplugging a cable. A nicer solution that works without the global System Exit has already been developed. It will raise an OSError with errno=ENODEV for that particular motor only. This will be part of a future release. Probably the next beta. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Laurensvalk, Ok, I can live with that... but not convinced :-) Is the System Exit never catchable? |
Beta Was this translation helpful? Give feedback.
-
|
Thank you for your answer. I am already using PUPDevice class, it works fine with Motor devices. I noted some issues with DCMotor devices (ID 1 I think, the one from batman LEGO set 76112), specially when battery charge is low. Sometimes the code would block until we disconnect the device. I think there was a detection problem related with a voltage level (I might have read about this somewere around here), but I had this situation much more often in v3.1.0b1, it seems v3.1.0c1 fixed it. |
Beta Was this translation helpful? Give feedback.
-
|
Hi Pybrickers! Sorry to get back to this problem, but I think there is really something wrong when you disconnect a device. |
Beta Was this translation helpful? Give feedback.
-
|
Tried in this: v3.1.0 on 2021-12-16 |
Beta Was this translation helpful? Give feedback.
-
|
I don´t know how to get a firmware version from there! |
Beta Was this translation helpful? Give feedback.
-
|
Cool! Thanks! |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I think I might have found something wrong in version v3.1.0c1 and also in the just released v3.1.0.
At least, in v3.1.0b1 things make much more sense to me...
It is related with disconnecting a device from the TechnicHub and exception handling.
Consider the below program to run in a TechnicHub with a Motor in Port.A.
It asks for a remote (white blinking light in th hub), and then, if you press a remote button it prints the device object.
With this program, if you disconnect the device, the program should print an error and go back to the main cycle.
But with versions v3.1.0c1 and v3.1.0 it crashes.
Ah! Just found out that it only happens with Motor, it does not happen with DCMotor!
Here is the output for v3.1.0b1, assuming you have a motor connected to Port.A when it starts.
You have to disconnect the Motor to get an exception and then you can connect it back with no problems.
Here is the output for v3.1.0c1 (similar to v3.1.0), assuming you have a motor connected to Port.A when it starts.
In this case, as soon as you disconnect the motor the program crashes.
I also noticed that if you start the program without the motor connected, the Exception is properly handled, but if you connect the motor, press a remote button and then disconnect the motor, it crashes.
Notice: the error looks like the error associated with the hub button but it happens when you desconnect the Motor cable. I never press the hub button.
Thanks and best regards!
VascoLP
Beta Was this translation helpful? Give feedback.
All reactions