Skip to content
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

Add power_m2 option to init() method of PUPRemoteSensor #9

Closed
Tracked by #8
ste7anste7an opened this issue Aug 16, 2023 · 0 comments
Closed
Tracked by #8

Add power_m2 option to init() method of PUPRemoteSensor #9

ste7anste7an opened this issue Aug 16, 2023 · 0 comments

Comments

@ste7anste7an
Copy link
Collaborator

ste7anste7an commented Aug 16, 2023

Pwer on M2 is enabled by using the capability string \x80\x00\x00\x00\x05\x04. It seems that both the PyBricks as well as the Lego Mindstorms Inventor implementation expects this capability string at a fixed offset in the mode_name field.

Only when the length of mode_name is 5, the capability string is on the right place (position 7 in the mode_name field. For longer or shorter names, it is not, and the power is not enabled on pin M2.

So we have the following requirements on the mode_name:

  • length not longer than 5
  • if length is shorter than 5, pad it with (5-len(info_name)) zero's before the capability string.

the code becomes:

if self.power:
            mode_name = mode_name.encode('ascii') + b'\x00'*(5-len(mode_name)) + b'\x00\x80\x00\x00\x00\x05\x04'
@ste7anste7an ste7anste7an mentioned this issue Aug 16, 2023
18 tasks
@antonvh antonvh closed this as completed Jan 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants