0
adafruit가 raspberry pi 용으로 설계된 GPS 유닛 중 하나에 제공하는 샘플 스크립트를 구현하려고합니다. 코드는 다음과 같다 : 그래서라스베리 파이 GPS 데몬
==============
import gps
# Listen on port 2947 (gpsd) of localhost
session = gps.gps("localhost", "2947")
session.stream(gps.WATCH_ENABLE | gps.WATCH_NEWSTYLE)
while True:
try:
report = session.next()
# Wait for a 'TPV' report and display the current time
# To see all report data, uncomment the line below
# print report
if report['class'] == 'TPV':
if hasattr(report, 'time'):
print report.time
except KeyError:
pass
except KeyboardInterrupt:
quit()
except StopIteration:
session = None
print "GPSD has terminated"
==============
"gps.py"파일의 맨 위에 "#!/usr/bin/python -tt"을 추가 한 다음 "chmod u + x /home/pi/gps.py"를 추가합니다.
, 나는 다음과 같은 오류가 발생하고 이유를 이해하지 못합니다 :
==============
[email protected] ~ $ /home/pi/gps.py
Traceback (most recent call last):
File "/home/pi/gps.py", line 2, in <module>
import gps
File "/home/pi/gps.py", line 5, in <module>
session = gps.gps("localhost", "2947")
TypeError: 'module' object is not callable
==============