-
Notifications
You must be signed in to change notification settings - Fork 123
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Technic Hub Port AB doesnt work #122
Comments
The MoveHub class is designed specifically for Lego Boost hub type, where joint motors are reported by the hardware. I'm not sure which kind of Technic Hub do you mention. Probably, for that type of Hub you'd need to issue a special command to join the motors. |
Dear Prof. King Kong, |
Ok here is the full debug log when i run the demo.py file:
|
Great, it is now much more clarity. The next question is: how many motors have you attached to your hub? |
If you have only two motors attached, try this line after hub initializes: hub.motor_AB = hub.peripherals[0x03] That's a hack-ish way of fixing it. The proper way would be to create a dedicated Hub subclass for device "Technic Hub 88012", so it would only expect specific set of devices to appear. And also create some peripheral classes for unhandled types of devices like temperature sensors. |
Sorry for the late feedback. |
How did you find out which port goes with what? Because I've looked at the data traffic from the Lego Handy APP and Hub and even with the BLE documentation I can't find out what is being sent. I find out the standard like Mac address etc. but not which commands are sent |
There are messages like this in the log: Regarding combining two motors, it looks like you need to do a "virtual port setup", as LEGO docs suggest here: https://lego.github.io/lego-ble-wireless-protocol-docs/index.html#virtual-port-setup No guarantees that it would work (see REMARK in docs). But it's worth trying. import time
from pylgbst.hub import Hub
from pylgbst.messages import MsgVirtualPortSetup
hub = Hub() # no point in using MoveHub here, should be base or dedicated class
time.sleep(5) # might be needed for Hub to sync up first
cmd_type = MsgVirtualPortSetup.CMD_CONNECT
ports_to_combine = (0x01, 0x02)
msg_combine = MsgVirtualPortSetup(cmd_type, ports_to_combine)
hub.send(msg_combine)
time.sleep(1)
# at this time, the MsgHubAttachedIO should arrive with combined port number
combined_port = 0x0 # put here the value that comes for it
hub.peripherals[combined_port].angled(180) # should be used like this This is a very interesting experiment, please keep on trying :) |
I apologize for the late response. I tried your code, added the Mac address, it establishes the connection and starts running for a moment. But only one motor is running and I get this message: Have no dedicated class for peripheral type 0x3c (TECHNIC_MEDIUM_HUB_TEMPERATURE_SENSOR) on port 0x3d with the command "combined_port", what do I have to add there? |
It works, so half :) After running your test code, the connection to the hub remains. Then I ran the Demo.py to test it and it ran completely. But why is it now and on which port is now AB? |
"Have no dedicated class for peripheral type" messages mean that the library does not have code to support certain onboard device types. This is harmless and there is a way to implement support for those. It's a separate story and requires running a "capability report" script like in #118. If you are willing to help, we can do that in a separate issue/PR. |
Regarding port combining, I'm confused. The message "Command error: Command 0x61 caused error 0x5: Command NOT recognized" means the hub does not support combining the motors together. I couldn't understand from your message, which code did you run and was it working as expected or not. |
I have now written my own little test. Everything works with this:
The feedback is: 155 INFO comms-gatt Discovering devices... Here you can also see that the virtual port runs on 0x10. I thank you for your help so far. |
Alright, so the combine command now works. I wonder why it did not work before. If we're strict, the port names are likely to be wrong, 'cause the kind of brick class is different. Still I'd create a dedicated subclass of |
Now that it works, I'll try a few more things. |
Hello everyone,
the library is great but I have problems with my Technic Hub.
The BLE connection works without any problems, I can also control and use any motor.
But I have problems with the AB port. Unfortunately, I cannot use two ports (A and B) at the same time.
If the Demo.py goes to "movehub.motor_AB.timed(1.5, -0.2, 0.2)" an error occurs.
With Run Debug I found out that the AB port is set to None.
Can someone help me here.
The text was updated successfully, but these errors were encountered: