-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.py
73 lines (61 loc) · 1.66 KB
/
example.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
65
66
67
68
69
70
71
72
73
#!/usr/bin/env python3
import serial
from ubx_cmd import UbxCmd
# s = serial.Serial("COM6") # Windows
s = serial.Serial(
"/dev/ttyAMA0",
exclusive=True,
baudrate=9600,
bytesize=8,
parity=serial.PARITY_NONE,
stopbits=1.0,
timeout=1,
xonxoff=False,
rtscts=False,
dsrdtr=False,
) # Linux
ubx = UbxCmd(s, read=True, write=True)
print(ubx)
ubx.ubx_cfg_cfg_reset_all()
# explicitly set protocols allowed on UART1
ubx.ubx_cfg_prt_uart(
uart=ubx.PORT.UART1,
in_protocol=ubx.INOUT_PROTOCOL.NMEA | ubx.INOUT_PROTOCOL.UBX,
out_protocol=ubx.INOUT_PROTOCOL.NMEA | ubx.INOUT_PROTOCOL.UBX,
)
# configure GNSS systems:
# enable major GPS, Galileo, BeiDou; minor QZSS, SBAS
ubx.ubx_cfg_gnss_enabled(
gnss=[
ubx.GNSS_ID_MAJOR.GPS,
ubx.GNSS_ID_MAJOR.Galileo,
ubx.GNSS_ID_MAJOR.BeiDou,
ubx.GNSS_ID_AUGMENT.QZSS,
ubx.GNSS_ID_AUGMENT.SBAS,
]
)
ubx.ubx_cfg_gnss_gps(min_channels=8, max_channels=24)
ubx.ubx_cfg_gnss_galileo(min_channels=4, max_channels=12)
ubx.ubx_cfg_gnss_beidou(min_channels=8, max_channels=24)
# we can see QZSS here, use it
ubx.ubx_cfg_gnss_qzss(min_channels=2, max_channels=4, sig_cfg_mask=0x05)
# new SouthPAN SBAS system is currently in test mode using PRN122
ubx.ubx_cfg_gnss_sbas(
min_channels=1,
max_channels=2,
test_mode=True,
ranging=False,
correction=True,
integrity=False,
prn_mask=ubx.SBAS_PRN.PRN122,
)
# disable NMEA-GSV spam
ubx.ubx_cfg_msg(0xF0, 0x03, rate=0)
# enable NMEA-ZDA date/time messages
ubx.ubx_cfg_msg(0xF0, 0x08, rate=1)
ubx.ubx_cfg_cfg_save_all()
# stop ubx processing threads
ubx.close()
s.cancel_write()
s.cancel_read()
s.close()