diff options
author | Eric S. Raymond <esr@thyrsus.com> | 2009-09-20 09:11:57 +0000 |
---|---|---|
committer | Eric S. Raymond <esr@thyrsus.com> | 2009-09-20 09:11:57 +0000 |
commit | da2351098ae281aa0e44dcf1069c8bd4356ebc01 (patch) | |
tree | 277b09daf2fbb7c686f62273237d5653c3630a5e | |
parent | edf73084048750021bd3438ac38963027c7142b9 (diff) | |
download | gpsd-da2351098ae281aa0e44dcf1069c8bd4356ebc01.tar.gz |
Ensure that the C and Python flag masks are consistent.
-rwxr-xr-x | devtools/maskaudit | 109 | ||||
-rw-r--r-- | gps.h | 2 | ||||
-rwxr-xr-x | gps.py | 64 |
3 files changed, 83 insertions, 92 deletions
diff --git a/devtools/maskaudit b/devtools/maskaudit index 1be71145..479cc167 100755 --- a/devtools/maskaudit +++ b/devtools/maskaudit @@ -1,61 +1,52 @@ #!/usr/bin/env python # -# Report on which status masks are used in the daemon vs. the client-side -# library. Warning: both the symbol list and the source list could be stale -# when you run this next - best to regenerate them. - -import commands, glob - -masks = ( - "ONLINE_SET ", - "TIME_SET", - "TIMERR_SET", - "LATLON_SET", - "ALTITUDE_SET", - "SPEED_SET", - "TRACK_SET", - "CLIMB_SET", - "STATUS_SET", - "MODE_SET", - "HDOP_SET", - "VDOP_SET", - "PDOP_SET", - "TDOP_SET", - "VERSION_SET", - "GDOP_SET", - "HERR_SET", - "VERR_SET", - "PERR_SET", - "POLICY_SET", - "SATELLITE_SET", - "RAW_SET", - "USED_SET", - "SPEEDERR_SET", - "TRACKERR_SET", - "CLIMBERR_SET", - "DEVICE_SET", - "DEVICELIST_SET", - "DEVICEID_SET", - "ERROR_SET", - "CYCLE_START", - "RTCM2_SET", - "RTCM3_SET", - "AIS_SET", -) - -def in_library(flag): - return commands.getstatus("grep %s libgps.c libgps_json.c") == 0 - -daemonfiles = " ".join(['serial.c', 'rtcm2_json.c', 'driver_garmin_txt.c', 'driver_zodiac.c', 'monitor_italk.c', 'bits.c', 'net_gnss_dispatch.c', 'crc24q.c', 'ntpshm.c', 'driver_rtcm3.c', 'subframe.c', 'net_remotegpsd.c', 'driver_garmin.c', 'driver_nmea.c', 'libgpsd_core.c', 'driver_superstar2.c', 'drivers.c', 'driver_aivdm.c', 'strl.c', 'gpsd_json.c', 'driver_rtcm2.c', 'gpsd_report.c', 'driver_ubx.c', 'gpspacket.c', 'driver_sirf.c', 'hex.c', 'ais_json.c', 'driver_tsip.c', 'bsd-base64.c', 'gpsd_dbus.c', 'monitor_sirf.c', 'net_ntrip.c', 'gpsutils.c', 'netlib.c', 'driver_proto.c', 'driver_navcom.c', 'gpsctl.c', 'driver_oncore.c', 'geoid.c','srecord.c', 'packet.c', 'driver_evermore.c', 'net_dgpsip.c', 'driver_italk.c', 'json.c', 'gpsd.c', 'isgps.c']) - - -def in_library(flag): - (status, output) = commands.getstatusoutput("grep %s libgps.c libgps_json.c" % flag) - return status == 0 - -def in_daemon(flag): - (status, output) = commands.getstatusoutput("grep %s %s" % (flag, daemonfiles)) - return status == 0 - -for flag in masks: - print "%-14s %8s %8s" % (flag, in_library(flag), in_daemon(flag)) +# With -t, report on which status masks are used in the daemon vs. the +# client-side library. +# +# With -p, dump a Python status mask list translated from the C one. + +import sys, commands, glob, getopt + +class SourceExtractor: + def __init__(self): + self.daemonfiles = ["gpsd.c", "libgpsd_core.c", "pseudonmea.c"] + glob.glob("driver_*.c") + self.masks = [] + for line in file("gps.h"): + if line.startswith("#define") and "_SET" in line: + fields = line.split() + self.masks.append((fields[1], fields[2])) + + def in_library(self, flag): + (status, output) = commands.getstatusoutput("grep %s libgps.c libgps_json.c" % flag) + return status == 0 + + def in_daemon(self, flag): + (status, output) = commands.getstatusoutput("grep %s %s" % (flag, " ".join(self.daemonfiles))) + return status == 0 + +if __name__ == '__main__': + try: + (options, arguments) = getopt.getopt(sys.argv[1:], "pt") + tabulate = False + pythonize = False + for (switch, val) in options: + if (switch == '-t'): + tabulate = True + if (switch == '-p'): + pythonize = True + + source = SourceExtractor() + print source.daemonfiles + + if tabulate: + print "%-14s %8s %8s" % (" ", "Library", "Daemon") + for (flag, value) in source.masks: + print "%-14s %8s %8s" % (flag, source.in_library(flag), source.in_daemon(flag)) + if pythonize: + for (d, v) in source.masks: + print "%-15s\t= %s" % (d, v[:-1]) + except KeyboardInterrupt: + pass + + + @@ -876,7 +876,7 @@ struct gps_data_t { #define VERR_SET 0x00002000u #define PERR_SET 0x00004000u /* only used in the daemon */ #define POLICY_SET 0x00020000u /* only used in client library */ -#define ERR_SET (HERR_SET | VERR_SET | PERR_SET) +#define ERR_SET (HERR_SET|VERR_SET|PERR_SET) #define SATELLITE_SET 0x00040000u #define RAW_SET 0x00080000u #define USED_SET 0x00100000u @@ -11,38 +11,38 @@ api_minor_version = 1 # bumped on compatible changes NaN = float('nan') def isnan(x): return str(x) == 'nan' -ONLINE_SET = 0x00000001 -TIME_SET = 0x00000002 -TIMERR_SET = 0x00000004 -LATLON_SET = 0x00000008 -ALTITUDE_SET = 0x00000010 -SPEED_SET = 0x00000020 -TRACK_SET = 0x00000040 -CLIMB_SET = 0x00000080 -STATUS_SET = 0x00000100 -MODE_SET = 0x00000200 -HDOP_SET = 0x00000400 -VDOP_SET = 0x00000800 -PDOP_SET = 0x00001000 -VERSION_SET = 0x00002000 -GDOP_SET = 0x00004000 -HERR_SET = 0x00008000 -VERR_SET = 0x00010000 -POLICY_SET = 0x00020000 -SATELLITE_SET = 0x00040000 -RAW_SET = 0x00080000 -USED_SET = 0x00100000 -SPEEDERR_SET = 0x00200000 -TRACKERR_SET = 0x00400000 -CLIMBERR_SET = 0x00800000 -DEVICE_SET = 0x01000000 -DEVICELIST_SET = 0x02000000 -DEVICEID_SET = 0x04000000 -ERROR_SET = 0x08000000 -RTCM2_SET = 0x10000000 -RTCM3_SET = 0x20000000 -AIS_SET = 0x40000000 -FIX_SET = (TIME_SET|MODE_SET|TIMERR_SET|LATLON_SET|HERR_SET|ALTITUDE_SET|VERR_SET|TRACK_SET|TRACKERR_SET|SPEED_SET|SPEEDERR_SET|CLIMB_SET|CLIMBERR_SET) +# Don't hand-hack this list, it's generated. +ONLINE_SET = 0x00000001 +TIME_SET = 0x00000002 +TIMERR_SET = 0x00000004 +LATLON_SET = 0x00000008 +ALTITUDE_SET = 0x00000010 +SPEED_SET = 0x00000020 +TRACK_SET = 0x00000040 +CLIMB_SET = 0x00000080 +STATUS_SET = 0x00000100 +MODE_SET = 0x00000200 +DOP_SET = 0x00000400 +VERSION_SET = 0x00000800 +HERR_SET = 0x00001000 +VERR_SET = 0x00002000 +PERR_SET = 0x00004000 +POLICY_SET = 0x00020000 +ERR_SET = (HERR_SET|VERR_SET|PERR_SET +SATELLITE_SET = 0x00040000 +RAW_SET = 0x00080000 +USED_SET = 0x00100000 +SPEEDERR_SET = 0x00200000 +TRACKERR_SET = 0x00400000 +CLIMBERR_SET = 0x00800000 +DEVICE_SET = 0x01000000 +DEVICELIST_SET = 0x02000000 +DEVICEID_SET = 0x04000000 +ERROR_SET = 0x08000000 +RTCM2_SET = 0x10000000 +RTCM3_SET = 0x20000000 +AIS_SET = 0x40000000 +FIX_SET = (TIME_SET|MODE_SET|TIMERR_SET|LATLON_SET|HERR_SET|ALTITUDE_SET|VERR_SET|TRACK_SET|TRACKERR_SET|SPEED_SET|SPEEDERR_SET|CLIMB_SET|CLIMBERR_SET STATUS_NO_FIX = 0 STATUS_FIX = 1 |