-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgps.py
50 lines (44 loc) · 3.54 KB
/
gps.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
##
#
# lightning-scooter : An e-scooter whose electrical support can be booked for a certain period and paid with lightning.
#
# @filename : gps.py
# @brief : init GPS serial port to get instant infos
# @author : Matthias Steinig
#
# Folders
# img : basic Images to display
# tmp : where the composed pictures are
#
##
import serial
import time
ser = serial.Serial("/dev/serial0",115200)
W_buff = ["AT+CGNSPWR=1\r\n", "AT+CGNSSEQ=\"RMC\"\r\n", "AT+CGNSINF\r\n", "AT+CGNSURC=2\r\n","AT+CGNSTST=1\r\n"]
ser.write(W_buff[0])
ser.flushInput()
data = ""
num = 0
try:
while True:
while num < 5:
data += ser.read(ser.inWaiting())
if num <= 4:
# print data
if num < 4:# the string have ok
# print num
time.sleep(0.5)
ser.write(W_buff[num+1])
num =num +1
if num == 4:
# print num
# print data
time.sleep(0.5)
ser.write(W_buff[4])
num = num +1
ser.close()
# print "nach serport close"
break
except:
if ser != None:
ser.close()