While at LEGO World and in the days prior to travelling I worked on enhancements to the firmware which would allow you to send direct and system commands from one NXT to another via either bluetooth or RS-485. I am still sorting out some brick hanging issues that I have encountered when processing incoming RS-485 data using the same "interpret" function that incoming bluetooth and USB data is fed through by default. If/when I get it working without problems then it will be exposed to NBC and NXC users with the enhanced firmware installed via Remote* API functions which take a connection number as the first parameter. Connections 0 through 3 are CONN_BT0, CONN_BT1, CONN_BT2, and CONN_BT3. Connection number 4 is CONN_HS4 and if you call an API function with that connection number it will attempt to communicate over RS-485 rather than Bluetooth.
Additionally, I am working on a minor change to the enhanced firmware which makes it always handle direct and system command responses rather than discarding all of them except for the MessageRead direct command (which is used by the firmware to handle reading a message from a remote NXT's response mailbox and writing it to the corresponding local NXT's mailbox). My initial thought (already partially implemented) is to copy the incoming direct and system command response data into a "last response" buffer that can be accessed via a new system call function that reads/clears the last response buffer. Using this new feature in conjunction with the RS-485 direct/system command processing changes, the intent is that all the existing direct and system commands will be supported, with those requiring a response actually waiting for the response to arrive and passing the relevant response data back to the user via the function call parameters.
I will almost certainly be adding more direct commands, as well, to expose more of the remote NXT's functionality to a "master" NXT so that you could also do things like output to the LCD. I'm considering adding a new API layer around existing API functions for reading sensor values and controlling motors so that you can do something like this:
Code: Select all
// control local motors
OnFwd(CONN_BT0, OUT_A, 75);
Wait(SEC_1);
OnRev(CONN_BT0, OUT_A, 75);
Wait(SEC_1);
Off(CONN_BT0, OUT_A);
// control motors on bluetooth connection 1
OnFwd(CONN_BT1, OUT_A, 75);
Wait(SEC_1);
OnRev(CONN_BT1, OUT_A, 75);
Wait(SEC_1);
Off(CONN_BT1, OUT_A);
// control motors on RS-485 connection 4 (device 0)
OnFwd(CONN_HS4, OUT_A, 75);
Wait(SEC_1);
OnRev(CONN_HS4, OUT_A, 75);
Wait(SEC_1);
Off(CONN_HS4, OUT_A);
In theory, with NXT's connected via RS-485 I could add a byte to the direct and system command protocol which would be a device ID/address byte so that you could connect more than one NXT as a remote slave over the hi-speed port and the direct/system command would only be processed by the slave with the specified device ID.
Does any of this sound interesting?
John Hansen