# GPS Polling?

Source: https://forum.modalai.com/topic/517/gps-polling
Category: General Questions (https://forum.modalai.com/category/2/general-questions)
Posted: 2021-10-26 01:36:59 UTC by Chuck Bokath
Replies: 8 · Views: 1473

## Chuck Bokath · 2021-10-26 01:36:59 UTC

Hi, Is it possible to poll the gps programmatically - i.e. open a serial port and read the NMEA sentences, or something like gpsd?

Thanks in advance!

## Reply by Eric Katzfey (ModalAI staff) · 2021-10-26 15:09:31 UTC

You mean attach an external GPS receiver and talk to it over a UART?

## Reply by Guest · 2021-10-26 16:50:18 UTC

If you don't need to manually sample the hardware, voxl-vision-px4 publishes the GPS data to the file system to /run/mpa/vvpx4_gps_raw_int in our MPA format. You can use ```voxl-inspect-gps``` to see a viewer friendly terminal output displaying current gps information, and the [source](https://gitlab.com/voxl-public/modal-pipe-architecture/voxl-mpa-tools/-/blob/master/tools/voxl-inspect-gps.c) serves as a good example of how you could use the information in a c/++ program on voxl.

## Reply by Chuck Bokath · 2021-10-26 17:22:29 UTC (in reply to Guest)

@Alex-Gardner I dont need to manually sample the hardware and it does not have to be extremely precise, I am looking to essentially use the drone system communicating with the cellular component to read cellular metadata via at commands, then tagging the metadata with the x/y/z points, pushing the data to a webserver while in flight to get near time data for analysis. If there was a api call to pull off the xyz that would be great, if not, I'd like to understand if I can use a script to pull off the gps source. Mind you I am just getting into this system and the various API's. Though as I write this, I have taken a step backwards in that I can sync time so I am struggling with the VPN connection back to the webserver, much less getting wwan0 to pull an IP from the carrier. augh. I am not able to locate the voxl-inspect-gps on my system.

## Reply by Eric Katzfey (ModalAI staff) · 2021-10-26 20:33:41 UTC

@Chuck-Bokath Yes, we have done the same things before. Basically log a position and signal strength indication. What platform are you using? Typically, in a PX4 system, that information will be encapsulated in Mavlink messages. On our Voxl board we have an endpoint for all of those messages that come over a serial port that we then forward on over UDP to a ground control station. However, as @Alex-Gardner points out, that voxl-vision-px4 module will dump all of that raw information to a Linux pipe as it is passing through. And, as @Alex-Gardner also pointed out, there is some example code that shows how to listen to that pipe and parse the message.

## Reply by Chuck Bokath · 2021-11-08 15:57:50 UTC (in reply to Eric Katzfey)

@Eric-Katzfey I will take a look and try this.

## Reply by Chuck Bokath · 2021-11-08 18:44:53 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Ok. I am new to modalai dev environment. What I have currently is a px4 LTE enabled drone with no camera. The drone is simply to be used to test BLOS capabilities. I have not set the dev environment up, a vendor did so, but now its mine to deal with. As mentioned, its a LTE enabled drone with a VPN back to the lab. The VPN fails at times after the LTE connects, because the time is not set, therefore the certificate is not valid. I used voxl-test-time it seemed to set the time correctly. Though I need the time to set on startup is that as simple as adding a service? Once I get that going, I realized that I dont have the voxl-vision-px4 module to extract the GPS off.  It seems logical to need a camera for the vision to work? I do have opkg setup and i pulled the most stable repository. Can I pull some packages off the repository that can provide me the pipe you are talking about? I am just not sure which ones. I can always write a quick script to extract the info I need from the pipe.

## Reply by groupo · 2024-08-29 15:02:54 UTC (in reply to Eric Katzfey)

@Eric-Katzfey Hey Eric, can you link to this example code?

## Reply by Eric Katzfey (ModalAI staff) · 2024-08-29 15:41:18 UTC (in reply to groupo)

@groupo This code https://gitlab.com/voxl-public/voxl-sdk/services/voxl-vision-hub/-/blob/master/src/mavlink_io.c?ref_type=heads#L156 sets up a pipe client to listen for Mavlink messages in the voxl-vision-hub application
