Discussion:
[USRP-users] Sample code to read GPS Lock/ NMEA stream etc..
keith
2011-11-29 21:20:44 UTC
Permalink
Hi all,

I'd really love it if somebody would help me out with a really basic
program to read the GPSDO info and the sensors on the board..

I've had a go.. a modifying some of the example code with the Ettus driver,
but my C++ skills are somewhat absent and get_mboard_sensor("gps_time") is
returning a sensor_value_t type.. and I think I need to define it, or
include something else.. but I'm a lowly php/perl/sh scripter.. so to make
it short, would somebody be so good as to point me to or write up a few
lines of code that I need to compile a small C++ example program that will
print out the GPS time? I can probably take it from there and figure out
how to the lock status and nmea data etc.

I would REALLY appreciate it.

Thanks!
keith
2011-11-29 21:45:59 UTC
Permalink
The ".value member will give you the sensor as a string. You will need
to parse this value for "gps_gpgsa", "gps_gprmc", and "gps_gpgga" sensors.
Cheers Josh, but I have browsed the doxygen manual and I have read the
notes, the problem for me at this time is specifically, I haven't got the
first idea how to write a program in C++ that would simply read and display
the value returned from get_mboard_sensor('gps_time') for example.

So, I'm asking if some kind soul would send me the code that does exactly
that.. with the includes I need, the structures defined and an example of
how to output the return value of get_mboard_sensor() to stdout. It would
save me doing a crash course in basic C++ and i'm well pushed for time.

thanks again,

K.
Jason Abele
2011-11-29 21:49:11 UTC
Permalink
Post by keith
The ".value member will give you the sensor as a string. You will need
to parse this value for "gps_gpgsa", "gps_gprmc", and "gps_gpgga" sensors.
Cheers Josh, but I have browsed the doxygen manual and I have read the
notes, the problem for me at this time is specifically, I haven't got the
first idea how to write a program in C++ that would simply read and display
the value returned from get_mboard_sensor('gps_time') for example.
So, I'm asking if some kind soul would send me the code that does exactly
that.. with the includes I need, the structures defined and an example of
how to output the return value of get_mboard_sensor() to stdout. It would
save me doing a crash course in basic C++ and i'm well pushed for time.
thanks again,
There is an example of reading an printing an mboard sensor
(ref_locked) in rx_samples_to_file (and other examples)

http://code.ettus.com/redmine/ettus/projects/uhd/repository/revisions/master/entry/host/examples/rx_samples_to_file.cpp#L195

Jason
keith
2011-11-29 22:14:03 UTC
Permalink
Post by Jason Abele
There is an example of reading an printing an mboard sensor
(ref_locked) in rx_samples_to_file (and other examples)
http://code.ettus.com/redmine/ettus/projects/uhd/repository/revisions/master/entry/host/examples/rx_samples_to_file.cpp#L195
Jason
nice one! brilliant. thanks jason!

so all i need is something like this:

uhd::sensor_value_t mimo_locked =
usrp->get_mboard_sensor("gps_locked",0);
std::cout << boost::format("Checking: %s ...") %
mimo_locked.to_pp_string() << std::endl;

results in Checking: GPS lock status: locked ...

and

uhd::sensor_value_t mimo_locked = usrp->get_mboard_sensor("gps_time",0);
std::cout << boost::format("Checking: %s ...") %
mimo_locked.to_pp_string() << std::endl;

Checking: GPS epoch time: 1322604511 seconds ...

Now i can figure out exactly how much of the rest of that code is
needed and make myself a nice little prog to watch how long the gps is
taking to get a lock!!

thanks!

Loading...