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

3.18.1 Format of Port Input Format Setup (CombinedMode) > Sub Command = 0x01 SetModeDataSet combination(s) #22

Open
Vouzamo opened this issue Apr 19, 2020 · 5 comments

Comments

@Vouzamo
Copy link

Vouzamo commented Apr 19, 2020

I am trying to set up combined mode sensors on a motor to get notified of changes to either absolute position or speed.

I was able to do this with single mode but I am unclear how to get combined mode working.

In my case I have two modes Speed (0x01) and Position (0x02).

Based on this I believe I want to set combination index based on the combination mode 0b0000000000000110 (Mode 1 and Mode 2).

The part I am unclear on it what I need to send for Mode/DataSet[0], Mode/DataSet[1], Mode/DataSet[n].

Perhaps this is device and mode specific but any guidance would be appreciated.

I know that the Speed mode notifies with a byte value and the Position mode notifies with an Int32 value but this doesn't seem to help me.

@Vouzamo
Copy link
Author

Vouzamo commented Apr 20, 2020

After working more on this today, I believe I have a better understanding of how to format the message but I am not getting the anticipated reply so something is still not quite right.

I have been able to determine the possible combination modes for a motor connected to port zero by sending a Port Information Request (Information Type 0x02).

This gives me just one option: 0b_0000_1110 (Mode 1 + Mode 2 + Mode 3).

In addition to this I am able to determine the Value Format for each mode using the Port Mode Information Request (Mode Information Type 0x80).

This gives me the following:
Mode # :: Mode Name :: Datasets Type Figures Decimals
1 :: Speed :: 1 0 4 0 (1 dataset, 8 bit type, 4 figures, 0 decimals)
2 :: Position :: 1 2 4 0
3 :: Absolute Position :: 1 1 3 0

1.) Send Port Input Format Setup CombinedMode (0x02 Sub-Command Lock LPF2 Device for setup) and currently wait 1000ms since this doesn't seem to trigger any reply I can wait for.
2.) Send Port Input Format Setup SingleMode for each mode (1, 2, and 3) waiting for replies to each before proceeding.
3.) Send Port Input Format Setup CombinedMode (0x01 Set ModeAndDataSet combinations):

9 Length
0 Hub Id
66 Message Type (0x42)
0 Port
1 Sub-Command: Set ModeAndDataSet combination(s)
0 Combination Index: Mode 1 + Mode 2 + Mode 3
17 00010001 Mode/DataSet[0] : Mode 1 / Dataset 1
33 00100001 Mode/DataSet[1] : Mode 2 / Dataset 1
49 00110001 Mode/DataSet[2] : Mode 3 / Dataset 1

This is what I expect to reply with 3.24. Port Input Format (CombinedMode) but it doesn't.

Is my understanding correct and the message above formatted correctly? It seems so based on the docs but failing to get any data back to give me confidence that I am on the right track with this.

Vouzamo added a commit to Vouzamo/Lego that referenced this issue Apr 20, 2020
…ormation to start to integrate support for combined mode. Issue with combined mode logged here: LEGO/lego-ble-wireless-protocol-docs#22
@a333klm
Copy link

a333klm commented Dec 22, 2020

Don't forget to send an unlock message. Without an unlock message, there won't be a confirmation.

@tthiery
Copy link

tthiery commented Dec 22, 2020

Setup is hard and the fun really starts when receiving mode/datasets. The protocol contains state (you have to remember what you set up to later decode it). This and the three layers of understanding here are a challenge.

Very underspeced. By now I hope I got it right in my lib but the documentation is really unclear on it.

@Vouzamo
Copy link
Author

Vouzamo commented Dec 22, 2020

Thank you for the response. Will take a look at that over the next few days to get it working but will continue to refer to your repo regarding new features etc.

@a333klm
Copy link

a333klm commented Dec 23, 2020

Got it now. This is how I set the TechnicMotorXL to combined mode.
>> for sending a message to the hub/motor
<< for a message received a message from the hub/motor

locking 
INFO   |     | >> Port_Input_Format_Setup__Combined_Mode | 05,00,42, | 03,02, 
INFO   |  << |                    Generic_Error_Messages | 05,00,05, | 42,06, 
WARNING| Port_Input_Format_Setup__Combined_Mode caused InvalidUse 
set single mode 1 
INFO   |     | >>        Port_Input_Format_Setup__Single | 0a,00,41, | 03,01,01,00,00,00,01, 
INFO   |  << |                 Port_Input_Format__Single | 0a,00,47, | 03,01,01,00,00,00,01, 
set single mode 2 
INFO   |     | >>        Port_Input_Format_Setup__Single | 0a,00,41, | 03,02,01,00,00,00,01, 
INFO   |  << |                 Port_Input_Format__Single | 0a,00,47, | 03,02,01,00,00,00,01, 
set single mode 3 
INFO   |     | >>        Port_Input_Format_Setup__Single | 0a,00,41, | 03,03,01,00,00,00,01, 
INFO   |  << |                 Port_Input_Format__Single | 0a,00,47, | 03,03,01,00,00,00,01, 
setting ModeDataSet 
INFO   |     | >> Port_Input_Format_Setup__Combined_Mode | 09,00,42, | 03,01,00,10,20,30, 
unlocking 
INFO   |     | >> Port_Input_Format_Setup__Combined_Mode | 05,00,42, | 03,04, 
INFO   |  << |          Port_Input_Format__Combined_Mode | 07,00,48, | 03,00,07,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,4f,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,4f,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,4f,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,50,00, 

When I send a Port Output Command immediately after that, it looks like that (together with the retrieved speed etc.):

INFO   |     | >>                    Port_Output_Command | 08,00,81, | 03,10,51,00,32, 
INFO   |  << |                 Port_Value__Combined_Mode | 08,00,46, | 03,00,04,4f,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 0c,00,46, | 03,00,06,f4,2f,00,00,54,00, 
INFO   |  << |                 Port_Value__Combined_Mode | 0d,00,46, | 03,00,07,08,09,30,00,00,69,00, 
WARNING|  
WARNING| Speed:            8 
WARNING| Position:         12297 
WARNING| absolutePosition: 105 
INFO   |  << |                 Port_Value__Combined_Mode | 0d,00,46, | 03,00,07,19,23,30,00,00,83,00, 
WARNING|  
WARNING| Speed:            25 
WARNING| Position:         12323 
WARNING| absolutePosition: 131 
INFO   |  << |                 Port_Value__Combined_Mode | 0d,00,46, | 03,00,07,22,3d,30,00,00,9d,00, 
WARNING|  
WARNING| Speed:            34 
WARNING| Position:         12349 
WARNING| absolutePosition: 157 
INFO   |  << |                 Port_Value__Combined_Mode | 0d,00,46, | 03,00,07,23,55,30,00,00,4d,ff, 

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

3 participants