|
Page 1 of 1
|
[ 9 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: 722
|
 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 updated help documentation and the ROBOTC Forums.
|
Tue Oct 09, 2012 12:40 pm |
|
 |
Spiked3
Expert
Joined: Tue Feb 28, 2012 3:10 pm Posts: 197
|
 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: 197
|
 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 |
|
 |
Guillaume17
Rookie
Joined: Wed Jul 10, 2013 1:18 pm Posts: 8
|
 Re: Nxt bluetooth issue
Hello,
I get to send a message to the NXT brick but can we send a message to the brick to the computer?
|
Thu Jul 18, 2013 9:00 am |
|
 |
roboRed
Expert
Joined: Fri Nov 02, 2012 12:07 am Posts: 163 Location: California, USA
|
 Re: Nxt bluetooth issue
Do you mean like a call, Computer to NXT and a Response, NXT to Computer?
_________________ string Robored = "Awesome" ~~Neil Balch~~
|
Fri Aug 02, 2013 11:44 pm |
|
 |
Guillaume17
Rookie
Joined: Wed Jul 10, 2013 1:18 pm Posts: 8
|
 Re: Nxt bluetooth issue
NXT to Computer and I am also interested to know the other
|
Sun Aug 04, 2013 7:30 pm |
|
 |
roboRed
Expert
Joined: Fri Nov 02, 2012 12:07 am Posts: 163 Location: California, USA
|
 Re: Nxt bluetooth issue
_________________ string Robored = "Awesome" ~~Neil Balch~~
|
Mon Aug 05, 2013 12:12 am |
|
|
|
Page 1 of 1
|
[ 9 posts ] |
|
Who is online |
Users browsing this forum: No registered users and 2 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
|
|