def run(self): i = 0 while True: data = self.socket.recv() if i == 5: i = 0 gps = GpsData() gps.ParseFromString(data) self.data = gps i += 1
def _receive(self): socket = self.socket_map['gps'] count = 0 while True: str = socket.recv() count += 1 if count == 5: count = 0 gps = GpsData() gps.ParseFromString(str) self.gps = gps
def gps(): global gps_data, socket_map socket = socket_map['gps'] i = 0 while True: data = socket.recv() if i == 5: i = 0 with gps_lock: gps_data = GpsData() gps_data.ParseFromString(data) i += 1
def gps(): global spinning, gps_data, socket_map gps_data = None socket = socket_map['gps'] i = 0 while True: with gps_lock: data = socket.recv() if spinning: continue if i == 5: i = 0 gps_data = GpsData() gps_data.ParseFromString(data) i += 1
def main(name): script_path = os.path.dirname(os.path.abspath(__file__)) gm = GeoMag(script_path + os.sep + 'geomag' + os.sep + 'WMM.COF') socket_map = generate_map(name) gps_socket = socket_map['gps'] decl_socket = socket_map['decl'] i = 0 while True: data = gps_socket.recv() if i == 20: i = 0 gps_data = GpsData() gps_data.ParseFromString(data) if gps_data.time and gps_data.fix >= 2: date = datetime.strptime(gps_data.time, '%Y-%m-%d %H:%M:%S').date() decl = gm.GeoMag(gps_data.lat, gps_data.lon, time = date).dec print time(), decl decl_socket.send('%f' % decl) i += 1
the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. """ import sys import zmq from gps_data_pb2 import GpsData from gpxdata import TrackPoint, TrackSegment, Track, Document from zmq_ipc import generate_map socket = generate_map('gpx_logger')['gps'] gps_data = GpsData() segment = TrackSegment() try: while True: str = socket.recv() gps_data.ParseFromString(str) print gps_data point = TrackPoint(gps_data.lat, gps_data.lon, gps_data.alt) segment.appendPoint(point) except: pass track = Track( name="Copter Track", description="Track recorded using the copter's onboard GPS module") track.appendSegment(segment)
def main(name): socket = generate_map(name)['gps'] socket.setsockopt(HWM, 1) while True: print 'send' gps_data = GpsData() sleep(0.2) gps_data.fix = 3 gps_data.time = 'NONE' gps_data.lat = 50.0 gps_data.lon = 10.0 gps_data.alt = 500.0 gps_data.sats = 6 gps_data.hdop = 1.0 gps_data.vdop = 2.0 for i in range(0, 5): si = gps_data.satinfo.add() si.id = i si.in_use = int(random() + 0.5) si.elv = int(random() * 100) - 50 si.azimuth = int(random() * 100) - 50 si.sig = int(random() * 100) socket.send(gps_data.SerializeToString())