appendix 1-lego mind storms nxt communication protocol

24
! " # ©$%%& # # #’ ! ! ! ! "!#( #!) * ! + ,)%%

Upload: doyoude

Post on 08-Apr-2015

823 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Appendix 1-LEGO Mind Storms NXT Communication Protocol

���� � ��� � ��� � ��� ����������������������������� � ��������� � �������� � ��� � ����������� � ��� � ������������������� !��"�������� � �� ���# �©$%%&�������� � �� ���# �� �����#��������������#��'�����!���!���������������� !��������������!��"���������!#����(�����#����!)� � � �

*��!���+�,)%%�

� ��

������� � � �� � � �� ���

��� � �������������������

Page 2: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � $�

*��!���+�,)%%�

�� ��������� �� �� �

TABLE OF CONTENTS ......................................................................................................2

LEGO® MINDSTORMS® NXT COMMUNICATION PROTOCOL ........................................3

OVERALL SYSTEM COMMUNICATION LAYERS ............................................................4

COMMANDS WITHIN THE COMMUNICATION PROTOCOL ............................................5 Open write command: .................................................................................................................................................. 7 Read command: ............................................................................................................................................................ 8 Write command: ........................................................................................................................................................... 8 Close command:............................................................................................................................................................ 8 Delete command: .......................................................................................................................................................... 9 Find first:....................................................................................................................................................................... 9 Find next:..................................................................................................................................................................... 10 Get firmware version: ................................................................................................................................................ 11 Open write linear command: ..................................................................................................................................... 11 Open read linear command (internal command): ................................................................................................... 12 Open write data command:........................................................................................................................................ 12 Open append data command:.................................................................................................................................... 13 Boot command: ........................................................................................................................................................... 13 Set brick name command:.......................................................................................................................................... 13 Get Device Info: .......................................................................................................................................................... 14 Direct commands: ....................................................................................................................................................... 14 Delete User Flash: ....................................................................................................................................................... 14 Poll Command Length: .............................................................................................................................................. 15 Poll Command: ........................................................................................................................................................... 15 Bluetooth Factory Reset Command: ......................................................................................................................... 15 Message command:..................................................................................................................................................... 15 Error message back to the host: ................................................................................................................................ 16 Wild cards: .................................................................................................................................................................. 16 File name conventions: ............................................................................................................................................... 16

IO-MAP ACCESS..............................................................................................................18 Direct IO-Map addressing and identification: ......................................................................................................... 18 Module ID encoding: .................................................................................................................................................. 18 Request First Module: ................................................................................................................................................ 19 Request Next Module: ................................................................................................................................................ 19 Close Module Handle command: .............................................................................................................................. 20 Read IO Map command:............................................................................................................................................ 20 Write IO Map command:........................................................................................................................................... 21

BLUETOOTH® COMMUNICATION...................................................................................22 Bluetooth® Class Of Device (COD)............................................................................................................................ 23

USB COMMUNICATION...................................................................................................24 ��

Page 3: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � .�

*��!���+�,)%%�

������� � � �� � � �� ������ � � ��� ��� �� �������������� � ��� � ��� � ��� ���#�������/ ��������������/ ���������������#�!!�0������!)�������/ ���������������#�!!�0����'�/ �������0������������������������!#���!���� ���#��(�� �/ �����!!���������������/ �����/ ����!�##������/ �# ��'�!�������!)���������� � �� � ��� � �� ����������!�����"����/ ��� ���������������#�!!�0������!+���

• Bluetooth® communication, V2.0 with EDR.

o Supporting the Serial Port Profile (SPP) • USB communication, V2.0

�1�!���������0�(����������� ��/ ���������������������#�������!��������� � �� � ��� � �� ���/ ������!�����������/ ���������������������"���!�/ �����#�����'�#��#�!���!���������������/ �����2���������0����� ���(���!)��

• One 6 wired digital communication port, maximum communication speed at 1 Mbit/s (High speed port) • Four 6 wired digital communication ports, maximum communication speed at 9600 bit/s (Low speed ports)

������/ 3!#��� ����������������!��!���������$����������������!������� )�����#�����'��!���!�"�����������3!#��� �#��������������0������� ������������������/ �����2���������(���!�/ �������4����!��������������������!#���!)�5 �����������������!���������3 �����������������#��������6/ / / )�3���)���7�/ ��������0��!������#�����������������������)����

Page 4: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � 8�

*��!���+�,)%%�

��� ����� � ��� ���� � � ������ ��� � � �����"������0���/ �!��/ !������������'��!����������������������!��� �0��/ ����������0����� ���(������� �����!�"�/ �������������)��9!�!��/ ���������"�����������!�#�!!�0������������������0��/ ���������/ ����(���!�����/ ����""������/ �'!���!����/ �����!!�����!������/ ���)���

������������

� ���������������

��������

����������������������

��� ��!��

��� ��!��

�����"��

��#� � �$%$���

&�������

��

'()��!��

��� ��!��

*� � �

**����������

����

���������

Figure 1: Communication block diagram

���/ ����0��#�!!�0����������!!�������������������/ �������� �����������!��� �������� � ��� � ��� � ��� �����������������#������������0 '�/ ���������� �����������/ �������������'������� �"�����������������3�����0�""��!)��5 ����/ ������ ������������ ��������'��������"��������0�""��!���������!����/ �'�������� �������������0���� �!����������� �0�� �"�������� �������)��

Page 5: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � :�

*��!���+�,)%%�

��� � � � �!��" � ��" ����� � � ��� ��� �� ����������!�!���������!���0�!������(��������������������"�������� � ��� � ��� � ��� �����������������#�������)�����!���'����!�# ����� ��0�(��0��������; �1���� �����1������������������������#���!�0����!�����!���'���/ ���������������� ���������/ ����0������#�'���� �/ ����������; �1���� �����1��������������������������'��!)���9��������������������"����� !������ �!������ ��"�#�� �������0��!�/ ����0��������� �0'���������(����������������������'��!�6�)�)�������������; �1������������������1��������������������������'��!7)���������/ ���������������#��������������!�����"����/ ������������������#��#�!�!+��� �/ ����� �"���!�6<����/ ����7+��

• Download firmware *.rfw • Download user defined programs *.rxe • OnBrick programming (Files are generated on the brick) *.rpg • Try-Me programs (Files are pre-programmed) *.rtm • Sound *.rso • Graphics *.ric

; #���� �"���!�6<��������7+�

• Upload programs *.rxe • Upload graphics *.ric • Upload sound *.rso • Upload datalog files *.rdt

�������!��3��"���� ���������������0����� �!'!����

• Delete sounds *.rso • Delete graphics *.ric • Delete user defined programs *.rxe • OnBrick programming (Files are generated on the brick) *.rpg • Try-Me programs (Files are pre-programmed) *.rtm • Delete datalog files *.rdt

��������������������/ �������� ���!'!���+�

• Get file list within NXT • Direct commands to the virtual machine • Messages command to mailboxes (Like the PB message in RCX 2.0) • Data directly from the high speed port

o Data should be written into a file on the HOST PC (This could be done using a handler which is specified to a handler. Then the communication port could be seen as a file, both as read and write).

Page 6: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � &�

*��!���+�,)%%�

� �������#���������(��(��/ ��#�'���� ������"��������; �1����1������������������������������+��

Figure 2: Protocol payload data

1'���% +�������� ��'#�)�����=�����/ �!��0����"����!�0'����!��!�� �"���������"'��� ������������ ��'#�)����������'�����!'!������!�����"����/ ����������� ��'#�!���������� ����0��������"��� )��1���=�6� �17��!��!�� �"���������"'����/ ������������������ �!����� ���(������#�'���!!����������)�

• 0x00: Direct command, reply required • 0x01: System command, reply required • 0x02: Reply command

• 0x80: Direct command, reply not required • 0x81: System command, reply not required

1'���,+�������� �0'��)�; !�� �0'����������������������������"'�/ ����!����� ���##���/ ������������)��� #���� �����5 ������ ������������ ��������������������/ ���� ��� 1'���$�3� +����!��0 '��!��""����������������"��������)� �����0�(��"������!��/ !�������� � ��� � ��� � ��� �����������������#��������!������� )�����!�#��������/ ����0��/ ��##�� �����������������1����������!������#��"�����������; �1�$)% ���������������#�������)�����/ ����0��#�!!�0��������/ ����� �&8�0'��!�6; �1�> 5 �0�""���!�?�7�0�"����������������������������!����!�(��������������<�9�> )�����!�/ ������ ���##��2������'�&���������� �/ �������������������������������������(�����������������)���������'�����!'!����!����!����������(�� �����30'��!��������0�""��������������!�$:&�0'��!��"�������/ ��������������!������������3#����/ ����������<�9�> ������'��"�����9�����9 � �#����!!��)��5 ����$:&�0'��!���(��0���������(�������'�����/ ����������������<�9�> ������'��"�����9�����9 � =�#����!!��)���9���"���!�����!���������������!�0���/ �/ �����!��,@�0 '��!�6,:).�����!7)��; ��!�� ����������!�!����� �0��"����� �/ �������������������!)���9����������!�/ �����0'���"��������(�����������#�� ���)�����������!�������"�����������#�� �����!���!����������������� �!����� ��2#������!#���"'�!��/ ����������������� )��������������!��������"����/ ��� �#���!������!�� �0��/ ������������������������(������� �������������������/ ����������"���/ ���)

Page 7: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � =�

*��!���+�,)%%�

��� � �� ���� � � #��1'���% +�%2%,�1'���,+�%2A%��1'���$�3�$,+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E������������������ ������#�� ���+��1'���% +�%2%$�1'���,+�%2A%�1'���$�������!+�%��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.��> �����+�> ���������0��)�1'���8+����1��"�"����!�?��6�������������7�1'���:+���1'���&+��1'���=+��� �1��"�"����!�?��� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )��5 �������!�������� �������!���!����!!�������!��������� ��!���4����� �"���F���!��������������G�/ ����������0��� �/ ����������������!����������� ���'�����)���"�����������!���������������"���/ ����/ �������!�������������������������')�

��� �! ������� � � #�

1'���% +�%2%,�1'���,+�%2A,��1'���$�3�$,+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E������������������1'���$$+����1��"�"����!�?��6�������������7�1'���$.+���1'���$8+��1'���$:+�� �1��"�"����!�?���� ������#�� ���+��1'���% +�%2%$�1'���,+�%2A,�1'���$�������!+�%��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.��> �����+�> ���������0��)�� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )��5 �������!�������� �������!���!����!!�������!��������� ��!���4����� �"���F���!��������������G�/ ����������0��� �/ ����������������!����������� ���'�����)���"�����������!���������������"���/ ����/ �������!�������������������������')�

Page 8: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � A�

*��!���+�,)%%�

�� ���� � � #�

1'���% +�%2%,�1'���,+�%2A$��1'���$+�> ���������0���1'���.+� ��0����"������0'��!����0����������1�1'���8+� ��0����"������0 '��!����0��������� �1�� ������#�� ���+��1'���% +�%2%$�1'���,+�%2A$�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0��)�1'���8+� ��0����"�������������(��0������������1�1'���:+� ��0����"�������������(��0����������� �1�1'���&�H� +� ����� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

! ������� � � #�

1'���% +�%2%,�1'���,+�%2A.��1'���$+�> ���������0���1'���.�H� +� �������0��/ ������������<�9�> �� ������#�� ���+��1'���% +�%2%$�1'���,+�%2A.�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0��)�1'���8+�����!���/ ����'�0'��!���(��0����/ ������������<�9�> ����1��1'���:+�����!���/ ����'�0'��!���(��0����/ ������������<�9�> ��� �1�

��������� � � #�

1'���% +�%2%,�1'���,+�%2A8�1'���$+�> ���������0���� ������#�� ���+��1'���% +�%2%$�1'���,+�%2A8�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0��)�

Page 9: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � @�

*��!���+�,)%%�

��������� � � #�

1'���% +�%2%,�1'���,+�%2A:��1'���$�3�$,+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E������������������ ������#�� ���+��1'���% +�%2%$�1'���,+�%2A:�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.�3�$$+�����������"������������ �"���)�<�����+�9����B3!����� �/ ������2�����!�?��C,:).�����!D�E�����������������

�� ��� � �#�

1'���% +�%2%,�1'���,+�%2A&��1'���$�3�$,+������"�����������I����2���!�����'#�!����"���6!7����!�����)�����5 ������� ���� ��/ �/ �����/ �������!���������/ �� )�E� ��������������)�� ������#�� ���+��1'���% +�%2%$�1'���,+�%2A&�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ������ ��0���1'���8�3�$.+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E�����������������1'���$8+����1��"�"����!�?��6�������������7�1'���$:+���1'���$&+��1'���$=+��� �1��"�"����!�?��� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )��5 �������"���!��2�!��/ ����������!'!����������������!!�����!��������� �/ �����������������#�� ���!�!�'��� +�F<��������"����G)���5 �������!�������� �������!���!����!!�������!��������� ��!���4����� �"���F���!��������������G�/ ����������0��� �/ ������������!����������� ���'�����)���"�����������!���������������"���/ ����/ �������!�������������������������')�

Page 10: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,%�

*��!���+�,)%%�

�� � ���#�

1'���% +�%2%,�1'���,+�%2A=��1'���$+�> ���������0���"��������#��(���!�"���� �"�������"��������<��� �<��!��������� )��� ������#�� ���+��1'���% +�%2%$�1'���,+�%2A=�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0����1'���8�3�$.+����������������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E�����������������1'���$8+����1��"�"����!�?��6�������������7�1'���$:+���1'���$&+��1'���$=+��� �1��"�"����!�?��� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )��5 �������"���!��2��!�/ ����������!'!����������������!!�����!��������� �/ ���������������#�� ���!�!�'��� +�F<��������"����G)���5 �������!�������� �������!���!����!!�������!��������� ��!���4����� �"���F���!��������������G�/ ����������0��� �/ ������������!����������� ���'�����)���"�����������!���������������"���/ ����/ �������!�������������������������')�

Page 11: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,,�

*��!���+�,)%%�

������ � !� ���� ��� #�

1'���% +�%2%,�1'���,+�%2AA�� ������#�� ���+��1'���% +�%2%$�1'���,+�%2AA�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�� �����(��!�����"�#���������1'���8+�� �J���(��!�����"�#��������1'���:+�� �����(��!�����"�"���/ ����1'���&+�� �J���(��!�����"�"���/ ����� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�����!�/ ��������/ �����#�!!�0����'��"���(������""������(��!���!��"�����"���/ ���)��<����2��#�����"�����0 '��!�����1'���.+�%2%$��1'���8+�%2%,��1'���:+�%2%.��1'���&+�%2%,K�����#��������(��!�������0����!�,)$���������"���/ ����(��!�������0����!�,).)������"����/ ��� ���"����������##���!����0��������"���/ ����(��!�������0������ �����#��������(��!�������0��)��1�� / ��� 3���#���0���������!���!���������������������"�����������(��!�������0������ �0�� / ��� 3�����#���0���������!���!���������������������"�������J���(��!�������0��)���������(������#���!�������J���(��!�������0���4������ �"����������(���������!��������J���(��!�������0������#���� �������������(�����������������"��������(����!����#���0���/ ����������(���)������������(��!�������0���/ ����0����#����� �0���������� ��������!��"�����(��!���3���� �������������)�

��� �! ������ �� ���� � � #�

1'���% +�%2%,�1'���,+�%2A@�1'���$�3�$,+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E������������������1'���$$+���1��"�"����!�?��1'���$.+��1'���$8+��1'���$:+�� �1��"�"����!�?��� � ������#�� ���+��1'���% +�%2%$�1'���,+�%2A@�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0���� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

Page 12: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,$�

*��!���+�,)%%�

��� � �� ��� �� ���� � � �$� �� ������ � � %#�

1'���% +�%2%,�1'���,+�%2A9� � ��1'���$�3�$,+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E������������������ � ������#�� ���+��1'���% +�%2%$�1'���,+�%2A9�1'���$+������!+�% ��4���!�!����!!)�� ������������% ��4���L!�������/ ���������(�������������!�������������!!���)��1'���.+� ��1��"�#����������������������'�!������)�1'���8+���1'���:+� �1'���&+� � �1��"�#����������������������'�!������)�� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

��� �! ���� � �� ���� � � #�

1'���% +�%2%,�1'���,+�%2A1��1'���$�H�$,+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E������������������1'���$$+���1��"�"����!�?��1'���$.+��1'���$8+��1'���$:+�� �1��"�"����!�?��� � ������#�� ���+��1'���% +�%2%$�1'���,+�%2A1�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0���� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

Page 13: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,.�

*��!���+�,)%%�

��� �� ��� � � �� ���� � � #�

1'���% +�%2%,�1'���,+�%2A���1'���$�3�$,+�����������"�����"���)�<�����+�9����B3!������/ ������2�����!�?��C,:).�����!D�E������������������� � ������#�� ���+��1'���% +�%2%$�1'���,+�%2A��1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0���1'���8+���1��"��(����0���"����!�?��1'���:+�3�1'���&+�3�1'���=+�� �1��"��(����0���"����!�?��� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

�������� � � #�

1'���% +�%2%,�1'���,+�%2@=��1'���$�3�$%+��F���L!������+��9� 19F�E������������������� � ������#�� ���+��1'���% +�%2%$�1'���,+�%2@=�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�MNL�1'���8+�M�L�1'���:+�M!L�1'���&+�MO%L�� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )����!�������� ��������'�0������#��� �0'�; �1)�

����� ��& � � � ����� � � #�

1'���% +�%2%,�1'���,+�%2@A��1'���$�H�,=+�� �/ �������"�0��� �6,:����������!�E����������������7�� � ������#�� ���+��1'���% +�%2%$�1'���,+�%2@A�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��

Page 14: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,8�

*��!���+�,)%%�

���� ������� ��#�

1'���% +�%2%,�1'���,+�%2@1�� � ������#�� ���+��1'���% +�%2%$�1'���,+�%2@1�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)�1'��!�.�H�,=+� ��������6,8����������!�E����������������7�1'��!�,A3$8+�1�������!!�1'���$:+���1��"�1���������!������!��������1'���$&+�1'���$=+�1'���$A+�� �1��"�1���������!������!��������1'���$@+���1��"�"�����!���<�9�> �1'���.%+�1'���.,+�1'���.$+�� �1��"�"�����!���<�9�> �� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

� ������� � � � #�

1'���% +�%2%%�P�������������"����������������� �1'���,�H�&.+� ������������� �� ������#�� ���+��1'���% +�%2%$�1'���,+�F ������������� �0'��G�1'���$+�<�����/ ����/ �������������?����0����!���������(����2#���!����������#�� ����"������������������� )�������!��!�������F��� � �� � ��� � �� ��� �������������G����������"���������!����/ ����������#�� ���!�!����� �0������!������ ���� ������(�� ����������������������!)��9���� �������������!�����# �!!�� �����������*� ���� ���"�����!�!����������������������*� ��������/ �������!�����'�"�������*� ����������)�

������� �� ���� �" #�

1'���% +�%2%,�1'���,+�%29%�� � ������#�� ���+��1'���% +�%2%$�1'���,+�%29%�1'���$+�%2%%�6�����!�������������4����� ��!��##��2������'�.�!�����!7�� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

Page 15: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,:�

*��!���+�,)%%�

�������� � � ��� ��" #�

1'���% +�%2%,�1'���,+�%29,�1'���$+�1�""��� ��0��+�%2%%�P������0�""����%2%,�P�> �����#��� �0�""���� � ������#�� ���+��1'���% +�%2%$�1'���,+�%29,�1'���$+�1�""��� ��0��+�%2%%�P������0�""����%2%,�P�> �����#��� �0�""���1'���.+�%�6�����!!7�1'���8+� ��0����"�0 '��!�"�������������� �����'��������0�""���6%�P����������� �����'7)�����!�/ ������#��� ����0�""���!�?�!)�� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

�������� � � #�

1'���% +�%2%,�1'���,+�%29$�1'���$+�1�""��� ��0��+�%2%%�P������0�""����%2%,�P�> �����#��� �0�""���1'���.+����������������� � ������#�� ���+��1'���% +�%2%$�1'���,+�%29$�1'���$+�1�""��� ��0��+�%2%%�P������0�""����%2%,�P�> �����#��� �0�""���1'���.+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)�1'���8+���������"������1'���:3&8+�������� �� ������#�� ���!�!����� �����0��� �!�0��� �"������!�������� )�

��������" ������ � �������� � � #�

1'���% +�%2%,�1'���,+�%298�� � ������#�� ���+��1'���% +�%2%$�1'���,+�%29$�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!�������/ ���������(�������������!�������������!!���)�����!�������� ��������0������!������ �(���1���������0����!������1���������"�����������'��!���!���0'����!��������Q�

� ���������� � � #�

9���!!����������� �����0�����������"��!������(����� ��������������� )�; !�������!�������� ����!����� �0��#�!!�0����������(������#������������#�����"���#������)����!��'#���"�������� ���������������������������� ������!����� �0������(���� ��������!��������)���� �!!���!�������!���0�� ����"������������������������ � �� � ��� � �� ��� ������������� ���������)�

Page 16: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,&�

*��!���+�,)%%�

� � �� �������� ��& �����" ��" ���#�

������"���������0���/ ���!���0�!���/ �/ ����������?����������!!���!K�������!�������!���0����!�#���������!#��������������!!���)����!���"���������/ ����0���������� �/ �����������������#�� ���!)���� ������#�� ���+��1'���% +�%2%$�1'���,+�������� �������!������(��� �����#�'�1'���$�������!+�%��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)�������"����/ ��� ���������!!���!���'�0�������(�� �"�������� �������+��

• Success 0x00 • No more handles 0x81 • No space 0x82 • No more files 0x83 • End of file expected 0x84 • End of file 0x85 • Not a linear file 0x86 • File not found 0x87 • Handle all ready closed 0x88 • No linear space 0x89 • Undefined error 0x8A • File is busy 0x8B • No write buffers 0x8C • Append not possible 0x8D • File is full 0x8E • File exists 0x8F • Module not found 0x90 • Out of boundary 0x91 • Illegal file name 0x92 • Illegal handle 0x93

����"����/ ��� ���������!!���!������������ �/ ����������#����������'��+��

• Device is not responding. This is included within the USB and Bluetooth protocols. • Not ready for receiving data. This is included within the USB and Bluetooth protocols.

�"������������#�� �����!���!�0�����������������!!����/ ����0����!�)������"�������������������/ �����������#�� ���!��������������#��0���!�"���������!��0����!�������'�0����(��������(��'�������!�"����/ ��������0��� ���!��������'��2#�������� ���#��0������� ���!�0��� �������������#����!!)�

!�� ��� � #�

����"����/ ��� ��'#�!��"�/ ��� �����!�/ ����0������#����/ ����������"���������������!'!���+��• Filename.Extension • *.[File type name] • Filename.* • *.*

����� � � ���� �� ��� � #�

9���"��������!�/ ����������!'!��������������������2������"�,@�0'��!�6,:).�����!7)��<��������!��������������##����!����� ���/ ����!�����������!�0���/ ����0�����#���� �/ ����������!'!����/ ��������!������!��!��������)����������!��������"�����������0��� �����'�����#������!�"���!�6R)�2�7�/ ����0��!��/ ���!�/ �������0'�

Page 17: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,=�

*��!���+�,)%%�

�����!����������� ������"���!�/ ����0�����##������ ���/ ����!�!����������!�/ ����0����!#��'�� �/ �����##������ ���/ �����!�����������!)��<���������2���!���!�/ ��������0��!��/ ���������0��� L!���!#��')��5 ������������� � �� � ��� � �� ���!�"�/ ��������!����� �0��#�!!�0��������!������"�����'#�!�����(������'�����������!��������)��

Page 18: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,A�

*��!���+�,)%%�

��'� � �������� ���������������(��������(����� ��!���������#����!������0�������������#������!��!����!�����"�"���0�� �"��������!'!����!����� �0��#�!!�0��)��������0����� �!'!�����!���!����� ������� ��� 3� �#!��/ �������������/ ���3��!���0�� ���'���0��/ ����������""����������������!I���(��!�!��� ���� �����*� �������� ������!��L!�����)��������2����!����!���� ������!��3����!!�0��������������#��!����� ���������� 3� �# )��; !�������!���"����������������(����� ��!�����!�"��������!!���� � ��/ �������"�������������!������"�������0����� �!'!��������������)�������������!�������!����#�������������!�� ��������'����������� � �� � ��� � �� ���!�"�/ ���Q�

� ������'� � ��� ���� ��� �� � ������ ��� #�

����!'!�����!�<�9�> 30�!�� ���� ���������� '������!'!���)�������#���������������!�����0���"���""�������� ������#��2��'���� �(��!���)��������0�������!'!�������"������!#���"�����������'#��������������!��� ��/ �����#�����������"���!#���"�����������!��������������!���4����� �"�������� )�

� � ����� �� ��� �#�

� �����!���(����F���4��G�� ����#�!�� ��"�����#���������L!�������"������������'#����!���#��������� ���(��!�������0������������ �0��������!����� �"����(��!���������!+� MSB PP TT CC FF LSB ���������!�F��G�������"'�����#������������)� )����� � �� ���# �P�%2%,)�����������!�F��G�����������������'#��������"�������)� � � �

• Cmd = 0x01 • Output = 0x02 • Input = 0x03 • Button = 0x04 • Comm = 0x05 • IOCtrl = 0x06 • Led = 0x07 • Sound = 0x08 • Loader = 0x09 • Display = 0x0A • Low Speed = 0x0B • UI = 0x0C

���������!�F��G���� �F<<G����������������(��!����������"����������)� )��%,���� �,8�����!�(��!����,������!�����0���,8)��� "�����!�������'#��!#���"��� �!����� �0���!�� �����������'��!����""������������0��/ ���������3���(���������!�!����� �0�����#����� �0'��!��� �����(��!�����!�/ ���)�

Page 19: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � ,@�

*��!���+�,)%%�

�( ������� ���� � ���#�

1'���% +�%2%,�1'���,+�%2@%��1'���$�3�$,+�������!�������������� ��2���!�����"���!�����6!7����!�����)�������2���!�����!���"�����!�����#��������� ���������/ ������� ��������'�0���!�� �"������������������)���9�/ ������� ��!��!�� ��"��������������!�������!���� ���! K������/ �!����!#���"������������0���!!��� �����������"����������0������!#���"���������)����������I/ ������� ��!������#����� �0'�6�7������0 '��6!7��!�����������������"�2�� �!�?���"�$%�����!�6,:).�E�%2%%7)��� ������#�� ���+��1'���% +� %2%$�1'���,+�%2@%�1'���$�������!+�%�6?���7��������� ��������������!����!!)� ��0��!�S�% �����������������������)�1'���.��> �����+�> ������ ��0���1'���8�3�$.+�����������"������������6��!�����7)���������I/ ������� ��!������#����� �0'�6�7������0 '��6!7��!�����������������"�2�� �!�?���"�$%�����!�6,:).�E�%2%%7)�1'���$8+���1��"���������) )�6�������������7�H�.$�0���1'���$:+�3�1'���$&+�3�1'���$=+�� �1��"���������) )�1'���$A+���1��"��������!�?��6�������������7�H�.$�0���1'���$@+�3�1'���.%+�3�1'���.,+�� �1��"��������!�?��1'���.$+���1��"�������������� 3� 9��!�?��6�������������7�H�,&�0���1'���..+�� �1��"���������� 3� 9��!�?���������!���##���������!����� ��� ������!���"����������������� !���!�����������������!��!�?�!�����)��<�����������!!��������������!�!����� �0�������� ��!�������!��� !)�

�( ����� ����� � ���#�

1'���% +�%2%,�1'���,+�%2@,��1'���$+�> ���������0���"��������#��(���!� �4��!�� �2��� ������������� ����"��������(��'�"��!�� �4��!��<��!��� ������������� )��� ������#�� ���+��1'���% +�%2%$�1'���,+�%2@,�1'���$�������!+�%�6?���7��������� ��������������!����!!)� ��0��!�S�% �����������������������)�1'���.��> �����+�> ������ ��0���1'���8�3�$.+�����������"������������6��!�����7)���������I/ ������� ��!������#����� �0'�6�7������0 '��6!7��!�����������������"�2�� �!�?���"�$%�����!�6,:).�E�%2%%7)�1'���$8+���1��"��������� �6�������������7�H�.$�0���1'���$:+�3�1'���$&+�3�1'���$=+�� �1��"��������� �1'���$A+���1��"��������!�?��6�������������7�H�.$�0���1'���$@+�3�1'���.%+�3�1'���.,+�� �1��"��������!�?��1'���.$+���1��"�������������� 3� 9��!�?��6�������������7�H�,&�0���1'���..+�� �1��"���������� 3� 9��!�?��

Page 20: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � $%�

*��!���+�,)%%�

������� � ����" � ������ � � #�

1'���% +�%2%,�1'���,+�%2@$�1'���$+�> ���������0���� ������#�� ���+��1'���% +�%2%$�1'���,+�%2@$�1'���$+������!+�% ��4���!�!����!!)�� ������������% �����!����������/ ���������(�������������!�������������!!���)��1'���.+�> �����+�> ���������0����9�!���!�� �"������!���������� 3��# ��������6#�����"���������7)�

�� ����� � ����� � � #��

1'���% +�%2%,�1'���,+�%2@8��1'���$+���1��"��������� �6�������������7�1'���.+��1'���8+��1'���:+�� �1��"��������� �1'���&+���1��"��""!���6����27�6�������������7�1'���=+�� �1��"������""!���1'���A+� ��0����"�0 '��!����0����������1�1'���@+� ��0����"�0'��!����0��������� �1�� ������#�� ���+��1'���% +�%2%$�1'���,+�%2@8�1'���$�������!+�%��4���!�!����!!)�� ������������% �6?���7�����!����������/ ���������(�������������!�������������!!���)��1'���.+���1��"��������� �1'���8+�1'���:+�1'���&+�� �1��"��������� �1'���=+� ��0����"�0 '��!��������(��0������������1�1'���A+� ��0����"�0'��!��������(��0����������� �1�1'���@�H� +��� 3��# ��������!�

Page 21: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � $,�

*��!���+�,)%%�

! �������� � ����� � � #�

1'���% +�%2%,�1'���,+�%2@:��1'���$+���1��"��������� �6�������������7�1'���.+��1'���8+��1'���:+�� �1��"��������� �1'���&+���1��"��""!���6����27�6�������������7�1'���=+�� �1��"������""!���1'���A+� ��0����"�0 '��!����0��/ ����������1�1'���@+� ��0����"�0'��!����0��/ ��������� �1�1'���,%�H� +��� 3��# ������������0��!����� ������ 3��#C����2DT ))�� 3��#C����2�E� D�� ������#�� ���+��1'���% +�%2%$�1'���,+�%2@:�1'���$�������!+�%��4���!�!����!!)�� ������������% �6?���7�����!����������/ ���������(�������������!�������������!!���)��1'���.+���1��"��������� �1'���8+�3�1'���:+�3�1'���&+��� �1��"��������� �1'���=+� ��0����"�������������(��0����/ ����������1�1'���A+� ��0����"�������������(��0����/ ��������� �1�

Page 22: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � $$�

*��!���+�,)%%�

��������" ����� � � ������ �����1����������"�����������'�/ ��������� � ��� � ��� � ��� ����!��!�����������������������"���)�����������"�����������1�������������# ����������0����� �!'!�����!��������!#��� �; 9 �������"�����������9 � =�#����!!��)��9�������0�!�0��� ��������� ��!������/ ����������1�������������# �/ ���������!���������������!���������� �"��������1�������������# ��!�����!���������������!�!���������� �"����������� � ��� � ��� � ��� ����������������������������'�������������!���)�����!��������������(���#�������!�!��/ �����������1��������������������������������������!�!������!��(������!�/ �����������!����!�������� �����)����!����!��(������!�!����"�����/ ��#��0���!+�0 �����������# �� ���!�����0�������(�� �/ ����!��������������""������!�"��������9 � �#����!!��K���� ��������!��������#�����'�6�"������� �.%���7�/ ����������1������������# �/ ����!/ ������� �"���������(�3������������!���3����)��������# �������?�����0�(��#��0���!�!����������������������� �"�����������'��!����������������� � ��� � ��� � ��� �����������������#���������������1�����������������������)����������������"�����������'�!����� ����'�0 ���!�� �/ �����!��� �1�����������������������)������������������#��0�����"������������ �����!�?���"����������������!�0���� ������(�����������0'��!�!����� �0������� ����"������"�������� � ��� � ��� � ��� ��������������������������#�'���� �����)�����!��0'��!���!���0��������������������"������ ����#�� ���!������!����� �0�������(�� �����!������������0'��!�����!��(�!)��9�����������������/ ����0���/ ��0 '��!���!���0��� �������������"�����#�� ���)����������������#��0�����"����������#�����'�/ ����������1��������� ����#���!��!�!����� �!��� �������!��� �1����������/ ���������4��!���������#�'�#�� ���)�����!�/ ������������������1��������� ����# �/ ��L����(�����!/ ���������������"����(��'������(�� �#�� ������� �/ ����������������.%����#�����'�"����(��'������# �� ���)���������"����������# �� ���!�"���1��������������������������� ��!�"����/ !+��

Figure 3: Data packages when sending Bluetooth® commands

Page 23: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � $.�

*��!���+�,)%%�

��������" ����� �� ���� ������$�� %�

����1�������������# �/ ������������� � ��� � ��� � ��� ���/ ����������������"����/ �������!!�� "� �(����/ ���������0���!�� ������������������1������������(�����'#�+���� �J��� �(�������!!�!������� �J������!!�!��������!����������!����(����"�����������'�"�����"��������1���������� �(���)�����������"���������"�����(�����!��!�� ��������������������J������!!�����#��� )������������.$���""������#�!!�0�����J������!!�!)�������!!���������"�������J������!!�"���� ��!���"���� ����������0���0���/ )�

Table 1: Major Device Classes

12 11 10 9 8 Major Device Class 0 0 0 0 0 Miscellaneous [Ref #2] 0 0 0 0 1 Computer (desktop, notebook, PDA, organizers, .... ) 0 0 0 1 0 Phone (cellular, cordless, payphone, modem, ...) 0 0 0 1 1 LAN /Network Access point 0 0 1 0 0 Audio/Video (headset, speaker, stereo, video display, vcr, ... 0 0 1 0 1 Peripheral (mouse, joystick, keyboards, ... ) 0 0 1 1 0 Imaging (printing, scanner, camera, display, ...) 0 0 1 1 1 Wearable 0 1 0 0 0 Toy 1 1 1 1 1 Uncategorized, specific device code not specified X X X X X All other values reserved ��������� � ®�� � ��� � �®� �����!�0����#���������������J�����(�������!!���')� � ����� �(�������!!�"���� �3���'�� �J������!!������� ��������!!�!��������!�������/ �!����(����"�����������'�"�����"��������1���������� �(���)������������&8���""������#�!!�0������������!!�!)�������!!���������"����!������� �(�������!!�"������!���"���� ����������0���0���/ )��

Table 2: Minor Device Classes

7 6 5 4 3 2 Minor Device Class bit no. of COD

0 0 0 0 0 1 Robot 0 0 0 0 1 0 Vehicle 0 0 0 0 1 1 Doll / Action Figure 0 0 0 1 0 0 Controller 0 0 0 1 0 1 Game X X X X X X All other values reserved �������� � ®�� � ��� � �®� �����!�0����#���������������������(�������!!� �0��)��

Page 24: Appendix 1-LEGO Mind Storms NXT Communication Protocol

����� � ��� � ��� � ��� ��������������������������- $%%&�������� � �� ���# � $8�

*��!���+�,)%%�

��� ���� � � ��� ��� ������; �1���������������#�!!�0����'�/ ������������� � ��� � ��� � ��� ���!����� �0��!�����!���!�##�������"��������!��!�/ ������!�L����(����1����������������)�������"����������������������#�!!�0������!�������������; �1���(����!����� �0������!����������������1������������(���)��

� ���+� � ��������� �15 +� ��'���� �!�?�+� > ���!�� �+�1�� � �� UP�&8�0'��!� N�!��!��������!� N�!� UP�,%$.�0'��!� ���������#��6,):7� �� � �2)�A�0 '��!� N�!��������#��6,$7� �� UP�&8�0'��!� N�!�

Figure 4 : USB 2.0 capabilities in the Atmel ARM7 microcontroller

����; �1����������������!���#�������� ��!����0�� �����!"���/ ���������!����������9 � =�#����!!�����!���&8�0'�������/ ����0�""���"��������(����; �1�����)����!�������������!���!����������� �/ ������������"���������������!��� �/ ����������#��������/ �����!����; �1��������������)�� �����"�������������; �1�������������������0�����������/ ��� �""��������(��!�/ ����������<�����������������������(������������������������ 9�����#����)�� �����(��!�/ ������������!������0�(��#���������������!���� �����/ �����"�������!��!�����/ ��������������������/ ���������#��������#��������!�����!����0������������ �/ �������������������������������'��)�> �(����0����#�!!�0������!����0��!��!����������� � ®�� � ��� � �®� ���������������/ ������ �����/ �#����������'����"������� )�<���"�������������!�#���!����"�������������������������"�������"���������(��)��