forked from r0ro/skytraq
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathagps.py
64 lines (46 loc) · 1.63 KB
/
agps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
from skytraq.venus8 import Venus8
import serial.tools.list_ports
def device_port():
"""Find UART Controller Port"""
ports = serial.tools.list_ports.comports()
device_ports = []
for port, desc, hwid in sorted(ports):
# print("{}: {} [{}]".format(port, desc, hwid))
if "USB to UART" in desc:
device_ports.append(port)
print(device_ports)
return device_ports
device_port = device_port()[0]
serial_speed = 115200
# Connect to Port
gps = Venus8(device_port, serial_speed, debug=True)
# Disable NMEA Output
gps.enable_nmea_output(enable=False)
print("> soft version", gps.getSoftwareVersion(0))
waas_enabled = gps.getWaasStatus()
print("> waas: ", waas_enabled)
nav_mode = gps.getNavigationMode()
print("> navigation mode: ", nav_mode)
# ensure waas is enabled
if not waas_enabled:
print("Enable WAAS")
gps.setWaasStatus(True, True)
print("> waas: ", gps.getWaasStatus())
# ensure we are in pedestrian mode
if nav_mode != "pedestrian":
print("Enable pedestrian mode")
gps.setNavigationMode(True, True)
print("> navigation mode: ", gps.getNavigationMode())
print("===================================")
print("====== agps warm start =======")
print("===================================")
# Send AGPS Warm Start Command
gps.send_restart(restart_type=Venus8.AGPS_WARM_START_MODE)
print("===================================")
print("==== update ephemeris info =====")
print("===================================")
# Download Ephemeris and Write to Venus8
gps.updateEphemeris()
# Enable NMEA Output
gps.enable_nmea_output(enable=True)
print("============ done =============")