View previous topic :: View next topic |
Author |
Message |
filjoa
Joined: 04 May 2008 Posts: 260
|
print array |
Posted: Thu May 22, 2008 10:02 am |
|
|
Hi
I have this array:
Quote: | 161229.000,A,3723.2475,N,12158.3416,W,0.13,309.62,120598,, |
is possible I save an part, for example "29" into variable?
in normal case i make:
strcpy(string1,"29");
but how I have an array a need copy to string1 position 4 and 5....
how I can make that? some one can help me?
regards |
|
|
KU5D
Joined: 10 Feb 2008 Posts: 46 Location: Asheville, North Carolina
|
|
Posted: Thu May 22, 2008 10:19 am |
|
|
I assume you have already captured the GPS string into an array or buffer, let's assume that buffer is defined as"gpsString[bufferSize].
Now you wanna grab the UTC seconds out of this string. Your string is:
161229.000,A,3723.2475,N,12158.3416,W,0.13,309.62,120598,,
Here we go.
Code: |
int8 secTens;
int8 secOnes;
int8 utcSeconds;
secTens = (gpsString[4] - 30) * 10; //converting ASCII char to int
secOnes = gpsString[5] - 30;
utcSeconds = secTens + secOnes;
|
There's my quick and dirty lunch-hour answer. This assumes also that you have ripped out the preceding $GPRMC, otherwise the position in the string will be off. _________________ Confidence is the feeling you have right before you fully understand the situation... |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Thu May 22, 2008 10:29 am |
|
|
hi
thank but my problem dont stay there.
I have this string saved but need Concatenate some parts of this string.
for example used this string a like have at the end:
str1=37d23.2475' N 121d58.3416' W
how I can make this?
regards |
|
|
KU5D
Joined: 10 Feb 2008 Posts: 46 Location: Asheville, North Carolina
|
|
Posted: Thu May 22, 2008 10:51 am |
|
|
Uhmmm...
I'm sorry, but I don't understand the question? Can you clarify for me a bit? _________________ Confidence is the feeling you have right before you fully understand the situation... |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Thu May 22, 2008 11:36 am |
|
|
Hi
I have this string:
161229.000,A,3723.2475,N,12158.3416,W,0.13,309.62,120598,,
on a variable... but I like print some parts of them. this string have be saved on variable string[60].
I like print some like that:"37d23.2475' N 121d58.3416' W" and save them into other variable, for example str1.
is possible? |
|
|
Douglas Kennedy
Joined: 07 Sep 2003 Posts: 755 Location: Florida
|
|
Posted: Thu May 22, 2008 12:41 pm |
|
|
I think you need to read a beginners instruction book for C. Your focus should be on how C handles strings. When you have mastered extracting a subset of a string you will be able to address your issues on your own. You are in the weeds with a GPS sentence. Someone on this board might do the work for you but as soon as you make any modification you will be back asking how to make it work again. Take a few days and read about C and strings it will be more productive than waiting for a stranger to do the work for you |
|
|
filjoa
Joined: 04 May 2008 Posts: 260
|
|
Posted: Thu May 22, 2008 2:03 pm |
|
|
Hi
yes you have reason... I find for instruction for C and I resolve the problem...
one more question...
if I have an float is possible convert this to a char[]?
the function ITOA make that? if yes it put '\0' on the string?
regards |
|
|
|