From 1cac345b5c7b6d576da87dc321af4223d515df51 Mon Sep 17 00:00:00 2001 From: Moritz Fischer Date: Thu, 16 Apr 2015 16:12:40 -0500 Subject: gps: gpsd: Adding gpsd_iface to interface with gpsd. The gpsd_iface class might be useful for more than just e3x0, it therefore belongs into lib/usrp instead of lib/usrp/e300. A new UHD component is being registered, to cope with the additional dependency. If libgps is not found, UHD and E300 will be compiled without GPS support. This has several consequences: - The E310 GPSDO should now work transparently over network - Users can use the GPS through gpsd for other applications *while* running UHD applications - We now have a dependency on libgps We need currently at least version 3.11 (while running 3.14), on the device. Older versions do work if 3.10 runs on both sides e.g Reviewed-by: Martin Braun Reviewed-by: Ashish Chaudhari Signed-off-by: Moritz Fischer --- host/lib/usrp/e300/e300_sensor_manager.cpp | 141 ++--------------------------- 1 file changed, 7 insertions(+), 134 deletions(-) (limited to 'host/lib/usrp/e300/e300_sensor_manager.cpp') diff --git a/host/lib/usrp/e300/e300_sensor_manager.cpp b/host/lib/usrp/e300/e300_sensor_manager.cpp index 527cfb91a..a4319fa4b 100644 --- a/host/lib/usrp/e300/e300_sensor_manager.cpp +++ b/host/lib/usrp/e300/e300_sensor_manager.cpp @@ -24,7 +24,6 @@ #include #include #include -#include namespace uhd { namespace usrp { namespace e300 { @@ -38,17 +37,13 @@ public: std::vector get_sensors() { - return boost::assign::list_of("temp")("gps_locked")("gps_time")("ref_locked"); + return boost::assign::list_of("temp")("ref_locked"); } uhd::sensor_value_t get_sensor(const std::string &key) { if (key == "temp") return get_mb_temp(); - else if (key == "gps_locked") - return get_gps_lock(); - else if (key == "gps_time") - return get_gps_time(); else if (key == "ref_locked") return get_ref_lock(); else @@ -94,108 +89,6 @@ public: "C"); } - uhd::sensor_value_t get_gps_time(void) - { - boost::mutex::scoped_lock(_mutex); - sensor_transaction_t transaction; - transaction.which = uhd::htonx(GPS_TIME); - { - uhd::transport::managed_send_buffer::sptr buff - = _xport->get_send_buff(1.0); - if (not buff or buff->size() < sizeof(transaction)) { - throw uhd::runtime_error("sensor proxy send timeout"); - } - std::memcpy( - buff->cast(), - &transaction, - sizeof(transaction)); - buff->commit(sizeof(transaction)); - } - { - uhd::transport::managed_recv_buffer::sptr buff - = _xport->get_recv_buff(1.0); - - if (not buff or buff->size() < sizeof(transaction)) - throw uhd::runtime_error("sensor proxy recv timeout"); - - std::memcpy( - &transaction, - buff->cast(), - sizeof(transaction)); - } - UHD_ASSERT_THROW(uhd::ntohx(transaction.which) == GPS_TIME); - // TODO: Use proper serialization here ... - return sensor_value_t("GPS epoch time", int(uhd::ntohx(transaction.value)), "seconds"); - } - - bool get_gps_found(void) - { - boost::mutex::scoped_lock(_mutex); - sensor_transaction_t transaction; - transaction.which = uhd::htonx(GPS_FOUND); - { - uhd::transport::managed_send_buffer::sptr buff - = _xport->get_send_buff(1.0); - if (not buff or buff->size() < sizeof(transaction)) { - throw uhd::runtime_error("sensor proxy send timeout"); - } - std::memcpy( - buff->cast(), - &transaction, - sizeof(transaction)); - buff->commit(sizeof(transaction)); - } - { - uhd::transport::managed_recv_buffer::sptr buff - = _xport->get_recv_buff(1.0); - - if (not buff or buff->size() < sizeof(transaction)) - throw uhd::runtime_error("sensor proxy recv timeout"); - - std::memcpy( - &transaction, - buff->cast(), - sizeof(transaction)); - } - UHD_ASSERT_THROW(uhd::ntohx(transaction.which) == GPS_FOUND); - // TODO: Use proper serialization here ... - return (uhd::ntohx(transaction.value) > 0); - } - - uhd::sensor_value_t get_gps_lock(void) - { - boost::mutex::scoped_lock(_mutex); - sensor_transaction_t transaction; - transaction.which = uhd::htonx(GPS_LOCK); - { - uhd::transport::managed_send_buffer::sptr buff - = _xport->get_send_buff(1.0); - if (not buff or buff->size() < sizeof(transaction)) { - throw uhd::runtime_error("sensor proxy send timeout"); - } - std::memcpy( - buff->cast(), - &transaction, - sizeof(transaction)); - buff->commit(sizeof(transaction)); - } - { - uhd::transport::managed_recv_buffer::sptr buff - = _xport->get_recv_buff(1.0); - - if (not buff or buff->size() < sizeof(transaction)) - throw uhd::runtime_error("sensor proxy recv timeout"); - - std::memcpy( - &transaction, - buff->cast(), - sizeof(transaction)); - } - UHD_ASSERT_THROW(uhd::ntohx(transaction.which) == GPS_LOCK); - // TODO: Use proper serialization here ... - return sensor_value_t("GPS lock status", (uhd::ntohx(transaction.value) > 0), "locked", "unlocked"); - } - uhd::sensor_value_t get_ref_lock(void) { boost::mutex::scoped_lock(_mutex); @@ -255,24 +148,20 @@ static const std::string E300_TEMP_SYSFS = "iio:device0"; class e300_sensor_local : public e300_sensor_manager { public: - e300_sensor_local(uhd::gps_ctrl::sptr gps_ctrl, global_regs::sptr global_regs) : - _gps_ctrl(gps_ctrl), _global_regs(global_regs) + e300_sensor_local(global_regs::sptr global_regs) : + _global_regs(global_regs) { } std::vector get_sensors() { - return boost::assign::list_of("temp")("gps_locked")("gps_time")("ref_locked"); + return boost::assign::list_of("temp")("ref_locked"); } uhd::sensor_value_t get_sensor(const std::string &key) { if (key == "temp") return get_mb_temp(); - else if (key == "gps_locked") - return get_gps_lock(); - else if (key == "gps_time") - return get_gps_time(); else if (key == "ref_locked") return get_ref_lock(); else @@ -291,21 +180,6 @@ public: return sensor_value_t("temp", (raw + offset) * scale / 1000, "C"); } - bool get_gps_found(void) - { - return _gps_ctrl->gps_detected(); - } - - uhd::sensor_value_t get_gps_lock(void) - { - return _gps_ctrl->get_sensor("gps_locked"); - } - - uhd::sensor_value_t get_gps_time(void) - { - return _gps_ctrl->get_sensor("gps_time"); - } - uhd::sensor_value_t get_ref_lock(void) { //PPSLOOP_LOCKED_MASK is asserted in the following cases: @@ -322,22 +196,21 @@ public: } private: - gps_ctrl::sptr _gps_ctrl; global_regs::sptr _global_regs; }; }}} using namespace uhd::usrp::e300; e300_sensor_manager::sptr e300_sensor_manager::make_local( - uhd::gps_ctrl::sptr gps_ctrl, global_regs::sptr global_regs) + global_regs::sptr global_regs) { - return sptr(new e300_sensor_local(gps_ctrl, global_regs)); + return sptr(new e300_sensor_local(global_regs)); } #else using namespace uhd::usrp::e300; e300_sensor_manager::sptr e300_sensor_manager::make_local( - uhd::gps_ctrl::sptr, global_regs::sptr) + global_regs::sptr) { throw uhd::assertion_error("e300_sensor_manager::make_local() !E300_NATIVE"); } -- cgit v1.2.3