Accessing the USB GPS programmatically
Now that you can access the GPS device, let's work on accessing the data programmatically. Your project should now have the GPS device connected and have access to query the data via the serial port. In this section, you will create a program to use this data to discover where you are, then you can determine what to do with that information.
If you've completed the previous section, you should be able to receive the raw data from the GPS unit. Now you want to be able to do something with this data; for example, find your current location and altitude and then decide whether your target location is to the West, East, North, or South.
First, get the information from the raw data. As noted previously, the position and speed is in the $GPMRC
output of the GPS device. Write a program to simply parse out a couple of pieces of information from that data. So, open a new file (you can name it location.py
) and edit it, as shown in the following screenshot:
#!/usr...