Hi kschaffer,
Are you using the fantom drivers, provided by LEGO? If not, I would encourage you to use them. They facilitate a lot the communication between a PC and an NXT. You can use classes and methods that take care of most the things you want to do. You can check here all the info:
-
http://cache.lego.com/upload/contentTem ... CBB206.zip
There is a Communication Protocol implemented by LEGO to handle communications over BT and USB that we have to respect. If you use the fantom drivers API, you don't need to worry about the communication protocol, because the drivers work it out for you. With this, I mean that if you use an appropriate method from this API to send a string to the NXT, from the host PC, you don't need to know what to fill in the first bytes (length, command type, command, etc); instead you just need to send the string.
Moreover, if you don't have problems with the ~58 bytes limitation of the mailing boxes I strongly recommend you to use that system. On the NXT you will just use something like MessageRead(...) and no further processing to the received data will be needed; and a correspondent API function from the PC, for writing to one of the NXT's mailbox.
Anyway, it's always worth to take a look at the NXT communication protocol:
-
http://cache.lego.com/upload/contentTem ... A8B567.zip
On that .zip, you can also find the list of "Direct Commands". This commands are still part of the communication protocol, that somehow are handled by the firmware to process them.
Actually, MESSAGEWRITE is a direct command to send messages to the mailboxes. On your PC you will have something like: sendDirectCommand(...,{MESSAGEWRITE|YOUR_MESSAGE},...). Yes, to work with mailboxes, you'll need to read these documents.
I think that this is a better solution than "writing to files", like you are doing. Otherwise you will always have to process the messages to send/receive to fulfil the LEGO communication protocol, on both sides.
Even doing this (writing and reading directly from the BT buffer), you can do it through the fantom API functions.
Well, I am far from an expert on this. Someone, correct me please if I said something wrong. I hope I helped.
Cheers,
Ricardo