Hello all,
I've been trying to implement a C/C++ program using fantom drivers to talk to a NXT over bluetooth. On the NXT I am running NXC.
I want to exchange my own messages, with no mailboxes. The reason is because with the mail boxes I'm limited to around 58 bytes, or something similar. So, I would like to write directly on the BT buffer.
Now the problem: from what I could understand, in the NXT, I can only read the buffer and not working like with mailboxes, pushing and popping msgs. I'm using the function GetBTInputBuffer() to fetch the buffer and it's a non-blocking function. What I want to say is that it's quite hard to be waiting for a message to arrive and knowing that I'm facing new data.
Also I noticed that I get in the buffer sometimes data from commands, that the firmware is handling, nothing to do with the data sent from the method "nFANTOM100::iNXT::write(...)" on the host application.
Am I thinking wrong about anything? Can someone give me some light on this?
Thanks a lot guys!
Ricardo
Bluetooth communication from a host PC
Re: Bluetooth communication from a host PC
I am very interested in this, too.
I use BluetoothWrite() on the NXT to send data over the Bluetooth-based serial port connection, and read the data on the PC using normal ReadFile() operation (opened with CreateFile on "com3").
I could find no information whatsoever on the format of the data sent, but I figured out the data is of this format:
unsigned char length;
unsigned char unknown; // BT address = 0? Or high byte of a 2-byte length? Never tried to send > 256 bytes as data payload
unsigned char dataSentFromBrick[];
Going the other way is a completely different story. Again, I can find no references. There is no equivalent BluetoothRead() function on the brick, nor anything I can find, in the Bricxcc references. Lack of orthogonality in design =D
So I assume I have to format up something to send that turns into a "mailbox" thing??? Then use ReadMessage()? So what would this block of data look like on the PC before I WriteFile'd it into the com port?
Here's the correct question to ask, as far as I can tell:
A. On the PC in C, I want to use WriteFile() and use what format? Len + BT address of brick (1-3 presumably) + data?
B. On the NXT, I want to have a thread listening, using what read function?
Here's a question I'm not even sure is a valid question: What would I do to send a "direct command" to the motors? This is PC-to-brick, not brick-to-brick, so the myriad examples I can find are utterly useless. And if so, would it use that same com port? Or the magical other one? Or some other thing?
I use BluetoothWrite() on the NXT to send data over the Bluetooth-based serial port connection, and read the data on the PC using normal ReadFile() operation (opened with CreateFile on "com3").
I could find no information whatsoever on the format of the data sent, but I figured out the data is of this format:
unsigned char length;
unsigned char unknown; // BT address = 0? Or high byte of a 2-byte length? Never tried to send > 256 bytes as data payload
unsigned char dataSentFromBrick[];
Going the other way is a completely different story. Again, I can find no references. There is no equivalent BluetoothRead() function on the brick, nor anything I can find, in the Bricxcc references. Lack of orthogonality in design =D
So I assume I have to format up something to send that turns into a "mailbox" thing??? Then use ReadMessage()? So what would this block of data look like on the PC before I WriteFile'd it into the com port?
Here's the correct question to ask, as far as I can tell:
A. On the PC in C, I want to use WriteFile() and use what format? Len + BT address of brick (1-3 presumably) + data?
B. On the NXT, I want to have a thread listening, using what read function?
Here's a question I'm not even sure is a valid question: What would I do to send a "direct command" to the motors? This is PC-to-brick, not brick-to-brick, so the myriad examples I can find are utterly useless. And if so, would it use that same com port? Or the magical other one? Or some other thing?
-
- Posts: 117
- Joined: 27 Dec 2010, 19:27
Re: Bluetooth communication from a host PC
Doesn't anyone have a clue about my questions? :\
I'm still trying to work around this..
Ricardo
I'm still trying to work around this..
Ricardo
Who is online
Users browsing this forum: Semrush [Bot] and 2 guests