aboutsummaryrefslogtreecommitdiffstats
path: root/host/lib/usrp/n230
diff options
context:
space:
mode:
Diffstat (limited to 'host/lib/usrp/n230')
-rw-r--r--host/lib/usrp/n230/CMakeLists.txt1
-rw-r--r--host/lib/usrp/n230/n230_clk_pps_ctrl.cpp9
-rw-r--r--host/lib/usrp/n230/n230_eeprom_manager.cpp2
-rw-r--r--host/lib/usrp/n230/n230_frontend_ctrl.cpp2
-rw-r--r--host/lib/usrp/n230/n230_fw_comm_protocol.h102
-rw-r--r--host/lib/usrp/n230/n230_fw_ctrl_iface.cpp245
-rw-r--r--host/lib/usrp/n230/n230_fw_ctrl_iface.hpp72
-rw-r--r--host/lib/usrp/n230/n230_impl.cpp36
-rw-r--r--host/lib/usrp/n230/n230_resource_manager.cpp28
-rw-r--r--host/lib/usrp/n230/n230_resource_manager.hpp8
-rw-r--r--host/lib/usrp/n230/n230_stream_manager.cpp3
-rw-r--r--host/lib/usrp/n230/n230_uart.cpp2
12 files changed, 463 insertions, 47 deletions
diff --git a/host/lib/usrp/n230/CMakeLists.txt b/host/lib/usrp/n230/CMakeLists.txt
index 9eaccffba..8bed1f26d 100644
--- a/host/lib/usrp/n230/CMakeLists.txt
+++ b/host/lib/usrp/n230/CMakeLists.txt
@@ -33,5 +33,6 @@ IF(ENABLE_N230)
${CMAKE_CURRENT_SOURCE_DIR}/n230_frontend_ctrl.cpp
${CMAKE_CURRENT_SOURCE_DIR}/n230_uart.cpp
${CMAKE_CURRENT_SOURCE_DIR}/n230_image_loader.cpp
+ ${CMAKE_CURRENT_SOURCE_DIR}/n230_fw_ctrl_iface.cpp
)
ENDIF(ENABLE_N230)
diff --git a/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp b/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp
index 2bcfb0394..372325fbe 100644
--- a/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp
+++ b/host/lib/usrp/n230/n230_clk_pps_ctrl.cpp
@@ -17,11 +17,10 @@
#include "n230_clk_pps_ctrl.hpp"
-#include <uhd/utils/msg.hpp>
+#include <uhd/utils/log.hpp>
#include <uhd/utils/safe_call.hpp>
#include <stdint.h>
#include <boost/format.hpp>
-#include <boost/foreach.hpp>
#include <stdexcept>
#include <cmath>
#include <cstdlib>
@@ -56,11 +55,11 @@ public:
double set_tick_rate(const double rate)
{
- UHD_MSG(status) << "Configuring a tick rate of " << rate/1e6 << " MHz... ";
+ UHD_LOGGER_INFO("N230") << "Configuring a tick rate of " << rate/1e6 << " MHz... ";
_tick_rate = _codec_ctrl->set_clock_rate(rate);
- UHD_MSG(status) << "got " << _tick_rate/1e6 << " MHz\n";
+ UHD_LOGGER_INFO("N230") << "got " << _tick_rate/1e6 << " MHz\n";
- BOOST_FOREACH(time_core_3000::sptr& time_core, _time_cores) {
+ for(time_core_3000::sptr& time_core: _time_cores) {
time_core->set_tick_rate(_tick_rate);
time_core->self_test();
}
diff --git a/host/lib/usrp/n230/n230_eeprom_manager.cpp b/host/lib/usrp/n230/n230_eeprom_manager.cpp
index d9d02c58c..c21eb9ddb 100644
--- a/host/lib/usrp/n230/n230_eeprom_manager.cpp
+++ b/host/lib/usrp/n230/n230_eeprom_manager.cpp
@@ -17,7 +17,7 @@
#include "n230_eeprom.h"
#include <uhd/utils/byteswap.hpp>
-#include <uhd/utils/msg.hpp>
+#include <uhd/utils/log.hpp>
#include <uhd/exception.hpp>
#include <uhd/types/mac_addr.hpp>
#include <boost/format.hpp>
diff --git a/host/lib/usrp/n230/n230_frontend_ctrl.cpp b/host/lib/usrp/n230/n230_frontend_ctrl.cpp
index 3d81721ec..80f1232b1 100644
--- a/host/lib/usrp/n230/n230_frontend_ctrl.cpp
+++ b/host/lib/usrp/n230/n230_frontend_ctrl.cpp
@@ -17,7 +17,7 @@
#include "n230_frontend_ctrl.hpp"
-#include <uhd/utils/msg.hpp>
+#include <uhd/utils/log.hpp>
#include <uhd/exception.hpp>
#include <uhd/types/dict.hpp>
#include <boost/format.hpp>
diff --git a/host/lib/usrp/n230/n230_fw_comm_protocol.h b/host/lib/usrp/n230/n230_fw_comm_protocol.h
new file mode 100644
index 000000000..b7c85f2ba
--- /dev/null
+++ b/host/lib/usrp/n230/n230_fw_comm_protocol.h
@@ -0,0 +1,102 @@
+//
+// Copyright 2014 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 <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_N230_FW_COMM_PROTOCOL
+#define INCLUDED_N230_FW_COMM_PROTOCOL
+
+#include <stdint.h>
+#ifndef __cplusplus
+#include <stdbool.h>
+#endif
+
+/*!
+ * Structs and constants for communication between firmware and host.
+ * This header is shared by the firmware and host code.
+ * Therefore, this header may only contain valid C code.
+ */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#define FW_COMM_PROTOCOL_SIGNATURE 0xACE3
+#define FW_COMM_PROTOCOL_VERSION 0
+#define FW_COMM_MAX_DATA_WORDS 16
+#define FW_COMM_PROTOCOL_MTU 256
+
+#define FW_COMM_FLAGS_ACK 0x00000001
+#define FW_COMM_FLAGS_CMD_MASK 0x00000FF0
+#define FW_COMM_FLAGS_ERROR_MASK 0xFF000000
+
+#define FW_COMM_CMD_ECHO 0x00000000
+#define FW_COMM_CMD_POKE32 0x00000010
+#define FW_COMM_CMD_PEEK32 0x00000020
+#define FW_COMM_CMD_BLOCK_POKE32 0x00000030
+#define FW_COMM_CMD_BLOCK_PEEK32 0x00000040
+
+#define FW_COMM_ERR_PKT_ERROR 0x80000000
+#define FW_COMM_ERR_CMD_ERROR 0x40000000
+#define FW_COMM_ERR_SIZE_ERROR 0x20000000
+
+#define FW_COMM_GENERATE_ID(prod) ((((uint32_t) FW_COMM_PROTOCOL_SIGNATURE) << 0) | \
+ (((uint32_t) prod) << 16) | \
+ (((uint32_t) FW_COMM_PROTOCOL_VERSION) << 24))
+
+#define FW_COMM_GET_PROTOCOL_SIG(id) ((uint16_t)(id & 0xFFFF))
+#define FW_COMM_GET_PRODUCT_ID(id) ((uint8_t)(id >> 16))
+#define FW_COMM_GET_PROTOCOL_VER(id) ((uint8_t)(id >> 24))
+
+typedef struct
+{
+ uint32_t id; //Protocol and device identifier
+ uint32_t flags; //Holds commands and ack messages
+ uint32_t sequence; //Sequence number (specific to FW communication transactions)
+ uint32_t data_words; //Number of data words in payload
+ uint32_t addr; //Address field for the command in flags
+ uint32_t data[FW_COMM_MAX_DATA_WORDS]; //Data field for the command in flags
+} fw_comm_pkt_t;
+
+#ifdef __cplusplus
+} //extern "C"
+#endif
+
+// The following definitions are only useful in firmware. Exclude in host code.
+#ifndef __cplusplus
+
+typedef void (*poke32_func)(const uint32_t addr, const uint32_t data);
+typedef uint32_t (*peek32_func)(const uint32_t addr);
+
+/*!
+ * Process a firmware communication packet and compute a response.
+ * Args:
+ * - (in) request: Pointer to the request struct
+ * - (out) response: Pointer to the response struct
+ * - (in) product_id: The 8-bit usrp3 specific product ID (for request filtering)
+ * - (func) poke_callback, peek_callback: Callback functions for a single peek/poke
+ * - return value: Send a response packet
+ */
+bool process_fw_comm_protocol_pkt(
+ const fw_comm_pkt_t* request,
+ fw_comm_pkt_t* response,
+ uint8_t product_id,
+ uint32_t iface_id,
+ poke32_func poke_callback,
+ peek32_func peek_callback
+);
+
+#endif //ifdef __cplusplus
+
+#endif /* INCLUDED_N230_FW_COMM_PROTOCOL */
diff --git a/host/lib/usrp/n230/n230_fw_ctrl_iface.cpp b/host/lib/usrp/n230/n230_fw_ctrl_iface.cpp
new file mode 100644
index 000000000..18c2c4cf8
--- /dev/null
+++ b/host/lib/usrp/n230/n230_fw_ctrl_iface.cpp
@@ -0,0 +1,245 @@
+//
+// Copyright 2013 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 <http://www.gnu.org/licenses/>.
+//
+
+#include "n230_fw_ctrl_iface.hpp"
+
+#include <uhd/utils/byteswap.hpp>
+#include <uhd/utils/log.hpp>
+#include <uhd/exception.hpp>
+#include <boost/format.hpp>
+#include <boost/asio.hpp> //used for htonl and ntohl
+#include "n230_fw_comm_protocol.h"
+
+namespace uhd { namespace usrp { namespace n230 {
+
+//----------------------------------------------------------
+// Factory method
+//----------------------------------------------------------
+uhd::wb_iface::sptr n230_fw_ctrl_iface::make(
+ uhd::transport::udp_simple::sptr udp_xport,
+ const uint16_t product_id,
+ const bool verbose)
+{
+ return wb_iface::sptr(new n230_fw_ctrl_iface(udp_xport, product_id, verbose));
+}
+
+//----------------------------------------------------------
+// udp_fw_ctrl_iface
+//----------------------------------------------------------
+
+n230_fw_ctrl_iface::n230_fw_ctrl_iface(
+ uhd::transport::udp_simple::sptr udp_xport,
+ const uint16_t product_id,
+ const bool verbose) :
+ _product_id(product_id), _verbose(verbose), _udp_xport(udp_xport),
+ _seq_num(0)
+{
+ flush();
+ peek32(0);
+}
+
+n230_fw_ctrl_iface::~n230_fw_ctrl_iface()
+{
+ flush();
+}
+
+void n230_fw_ctrl_iface::flush()
+{
+ boost::mutex::scoped_lock lock(_mutex);
+ _flush();
+}
+
+void n230_fw_ctrl_iface::poke32(const wb_addr_type addr, const uint32_t data)
+{
+ boost::mutex::scoped_lock lock(_mutex);
+
+ for (size_t i = 1; i <= NUM_RETRIES; i++) {
+ try {
+ _poke32(addr, data);
+ return;
+ } catch(const std::exception &ex) {
+ const std::string error_msg = str(boost::format(
+ "udp fw poke32 failure #%u\n%s") % i % ex.what());
+ if (_verbose) UHD_LOGGER_WARNING("N230") << error_msg ;
+ if (i == NUM_RETRIES) throw uhd::io_error(error_msg);
+ }
+ }
+}
+
+uint32_t n230_fw_ctrl_iface::peek32(const wb_addr_type addr)
+{
+ boost::mutex::scoped_lock lock(_mutex);
+
+ for (size_t i = 1; i <= NUM_RETRIES; i++) {
+ try {
+ return _peek32(addr);
+ } catch(const std::exception &ex) {
+ const std::string error_msg = str(boost::format(
+ "udp fw peek32 failure #%u\n%s") % i % ex.what());
+ if (_verbose) UHD_LOGGER_WARNING("N230") << error_msg ;
+ if (i == NUM_RETRIES) throw uhd::io_error(error_msg);
+ }
+ }
+ return 0;
+}
+
+void n230_fw_ctrl_iface::_poke32(const wb_addr_type addr, const uint32_t data)
+{
+ //Load request struct
+ fw_comm_pkt_t request;
+ request.id = uhd::htonx<uint32_t>(FW_COMM_GENERATE_ID(_product_id));
+ request.flags = uhd::htonx<uint32_t>(FW_COMM_FLAGS_ACK | FW_COMM_CMD_POKE32);
+ request.sequence = uhd::htonx<uint32_t>(_seq_num++);
+ request.addr = uhd::htonx(addr);
+ request.data_words = 1;
+ request.data[0] = uhd::htonx(data);
+
+ //Send request
+ _flush();
+ _udp_xport->send(boost::asio::buffer(&request, sizeof(request)));
+
+ //Recv reply
+ fw_comm_pkt_t reply;
+ const size_t nbytes = _udp_xport->recv(boost::asio::buffer(&reply, sizeof(reply)), 1.0);
+ if (nbytes == 0) throw uhd::io_error("udp fw poke32 - reply timed out");
+
+ //Sanity checks
+ const size_t flags = uhd::ntohx<uint32_t>(reply.flags);
+ UHD_ASSERT_THROW(nbytes == sizeof(reply));
+ UHD_ASSERT_THROW(not (flags & FW_COMM_FLAGS_ERROR_MASK));
+ UHD_ASSERT_THROW(flags & FW_COMM_CMD_POKE32);
+ UHD_ASSERT_THROW(flags & FW_COMM_FLAGS_ACK);
+ UHD_ASSERT_THROW(reply.sequence == request.sequence);
+ UHD_ASSERT_THROW(reply.addr == request.addr);
+ UHD_ASSERT_THROW(reply.data[0] == request.data[0]);
+}
+
+uint32_t n230_fw_ctrl_iface::_peek32(const wb_addr_type addr)
+{
+ //Load request struct
+ fw_comm_pkt_t request;
+ request.id = uhd::htonx<uint32_t>(FW_COMM_GENERATE_ID(_product_id));
+ request.flags = uhd::htonx<uint32_t>(FW_COMM_FLAGS_ACK | FW_COMM_CMD_PEEK32);
+ request.sequence = uhd::htonx<uint32_t>(_seq_num++);
+ request.addr = uhd::htonx(addr);
+ request.data_words = 1;
+ request.data[0] = 0;
+
+ //Send request
+ _flush();
+ _udp_xport->send(boost::asio::buffer(&request, sizeof(request)));
+
+ //Recv reply
+ fw_comm_pkt_t reply;
+ const size_t nbytes = _udp_xport->recv(boost::asio::buffer(&reply, sizeof(reply)), 1.0);
+ if (nbytes == 0) throw uhd::io_error("udp fw peek32 - reply timed out");
+
+ //Sanity checks
+ const size_t flags = uhd::ntohx<uint32_t>(reply.flags);
+ UHD_ASSERT_THROW(nbytes == sizeof(reply));
+ UHD_ASSERT_THROW(not (flags & FW_COMM_FLAGS_ERROR_MASK));
+ UHD_ASSERT_THROW(flags & FW_COMM_CMD_PEEK32);
+ UHD_ASSERT_THROW(flags & FW_COMM_FLAGS_ACK);
+ UHD_ASSERT_THROW(reply.sequence == request.sequence);
+ UHD_ASSERT_THROW(reply.addr == request.addr);
+
+ //return result!
+ return uhd::ntohx<uint32_t>(reply.data[0]);
+}
+
+void n230_fw_ctrl_iface::_flush(void)
+{
+ char buff[FW_COMM_PROTOCOL_MTU] = {};
+ while (_udp_xport->recv(boost::asio::buffer(buff), 0.0)) {
+ /*NOP*/
+ }
+}
+
+std::vector<std::string> n230_fw_ctrl_iface::discover_devices(
+ const std::string& addr_hint, const std::string& port,
+ uint16_t product_id)
+{
+ std::vector<std::string> addrs;
+
+ //Create a UDP transport to communicate:
+ //Some devices will cause a throw when opened for a broadcast address.
+ //We print and recover so the caller can loop through all bcast addrs.
+ uhd::transport::udp_simple::sptr udp_bcast_xport;
+ try {
+ udp_bcast_xport = uhd::transport::udp_simple::make_broadcast(addr_hint, port);
+ } catch(const std::exception &e) {
+ UHD_LOGGER_ERROR("N230") << boost::format("Cannot open UDP transport on %s for discovery\n%s")
+ % addr_hint % e.what() ;
+ return addrs;
+ }
+
+ //Send dummy request
+ fw_comm_pkt_t request;
+ request.id = uhd::htonx<uint32_t>(FW_COMM_GENERATE_ID(product_id));
+ request.flags = uhd::htonx<uint32_t>(FW_COMM_FLAGS_ACK|FW_COMM_CMD_ECHO);
+ request.sequence = uhd::htonx<uint32_t>(std::rand());
+ udp_bcast_xport->send(boost::asio::buffer(&request, sizeof(request)));
+
+ //loop for replies until timeout
+ while (true) {
+ char buff[FW_COMM_PROTOCOL_MTU] = {};
+ const size_t nbytes = udp_bcast_xport->recv(boost::asio::buffer(buff), 0.050);
+ if (nbytes != sizeof(fw_comm_pkt_t)) break; //No more responses or responses are invalid
+
+ const fw_comm_pkt_t *reply = (const fw_comm_pkt_t *)buff;
+ if (request.id == reply->id &&
+ request.flags == reply->flags &&
+ request.sequence == reply->sequence)
+ {
+ addrs.push_back(udp_bcast_xport->get_recv_addr());
+ }
+ }
+
+ return addrs;
+}
+
+uint32_t n230_fw_ctrl_iface::get_iface_id(
+ const std::string& addr, const std::string& port,
+ uint16_t product_id)
+{
+ uhd::transport::udp_simple::sptr udp_xport =
+ uhd::transport::udp_simple::make_connected(addr, port);
+
+ //Send dummy request
+ fw_comm_pkt_t request;
+ request.id = uhd::htonx<uint32_t>(FW_COMM_GENERATE_ID(product_id));
+ request.flags = uhd::htonx<uint32_t>(FW_COMM_FLAGS_ACK|FW_COMM_CMD_ECHO);
+ request.sequence = uhd::htonx<uint32_t>(std::rand());
+ udp_xport->send(boost::asio::buffer(&request, sizeof(request)));
+
+ //loop for replies until timeout
+ char buff[FW_COMM_PROTOCOL_MTU] = {};
+ const size_t nbytes = udp_xport->recv(boost::asio::buffer(buff), 1.0);
+
+ const fw_comm_pkt_t *reply = (const fw_comm_pkt_t *)buff;
+ if (nbytes > 0 &&
+ request.id == reply->id &&
+ request.flags == reply->flags &&
+ request.sequence == reply->sequence)
+ {
+ return uhd::ntohx<uint32_t>(reply->data[0]);
+ } else {
+ throw uhd::io_error("udp get_iface_id - bad response");
+ }
+}
+
+}}} //namespace
diff --git a/host/lib/usrp/n230/n230_fw_ctrl_iface.hpp b/host/lib/usrp/n230/n230_fw_ctrl_iface.hpp
new file mode 100644
index 000000000..675c843b3
--- /dev/null
+++ b/host/lib/usrp/n230/n230_fw_ctrl_iface.hpp
@@ -0,0 +1,72 @@
+//
+// Copyright 2014 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 <http://www.gnu.org/licenses/>.
+//
+
+#ifndef INCLUDED_LIBUHD_USRP_N230_UDP_FW_CTRL_IFACE_HPP
+#define INCLUDED_LIBUHD_USRP_N230_UDP_FW_CTRL_IFACE_HPP
+
+#include <uhd/types/wb_iface.hpp>
+#include <uhd/transport/udp_simple.hpp>
+#include <boost/thread/mutex.hpp>
+#include <vector>
+
+namespace uhd { namespace usrp { namespace n230 {
+
+class n230_fw_ctrl_iface : public uhd::wb_iface
+{
+public:
+ n230_fw_ctrl_iface(
+ uhd::transport::udp_simple::sptr udp_xport,
+ const uint16_t product_id,
+ const bool verbose);
+ virtual ~n230_fw_ctrl_iface();
+
+ // -- uhd::wb_iface --
+ void poke32(const wb_addr_type addr, const uint32_t data);
+ uint32_t peek32(const wb_addr_type addr);
+ void flush();
+
+ static uhd::wb_iface::sptr make(
+ uhd::transport::udp_simple::sptr udp_xport,
+ const uint16_t product_id,
+ const bool verbose = true);
+ // -- uhd::wb_iface --
+
+ static std::vector<std::string> discover_devices(
+ const std::string& addr_hint, const std::string& port,
+ uint16_t product_id);
+
+ static uint32_t get_iface_id(
+ const std::string& addr, const std::string& port,
+ uint16_t product_id);
+
+private:
+ void _poke32(const wb_addr_type addr, const uint32_t data);
+ uint32_t _peek32(const wb_addr_type addr);
+ void _flush(void);
+
+ const uint16_t _product_id;
+ const bool _verbose;
+ uhd::transport::udp_simple::sptr _udp_xport;
+ uint32_t _seq_num;
+ boost::mutex _mutex;
+
+ static const size_t NUM_RETRIES = 3;
+};
+
+}}} //namespace
+
+#endif // INCLUDED_LIBUHD_USRP_N230_UDP_FW_CTRL_IFACE_HPP
diff --git a/host/lib/usrp/n230/n230_impl.cpp b/host/lib/usrp/n230/n230_impl.cpp
index 015140fcc..63971fb34 100644
--- a/host/lib/usrp/n230/n230_impl.cpp
+++ b/host/lib/usrp/n230/n230_impl.cpp
@@ -17,7 +17,7 @@
#include "n230_impl.hpp"
-#include "usrp3_fw_ctrl_iface.hpp"
+#include "n230_fw_ctrl_iface.hpp"
#include "validate_subdev_spec.hpp"
#include <uhd/utils/static.hpp>
#include <uhd/transport/if_addrs.hpp>
@@ -25,7 +25,7 @@
#include <uhd/usrp/subdev_spec.hpp>
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/log.hpp>
-#include <uhd/utils/msg.hpp>
+
#include <uhd/types/sensors.hpp>
#include <uhd/types/ranges.hpp>
#include <uhd/types/direction.hpp>
@@ -33,7 +33,6 @@
#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/usrp/gps_ctrl.hpp>
#include <boost/format.hpp>
-#include <boost/foreach.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/bind.hpp>
#include <boost/algorithm/string.hpp>
@@ -42,7 +41,6 @@
#include <boost/asio.hpp> //used for htonl and ntohl
#include <boost/make_shared.hpp>
-#include "../common/fw_comm_protocol.h"
#include "n230_defaults.h"
#include "n230_fpga_defs.h"
#include "n230_fw_defs.h"
@@ -71,7 +69,7 @@ uhd::device_addrs_t n230_impl::n230_find(const uhd::device_addr_t &multi_dev_hin
if (hints.size() > 1){
device_addrs_t found_devices;
std::string error_msg;
- BOOST_FOREACH(const device_addr_t &hint_i, hints){
+ for(const device_addr_t &hint_i: hints){
device_addrs_t found_devices_i = n230_find(hint_i);
if (found_devices_i.size() != 1) error_msg += str(boost::format(
"Could not resolve device hint \"%s\" to a single device."
@@ -98,7 +96,7 @@ uhd::device_addrs_t n230_impl::n230_find(const uhd::device_addr_t &multi_dev_hin
//if no address was specified, send a broadcast on each interface
if (not hint.has_key("addr")) {
- BOOST_FOREACH(const if_addrs_t &if_addrs, get_if_addrs()) {
+ for(const if_addrs_t &if_addrs: get_if_addrs()) {
//avoid the loopback device
if (if_addrs.inet == asio::ip::address_v4::loopback().to_string()) continue;
@@ -116,10 +114,10 @@ uhd::device_addrs_t n230_impl::n230_find(const uhd::device_addr_t &multi_dev_hin
}
std::vector<std::string> discovered_addrs =
- usrp3::usrp3_fw_ctrl_iface::discover_devices(
+ n230_fw_ctrl_iface::discover_devices(
hint["addr"], BOOST_STRINGIZE(N230_FW_COMMS_UDP_PORT), N230_FW_PRODUCT_ID);
- BOOST_FOREACH(const std::string& addr, discovered_addrs)
+ for(const std::string& addr: discovered_addrs)
{
device_addr_t new_addr;
new_addr["type"] = "n230";
@@ -136,10 +134,10 @@ uhd::device_addrs_t n230_impl::n230_find(const uhd::device_addr_t &multi_dev_hin
//connected communication can fail. Retry the following call to allow
//the stack to update
size_t first_conn_retries = 10;
- usrp3::usrp3_fw_ctrl_iface::sptr fw_ctrl;
+ n230_fw_ctrl_iface::sptr fw_ctrl;
while (first_conn_retries > 0) {
try {
- fw_ctrl = usrp3::usrp3_fw_ctrl_iface::make(ctrl_xport, N230_FW_PRODUCT_ID, false /*verbose*/);
+ fw_ctrl = n230_fw_ctrl_iface::make(ctrl_xport, N230_FW_PRODUCT_ID, false /*verbose*/);
break;
} catch (uhd::io_error& ex) {
boost::this_thread::sleep(boost::posix_time::milliseconds(500));
@@ -192,7 +190,7 @@ device::sptr n230_impl::n230_make(const device_addr_t &device_addr)
**********************************************************************/
n230_impl::n230_impl(const uhd::device_addr_t& dev_addr)
{
- UHD_MSG(status) << "N230 initialization sequence..." << std::endl;
+ UHD_LOGGER_INFO("N230") << "N230 initialization sequence...";
_dev_args.parse(dev_addr);
_tree = uhd::property_tree::make();
@@ -210,9 +208,9 @@ n230_impl::n230_impl(const uhd::device_addr_t& dev_addr)
const mboard_eeprom_t& mb_eeprom = _eeprom_mgr->get_mb_eeprom();
bool recover_mb_eeprom = dev_addr.has_key("recover_mb_eeprom");
if (recover_mb_eeprom) {
- UHD_MSG(warning) << "UHD is operating in EEPROM Recovery Mode which disables hardware version "
+ UHD_LOGGER_WARNING("N230") << "UHD is operating in EEPROM Recovery Mode which disables hardware version "
"checks.\nOperating in this mode may cause hardware damage and unstable "
- "radio performance!"<< std::endl;
+ "radio performance!";
}
uint16_t hw_rev = boost::lexical_cast<uint16_t>(mb_eeprom["revision"]);
uint16_t hw_rev_compat = boost::lexical_cast<uint16_t>(mb_eeprom["revision_compat"]);
@@ -234,11 +232,11 @@ n230_impl::n230_impl(const uhd::device_addr_t& dev_addr)
//Debug loopback mode
switch(_dev_args.get_loopback_mode()) {
case n230_device_args_t::LOOPBACK_RADIO:
- UHD_MSG(status) << "DEBUG: Running in TX->RX Radio loopback mode.\n";
+ UHD_LOGGER_INFO("N230") << "DEBUG: Running in TX->RX Radio loopback mode.";
_resource_mgr->get_frontend_ctrl().set_self_test_mode(LOOPBACK_RADIO);
break;
case n230_device_args_t::LOOPBACK_CODEC:
- UHD_MSG(status) << "DEBUG: Running in TX->RX CODEC loopback mode.\n";
+ UHD_LOGGER_INFO("N230") << "DEBUG: Running in TX->RX CODEC loopback mode.";
_resource_mgr->get_frontend_ctrl().set_self_test_mode(LOOPBACK_CODEC);
break;
default:
@@ -397,11 +395,11 @@ void n230_impl::_initialize_property_tree(const fs_path& mb_path)
// Initialize subdev specs
//------------------------------------------------------------------
subdev_spec_t rx_spec, tx_spec;
- BOOST_FOREACH(const std::string &fe, _tree->list(mb_path / "dboards" / "A" / "rx_frontends"))
+ for(const std::string &fe: _tree->list(mb_path / "dboards" / "A" / "rx_frontends"))
{
rx_spec.push_back(subdev_spec_pair_t("A", fe));
}
- BOOST_FOREACH(const std::string &fe, _tree->list(mb_path / "dboards" / "A" / "tx_frontends"))
+ for(const std::string &fe: _tree->list(mb_path / "dboards" / "A" / "tx_frontends"))
{
tx_spec.push_back(subdev_spec_pair_t("A", fe));
}
@@ -437,7 +435,7 @@ void n230_impl::_initialize_property_tree(const fs_path& mb_path)
//------------------------------------------------------------------
if (_resource_mgr->is_gpsdo_present()) {
uhd::gps_ctrl::sptr gps_ctrl = _resource_mgr->get_gps_ctrl();
- BOOST_FOREACH(const std::string &name, gps_ctrl->get_sensors())
+ for(const std::string &name: gps_ctrl->get_sensors())
{
_tree->create<sensor_value_t>(mb_path / "sensors" / name)
.set_publisher(boost::bind(&gps_ctrl::get_sensor, gps_ctrl, name));
@@ -499,7 +497,7 @@ void n230_impl::_initialize_radio_properties(const fs_path& mb_path, size_t inst
//RF Frontend Interfacing
static const std::vector<direction_t> data_directions = boost::assign::list_of(RX_DIRECTION)(TX_DIRECTION);
- BOOST_FOREACH(direction_t direction, data_directions) {
+ for(direction_t direction: data_directions) {
const std::string dir_str = (direction == RX_DIRECTION) ? "rx" : "tx";
const std::string key = boost::to_upper_copy(dir_str) + str(boost::format("%u") % (instance + 1));
const fs_path rf_fe_path = mb_path / "dboards" / "A" / (dir_str + "_frontends") / ((instance==0)?"A":"B");
diff --git a/host/lib/usrp/n230/n230_resource_manager.cpp b/host/lib/usrp/n230/n230_resource_manager.cpp
index b96de542a..61a80ae43 100644
--- a/host/lib/usrp/n230/n230_resource_manager.cpp
+++ b/host/lib/usrp/n230/n230_resource_manager.cpp
@@ -17,11 +17,11 @@
#include "n230_resource_manager.hpp"
-#include "usrp3_fw_ctrl_iface.hpp"
+#include "n230_fw_ctrl_iface.hpp"
#include <uhd/transport/if_addrs.hpp>
#include <uhd/transport/udp_zero_copy.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <uhd/utils/msg.hpp>
+#include <uhd/utils/log.hpp>
#include <uhd/utils/platform.hpp>
#include <uhd/utils/paths.hpp>
#include <boost/format.hpp>
@@ -58,7 +58,7 @@ public:
}
}
clocking_mode_t get_clocking_mode() {
- return AD9361_XTAL_N_CLK_PATH;
+ return clocking_mode_t::AD9361_XTAL_N_CLK_PATH;
}
digital_interface_mode_t get_digital_interface_mode() {
return AD9361_DDR_FDD_LVDS;
@@ -80,18 +80,18 @@ n230_resource_manager::n230_resource_manager(
_safe_mode(safe_mode),
_last_host_enpoint(0)
{
- if (_safe_mode) UHD_MSG(warning) << "Initializing device in safe mode\n";
- UHD_MSG(status) << "Setup basic communication...\n";
+ if (_safe_mode) UHD_LOGGER_WARNING("N230") << "Initializing device in safe mode\n";
+ UHD_LOGGER_INFO("N230") << "Setup basic communication...";
//Discover ethernet interfaces
bool dual_eth_expected = (ip_addrs.size() > 1);
- BOOST_FOREACH(const std::string& addr, ip_addrs) {
+ for(const std::string& addr: ip_addrs) {
n230_eth_conn_t conn_iface;
conn_iface.ip_addr = addr;
uint32_t iface_id = 0xFFFFFFFF;
try {
- iface_id = usrp3::usrp3_fw_ctrl_iface::get_iface_id(
+ iface_id = n230::n230_fw_ctrl_iface::get_iface_id(
conn_iface.ip_addr, BOOST_STRINGIZE(N230_FW_COMMS_UDP_PORT), N230_FW_PRODUCT_ID);
} catch (uhd::io_error&) {
throw uhd::io_error(str(boost::format(
@@ -118,7 +118,7 @@ n230_resource_manager::n230_resource_manager(
}
//Create firmware communication interface
- _fw_ctrl = usrp3::usrp3_fw_ctrl_iface::make(
+ _fw_ctrl = n230::n230_fw_ctrl_iface::make(
transport::udp_simple::make_connected(
_get_conn(PRI_ETH).ip_addr, BOOST_STRINGIZE(N230_FW_COMMS_UDP_PORT)), N230_FW_PRODUCT_ID);
if (_fw_ctrl.get() == NULL) {
@@ -145,7 +145,7 @@ n230_resource_manager::n230_resource_manager(
}
_check_fpga_compat();
- UHD_MSG(status) << boost::format("Version signatures... Firmware:%s FPGA:%s...\n")
+ UHD_LOGGER_INFO("N230") << boost::format("Version signatures... Firmware:%s FPGA:%s...")
% _fw_version.get_hash_str() % _fpga_version.get_hash_str();
_core_radio_ctrl_reg.initialize(*_core_ctrl, true /*flush*/);
@@ -160,7 +160,7 @@ n230_resource_manager::n230_resource_manager(
}
//Create AD9361 interface
- UHD_MSG(status) << "Initializing CODEC...\n";
+ UHD_LOGGER_INFO("N230") << "Initializing CODEC...";
_codec_ctrl = ad9361_ctrl::make_spi(
boost::make_shared<n230_ad9361_client_t>(), _core_spi_ctrl, fpga::AD9361_SPI_SLAVE_NUM);
if (_codec_ctrl.get() == NULL) {
@@ -210,7 +210,7 @@ n230_resource_manager::n230_resource_manager(
//Create GPSDO interface
if (_core_status_reg.read(fpga::core_status_reg_t::GPSDO_STATUS) != fpga::GPSDO_ST_ABSENT) {
- UHD_MSG(status) << "Detecting GPSDO.... " << std::flush;
+ UHD_LOGGER_INFO("N230") << "Detecting GPSDO.... ";
try {
const sid_t gps_uart_sid = _generate_sid(GPS_UART, _get_conn(PRI_ETH).type);
transport::zero_copy_if::sptr gps_uart_xport =
@@ -221,7 +221,7 @@ n230_resource_manager::n230_resource_manager(
boost::this_thread::sleep(boost::posix_time::seconds(1)); //allow for a little propagation
_gps_ctrl = gps_ctrl::make(_gps_uart);
} catch(std::exception &e) {
- UHD_MSG(error) << "An error occurred making GPSDO control: " << e.what() << std::endl;
+ UHD_LOGGER_ERROR("N230") << "An error occurred making GPSDO control: " << e.what() ;
}
if (not is_gpsdo_present()) {
_core_ctrl->poke32(fpga::sr_addr(fpga::SR_CORE_GPSDO_ST), fpga::GPSDO_ST_ABSENT);
@@ -276,7 +276,7 @@ transport::zero_copy_if::sptr n230_resource_manager::create_transport(
return xport;
}
-bool n230_resource_manager::is_device_claimed(uhd::usrp::usrp3::usrp3_fw_ctrl_iface::sptr fw_ctrl)
+bool n230_resource_manager::is_device_claimed(n230_fw_ctrl_iface::sptr fw_ctrl)
{
boost::mutex::scoped_lock(_claimer_mutex);
@@ -488,7 +488,7 @@ bool n230_resource_manager::_radio_data_loopback_self_test(wb_iface::sptr iface)
const uint32_t rb_rx = uint32_t(rb_word64 & 0xffffffff);
test_fail = word32 != rb_tx or word32 != rb_rx;
if (test_fail){
- UHD_MSG(fastpath) << boost::format("mismatch (exp:%x, got:%x and %x)... ") % word32 % rb_tx % rb_rx;
+ UHD_LOG_ERROR("N230", str(boost::format("mismatch (exp:%x, got:%x and %x)... ") % word32 % rb_tx % rb_rx));
break; //exit loop on any failure
}
}
diff --git a/host/lib/usrp/n230/n230_resource_manager.hpp b/host/lib/usrp/n230/n230_resource_manager.hpp
index 180f4f437..6da3b9035 100644
--- a/host/lib/usrp/n230/n230_resource_manager.hpp
+++ b/host/lib/usrp/n230/n230_resource_manager.hpp
@@ -37,7 +37,7 @@
#include <uhd/transport/bounded_buffer.hpp>
#include <uhd/usrp/gps_ctrl.hpp>
-#include "usrp3_fw_ctrl_iface.hpp"
+#include "n230_fw_ctrl_iface.hpp"
#include "n230_clk_pps_ctrl.hpp"
#include "n230_cores.hpp"
#include "n230_fpga_defs.h"
@@ -98,7 +98,7 @@ public: //Methods
n230_resource_manager(const std::vector<std::string> ip_addrs, const bool safe_mode);
virtual ~n230_resource_manager();
- static bool is_device_claimed(uhd::usrp::usrp3::usrp3_fw_ctrl_iface::sptr fw_ctrl);
+ static bool is_device_claimed(n230_fw_ctrl_iface::sptr fw_ctrl);
inline bool is_device_claimed() {
if (_fw_ctrl.get()) {
@@ -276,12 +276,12 @@ private:
ver_info_t _fpga_version;
//Firmware register interface
- uhd::usrp::usrp3::usrp3_fw_ctrl_iface::sptr _fw_ctrl;
+ n230_fw_ctrl_iface::sptr _fw_ctrl;
uhd::task::sptr _claimer_task;
static boost::mutex _claimer_mutex; //All claims and checks in this process are serialized
//Transport
- uint8_t _last_host_enpoint;
+ uint8_t _last_host_enpoint;
//Radio settings interface
radio_ctrl_core_3000::sptr _core_ctrl;
diff --git a/host/lib/usrp/n230/n230_stream_manager.cpp b/host/lib/usrp/n230/n230_stream_manager.cpp
index 0528212d0..95da2752e 100644
--- a/host/lib/usrp/n230/n230_stream_manager.cpp
+++ b/host/lib/usrp/n230/n230_stream_manager.cpp
@@ -24,7 +24,6 @@
#include <boost/bind.hpp>
#include <uhd/utils/tasks.hpp>
#include <uhd/utils/log.hpp>
-#include <boost/foreach.hpp>
#include <boost/make_shared.hpp>
static const double N230_RX_SW_BUFF_FULL_FACTOR = 0.90; //Buffer should ideally be 90% full.
@@ -478,7 +477,7 @@ void n230_stream_manager::_handle_tx_async_msgs(
_cvita_hdr_unpack(packet_buff, if_packet_info);
endian_conv = uhd::ntohx;
} catch(const std::exception &ex) {
- UHD_MSG(error) << "Error parsing async message packet: " << ex.what() << std::endl;
+ UHD_LOGGER_ERROR("N230") << "Error parsing async message packet: " << ex.what() ;
return;
}
diff --git a/host/lib/usrp/n230/n230_uart.cpp b/host/lib/usrp/n230/n230_uart.cpp
index 7291a7276..7330dff4a 100644
--- a/host/lib/usrp/n230/n230_uart.cpp
+++ b/host/lib/usrp/n230/n230_uart.cpp
@@ -20,7 +20,7 @@
#include <uhd/transport/bounded_buffer.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/utils/byteswap.hpp>
-#include <uhd/utils/msg.hpp>
+#include <uhd/utils/log.hpp>
#include <uhd/types/time_spec.hpp>
#include <uhd/exception.hpp>