miércoles, 19 de enero de 2011

PC - NXT Communications

One of the great successes of LEGO MINDSTORMS NXT development is the native implementation of Blutetooth Serial communications layer.



This means that we have a wireless serial communications interface that allows us to develop programs that interact with our robots and perform remote control and telemetry in real time.
NXT communication between devices is documented in Appendix 1 of BtDeveloperKit, but the PC-NXT communication requeire undocumented technique both for the host device settings, and to control data flow.
If you work in c, my recommendation is to create a library that allows communication NXT TXRX.h added as file in any program that subsequently perform well have the concept of "communication layer that allows us to abstract and focus on the object programming.
From the host side (PC in our case), we must also develop a small code that will allow us to abstract the process.

And advancement, resolved in an efficient communication process is to develop a communication interface to provide us with certain communication services.
For example, our development has developed two types of service:
Service 1 º Sending information
Service 2º  Consultation Service Information
Both services are symmetrical and are located at each end of the interface. The purpose of these services is to have a mechanism that allows us to send asynchronous commands (remote) and request information (telemetry). In the definition of service we set the format of the information, so the maximum length. Advance and we may be interested in having a short data or a large amount of data, and therefore we must establish mechanisms to fragment and reconstruct the information at the other end.

NXT BT SDK
In the LEGO website, you can download the SDK Bluetooth where we describe the characteristics of the packet format used, along with communication services that this layer implements.
Although we have a lot of services 'high' as access to files, internal variables, etc, which interests us is the generic coumunicaciones on MailBox (0-9), which allows us to send a packet of 64bytes (6 bytes payload) on a 'connection' that will be glued to 5 packets (messages) on the other end and managed automatically returning overflow error in the host side to let us know that we can not continue to transmit.

This will be the communications service will use to build our application interface, allowing us to have up to 10 Mailboxes (0-9) (lines of communication or different data streams) to our communication process. In our case only use a single stream of information.

No hay comentarios:

Publicar un comentario