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'
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 themode_name
field.Only when the length of
mode_name
is 5, thecapability
string is on the right place (position 7 in themode_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
:the code becomes: