summaryrefslogtreecommitdiff
path: root/gps
Commit message (Collapse)AuthorAgeFilesLines
* Makes 'GPSD' SHM IDs unique during regression tests.Fred Wright2017-03-241-3/+11
| | | | | | | | | | | | | | | | | Prior to this change, multiple gpsd instances would normally share a single SHM segment, confusing anyone using it. This was a problem either when running parallel regression tests, or even when running a single test with a system gpsd also running. Now, each gpsd instance launched by fake.py gets a SHM ID of the form 0x4770xxxx, where xxxx is the TCP or UDP port number. The high-order part is 0x4770 ('Gp') instead of 0x4750 ('GP') to ensure that it doesn't collide with the standard 'GPSD'. This does not do anything about 'NTPx' SHM segments. TESTED: Ran "scons -j24 check", and observed many 'Gpxx' SHM segments with ipcs, all disappearing by the end of testing.
* Makes connect failure to dead fake.py daemon more informative.Fred Wright2017-02-191-1/+6
| | | | | | | | | | | This generates a more specific exception when a connect from client_add() fails due to the daemon's having died. Aside from real daemon failures, this also catches some broken valgrind cases. TESTED: Ran "scons build-all check" on OSX. Also ran failing valgrind-audit and observed more informative (and less verbose) backtrace. Note that this is due to an OSX issue with valgrind itself, not the daemon.
* Reworks local exception definitions in fake.py.Fred Wright2017-02-191-15/+11
| | | | | | | | | This reduces duplicated code by using subclasses for local exceptions. It's not entirely clear that limiting __str__() to only certain exceptions is necessary, but it preserves that behavior. TESTED: Ran "scons build-all check" on several platforms.
* Reworks DaemonInstance in fake.py.Fred Wright2017-02-191-72/+80
| | | | | | | | | | | | | | | | | | | | This does two things: 1) It splits DaemonInstance into a base class and subclass, where the base class is a more generic subprogram runner. This makes it easier to add additional program runners without code duplication. 2) It switches from os.system() to subprocess.Popen() as the mechanism for running subprograms. This is generally cleaner, and in "background mode" is able to use natural parallelism rather than the ugly kludge of using shell backgrounding. Aside from being less ugly, this also makes termination of the "background" process directly visible, avoiding, e.g., hangs when valgrind bombs. TESTED: Ran "scons build-all check" on several platforms. Also ran valgrind-audit where valgrind was installed, though this has issues on some platforms.
* Updates MAXCHANNELS in gps.py to match gps.h.Fred Wright2017-01-191-1/+1
| | | | | | | | | | This value is only provided as a convenience, and has no internal function at all. It was never updated to reflect the two increases in gps.h. The new value would be excessive for xgps, but that no longer uses this definition. TESTED: No point.
* Changes fake.py stream type to 'bytes'.Fred Wright2016-12-252-5/+15
| | | | | | | | | | | | | | | | | | | Given that the data returned bye fake.py may include binary data, 'bytes' is a more appropriate type. Unlike the client API, where it's easy to provide both return types, it would be less convenient to do that here, so 'bytes' is preferred as the one choice (and is consistent with network sockets). When sending such data to stdout (or stderr), the straightforward method is to write to sys.stdXXX.buffer rather than sys.stdXXX. That doesn't exist in Python 2, but a helper function is now provided to get the appropriate 'bytes' stream for stdXXX. Since no previous *release* of GPSD is compatible with Python 3, changing this now doesn't break anything based on released code. TESTED: Ran "scons check" on OSX with all supported Python versions.
* Adds bytes-typed alternative response to Python client.Fred Wright2016-12-241-5/+12
| | | | | | | | | | | | | | | | | | | | | In Python 2, 'bytes' and 'str' are synonyms, but in Python 3 they are not. Since the client may return binary data in some cases, 'bytes' is a more appropriate data type. Rather than requiring double conversions in this case (the socket returns 'bytes'), this adds an alternative response item which is typed as 'bytes'. Although the accessor method 'data()' has always existed, it's shadowed by a name collision in some cases, resulting in the requirement that the caller access the 'response' item directly (as noted in the documentation). Thus, it's not possible to avoid the conversion to 'str' in the cases where it isn't actually used. This change doesn't bother to add an accessor method for 'bresponse', for consistency with the way the API is normally used, though that should be fixed if this aspect of the API is ever cleaned up. TESTED: Ran "scons check" on OSX with all supported versions of Python.
* Decode "device", some format cleanup.Gary E. Miller2016-09-131-19/+23
|
* Add missing tdop, alpha sort attributes.Gary E. Miller2016-09-131-11/+12
|
* gpsddata.fix.time was toggling from ISO time string to UNIX secondsGary E. Miller2016-09-121-5/+3
| | | | JSON TPV always sends ISO 8601 strings, as documented in gpsd_json(5)
* Retab for Python 3, clean up some formatting.Gary E. Miller2016-09-121-50/+53
|
* Whoops, MeterOffset() really was used, restore it.Gary E. Miller2016-07-271-0/+12
| | | | | Also, do a sign change by negation, not multiplication! Much better thing to do in double math.
* Rip out guts of EarthDistance() replace with Vincenty's FormulaGary E. Miller2016-07-261-35/+69
| | | | | | | The old EarthDistance was aweful. Vincenty's is supposed accurate to 1 mm! In some extreme cases it fails to converge, so fall back to EarthDistanceSmall() in that case.
* Convert CalcRad() to use WGS 84Gary E. Miller2016-07-261-11/+17
| | | | Most GPS are WGS 84, we should calculate in WGS 84.
* Move EarthDistanceSmall() into gps/misc.pyGary E. Miller2016-07-251-0/+18
| | | | | Other programs can use it. The accuracy looks good, not great, but WAY better than EarthDistance() and small angles.
* remove another UTF-8 character from a commentGary E. Miller2016-07-251-1/+1
|
* Remove unicode char from Python file.Gary E. Miller2016-07-251-1/+1
| | | | Ooops.
* Add comments on EarthDistance computations.Gary E. Miller2016-07-251-0/+6
| | | | Funny, in Texas a foot is not the same as everywhere else!
* Update some conversion constants to higher precision.Gary E. Miller2016-07-221-9/+9
|
* gps.py: Don't negate flags twice!Nuno Gonçalves2016-06-141-1/+1
| | | | | | | Flags are already interpreted as false at class gpsjson when WATCH_DISABLE is present. Signed-off-by: Gary E. Miller <gem@rellim.com>
* Fixes gps.gps.gps iterator for Python 3.Fred Wright2016-04-161-1/+6
| | | | | | | | | | | | | | | Python 3 renames the iterator next() method to __next__(). Without the new name, attempting to use the object as an iterator doesn't work. This didn't surface until trying webgps.py. For compatibility with both Python 2 and Python 3, both names need to be provided. This change renames the existing method to conformto Python 3 naming, and then adds a wrapper to provide the old name for Python 2. TESTED: Ran webgps.py (with uncommitted fixes) with both Python 2 and Python 3.
* Restores json_error definition accidentally removed by 94cb114.Fred Wright2016-04-141-0/+7
| | | | | | TESTED: Ran "scons check". Note that this doesn't test the actual change, since the exception in question is only used in certain error cases.
* Changes fake.py subclasses to use super() in __init__().Fred Wright2016-04-111-7/+7
| | | | | | | | | | | | | This doesn't really change any behavior, but serves as a better example for future code. Note that this can't be done so easily for gps.gps, due to the mismatched init signatures. This uses the older super() syntax, which is compatible with both Python 2 and Python 3. TESTED: Ran "scons build-all check" with all six supported Python versions. Also tested exception objects manually.
* Fixes gps/*.py to use new-style classes.Fred Wright2016-04-113-9/+9
| | | | | | | | | | | | | | | | | | | | | | | Although this isn't strictly a Python 3 requirement, using the new-style class definition syntax improves consistency between Python 2 and Python 3. Old-style classes have been deprecated since Python 2.2, but many such definitions linger on. Python 3 eliminates old-style classes, but instead of complaining about old-style definitions, it simply unconditionally and silently makes all classes new-style. The only incompatible differences are quite subtle and rarely matter in practice, but things are more consistent across versions if the new-style definitions are used. Also, the preferred method for subclasses to invoke parent init methods is via the super() construct, which is only available with new-style classes. Using super() is especially useful with multiple inheritance, which it handles automatically (provided that the init methods have compatible signatures). TESTED: Ran "scons build-all check valgrind-audit", as well as gegps, gpscat, gpsprof, xgps, and xgpsspeed, with all six supported Python versions (except 2.6 for xgps*).
* Makes "future imports" and Python version comments consistent.Fred Wright2016-04-103-3/+5
| | | | | | | | | | | | | | | | | | | | This makes the "future import" statements consistently specify absolute_import, print_function, and division, for maximum consistency between Python 2 and Python 3. Although absolute_import is probably a don't care for top-level programs, if unit tests were ever implemented for the programs they would be imported as modules, making the module import behavior relevant. Note that previous Python 3 fixes are a prerequisite for this change. Also makes the "polyglot comment" consistent across sources. TESTED: Using a version of SConstruct patched to use the target Python for build helpers, ran "scons build-all check valgrind-audit www/hardware.html" with all six supported Python versions. Also ran gegps, gpscat, gpsprof, xgps, and xgpsspeed with both Python 2 and Python 3.
* Removes redundant polystr/polybytes defs from client.py.Fred Wright2016-04-091-23/+2
| | | | | TESTED: Ran "scons check" with both Python 2 and Python 3.
* Fixes fake.py and gpsfake for Python 3.Fred Wright2016-04-092-18/+74
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | This incorporates the following changes: 1) Adds definitions for polystr(), polybytes(), and make_std_wrapper() to misc.py (the most logical place for code needed by multiple modules), using dummy definitions in the Python 2 case. For more info, see the Practical Python Porting guide. 2) Reworks the logfile->daemon data path in fake.py to use 'bytes' consistently. 3) Uses polybytes() in fake.py to construct control-socket commands as 'bytes', as expected by the socket I/O. 4) Uses make_std_wrapper() in gpsfake, to ensure that binary data is correctly written to stdout. 5) Adds 'division' to the future imports in gpsfake for consistency, though it doesn't actually matter in practice. Also updates the compatibility comments in all three files, and fixes a minor typo in misc.py. TESTED: Ran "scons build-all check" with Python 2.7, and ran all daemon regression tests with Python 2.6 and with Python 3.2-3.5 (with appropriately built extensions; not yet a build option).
* Changes type checks in misc.py:isotime to use isinstance().Fred Wright2016-04-091-3/+9
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Using isinstance() rather than type() == is preferable for a few reasons: 1) It's generally considered more pythonic. 2) Referring to types by name is a bit more readable than applying type() to sample values. 3) Both 'str' and the Python 2 'unicode' type can be checked in a single call. 4) Since the 'str' type check was the only use of a Unicode literal in the common code, changing this eliminates Python 3.2 incompatibility. In Python 2, both 'str' and 'unicode' are derived from the abstract 'basestring' class. In Python 3, 'unicode' has been folded into 'str', and the latter is itself the base class. Thus, an import-time conditional is used to set up the proper STR_CLASS for comparison. TESTED: Ran "scons build-all check" (with Python 2.7). Also verified that the regression tests and test_maidenhead.py run with Python 2.6, and that gpsfake -T and test_maidenhead.py run with Python 3.2-3.5 when the extensions are built for Python 3 (not yet a build option). Also verified that xgps and xgpsspeed work with 2.7 and 3.2-3.5 (with a pending fix to xgps for 3.2).
* Fixes a client.py exception for Python 3.Fred Wright2016-04-091-1/+2
| | | | | | | | | | | | In Python 3, exception objects are local to the try/except block, making them inaccessible outside that block. It was probably actually an error to set the "message" to be the exception object rather than its string representation, anyway. TESTED: Ran xgps without gpsd running, and verified that the proper error box is displayed, in both Python 2 and Python 3 (with appropriate builds of the extensions).
* Forces Python 3 import behavior in all gps/* modules.Fred Wright2016-04-095-4/+6
| | | | | | | | | | | | This ensures that any future changes that accidentally rely on the Python 2 implicit relative import behavior will fail in Python 2 as well as Python 3. TESTED: Ran "scons build-all check" (with Python 2.7). Also verified that the regression tests and test_maidenhead.py run with Python 2.6, and that gpsfake -T and test_maidenhead.py run with Python 3 when the extensions are built for Python 3 (not yet a build option).
* Fixes fake.py 'packet' import for Python 3.Fred Wright2016-04-091-1/+1
| | | | | | | | | | | | This changes the import of the 'packet' module to be an explicit relative import, which is valid in both Python2 and Python 3. The old implicit relative import doesn't work in Python 3. TESTED: Ran "scons build-all check" (with Python 2.7). Also verified that the regression tests and test_maidenhead.py run with Python 2.6, and that gpsfake -T and test_maidenhead.py run with Python 3 when the extensions are built for Python 3 (not yet a build option).
* RTCM3 JSON can be over 4.4k long, So go big in regres driver.Gary E. Miller2016-04-071-1/+2
| | | | Thanks to Fred Wright for locating the trouble spot.
* Fixes client.py bug ausing RTCM3.2 regression-test failures.Fred Wright2016-04-071-0/+1
| | | | | | | | | | | | | | | | | When an entire 4K buffer of packet data contains no newlines, it's simply retained for future use. But the code was failing to clear the previous response in that case, causing the caller to see duplicate data. Since this bug only mattered with lines longer than 4K bytes, and since even then it varied as a function of the alignment of lines vs. 4K boundaries, it was never seen on previous regression tests. TESTED: Ran "scons build-all check" with the updated code and the corrected test data for RTCM3.2. Signed-off-by: Gary E. Miller <gem@rellim.com>
* Add "status" to TPV for DGPS notificationGary E. Miller2016-04-061-0/+1
| | | | | Also update the affected regression files. gpsd had been throwing away the DGPS status.
* Fix a slightly botched Python 3 move.Eric S. Raymond2016-04-061-2/+2
|
* Restore language about 2.6 portability, clean up Python imports.Eric S. Raymond2016-03-274-7/+15
|
* Second fix for Python 3 sat display.Eric S. Raymond2016-03-271-1/+1
|
* Fix Python 3 compatibility.Eric S. Raymond2016-03-241-2/+2
|
* jsongen.py now runs polyglot under Python 2 or Python 3.Eric S. Raymond2016-03-221-1/+0
| | | | Also, remove an archaism from the gps/ client library.
* Clear out a remnant of the old pre-JSON protocol in the Python code.Eric S. Raymond2016-03-221-78/+0
| | | | Also, set xgps back to requiring python2 because of the gobject problem.
* pylint cleanup.Eric S. Raymond2016-03-221-4/+4
|
* gpsfake now runs polyglot under Python 2 or 3.Eric S. Raymond2016-03-221-2/+17
|
* Forward-port gps/ Python client code to run polyglot under Python 2 or 3.Eric S. Raymond2016-03-225-29/+37
| | | | | | | Verified by testing gpsprof under both versions. leapecond.py is also OK. Not yet polyglot: gegps, gpscap.py, gpscat, gpsfake, jsongen.py, maskaudit.py, test_maidenhead.py, valgrind_audit.py, xgps, xgpsspeed.
* Makes gpsfake -T take -S into account.Fred Wright2016-03-031-8/+13
| | | | | | | | | | | | | | | | | | | | This makes it possible to view the "slow" as well as the normal WRITE_PAD values with gpsfake -T, without having to look at the source code. It adds a new GetDelay() function to fake.py, which returns the proper delay value, taking into account both the possible environment variable and the "slow" option. This is now used for all hree uses of WRITE_PAD. Because the environment override is now part of the function, the WRITE_PAD constant is no longer modified by the environment value, but instead reflects the platform default. TESTED: Ran the full set of regression tests, with both default and acceptably shortened WRITE_PAD. Also verified that a zero value causes trouble (OSX), and that adding -S to the zero value makes it work. Signed-off-by: Jon Schlueter <jon.schlueter@gmail.com>
* Eliminates spurious gpsd errors with gpsfake in TCP mode.Fred Wright2016-02-291-1/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Depending on timing, in TCP mode, gpsd may try to reconnect to fake.py between the time that the logfile is complete and the time that the remove_device is issued. With no listener, this results in a set of three error messages from gpsd. They don't affect the test outcome, since they only go to stderr and the "real" output is complete, but they're annoying to the user. The likelihood of this happening increases with longer logfiles and with larger WRITE_PAD values. With a 30ms WRITE_PAD (the default on OSX), most logfiles exhibit this on all platforms, though it's not seen on Linux with the default zero WRITE_PAD. The fix is simply to avoid closing the listener after accepting the incoming connection. It's not necessary to explicitly service the listener further, since the OS listen queue is sufficient to accept the additional connection. Closing the listener at drain time is almost acceptable, but still occasionally fails due to the fact that drain() is (necessarily) called before remove_device(). Not explicitly closing it at all is acceptable, since Python closes it as part of the object cleanup. TESTED: Ran regress-driver in TCP mode with a 30ms WRITE_PAD on all logfiles on three versions of OSX, as well as Linux, FreeBSD, and OpenBSD, both with and without the fix. Observed spurious errors in all cases without the fix, and no cases with the fix. Also verified that no dangling sockets were left at the end of the runs.
* Makes fake.py's TCP and UDP port assignments parallel-compatible.Fred Wright2016-02-291-15/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | The current method for assigning ports uses a counter initialized to a constant. Although this works fine for multiple sessions managed by a single instance of fake.py, it fails miserably when running multiple parallel instances of fake.py. The fix is to allow the OS to assign the port numbers, since it's guaranteed to pick unused ports. In the TCP case, this is simply a matter of specifying 0 as the port, and then extracting the actual assigned port number with getsockname(). In the UDP case, it's more complicated since the port number being picked is actually for *gpsd's* end, which can't be done in a straightforward manner. The workaround, which was already being used to pick the control-socket port for gpsd, is to bind a socket with a reusable address, close it, and then assume that the port will remain available until gpsd grabs it. This change turns the existing code to do that into a function, with the socket type now being specifiable. TESTED: Ran all daemon tests in both TCP and UDP modes, on three versions of OSX as well as Linux, FreeBSD, and OpenBSD. Used default WRITE_PAD values except on OSX, where it was reduced to 1ms to save time. Signed-off-by: Jon Schlueter <jon.schlueter@gmail.com>
* [pep8] cleanup in gps/gps.py and misc.pyJon Schlueter2016-02-092-30/+35
|
* [pep8] cleanup of gps/fake.py for readablityJon Schlueter2016-02-091-20/+19
|
* [pep8] autopep8 whitespace cleanupJon Schlueter2016-02-094-10/+67
| | | | | large scale autopep8 cleanup of several pep8 whitespace warnings
* Correct buggy detection of SBAS satellites in the Python client code.Eric S. Raymond2015-04-071-0/+4
| | | | | Before this fix, satellites from the Beidou or QZNSS wuld have been incirrectly displayed with the SBAS shape.