Example #1
0
def talker():

    rospy.init_node('GPS_Streamer')
    pub = rospy.Publisher("GPS_Data",
                          mavric.msg.GPS,
                          queue_size=10,
                          latch=True)
    r = rospy.Rate(10)
    gps = GPS('/dev/serial0')
    gps.begin()
    while not rospy.is_shutdown():
        print(gps._data)
        gps.update()
        pub.publish(gps.good_fix, gps.latitude, gps.longitude, gps.altitude,
                    gps.speed, gps.heading, gps.satellites)
        r.sleep()
Example #2
0
from gps import GPS
from rfcomm import RFCOMM
import time
import subprocess

print("STARTING...")

rf = RFCOMM()
gps = GPS()

subprocess.run(["hciconfig", "hci0", "piscan"])

while True:

    if rf.client_connected:
        data = gps.update()

        if data is not None:
            print("DATA: " + data)
            rf.send_data(data + "\r\n")
        time.sleep(0.1)
    else:
        gps.stop()
        print("WAIT FOR CLIENT...")
        rf.wait_for_client()
        print("CLIENT ACCEPTED")
        gps.start()
        print("ENABLE GPS")