if i receive serially a string like this, i'll refer to this
string as 'ALL'
ALL = 1.4,832.5,( ... etc, keeps going)
i am trying to store store each value in between commas as a separate variable. i already know that string 'ALL' is correct because if i output the string to LCD it shows up perfect, but something must be wrong with my processing of each individual substring.
this is how i'm trying to do it:
i = 0
j = 0
loop1:
if ALL[i] != "," then
hdop[i] = ALL[i]
hdopsize = i
i = i + 1
goto loop1
endif
i = i+1 'get off the comma and go to next data
loop2:
if ALL[i] != "," then
j = i - hdopsize - 1 'i = hdopsize + comma + altitude[j]
altitude[j] = ALL[i]
altitudesize = j
i = i + 1
goto loop2
endif
ok i'm hoping that at this point to have two variables, in this case i expect this:
hdop = 1.4
hdopsize = 3
altitude = 832.5
altitudesize = 5
so i should be able to output the variables to LCD as follows:
lcdout cmd, clr
lcdout cmd, line1, "HDOP = "
lcdout str hdop\hdopsize
lcdout cmd, line2, "Altitude = "
lcdout str altitude\altitudesize
it all seems right to me, but its not working right.
hdopsize and altitudesize are bytes
hdop and altitude are defined as byte arrays length 10
(an unknown value, but no larger than 10)
can anyone see any obvious errors with my code?
Bookmarks