|
Page 1 of 1
|
[ 5 posts ] |
|
| Author |
Message |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Nxt bluetooth issue
I am trying to send messages to the nxt via bluetooth using c#. The nxt reads the data and then displays it on the screen. However, I am confused on what is wrong with the program though I'm quite sure the issue is in the c# code, not RobotC. It is highly likely that the bytes I'm sending is wrong. If so, what should they be? The c# code is And the RobotC code is:  |  |  |  | Code: task main() { string str1 = ""; const int kMaxSizeOfMessage = 56; ubyte nReceiveBuffer[kMaxSizeOfMessage];
while(true){ if(nBTCurrentStreamIndex >= 0) // if there is currently an open Bluetooth connection: { nxtDisplayTextLine(1,"Success"); } else{ nxtDisplayTextLine(1,"Fail"); } TFileIOResult messageIn = cCmdMessageRead(nReceiveBuffer, kMaxSizeOfMessage, mailbox1); for(int i=0;i<kMaxSizeOfMessage;i++){ str1 += nReceiveBuffer[i]; if(nReceiveBuffer[i] != 0){ nxtDisplayTextLine(6,"EWFG"); } }
nxtDisplayTextLine(3,"%s",str1); nxtDisplayTextLine(5,"%3d, %3d",cCmdBTCheckStatus(nBTCurrentStreamIndex)); wait1Msec(10);
} } |  |  |  |  |
|
| Sun Sep 30, 2012 11:29 pm |
|
 |
|
JohnWatson
Site Admin
Joined: Thu May 24, 2012 12:15 pm Posts: 384
|
 Re: Nxt bluetooth issue
The ROBOTC side of the code seems to be in order (especially if the NXT is receiving the data and displaying it properly). For the C# code, I would suggest posting it in a C# specific forum (such as Microsoft's C Sharp answer database: http://social.msdn.microsoft.com/Forums ... sualcsharp) as I am not sure how fluent in C# anyone here may be.
_________________Check out our Blog! And our Facebook page! Need help? Take a look at our Wiki and our Forums.I just met you, And this is crazy, But here's my code now, So fix it, maybe? ~ Carly Rae Jepsen parody
|
| Tue Oct 09, 2012 12:40 pm |
|
 |
|
Spiked3
Expert
Joined: Tue Feb 28, 2012 3:10 pm Posts: 195
|
 Re: Nxt bluetooth issue
I'd have to code it up and see, which I have not done, but off the top of my head; does do what you think it does? try printing the hex value of (byte)hello[i] to see. I think you may need to use ASCIIEncoding.UTF8.GetBytes instead. Also, I don't have the pdf doc in front of me, but is Command [2] = 80; supposed to be in hex instead? Like I said, no code in front of me ATM, but those are 2 things I would verify first.
_________________Mike aka Spiked3 http://www.spiked3.com
|
| Tue Oct 09, 2012 2:12 pm |
|
 |
|
Spiked3
Expert
Joined: Tue Feb 28, 2012 3:10 pm Posts: 195
|
 Re: Nxt bluetooth issue
On the robotC side, I'm not sure what this is trying to accomplish Does it do anything now?
_________________Mike aka Spiked3 http://www.spiked3.com
|
| Tue Oct 09, 2012 2:21 pm |
|
 |
|
brianchen11
Rookie
Joined: Tue Jul 03, 2012 5:16 am Posts: 43
|
 Re: Nxt bluetooth issue
Sorry, I haven't done much robotics lately, and haven't checked the forum. I have to admit, my original code was a bit dodgy. I have figured how to do it in raw mode now. Attached is a c# application (the code in a text file). Not only can you send messages from a text box, you can draw in an area, and the program will send the coordinate info to the NXT. It will also send if you're erasing or drawing. And the robotc code is:
|
| Sun Oct 21, 2012 3:17 am |
|
|
|
Page 1 of 1
|
[ 5 posts ] |
|
Who is online |
Users browsing this forum: magicode and 4 guests |
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot post attachments in this forum
|
|