Changeset 6fec060 for src/python
- Timestamp:
- Aug 10, 2017, 7:21:07 PM (9 years ago)
- Branches:
- 0.5, app-cordova, debian/bullseye, debian/jessie, master
- Children:
- 12d7e6f, 1ba85cf
- Parents:
- c455d7b
- File:
-
- 1 edited
-
src/python/bin/gnuboat (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/python/bin/gnuboat
rc455d7b r6fec060 42 42 shutdownfile = "/var/spool/gnuboat/shutdown.request" 43 43 logdir = "/var/log/gnuboat" 44 nmeaLogFile = "nmea0183.log"45 44 logperiod = 2 46 45 displayperiod = 5 … … 48 47 shutdownRequested = None 49 48 nmeafile = None 49 nmeaFileDate = None 50 50 51 51 … … 116 116 print " -o --output Directory where the log files are stored (e.g. the NMEA0183 log files)" 117 117 118 def log(gpsFix, gpsTime, gpsStatus, latitude, latitudeDirection, longitude, 119 longitudeDirection, courseOverGround, speedOverGround, waterDepth, waterDepthValid): 120 global nmeafile 121 122 # Only log, if we have a gps fix 123 if gpsFix < 2: 124 return 125 126 nmeaFileDateShould = datetime.datetime.utcnow().strftime("%Y-%m-%d") 127 mode = 'A' 128 if nmeafile == None or nmeaFileDate != nmeaFileDateShould: 129 if nmeaFile: 130 nmeafile.close() 131 try: 132 nmeaFileDate = nmeaFileDateShould 133 nmeaLogFile = "nmea0183-%s.log" % nmeaFileDate 134 nmeafile = open("%s/%s" % (logdir, nmeaLogFile), 'a', 0) 135 except IOError as error: 136 print "Could not open the logfile: %s" % error 137 sys.exit(2) 138 139 nmeafile.write("%s\r\n" % str(pynmea2.RMC('GN', 'RMC', 140 (gpsTime.strftime("%H%M%S"), gpsStatus, '$%04.3f' % latitude, 141 latitudeDirection, '$%05.3f' % longitude, longitudeDirection, 142 '$%02.1f' % speedOverGround, '$%02.1f' % courseOverGround, 143 gpsTime.strftime("%d%m%y"), '', '', mode)))) 144 if waterDepthValid: 145 nmeafile.write("%s\r\n" % str(pynmea2.DPT('SD', 'DPT', ('%02.2f' % waterDepth, '00.00')))) 118 146 119 147 def main(argv): … … 124 152 global logdir 125 153 global nmeaLogFile 126 global nmeafile127 154 128 155 try: … … 176 203 createDatabase(rrdfile) 177 204 178 try:179 nmeafile = open("%s/%s" % (logdir, nmeaLogFile), 'a', 0)180 except IOError as error:181 print "Could not open the logfile: %s" % error182 sys.exit(2)183 184 205 displayHandler = daemon.DisplayHandler(displayperiod) 185 206 … … 206 227 207 228 # append to log 208 if gpsp.gpsFix() >= 2: 209 timeUtc = gpsp.timeUtc() 210 status = gpsp.status() 211 latitudeDirection = gpsp.latitudeDirection() 212 longitudeDirection = gpsp.longitudeDirection() 213 courseOverGround = gpsp.courseOverGround() 214 215 mode = 'N' 216 if gpsFix >= 2: 217 mode = 'A' 218 219 nmeafile.write("%s\r\n" % str(pynmea2.RMC('GN', 'RMC', 220 (timeUtc.strftime("%H%M%S"), status, '$%04.3f' % latitude, 221 latitudeDirection, '$%05.3f' % longitude, longitudeDirection, 222 '$%02.1f' % speedOverGround, '$%02.1f' % courseOverGround, 223 timeUtc.strftime("%d%m%y"), '', '', mode)))) 224 if n2kd.waterDepthValid(): 225 nmeafile.write("%s\r\n" % str(pynmea2.DPT('SD', 'DPT', 226 ('%02.2f' % waterDepth, '00.00')))) 227 229 log(gpsFix, gpsp.timeUtc(), gpsp.status(), latitude, gpsp.latitudeDirection(), 230 longitude, gpsp.longitudeDirection(), gpsp.courseOverGround(), speedOverGround, 231 waterDepth, n2kd.waterDepthValid()) 232 228 233 # display data 229 234 displayHandler.setValues(
Note:
See TracChangeset
for help on using the changeset viewer.
