-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
49 lines (40 loc) · 1.2 KB
/
Copy pathmain.py
File metadata and controls
49 lines (40 loc) · 1.2 KB
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
# -*- coding:utf-8 -*-
import L76X
import time
import math
import Lora
import daemon
def Main():
try:
x=L76X.L76X()
x.L76X_Set_Baudrate(9600)
x.L76X_Send_Command(x.SET_NMEA_BAUDRATE_115200)
time.sleep(2)
x.L76X_Set_Baudrate(115200)
x.L76X_Send_Command(x.SET_POS_FIX_400MS);
#Set output message
x.L76X_Send_Command(x.SET_NMEA_OUTPUT);
x.L76X_Exit_BackupMode();
while(1):
x.L76X_Gat_GNRMC()
if(x.Status == 1):
print 'Already positioned'
else:
print 'No positioning'
# print ' Lat = %f'%x.Lat
x.L76X_Baidu_Coordinates(x.Lat, x.Lon)
try:
x.Get_GNGGA()
x.Get_TP()
message = "*" + str(x.Lon_Baidu) + "," + str(x.Lat_Baidu) + "," + x._Status + ',' + x.Satellites + ',' + x.Elevation + ',' + x.Temperture + ',' + x.Pressure
Lora.Send(message)
except:
print("error.")
Lora.Send("Main ERROR!")
# time.sleep(0.5)
except:
#GPIO.cleanup()
print "\nProgram end"
exit()
with daemon.DaemonContext():
Main()