加我两分钱。
无论出于何种原因,我的覆盆子pi将继续执行一个线程,我必须硬重置pi。
所以我结合了sysnthesizerpatel和我在Dan Mandel的博客here上找到的答案。
我的gps_poller类看起来像这样:
import os
from gps import *
from time import *
import time
import threading
class GpsPoller(threading.Thread):
def __init__(self):
threading.Thread.__init__(self)
self.session = gps(mode=WATCH_ENABLE)
self.current_value = None
self.running = True
def get_current_value(self):
return self.current_value
def run(self):
try:
while self.running:
self.current_value = self.session.next()
except StopIteration:
pass并且使用中的代码如下所示:
from gps_poll import *
if __name__ == '__main__':
gpsp = GpsPoller()
try:
gpsp.start()
while True: