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

[REBOL] Re: Serial Communications - GPS Sings!

From: gscottjones:mchsi at: 27-Feb-2002 7:56

Hi, Jim, ...
> My next wish is to pull the data out of the strings and do a "Z > transform" on the lat/long positions. This is where we interleave > the two numbers to wash out a bias when storing them in a > linear medium such as computer memory. When they are > stored (depending upon their density) > they will follow a nested raster chaining pattern if we connected them > together on the surface of the earth.
... (full message: http://www.escribe.com/internet/rebol/m19950.html ) Since I can't access the actual stream, I created a data block of NMEA statements as data. The code parses *all* statements, but then only further processes statements beginning with "$GPGLL". Then it creates a z-transform value and a new block that stores the parsed $GPGLL NMEA statement with the z-transform data tacked on the end. The last statements manipulate the block to demonstrate the data and a sort on the z-transform. Hopefully, the following hack is getting close to what you need. --Scott Jones GPGLL_Z_DATA: copy [] ;normally open stream here but use simulated stream instead ;GPS_STREAM: open/read/lines serial://port2/4800/8/none/1 ;simulated stream for illustration purposes GPS_STREAM: [ $GPGLL,4339.015,N,07953.247,W,051936,A*30 $GPGLL,4339.015,N,07953.247,W,051938,A*3E $GPGLL,4339.015,N,07953.247,W,051940,A*31 $GPGLL,4339.015,N,07953.247,W,051942,A*33 $GPGLL,4339.015,N,07953.247,W,051944,A*35 $GPGLL,4339.015,N,07953.247,W,051946,A*37 $GPGLL,4339.015,N,07953.247,W,051948,A*39 $GPGLL,4339.015,N,07953.247,W,051950,A*30 $GPGLL,4339.015,N,07953.247,W,051952,A*32 $GPGLL,4339.015,N,07953.247,W,051954,A*34 $GPGLL,4339.015,N,07953.247,W,051956,A*36 $GPGLL,4339.015,N,07953.247,W,051958,A*38 $GPGLL,4339.048,N,07953.247,W,052000,A*37 $GPGLL,4339.096,N,07953.247,W,052002,A*36 $GPGLL,4339.144,N,07953.247,W,052004,A*3E $GPGLL,4339.117,N,07953.323,W,052006,A*39 $GPGLL,4339.103,N,07953.386,W,052008,A*3D $GPGLL,4339.088,N,07953.449,W,052010,A*32 $GPGLL,4339.073,N,07953.513,W,052012,A*3A $GPGLL,4339.058,N,07953.576,W,052014,A*36 $GPGLL,4339.043,N,07953.639,W,052016,A*36 $GPGLL,4339.028,N,07953.702,W,052018,A*3C $GPGLL,4339.013,N,07953.766,W,052020,A*3D $GPGLL,4338.998,N,07953.829,W,052022,A*30 $GPGLL,4338.983,N,07953.892,W,052024,A*3C $GPGLL,4338.968,N,07953.956,W,052026,A*32 $GPGLL,4338.953,N,07954.019,W,052028,A*31 $GPGLL,4338.938,N,07954.082,W,052030,A*37 $GPGLL,4338.923,N,07954.145,W,052032,A*35 $GPGLL,4338.908,N,07954.209,W,052034,A*31 $GPGLL,4338.893,N,07954.272,W,052036,A*3C $GPGLL,4338.878,N,07954.335,W,052038,A*35 $GPGLL,4338.863,N,07954.399,W,052040,A*36 $GPGLL,4338.848,N,07954.462,W,052042,A*3E $GPGLL,4338.833,N,07954.525,W,052044,A*36 $GPGLL,4338.818,N,07954.588,W,052046,A*3A $GPGLL,4338.803,N,07954.652,W,052048,A*3A $GPGLL,4338.788,N,07954.715,W,052050,A*3D $GPGLL,4338.773,N,07954.778,W,052052,A*30 $GPGLL,4338.758,N,07954.841,W,052054,A*3A $GPGLL,4338.743,N,07954.905,W,052056,A*33 $GPGLL,4338.728,N,07954.968,W,052058,A*3B $GPGLL,4338.713,N,07955.031,W,052100,A*3B $GPGLL,4338.698,N,07955.095,W,052102,A*35 $GPGLL,4338.683,N,07955.158,W,052104,A*39 $GPGLL,4338.668,N,07955.221,W,052106,A*33 $GPGLL,4338.653,N,07955.284,W,052108,A*3A $GPGLL,4338.638,N,07955.348,W,052110,A*3F $GPGLL,4338.623,N,07955.411,W,052112,A*3C $GPGLL,4338.609,N,07955.474,W,052114,A*31 $GPGLL,4338.594,N,07955.537,W,052116,A*32 $GPGLL,4338.579,N,07955.601,W,052118,A*39 $GPGLL,4338.564,N,07955.664,W,052120,A*3D $GPGLL,4338.549,N,07955.727,W,052122,A*36 $GPGLL,4338.534,N,07955.791,W,052124,A*37 $GPGLL,4338.519,N,07955.854,W,052126,A*3C $GPGLL,4338.504,N,07955.917,W,052128,A*38 $GPGLL,4338.489,N,07955.980,W,052130,A*3B $GPGLL,4338.474,N,07956.044,W,052132,A*39 $GPGLL,4338.459,N,07956.107,W,052134,A*36 $GPGLL,4338.444,N,07956.170,W,052136,A*38 $GPGLL,4338.429,N,07956.233,W,052138,A*39 $GPGLL,4338.414,N,07956.297,W,052140,A*36 $GPGLL,4338.399,N,07956.360,W,052142,A*3F $GPGLL,4338.384,N,07956.423,W,052144,A*35 $GPGLL,4338.369,N,07956.486,W,052146,A*3B $GPGLL,4338.354,N,07956.550,W,052148,A*31 $GPGLL,4338.339,N,07956.613,W,052150,A*37 $GPGLL,4338.324,N,07956.676,W,052152,A*3A $GPGLL,4338.309,N,07956.739,W,052154,A*39 $GPGLL,4338.294,N,07956.803,W,052156,A*38 $GPGLL,4338.279,N,07956.866,W,052158,A*36 $GPGLL,4338.264,N,07956.929,W,052200,A*3E $GPGLL,4338.249,N,07956.992,W,052202,A*33 $GPGLL,4338.234,N,07957.056,W,052204,A*3F $GPGLL,4338.218,N,07957.119,W,052206,A*39 $GPGLL,4338.203,N,07957.182,W,052208,A*3F $GPGLL,4338.188,N,07957.245,W,052210,A*3E $GPGLL,4338.173,N,07957.309,W,052212,A*31 $GPGLL,4338.158,N,07957.372,W,052214,A*32 $GPGLL,4338.144,N,07957.435,W,052216,A*39 $GPGLL,4338.129,N,07957.498,W,052218,A*3B ] ;process stream ;use following to iterate over simulated stream foreach NMEA_LINE GPS_STREAM [ NMEA_LINE_BLOCK: parse/all NMEA_LINE "," if NMEA_LINE_BLOCK/1 = "$GPGLL" [ lat: join "0" [head remove find copy NMEA_LINE_BLOCK/2 "." "0"] lon: join head remove find copy NMEA_LINE_BLOCK/4 "." "0" z-trans: join copy/part lat 3 [ copy/part lon 3 copy/part skip lat 3 2 copy/part skip lon 3 2 copy/part skip lat 5 2 copy/part skip lon 5 2 copy/part skip lat 7 2 copy/part skip lon 7 2 ] ;print z-trans append NMEA_LINE_BLOCK z-trans append/only GPGLL_Z_DATA next NMEA_LINE_BLOCK ] ] ;show new data block contents - not sorted foreach k GPGLL_Z_DATA [print k] ;sort data based on z-transform i: copy sort/compare GPGLL_Z_DATA 7 ;show new data block contents - sorted by z-transform value foreach k i [print k]