aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/e300/e300_sensor_manager.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/e300/e300_sensor_manager.cpp')
-rw-r--r--host/lib/usrp/e300/e300_sensor_manager.cpp141
1 files changed, 7 insertions, 134 deletions
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 <cstring>
#include <uhd/exception.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <uhd/usrp/gps_ctrl.hpp>
namespace uhd { namespace usrp { namespace e300 {
@@ -38,17 +37,13 @@ public:
std::vector<std::string> 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<boost::uint32_t>(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<void *>(),
- &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<const void *>(),
- sizeof(transaction));
- }
- UHD_ASSERT_THROW(uhd::ntohx<boost::uint32_t>(transaction.which) == GPS_TIME);
- // TODO: Use proper serialization here ...
- return sensor_value_t("GPS epoch time", int(uhd::ntohx<boost::uint32_t>(transaction.value)), "seconds");
- }
-
- bool get_gps_found(void)
- {
- boost::mutex::scoped_lock(_mutex);
- sensor_transaction_t transaction;
- transaction.which = uhd::htonx<boost::uint32_t>(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<void *>(),
- &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<const void *>(),
- sizeof(transaction));
- }
- UHD_ASSERT_THROW(uhd::ntohx<boost::uint32_t>(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<boost::uint32_t>(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<void *>(),
- &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<const void *>(),
- sizeof(transaction));
- }
- UHD_ASSERT_THROW(uhd::ntohx<boost::uint32_t>(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<std::string> 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");
}