Spin String Confusion
Hey all, im working on wunderground reporting project for the spinneret that will report data from my wireless weather station. this is my first leap into spin and I am having trouble debugging out some strings and i was hoping someone could spot my error. i am using some "barrowed" code from jonnymac's simple gps demo to move some ascii characters around, and its acting like the strings arnt zero terminated when i debug them out through the parallax serial terminal object.
please help me understand, thanks!
the output on the debug looks like this:
it should look like this : &2012-07-10 03:53:05&realtime=1&tempf=
what i dont get is why it debugs the string for time correctly the first time after i format the data, but the second time i spit it out the debug, i get more data in the string then should be.
please help me understand, thanks!
the output on the debug looks like this:
Startup... !!WX,225305,070912, 259, 786, 772, 296, 247 03:53:05 2012-07-10 78.6 77.2 29.6 &2012-07-10 78. 77. 29.6 03:53:052012-07-10 78. 77. 29.6&realtime=1&tempf= Finished...
it should look like this : &2012-07-10 03:53:05&realtime=1&tempf=
what i dont get is why it debugs the string for time correctly the first time after i format the data, but the second time i spit it out the debug, i get more data in the string then should be.
PUB Main | ch, hr, dy Digi.GetStr(@DigiBuf) ' get string from ether Pst.Str(@digiBuf) ' deebug string PST.CHAR (13) ''''''''''''''''''''''''''' fcopy(@UTCTIME, @digiBuf, 1) hr := str2dec(@utctime, 2) ' get utc hours hr := (hr + (24 + utcoffset)) // 24 ' add utc offset utctime[0] := (hr / 10) + "0" ' convert back to string utctime[1] := (hr // 10) + "0" s_insert(":", 2, @utctime) s_insert(":", 5, @utctime) utctime[8] := 0 Pst.Str(@UTCTime) PST.CHAR (13) '''''''''''''''''''''''''''' fcopy(@UTCdate, @digiBuf, 2) if hr <= utcoffset ' catch day shift dy :=str2dec(@utcdate[2],2) dy := dy + 1 utcdate[2] := (dy / 10) + "0" ' convert back to string utcdate[3] := (dy // 10) + "0" s_insert("0", 0,@utcdate) ' format for msql style time from mmddyy to yyyy-mm-dd s_insert("2", 0,@utcdate) ' add century s_insert(utcdate[6], 2,@utcdate) ' move year to end of century s_insert(utcdate[8], 3,@utcdate) s_insert("-", 4,@utcdate) ' add dashes s_insert("-", 7,@utcdate) utcdate[10] := 0 ' terminate Pst.Str(@UTCdate) PST.CHAR (13) ''''''''''''''''''''''''''''''' fcopy(@tempF, @digiBuf, 4) s_insert(".", 4, @tempf) tempf[6] := 0 Pst.Str(@tempF) PST.CHAR (13) ''''''''''''''''''''''''''''''' fcopy(@humP, @digiBuf, 5) s_insert(".", 4, @humP) hump[6] := 0 Pst.Str(@humP) PST.CHAR (13) ''''''''''''''''''''''''''''''' fcopy(@PresIn, @digiBuf, 6) s_insert(".", 4, @PresIn) presIn[6] := 0 Pst.Str(@PresIn) PST.CHAR (13) ''''''''''''''''''''''''''''''' 'now lets spit it all out at once! PST.char("&") PST.str(@UTCdate) pst.char(" ") pst.str(@utctime) pst.str(string("&realtime=1&tempf="))
Comments