1. 구성도
2. 위도/경도 값 가공
from gps import *
import time
gpsd = gps(mode=WATCH_ENABLE|WATCH_NEWSTYLE)
dict2 = {}
def gpsRead():
try:
report = gpsd.next()
if report['class'] == 'TPV':
dict2['lat']=getattr(report,'lat',0.0)
dict2['lon']=getattr(report,'lon',0.0)
#print(dict2['lat'])
#print(dict2['lon'])
#print(dict2['time'])
#print(getattr(report,'lat',0.0))
#print(getattr(report,'lon',0.0))
#print(getattr(report,'time',''))
time.sleep(1)
except (KeyboardInterrupt, SystemExit): #when you press ctrl+c
print("Done.\nExiting.")
return dict2
3. Flask 데이터 전송
from re import A
from flask import Flask, redirect
import gpstest4
import json
s = ''
a = 0
app = Flask(__name__)
@app.route('/')
def index():
for i in range(5):
dict2 = gpstest4.gpsRead()
s = json.dumps(dict2)
print(s)
return redirect(f'http://172.30.1.45:8081/PTSD_project/gpsService?data={s}')
if __name__ == '__main__':
app.run(host='192.168.137.119', port=5020)
'Project > PTSD_Project' 카테고리의 다른 글
PTSD시연 영상 / PPT (0) | 2022.07.15 |
---|---|
[Raspberry Pi]인체감지센서(HC-SR501) Display ON/OFF (0) | 2022.07.11 |
테이블 명세서 (0) | 2022.07.11 |
요구사항정의서 (0) | 2022.07.11 |