Author |
Message |
t1techno
Rookie
Joined: Tue Oct 22, 2013 11:00 am Posts: 15 Location: Texas
|
 Making GPS sensor talk to NXTBEE
We are running code on a robot using multiple sensors and needing to see if something is possible.
Using Dexter industries GPS and NXTBee radio
GPS creates longs for longitude and latitude
I am wanting to create either a string combining the word longitude and the longitude long
And then need to either be able to move through that string one character at a time or convert it to an array of characters.
For people who are familiar with Java - I am looking to see if something like stringname.charAt(location) will return a character
The same can obviously done going through an array of characters one index at a time
The NXTBee will send 1 character at time time easily enough and I can not find a way to send a number or a string as one piece.
Ideas???
Working with students on a tight timeline so any help will be appreciated
|
Thu Apr 23, 2015 10:29 am |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Making GPS sensor talk to NXTBEE
char strIndex(const string &sString, const short nIndex); may be the function you're looking for. You can also "convert" the string to a char array by simply copying it with memcpy(); Make sure the array is large enough to hold the string  = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Thu Apr 23, 2015 10:38 am |
|
 |
t1techno
Rookie
Joined: Tue Oct 22, 2013 11:00 am Posts: 15 Location: Texas
|
 Re: Making GPS sensor talk to NXTBEE
Thanks for quick response - the string and char part I understand now.
Will Robot C let you copy a long into a string?
|
Thu Apr 23, 2015 12:06 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Making GPS sensor talk to NXTBEE
You mean convert it to ascii? sure, just use snprintf()  = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Thu Apr 23, 2015 12:14 pm |
|
 |
t1techno
Rookie
Joined: Tue Oct 22, 2013 11:00 am Posts: 15 Location: Texas
|
 Re: Making GPS sensor talk to NXTBEE
So I can copy a long into a string
task main() { string message; long longitude = 10234161; wait1Msec(1000); snprintf(longitude, message); or did you mean sprintf(longitude, message);
}
|
Thu Apr 23, 2015 1:47 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Making GPS sensor talk to NXTBEE
snprintf(ppDest, nDestLength, pzFormatString, ...); is the call, you can also use sprintf, if you don't want to specify the max length of the receiving buffer: = Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Thu Apr 23, 2015 3:59 pm |
|
 |
mightor
Site Admin
Joined: Wed Mar 05, 2008 8:14 am Posts: 3654 Location: Rotterdam, The Netherlands
|
 Re: Making GPS sensor talk to NXTBEE
Btw, do not cross post in multiple sub forums. I have deleted the other post.
= Xander
_________________| Professional Conduit of Reasonableness| (Title bestowed upon on the 8th day of November, 2013) | My Blog: I'd Rather Be Building Robots| ROBOTC 3rd Party Driver Suite: [ Project Page]
|
Thu Apr 23, 2015 4:01 pm |
|
|