Changeset 12
- Timestamp:
- Jan 10, 2008, 6:36:38 PM (13 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
openmoko/gps/gps_reader.py
r11 r12 43 43 above_sea_unit, geoidal_separation, 44 44 geoidal_separation_unit, data_age, 45 diff_ref_stationID) = self. l45 diff_ref_stationID) = self.splitted_line 46 46 47 47 # build the timestamp in a human-readable form … … 73 73 latitude = latitude_degrees + (latitude_minutes/60) 74 74 longitude = longitude_degrees + (longitude_minutes/60) 75 76 # str(latitude_degrees) + "" + " " + northsouth75 76 # human-friendly coordinates 77 77 return "%d° %d' %.3f\" %s\n%d° %d' %.3f\" %s" % \ 78 78 (latitude_degrees,latitude_minutes,latitude_seconds,northsouth, … … 80 80 # end parse_coord 81 81 82 def read_ stuff(self,source, condition):82 def read_line(self,source, condition): 83 83 line = self.file.readline() 84 self. l= line.split(",")84 self.splitted_line = line.split(",") 85 85 86 86 # did we get a GPGGGA line ? 87 if self. l[0] == "$GPGGA":87 if self.splitted_line[0] == "$GPGGA": 88 88 self.parse_gga() 89 89 if trace: 90 90 self.trace_file.write(line) 91 91 92 # return false to deactivate callback, true to let it run92 # return False to deactivate callback, True to let it run 93 93 return True 94 # end read_ stuff94 # end read_line 95 95 96 96 def spawn_gps(self, widget, data=None): … … 98 98 self.pid = os.spawnl(os.P_NOWAIT,gllin_path) 99 99 self.lbl_status.set_text("Starting...") 100 # wait 4 seconds to let gllin boot properly, and then start parsing data 100 101 source_id = gobject.timeout_add(4000, self.init_gps_reader,self) 101 102 # end spawn_gps … … 126 127 else: # there is a process accessing that file, it's likely to be gllin, so open it 127 128 self.file = open(nmea_file,'r') 128 self.gps_source = gobject.io_add_watch(self.file, gobject.IO_IN, self.read_ stuff)129 self.gps_source = gobject.io_add_watch(self.file, gobject.IO_IN, self.read_line) 129 130 self.gps_is_on() 130 131 else: # no nmea_file 131 132 self.gps_is_off() 132 133 133 # disable future runs of callbacks134 # disable future runs, it's only necessary to run it once 134 135 return False 135 136 # end init_gps_reader … … 224 225 # interpreter then create a GpsRead instance and show it 225 226 if __name__ == "__main__": 226 hello= GpsRead()227 hello.main()227 reader = GpsRead() 228 reader.main()
Note: See TracChangeset
for help on using the changeset viewer.