Retrieves a "NXT-to-NXT message" from the specified inbox
[message localInboxReturn] = NXT_MessageRead(LocalInbox, RemoteInbox, RemoveFromRemote)
[message localInboxReturn] = NXT_MessageRead(LocalInbox, RemoteInbox, RemoveFromRemote, handle)
[message localInboxReturn statusByte] = NXT_MessageRead(LocalInbox, RemoteInbox, RemoveFromRemote)
[message localInboxReturn statusByte] = NXT_MessageRead(LocalInbox, RemoteInbox, RemoveFromRemote, handle)
This function reads a NXT-to-NXT bluetooth message from a mailbox queue on the NXT. LocalInbox and RemoteInbox are the mailbox numbers and must be between 0 and 9. The difference between local and remote mailbox is not fully understood, so it's best to use the same value for both parameters. For more details see the official LEGO Mindstorms communication protocol.
Set RemoveFromRemote to true to clear the just retrieved message from the NXT's mailbox (and free occupied memory). Set it to false to just "look into" the message while it will still remain on the NXT's message queue.
message contains the actual message (string) that has been retrieved. localInboxReturn is just the mailbox number that the message was read from (again, see official Mindstorms communication protocol).
Optionally, the packet's statusbyte is returned in the output argument statusByte, if requested. Warning from this functions will then be supressed (i.e. no warnings are raised then).
If no NXT handle is specified the default one (COM_GetDefaultNXT) is used.
This command can only be used when an external program (e.g. written in NXT-G, NXC or NBC) is running on the NXT. Otherwise a warning will be thrown (and an empty message will be returned).
Use this function to read data locally stored on the NXT. There are 10 usable mailbox queues, each with a certain size (so be careful to avoid overflows). Maximum message limit is 58 bytes / chars. This function can be used to communicate with NXC programs (the NXC-function "SendMessage" can be used to write the data on the NXT).
NXT_MessageWrite('Test message', 0); pause(1) % an NXC program will process this message from inbox 0 % and generate / "send" an answer to inbox 1 for us reply = NXT_MessageRead(1, 1, true);
- Author: Linus Atorf (see AUTHORS)
- Date: 2009/08/31
- Copyright: 2007-2010, RWTH Aachen University