LEGO / lego-ble-wireless-protocol-docs

This repository contains information about LEGO Hubs (name, battery level, etc.) and to interact with any sensors and motors connected to it.
https://lego.github.io/lego-ble-wireless-protocol-docs
MIT License
334 stars 43 forks source link

Possible FW bug in GotoAbsolutePosition for virtual ports #28

Open gyenesvi opened 4 years ago

gyenesvi commented 4 years ago

I believe I have found a FW bug in the implementation of the output subcommand 'GotoAbsolutePosition' for virtual ports (both commands 0x0D and 0x0E) when using immediate execution that happens to discard a previous command. The symptom is that the command starts executing and moves the motors past the desired position but never stops. In line with that, when observing the output command feedbacks, starting from an 'idle' state, executing a first command moves the system into 'in-progress state'. Then a second immediate command discards the first, and leaves the system in 'in-progress' state, but afterwards a 'completed' feedback may never be received (neither a 'discarded', in fact, no feedback may be received afterwards). Another command sent in immediate mode can discard it, but then the next command never completes again. I was able to reproduce this behaviour by sending commands from my own custom bluetooth client and also via the Powered-Up app, which makes me believe that the error is not on my side.

The same command works well for non-virtual ports (single motor). The problem only seems to manifest itself when the command is sent in immediate mode and the previous command is still executing and is thus discarded. If I wait for the first command to finish and then send the next one, everything seems to be working fine (the second one also completes). Tested with Technic Hub with 4 ports, FW version 1.1, two technic XL motors (linear) on ports A+B.

The setup is as follows.

Then a series of GotoAbsolutePosition commands are sent (0x0D or 0x0E) in response to moving a slider. Tried to use various speeds with the same result.

In the Powered Up app, I could reproduce it as follows:

Did anyone experience a similar problem? Could anyone make synced motors go to absolute position properly in such a scenario?