-
Notifications
You must be signed in to change notification settings - Fork 6
/
extract_log.py
executable file
·63 lines (50 loc) · 1.95 KB
/
extract_log.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
#!/usr/bin/env python3
# -*- coding: utf8 -*-
import binascii
from skytraq.venus6 import Venus6
serial_speed = None # 9600
# open com port
gps = Venus6('/dev/ttyUSB0', serial_speed, debug=False)
if serial_speed == None:
# try to guess serial speed
serial_speed = gps.guessSerialSpeed()
print("===================================")
print("==== device info =====")
print("===================================")
print("> serial port speed: ", serial_speed)
print("> soft version", gps.getSoftwareVersion(0))
print("> soft crc", binascii.hexlify(gps.getSoftwareCRC()).decode('utf8').upper())
print("===================================")
print("==== getting log status =====")
print("===================================")
(log_wr_ptr, sector_left, total_sector,
min_time, max_time,
min_distance, max_distance,
min_speed, max_speed,
data_log_enable, log_fifo_mode) = gps.getLogStatus()
print("> log_wr_ptr: 0x%X" % log_wr_ptr)
print("> sector_left: %d / %d" % (sector_left, total_sector))
print("> time min: %ds / max %ds" % (min_time, max_time))
print("> distance min: %d m / max %d m" % (min_distance, max_distance))
print("> speed min: %d km/h / max %d km/h" % (min_speed, max_speed))
print("> data_log_enable: %d" % data_log_enable)
print("> log_fifo_mode: %d" % log_fifo_mode)
print("===================================")
print("==== read logs =====")
print("===================================")
if serial_speed != 115200:
print("/!\\ CHANGING SERIAL SPEED TO 115200 /!\\")
gps.setSerialSpeed(115200)
entries = []
with open('raw.bin', 'wb') as raw:
for s in range(total_sector - sector_left + 1):
print("start reading sector %d" % s)
data = gps.readLog(s, 1)
print("got data: ", data[0:32])
raw.write(data)
print("Saved data to raw.bin")
# restore serial speed
if serial_speed != 115200:
print("/!\\ RESTORE SERIAL SPEED TO %d /!\\", serial_speed)
gps.setSerialSpeed(serial_speed)
# gps.clearLogs()