Changeset 12


Ignore:
Timestamp:
Jan 10, 2008, 6:36:38 PM (13 years ago)
Author:
lucas
Message:

gps_reader.py: code cleanup

File:
1 edited

Legend:

Unmodified
Added
Removed
  • openmoko/gps/gps_reader.py

    r11 r12  
    4343         above_sea_unit, geoidal_separation,
    4444         geoidal_separation_unit, data_age,
    45          diff_ref_stationID) = self.l
     45         diff_ref_stationID) = self.splitted_line
    4646
    4747        # build the timestamp in a human-readable form
     
    7373        latitude = latitude_degrees + (latitude_minutes/60)
    7474        longitude = longitude_degrees + (longitude_minutes/60)
    75        
    76         # str(latitude_degrees) + "" + " " + northsouth
     75
     76        # human-friendly coordinates
    7777        return "%d° %d' %.3f\" %s\n%d° %d' %.3f\" %s" % \
    7878               (latitude_degrees,latitude_minutes,latitude_seconds,northsouth,
     
    8080    # end parse_coord
    8181
    82     def read_stuff(self,source, condition):
     82    def read_line(self,source, condition):
    8383        line = self.file.readline()
    84         self.l = line.split(",")
     84        self.splitted_line = line.split(",")
    8585
    8686        # did we get a GPGGGA line ?
    87         if self.l[0] == "$GPGGA":
     87        if self.splitted_line[0] == "$GPGGA":
    8888            self.parse_gga()
    8989            if trace:
    9090                self.trace_file.write(line)
    9191       
    92         # return false to deactivate callback, true to let it run
     92        # return False to deactivate callback, True to let it run
    9393        return True
    94     # end read_stuff
     94    # end read_line
    9595
    9696    def spawn_gps(self, widget, data=None):
     
    9898        self.pid = os.spawnl(os.P_NOWAIT,gllin_path)
    9999        self.lbl_status.set_text("Starting...")
     100        # wait 4 seconds to let gllin boot properly, and then start parsing data
    100101        source_id = gobject.timeout_add(4000, self.init_gps_reader,self)
    101102    # end spawn_gps
     
    126127            else: # there is a process accessing that file, it's likely to be gllin, so open it
    127128                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)
    129130                self.gps_is_on()
    130131        else: # no nmea_file
    131132            self.gps_is_off()
    132133
    133         # disable future runs of callbacks
     134        # disable future runs, it's only necessary to run it once
    134135        return False
    135136    # end init_gps_reader
     
    224225# interpreter then create a GpsRead instance and show it
    225226if __name__ == "__main__":
    226     hello = GpsRead()
    227     hello.main()
     227    reader = GpsRead()
     228    reader.main()
Note: See TracChangeset for help on using the changeset viewer.