From 330a014dfc32b34a7fe5555d3ae2d87a25dc2466 Mon Sep 17 00:00:00 2001 From: Nick Foster Date: Mon, 17 Jan 2011 22:51:14 -0800 Subject: next: generalized the GPS interface to any USRP device. just give it a function to write/read strings to UART. not sure if i'm happy with the interface; maybe inheriting is cleaner. this works though. gps interface for usrp2 is disabled right now in mboard_impl. --- host/include/uhd/usrp/CMakeLists.txt | 1 + host/include/uhd/usrp/gps_ctrl.hpp | 56 ++++++++++ host/lib/usrp/CMakeLists.txt | 1 + host/lib/usrp/gps_ctrl.cpp | 210 +++++++++++++++++++++++++++++++++++ host/lib/usrp/usrp2/CMakeLists.txt | 2 - host/lib/usrp/usrp2/codec_impl.cpp | 2 +- host/lib/usrp/usrp2/gps_ctrl.cpp | 208 ---------------------------------- host/lib/usrp/usrp2/gps_ctrl.hpp | 53 --------- host/lib/usrp/usrp2/mboard_impl.cpp | 5 +- host/lib/usrp/usrp2/usrp2_iface.cpp | 8 ++ host/lib/usrp/usrp2/usrp2_iface.hpp | 9 ++ host/lib/usrp/usrp2/usrp2_impl.hpp | 4 +- 12 files changed, 292 insertions(+), 267 deletions(-) create mode 100644 host/include/uhd/usrp/gps_ctrl.hpp create mode 100644 host/lib/usrp/gps_ctrl.cpp delete mode 100644 host/lib/usrp/usrp2/gps_ctrl.cpp delete mode 100644 host/lib/usrp/usrp2/gps_ctrl.hpp (limited to 'host') diff --git a/host/include/uhd/usrp/CMakeLists.txt b/host/include/uhd/usrp/CMakeLists.txt index c8d7281d3..f60b35e59 100644 --- a/host/include/uhd/usrp/CMakeLists.txt +++ b/host/include/uhd/usrp/CMakeLists.txt @@ -34,6 +34,7 @@ INSTALL(FILES ### utilities ### dsp_utils.hpp + gps_ctrl.hpp mboard_eeprom.hpp misc_utils.hpp subdev_spec.hpp diff --git a/host/include/uhd/usrp/gps_ctrl.hpp b/host/include/uhd/usrp/gps_ctrl.hpp new file mode 100644 index 000000000..74f984ee0 --- /dev/null +++ b/host/include/uhd/usrp/gps_ctrl.hpp @@ -0,0 +1,56 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 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. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#ifndef INCLUDED_GPS_CTRL_HPP +#define INCLUDED_GPS_CTRL_HPP + +#include +#include +#include +#include + +using namespace boost::posix_time; + +typedef boost::function gps_send_fn_t; +typedef boost::function gps_recv_fn_t; + +class gps_ctrl : boost::noncopyable{ +public: + typedef boost::shared_ptr sptr; + + /*! + * Make a GPS config for Jackson Labs or generic NMEA GPS devices + */ + static sptr make(gps_send_fn_t, gps_recv_fn_t); + + /*! + * Get the current GPS time and date + * \return current GPS time and date as boost::posix_time::ptime object + */ + virtual ptime get_time(void) = 0; + + /*! + * Tell you if there's a supported GPS connected or not + * \return true if a supported GPS is connected + */ + virtual bool gps_detected(void) = 0; + + //TODO: other fun things you can do with a GPS. + +}; + +#endif /* INCLUDED_GPS_CTRL_HPP */ diff --git a/host/lib/usrp/CMakeLists.txt b/host/lib/usrp/CMakeLists.txt index 9dc74a5fe..bd25aec2b 100644 --- a/host/lib/usrp/CMakeLists.txt +++ b/host/lib/usrp/CMakeLists.txt @@ -25,6 +25,7 @@ LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dboard_manager.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dsp_utils.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mboard_eeprom.cpp ${CMAKE_CURRENT_SOURCE_DIR}/misc_utils.cpp ${CMAKE_CURRENT_SOURCE_DIR}/multi_usrp.cpp diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp new file mode 100644 index 000000000..3c7c00134 --- /dev/null +++ b/host/lib/usrp/gps_ctrl.cpp @@ -0,0 +1,210 @@ +// +// Copyright 2010 Ettus Research LLC +// +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 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. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// + +#include +#include +#include +#include +#include +#include +#include +#include + +using namespace uhd; +using namespace boost::gregorian; +using namespace boost::posix_time; +using namespace boost::algorithm; + +/*! + * A GPS control for Jackson Labs devices (and other NMEA compatible GPS's) + */ + +//TODO: multiple baud rate support (requires mboard_impl changes for poking UART registers) +class gps_ctrl_impl : public gps_ctrl{ +public: + gps_ctrl_impl(gps_send_fn_t send, gps_recv_fn_t recv){ + _send = send; + _recv = recv; + + std::string reply; + bool i_heard_some_nmea = false, i_heard_something_weird = false; + + gps_type = GPS_TYPE_NONE; + +// set_uart_baud_rate(GPS_UART, 115200); + //first we look for a Jackson Labs Firefly (since that's what we sell with the USRP2+...) + + _recv(); //get whatever junk is in the rx buffer right now, and throw it away + _send("HAAAY GUYYYYS\n"); //to elicit a response from the Firefly + + //then we loop until we either timeout, or until we get a response that indicates we're a JL device + int timeout = GPS_TIMEOUT_TRIES; + while(timeout--) { + reply = safe_gps_read(); + if(trim_right_copy(reply) == "Command Error") { + gps_type = GPS_TYPE_JACKSON_LABS; + break; + } + else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response + else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate + boost::this_thread::sleep(boost::posix_time::milliseconds(200)); + } + + if((i_heard_some_nmea) && (gps_type != GPS_TYPE_JACKSON_LABS)) gps_type = GPS_TYPE_GENERIC_NMEA; + + //otherwise, we can try some other common baud rates looking to see if a GPS is connected (todo, later) + if((gps_type == GPS_TYPE_NONE) && i_heard_something_weird) { + std::cout << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl; + } + + bool found_gprmc = false; + + switch(gps_type) { + case GPS_TYPE_JACKSON_LABS: + std::cout << "Found a Jackson Labs GPS" << std::endl; + //issue some setup stuff so it spits out the appropriate data + //none of these should issue replies so we don't bother looking for them + //we have to sleep between commands because the JL device, despite not acking, takes considerable time to process each command. + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); + _send("SYST:COMM:SER:ECHO OFF\n"); + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); + _send("SYST:COMM:SER:PRO OFF\n"); + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); + _send("GPS:GPGGA 0\n"); + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); + _send("GPS:GGAST 0\n"); + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); + _send("GPS:GPRMC 1\n"); + boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); + +// break; + + case GPS_TYPE_GENERIC_NMEA: + if(gps_type == GPS_TYPE_GENERIC_NMEA) std::cout << "Found a generic NMEA GPS device" << std::endl; + found_gprmc = false; + //here we loop around looking for a GPRMC packet. if we don't get one, we don't have a usable GPS. + timeout = GPS_TIMEOUT_TRIES; + while(timeout--) { + reply = safe_gps_read(); + if(reply.substr(0, 6) == "$GPRMC") { + found_gprmc = true; + break; + } + } + if(!found_gprmc) { + if(gps_type == GPS_TYPE_JACKSON_LABS) std::cout << "Firefly GPS not locked or warming up." << std::endl; + else std::cout << "GPS does not output GPRMC packets. Cannot retrieve time." << std::endl; + gps_type = GPS_TYPE_NONE; + } + break; + + case GPS_TYPE_NONE: + default: + break; + + } + + + } + + ~gps_ctrl_impl(void){ + + } + +//TODO: this isn't generalizeable to non-USRP2 USRPs. + std::string safe_gps_read() { + std::string reply; + try { + reply = _recv(); + } catch (std::runtime_error err) { + if(err.what() != std::string("usrp2 no control response")) throw; //sorry can't cope with that + else { //we don't actually have a GPS installed + reply = std::string(); + } + } + return reply; + } + + ptime get_time(void) { + std::string reply; + ptime now; + boost::tokenizer > tok(reply); + std::vector toked; + int timeout = GPS_TIMEOUT_TRIES; + bool found_gprmc = false; + switch(gps_type) { + case GPS_TYPE_JACKSON_LABS: //deprecated in favor of a single NMEA parser + case GPS_TYPE_GENERIC_NMEA: + + while(timeout--) { + reply = safe_gps_read(); + if(reply.substr(0, 6) == "$GPRMC") { + found_gprmc = true; + break; + } + } + UHD_ASSERT_THROW(found_gprmc); + + tok.assign(reply); + toked.assign(tok.begin(), tok.end()); + + UHD_ASSERT_THROW(toked.size() == 11); //if it's not we got something weird in there + + now = ptime( date( + greg_year(boost::lexical_cast(toked[8].substr(4, 2)) + 2000), //just trust me on this one + greg_month(boost::lexical_cast(toked[8].substr(2, 2))), + greg_day(boost::lexical_cast(toked[8].substr(0, 2))) + ), + hours( boost::lexical_cast(toked[1].substr(0, 2))) + + minutes(boost::lexical_cast(toked[1].substr(2, 2))) + + seconds(boost::lexical_cast(toked[1].substr(4, 2))) + ); + break; + case GPS_TYPE_NONE: + default: + throw std::runtime_error("get_time(): Unsupported GPS or no GPS detected\n"); + break; + } + return now; + } + + bool gps_detected(void) { + return (gps_type != GPS_TYPE_NONE); + } + +private: + gps_send_fn_t _send; + gps_recv_fn_t _recv; + + enum { + GPS_TYPE_JACKSON_LABS, + GPS_TYPE_GENERIC_NMEA, + GPS_TYPE_NONE + } gps_type; + + static const int GPS_TIMEOUT_TRIES = 5; + static const int GPS_TIMEOUT_DELAY_MS = 200; + static const int FIREFLY_STUPID_DELAY_MS = 200; + +}; + +/*********************************************************************** + * Public make function for the GPS control + **********************************************************************/ +gps_ctrl::sptr gps_ctrl::make(gps_send_fn_t send, gps_recv_fn_t recv){ + return sptr(new gps_ctrl_impl(send, recv)); +} diff --git a/host/lib/usrp/usrp2/CMakeLists.txt b/host/lib/usrp/usrp2/CMakeLists.txt index d83c82063..e8811a8fb 100644 --- a/host/lib/usrp/usrp2/CMakeLists.txt +++ b/host/lib/usrp/usrp2/CMakeLists.txt @@ -34,8 +34,6 @@ IF(ENABLE_USRP2) ${CMAKE_CURRENT_SOURCE_DIR}/dboard_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dboard_iface.cpp ${CMAKE_CURRENT_SOURCE_DIR}/dsp_impl.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.hpp - ${CMAKE_CURRENT_SOURCE_DIR}/gps_ctrl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/io_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/mboard_impl.cpp ${CMAKE_CURRENT_SOURCE_DIR}/usrp2_iface.cpp diff --git a/host/lib/usrp/usrp2/codec_impl.cpp b/host/lib/usrp/usrp2/codec_impl.cpp index eda15697b..df4975bb1 100644 --- a/host/lib/usrp/usrp2/codec_impl.cpp +++ b/host/lib/usrp/usrp2/codec_impl.cpp @@ -28,7 +28,7 @@ using namespace uhd; using namespace uhd::usrp; using namespace boost::assign; -//this only applies to USRP2P +//this only applies to N2XX static const uhd::dict codec_rx_gain_ranges = map_list_of ("analog", gain_range_t(0, 3.5, 3.5)) ("digital", gain_range_t(0, 6.0, 0.5)) diff --git a/host/lib/usrp/usrp2/gps_ctrl.cpp b/host/lib/usrp/usrp2/gps_ctrl.cpp deleted file mode 100644 index 9f9b27954..000000000 --- a/host/lib/usrp/usrp2/gps_ctrl.cpp +++ /dev/null @@ -1,208 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 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. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#include "gps_ctrl.hpp" -#include -#include -#include -#include -#include -#include -#include - -using namespace uhd; -using namespace boost::gregorian; -using namespace boost::posix_time; -using namespace boost::algorithm; - -/*! - * A usrp2 GPS control for Jackson Labs devices - */ - -//TODO: multiple baud rate support (requires mboard_impl changes for poking UART registers) -class usrp2_gps_ctrl_impl : public usrp2_gps_ctrl{ -public: - usrp2_gps_ctrl_impl(usrp2_iface::sptr iface){ - _iface = iface; - - std::string reply; - bool i_heard_some_nmea = false, i_heard_something_weird = false; - - gps_type = GPS_TYPE_NONE; - -// set_uart_baud_rate(GPS_UART, 115200); - //first we look for a Jackson Labs Firefly (since that's what we sell with the USRP2+...) - - _iface->read_uart(GPS_UART); //get whatever junk is in the rx buffer right now, and throw it away - _iface->write_uart(GPS_UART, "HAAAY GUYYYYS\n"); //to elicit a response from the Firefly - - //then we loop until we either timeout, or until we get a response that indicates we're a JL device - int timeout = GPS_TIMEOUT_TRIES; - while(timeout--) { - reply = safe_gps_read(); - if(trim_right_copy(reply) == "Command Error") { - gps_type = GPS_TYPE_JACKSON_LABS; - break; - } - else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response - else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate - boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); - } - - if((i_heard_some_nmea) && (gps_type != GPS_TYPE_JACKSON_LABS)) gps_type = GPS_TYPE_GENERIC_NMEA; - - //otherwise, we can try some other common baud rates looking to see if a GPS is connected (todo, later) - if((gps_type == GPS_TYPE_NONE) && i_heard_something_weird) { - std::cout << "GPS invalid reply \"" << reply << "\", assuming none available" << std::endl; - } - - bool found_gprmc = false; - - switch(gps_type) { - case GPS_TYPE_JACKSON_LABS: - std::cout << "Found a Jackson Labs GPS" << std::endl; - //issue some setup stuff so it spits out the appropriate data - //none of these should issue replies so we don't bother looking for them - //we have to sleep between commands because the JL device, despite not acking, takes considerable time to process each command. - boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); - _iface->write_uart(GPS_UART, "SYST:COMM:SER:ECHO OFF\n"); - boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); - _iface->write_uart(GPS_UART, "SYST:COMM:SER:PRO OFF\n"); - boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); - _iface->write_uart(GPS_UART, "GPS:GPGGA 0\n"); - boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); - _iface->write_uart(GPS_UART, "GPS:GGAST 0\n"); - boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); - _iface->write_uart(GPS_UART, "GPS:GPRMC 1\n"); - boost::this_thread::sleep(boost::posix_time::milliseconds(FIREFLY_STUPID_DELAY_MS)); - -// break; - - case GPS_TYPE_GENERIC_NMEA: - if(gps_type == GPS_TYPE_GENERIC_NMEA) std::cout << "Found a generic NMEA GPS device" << std::endl; - found_gprmc = false; - //here we loop around looking for a GPRMC packet. if we don't get one, we don't have a usable GPS. - timeout = GPS_TIMEOUT_TRIES; - while(timeout--) { - reply = safe_gps_read(); - if(reply.substr(0, 6) == "$GPRMC") { - found_gprmc = true; - break; - } - } - if(!found_gprmc) { - if(gps_type == GPS_TYPE_JACKSON_LABS) std::cout << "Firefly GPS not locked or warming up." << std::endl; - else std::cout << "GPS does not output GPRMC packets. Cannot retrieve time." << std::endl; - gps_type = GPS_TYPE_NONE; - } - break; - - case GPS_TYPE_NONE: - default: - break; - - } - - - } - - ~usrp2_gps_ctrl_impl(void){ - - } - - std::string safe_gps_read() { - std::string reply; - try { - reply = _iface->read_uart(GPS_UART); - //std::cerr << "Got reply from GPS: " << reply.c_str() << " with length = " << reply.length() << std::endl; - } catch (std::runtime_error err) { - if(err.what() != std::string("usrp2 no control response")) throw; //sorry can't cope with that - else { //we don't actually have a GPS installed - reply = std::string(); - } - } - return reply; - } - - ptime get_time(void) { - std::string reply; - ptime now; - boost::tokenizer > tok(reply); - std::vector toked; - int timeout = GPS_TIMEOUT_TRIES; - bool found_gprmc = false; - switch(gps_type) { - case GPS_TYPE_JACKSON_LABS: //deprecated in favor of a single NMEA parser - case GPS_TYPE_GENERIC_NMEA: - - while(timeout--) { - reply = safe_gps_read(); - if(reply.substr(0, 6) == "$GPRMC") { - found_gprmc = true; - break; - } - } - UHD_ASSERT_THROW(found_gprmc); - - tok.assign(reply); - toked.assign(tok.begin(), tok.end()); - - UHD_ASSERT_THROW(toked.size() == 11); //if it's not we got something weird in there - - now = ptime( date( - greg_year(boost::lexical_cast(toked[8].substr(4, 2)) + 2000), //just trust me on this one - greg_month(boost::lexical_cast(toked[8].substr(2, 2))), - greg_day(boost::lexical_cast(toked[8].substr(0, 2))) - ), - hours( boost::lexical_cast(toked[1].substr(0, 2))) - + minutes(boost::lexical_cast(toked[1].substr(2, 2))) - + seconds(boost::lexical_cast(toked[1].substr(4, 2))) - ); - break; - case GPS_TYPE_NONE: - default: - throw std::runtime_error("get_time(): Unsupported GPS or no GPS detected\n"); - break; - } - return now; - } - - bool gps_detected(void) { - return (gps_type != GPS_TYPE_NONE); - } - -private: - usrp2_iface::sptr _iface; - - enum { - GPS_TYPE_JACKSON_LABS, - GPS_TYPE_GENERIC_NMEA, - GPS_TYPE_NONE - } gps_type; - - static const int GPS_UART = 2; //TODO: this should be plucked from fw_common.h or memory_map.h or somewhere in common with the firmware - static const int GPS_TIMEOUT_TRIES = 5; - static const int FIREFLY_STUPID_DELAY_MS = 200; - -}; - -/*********************************************************************** - * Public make function for the GPS control - **********************************************************************/ -usrp2_gps_ctrl::sptr usrp2_gps_ctrl::make(usrp2_iface::sptr iface){ - return sptr(new usrp2_gps_ctrl_impl(iface)); -} diff --git a/host/lib/usrp/usrp2/gps_ctrl.hpp b/host/lib/usrp/usrp2/gps_ctrl.hpp deleted file mode 100644 index 5936a6fb6..000000000 --- a/host/lib/usrp/usrp2/gps_ctrl.hpp +++ /dev/null @@ -1,53 +0,0 @@ -// -// Copyright 2010 Ettus Research LLC -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU General Public License as published by -// the Free Software Foundation, either version 3 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. -// -// You should have received a copy of the GNU General Public License -// along with this program. If not, see . -// - -#ifndef INCLUDED_GPS_CTRL_HPP -#define INCLUDED_GPS_CTRL_HPP - -#include "usrp2_iface.hpp" -#include -#include -#include - -using namespace boost::posix_time; - -class usrp2_gps_ctrl : boost::noncopyable{ -public: - typedef boost::shared_ptr sptr; - - /*! - * Make a GPS config for Jackson Labs or generic NMEA GPS devices - */ - static sptr make(usrp2_iface::sptr iface); - - /*! - * Get the current GPS time and date - * \return current GPS time and date as boost::posix_time::ptime object - */ - virtual ptime get_time(void) = 0; - - /*! - * Tell you if there's a supported GPS connected or not - * \return true if a supported GPS is connected - */ - virtual bool gps_detected(void) = 0; - - //TODO: other fun things you can do with a GPS. - -}; - -#endif /* INCLUDED_CLOCK_CTRL_HPP */ diff --git a/host/lib/usrp/usrp2/mboard_impl.cpp b/host/lib/usrp/usrp2/mboard_impl.cpp index 95a3819b3..95f7013e7 100644 --- a/host/lib/usrp/usrp2/mboard_impl.cpp +++ b/host/lib/usrp/usrp2/mboard_impl.cpp @@ -17,6 +17,7 @@ #include "usrp2_impl.hpp" #include "usrp2_regs.hpp" +#include #include #include #include @@ -65,7 +66,9 @@ usrp2_mboard_impl::usrp2_mboard_impl( //contruct the interfaces to mboard perifs _clock_ctrl = usrp2_clock_ctrl::make(_iface); _codec_ctrl = usrp2_codec_ctrl::make(_iface); - _gps_ctrl = usrp2_gps_ctrl::make(_iface); + //_gps_ctrl = gps_ctrl::make( + // _iface->get_gps_write_fn(), + // _iface->get_gps_read_fn()); //if(_gps_ctrl->gps_detected()) std::cout << "GPS time: " << _gps_ctrl->get_time() << std::endl; diff --git a/host/lib/usrp/usrp2/usrp2_iface.cpp b/host/lib/usrp/usrp2/usrp2_iface.cpp index dcb25dc54..149c5011f 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.cpp +++ b/host/lib/usrp/usrp2/usrp2_iface.cpp @@ -218,6 +218,14 @@ public: } return result; } + + gps_send_fn_t get_gps_write_fn(void) { + return boost::bind(&usrp2_iface_impl::write_uart, this, 2, _1); //2 is the GPS UART port on USRP2 + } + + gps_recv_fn_t get_gps_read_fn(void) { + return boost::bind(&usrp2_iface_impl::read_uart, this, 2); //2 is the GPS UART port on USRP2 + } /*********************************************************************** * Send/Recv over control diff --git a/host/lib/usrp/usrp2/usrp2_iface.hpp b/host/lib/usrp/usrp2/usrp2_iface.hpp index 2b4378ddf..49cb0e6dc 100644 --- a/host/lib/usrp/usrp2/usrp2_iface.hpp +++ b/host/lib/usrp/usrp2/usrp2_iface.hpp @@ -24,11 +24,17 @@ #include #include #include +#include #include #include #include "fw_common.h" #include "usrp2_regs.hpp" + +//TODO: kill this crap when you have the top level GPS include file +typedef boost::function gps_send_fn_t; +typedef boost::function gps_recv_fn_t; + /*! * The usrp2 interface class: * Provides a set of functions to implementation layer. @@ -100,6 +106,9 @@ public: virtual void write_uart(boost::uint8_t dev, const std::string &buf) = 0; virtual std::string read_uart(boost::uint8_t dev) = 0; + + virtual gps_recv_fn_t get_gps_read_fn(void) = 0; + virtual gps_send_fn_t get_gps_write_fn(void) = 0; //! The list of possible revision types enum rev_type { diff --git a/host/lib/usrp/usrp2/usrp2_impl.hpp b/host/lib/usrp/usrp2/usrp2_impl.hpp index d0f5ecf37..ad95b2a4a 100644 --- a/host/lib/usrp/usrp2/usrp2_impl.hpp +++ b/host/lib/usrp/usrp2/usrp2_impl.hpp @@ -21,7 +21,7 @@ #include "usrp2_iface.hpp" #include "clock_ctrl.hpp" #include "codec_ctrl.hpp" -#include "gps_ctrl.hpp" +#include #include #include #include @@ -106,7 +106,7 @@ private: usrp2_iface::sptr _iface; usrp2_clock_ctrl::sptr _clock_ctrl; usrp2_codec_ctrl::sptr _codec_ctrl; - usrp2_gps_ctrl::sptr _gps_ctrl; + gps_ctrl::sptr _gps_ctrl; //properties for this mboard void get(const wax::obj &, wax::obj &); -- cgit v1.2.3