generated from pimoroni/boilerplate-python
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from pimoroni/patch-py39
Fix Python 3.9 support for #11
- Loading branch information
Showing
5 changed files
with
113 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
#!/usr/bin/env python3 | ||
import time | ||
import sys | ||
|
||
from pa1010d import PA1010D | ||
|
||
|
||
""" | ||
Run raw commands against the PA1010D GPS and return the respones. | ||
Eg: | ||
PMTK605 = Query Firmware Release Info | ||
PMTK430 = Query Datum | ||
PMTK414 = Query NMEA Output Frequency | ||
PMTK400 = Query Update Rate | ||
PMTK225,<1 or 0> = Enable/Disable PPS | ||
""" | ||
|
||
def timeout(err=None, timeout=5.0): | ||
if err is None: | ||
err = "Timed out!" | ||
t_start = time.time() | ||
while time.time() - t_start < timeout: | ||
yield | ||
raise TimeoutError(err) | ||
|
||
|
||
responses = { | ||
} | ||
|
||
if len(sys.argv) < 2: | ||
print(f"Usage: {sys.argv[0]} <command>") | ||
sys.exit() | ||
|
||
command = sys.argv[1] | ||
response = responses.get(command, f"$PMTK{int(command[4:]) + 100}") | ||
|
||
gps = PA1010D() | ||
|
||
gps.update() | ||
|
||
gps.send_command(sys.argv[1]) | ||
|
||
if response: | ||
print(f"Waiting for {response}...") | ||
for t in timeout("Timed out waiting for command response."): | ||
message = gps.read_sentence() | ||
if message.startswith(response): | ||
print(message) | ||
break |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/usr/bin/env python3 | ||
import time | ||
import sys | ||
|
||
from pa1010d import PA1010D | ||
|
||
|
||
if len(sys.argv) < 2: | ||
print(f"Usage: {sys.argv[0]} <on/off>") | ||
sys.exit() | ||
|
||
gps = PA1010D() | ||
|
||
if sys.argv[1] == "on": | ||
gps.send_command("PMTK255,1") | ||
else: | ||
gps.send_command("PMTK255,0") | ||
|
||
result = gps.update() | ||
|
||
print("OK" if result else "Uh oh!") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters