Mailing List Archive: 49091 messages
  • Home
  • Script library
  • AltME Archive
  • Mailing list
  • Articles Index
  • Site search
 

Parsing a "Brick Wall" - Need help!

 [1/4] from: webmaster::windsweptfarm::com at: 10-Sep-2002 10:53


Dear List, Here's the background: I have a stream of "NMEA sentences" coming from a GPS unit on a serial port. I wish to parse the various elements within each sentence into variables/words. The hickup in this is that Rebol wants to evaluate these elements and is convinced that they are malformed data types. The $ prefix convinces Rebol that I am talking money, while the decimals are also generating errors of their own. How do I block this behaviour? I want these elements to be vanilla values until they are shunted. How can I insulate the data from evaluation prior to assignment? This is a typical NMEA sentences of one type ($GPGLL) that I wish to package into variables: $GPGLL,327.900,N,08056.851,W,141608,A*3E Here is the code to pull only "$GPGLL" data from GPS unit on com1: ;START CODE==========> GPS_STREAM: open/read/lines serial://port1/4800/8/none/1 while [0 <> (length? (NMEA_LINE: first GPS_STREAM)) ][while [(GEO_POS: find/match NMEA_LINE "$GPGLL,")][ (print GEO_POS) BREAK ]] close GPS_STREAM ;STOP CODE==========^ This prints all "NMEA sentences": START CODE==========> GPS_STREAM: open/read/lines serial://port1/4800/8/none/1 while [0 <> (length? (NMEA_LINE: first GPS_STREAM))][print NMEA_LINE] close GPS_STREAM ;STOP CODE==========^ Here is a raw stream of NMEA sentences from the GPS unit via com port: BTW: It is a simulation of the unit travelling at 160mph towards Garmin (the gps manufacturer, in Kansas). That is why we see the word "GARMIN". $GPRMC,143959,A,4309.445,N,08208.192,W,139.0,250.1,100902,008.1,W*78 $GPRMB,A,0.00,R,,GARMIN,3851.333,N,09447.941,W,629.5,250.0,139.0,V*2E $GPGGA,143959,4309.443,N,08208.202,W,1,11,2.0,378.3,M,-35.0,M,,*7A $GPGSA,A,3,03,09,14,15,17,18,21,23,26,29,31,,4.1,2.0,3.0*3D $GPGSV,3,1,11,03,14,284,36,09,52,111,46,14,24,241,40,15,64,189,48*71 $GPGSV,3,2,11,17,52,167,46,18,75,357,49,21,46,302,45,23,24,094,40*73 $GPGSV,3,3,11,26,19,054,38,29,11,056,34,31,06,319,30,,,,*4C $PGRME,15.0,M,22.5,M,15.0,M*1B $GPGLL,4309.435,N,08208.231,W,143959,A*35 $PGRMZ,1241,f,3*2D $PGRMM,WGS 84*06 $GPBOD,250.0,T,258.1,M,GARMIN,*50 $GPRTE,1,1,c,0,GARMIN*35 $GPWPL,3851.333,N,09447.941,W,GARMIN*49 $GPRMC,144001,A,4309.419,N,08208.291,W,139.0,250.1,100902,008.1,W*72 $GPRMB,A,0.00,R,,GARMIN,3851.333,N,09447.941,W,629.4,250.0,139.0,V*2F $GPGGA,144001,4309.417,N,08208.301,W,1,11,2.0,378.3,M,-35.0,M,,*7A $GPGSA,A,3,03,09,14,15,17,18,21,23,26,29,31,,4.1,2.0,3.0*3D $GPGSV,3,1,11,03,14,284,36,09,52,111,46,14,24,241,40,15,64,189,48*71 $GPGSV,3,2,11,17,52,167,46,18,75,001,49,21,46,302,45,23,24,094,40*73 $GPGSV,3,3,11,26,19,054,38,29,11,056,34,31,06,319,30,,,,*4C $PGRME,15.0,M,22.5,M,15.0,M*1B $GPGLL,4309.409,N,08208.331,W,144001,A*38 $PGRMZ,1241,f,3*2D $PGRMM,WGS 84*06 $GPBOD,250.0,T,258.1,M,GARMIN,*50 $GPRTE,1,1,c,0,GARMIN*35 $GPWPL,3851.333,N,09447.941,W,GARMIN*49 $GPRMC,144003,A,4309.393,N,08208.390,W,139.0,250.1,100902,008.1,W*75 $GPRMB,A,0.00,R,,GARMIN,3851.333,N,09447.941,W,629.4,250.0,139.0,V*2F $GPGGA,144003,4309.390,N,08208.400,W,1,11,2.0,378.3,M,-35.0,M,,*76 $GPGSA,A,3,03,09,14,15,17,18,21,23,26,29,31,,4.1,2.0,3.0*3D $GPGSV,3,1,11,03,14,284,36,09,52,111,46,14,24,241,40,15,64,189,48*71 $GPGSV,3,2,11,17,52,167,46,18,75,001,49,21,46,302,45,23,24,094,40*73 $GPGSV,3,3,11,26,19,054,38,29,11,056,34,31,06,319,30,,,,*4C $PGRME,15.0,M,22.5,M,15.0,M*1B $GPGLL,4309.382,N,08208.430,W,144003,A*38 $PGRMZ,1241,f,3*2D $PGRMM,WGS 84*06 $GPBOD,250.0,T,258.1,M,GARMIN,*50 $GPRTE,1,1,c,0,GARMIN*35 $GPWPL,3851.333,N,09447.941,W,GARMIN*49 $GPRMC,144005,A,4309.366,N,08208.489,W,139.0,250.1,100902,008.1,W*76 $GPRMB,A,0.00,R,,GARMIN,3851.333,N,09447.941,W,629.3,250.0,139.0,V*28 $GPGGA,144005,4309.364,N,08208.499,W,1,11,2.0,378.3,M,-35.0,M,,*7B $GPGSA,A,3,03,09,14,15,17,18,21,23,26,29,31,,4.1,2.0,3.0*3D $GPGSV,3,1,11,03,14,284,36,09,52,111,46,14,24,241,40,15,64,189,48*71 $GPGSV,3,2,11,17,52,167,46,18,75,001,49,21,46,302,45,23,24,094,40*73 $GPGSV,3,3,11,26,19,054,38,29,11,056,34,31,06,319,30,,,,*4C $PGRME,15.0,M,22.5,M,15.0,M*1B $GPGLL,4309.356,N,08208.529,W,144005,A*3E $PGRMZ,1241,f,3*2D $PGRMM,WGS 84*06 $GPBOD,250.0,T,258.1,M,GARMIN,*50 $GPRTE,1,1,c,0,GARMIN*35 $GPWPL,3851.333,N,09447.941,W,GARMIN*49 $GPRMC,144007,A,4309.340,N,08208.589,W,139.0,250.1,100902,008.1,W*71 $GPRMB,A,0.00,R,,GARMIN,3851.333,N,09447.941,W,629.2,250.0,139.0,V*29 $GPGGA,144007,4309.337,N,08208.599,W,1,11,2.0,378.3,M,-35.0,M,,*7E $GPGSA,A,3,03,09,14,15,17,18,21,23,26,29,31,,4.1,2.0,3.0*3D $GPGSV,3,1,11,03,14,284,36,09,52,111,46,14,24,241,40,15,64,189,48*71 $GPGSV,3,2,11,17,52,167,46,18,75,001,49,21,46,302,45,23,24,094,40*73 $GPGSV,3,3,11,26,19,054,38,29,11,056,34,31,06,319,30,,,,*4C $PGRME,15.0,M,22.5,M,15.0,M*1B $GPGLL,4309.330,N,08208.628,W,144007,A*3E $PGRMZ,1241,f,3*2D $PGRMM,WGS 84*06 $GPBOD,250.0,T,258.1,M,GARMIN,*50 $GPRTE,1,1,c,0,GARMIN*35 $GPWPL,3851.333,N,09447.941,W,GARMIN*49 $GPRMC,144009,A,4309.314,N,08208.688,W,139.0,250.1,100902,008.1,W*7C $GPRMB,A,0.00,R,,GARMIN,3851.333,N,09447.941,W,629.1,250.0,139.0,V*2A $GPGGA,144009,4309.311,N,08208.698,W,1,11,2.0,378.3,M,-35.0,M,,*76 $GPGSA,A,3,03,09,14,15,17,18,21,23,26,29,31,,4.1,2.0,3.0*3D $GPGSV,3,1,11,03,14,284,36,09,52,111,46,14,24,241,40,15,64,189,48*71 $GPGSV,3,2,11,17,52,167,46,18,75,001,49,21,46,302,45,23,24,094,40*73 Thanks in advance! Jim

 [2/4] from: gscottjones:mchsi at: 10-Sep-2002 11:05


Hi, Jim, Perhaps you did not see my submission a few months ago: http://www.escribe.com/internet/rebol/m19956.html The pertinent issue for your current request being: parse/all a-nmea-line "," Hope that helps. --Scott Jones

 [3/4] from: webmaster::windsweptfarm::com at: 10-Sep-2002 12:42

Duh! was - (Parsing a "Brick Wall")


Dear Self, loop forever [rebol: elegance] Am I a dope, or what? Instead of solving the problem from the bottom up I came in from the top and wasted time churning around trying to fathom a miriad of interactions that were unrelated to the real problem. What was I thinking? This is the essence of the solution: ;===== Start Code GPGLL: "$GPGLL,4238.683,N,08359.840,W,151748,A*3D" GPGLL_EXPANSION: parse GPGLL "," print GPGLL_EXPANSION foreach element GPGLL_EXPANSION [print element] ;===== End Code ;====== start output ==>
>> GPGLL: "$GPGLL,4238.683,N,08359.840,W,151748,A*3D"
== "$GPGLL,4238.683,N,08359.840,W,151748,A*3D"
>> GPGLL_EXPANSION: parse GPGLL ","
== ["$GPGLL" "4238.683" "N" "08359.840" "W" "151748" "A*3D"]
>> >> print GPGLL_EXPANSION
$GPGLL 4238.683 N 08359.840 W 151748 A*3D
>> >> foreach element GPGLL_EXPANSION [print element]
$GPGLL 4238.683 N 08359.840 W 151748 A*3D
>>
;====== End output ==^ Sorry for the stupid post! Jim _ wrote:

 [4/4] from: webmaster:windsweptfarm at: 10-Sep-2002 20:43

Re: Parsing a "Brick Wall" - Need help!


Dear Scott, Thanks! Yes I read it when it came out. There seems to be so many subtle details to grasp before I can conceive of how to implement a program in Rebol. Like so many things that are unfamiliar it is easy to get caught up in a series of eddies that never make their way back to the main channel. I got caught in a few of those. I think I will concentrate on the small and finite problems until I have enough "bricks" to start building. Being a dyed in the wool do it yourselfer, I tend to struggle long and hard before I break down and ask for help. Many thanks to one and all for your generous and responsive assistance. Sincerely, Jim G. Scott Jones wrote: