31 Commits

Author SHA1 Message Date
Dmitry Sharshakov
4867d84b1e host: change UHD pointer types based on UHD version
Follow-up: 58b4d869d4
2023-11-26 22:50:28 +02:00
Dmitry Sharshakov
dbbedb55b3 usrp_cal_utils: compatibility with UHD3
Follow-up: 98bd84035b
2023-11-26 22:50:28 +02:00
Dmitry Sharshakov
966d38e710 host: fix Boost warnings due to global placeholders 2023-11-26 22:50:28 +02:00
Dmitry Sharshakov
bac43dcb6c host: remove unused variables and functions 2023-11-26 22:50:28 +02:00
Dmitry Sharshakov
1be7c63ac2 host: use std::shared_ptr for UHD objects
UHD 4 moved to C++11 smart pointers instead of Boost ones. Follow this to allow building with UHD 4. This change is limited to symbols interacting with libuhd.

Ref: 1fe98e8701
2023-11-26 22:50:28 +02:00
Dmitry Sharshakov
845b9029df host: add missing includes for BOOST_FOREACH 2023-11-26 22:50:28 +02:00
Dmitry Sharshakov
ce07ca65ff umtrx_impl: remove header deprecated in UHD 4 2023-11-26 22:50:28 +02:00
Dmitry Sharshakov
c59bb6d776 usrp_cal_utils: use UHD 4 calibration data path
UHD 4 removed get_app_path, replace it with designated calibration data directory.

This change will require users to move calibration blobs to new location for UHD 4 or recalibrate.

Reference: 1383fde345
2023-11-26 22:50:28 +02:00
Kirill Zakharenko
20ab77fe91 release 1.0.19 2020-05-26 07:55:28 +03:00
Kirill Zakharenko
e597866c9d python: install umtrx property tree lib for python 3 as well 2020-05-26 05:51:02 +03:00
Clément BRUGUERA
9f0bf718e2 Fix compilation error against libboost 1.67 2019-11-01 00:23:23 +03:00
Alexander Chemeris
9797c410e3 Do not rely on N200 EEPROM code.
New UHD versions removed device-specific code from public headers, so
we've copied relevant code into our own codebase.

Also renamed N100 to N200 to follow the main UHD codebase naming.
2019-10-31 19:22:50 +03:00
Alexander Chemeris
c87ac1ba32 Detect uhd/utils/thread_priority.hpp deprecation 2019-10-31 19:22:50 +03:00
Alexander Chemeris
48ad4cd890 Don't include uhd/utils/atomic.hpp - we disabled threading here long time ago 2019-10-31 19:22:50 +03:00
Alexander Chemeris
828c811f79 Fix uhd/utils/msg.hpp missing in newer UHD 2019-10-31 19:22:50 +03:00
Kirill Zakharenko
6c9567c46f bump version to 1.0.18 2019-07-15 18:03:30 +03:00
Kirill Zakharenko
2fa07d28d6 umtrx_monitor: bind to localhost instead of 0.0.0.0 2019-07-15 18:03:13 +03:00
Kirill Zakharenko
e4dff6e07c bumped version to 1.0.17 2019-07-08 21:48:01 +03:00
Kirill Zakharenko
fab18d97a2 umtrx_auto_calibration: save result files to /var/lib/umtrx by default 2019-07-05 15:13:26 +03:00
Kirill Zakharenko
c9304575bf bumped version to 1.0.16 2019-07-03 21:17:31 +03:00
Kirill Zakharenko
61ac2ee278 umtrx_cal_*: fix for abrupt termination
tx_thread creates a child thread, which it join()s on, when terminating
calling interrupt() on tx_thread interferes with the join()
so we replace interrupt() with an atomic flag

(not sure how this worked before)
2019-07-03 21:17:31 +03:00
Kirill Zakharenko
7199b8667f boost: use minimally required build Boost dependencies
speeds up clean builds
2019-07-03 21:17:31 +03:00
Kirill Zakharenko
91185de06a util: install python utils directly into /usr/bin 2019-07-03 21:17:30 +03:00
Kirill Zakharenko
99d1b8adf3 utils: move umtrx python libraries to PYTHONPATH 2019-07-03 21:17:30 +03:00
Kirill Zakharenko
b81240db26 utils: remove collectd integration, it belongs in another package 2019-07-03 21:17:30 +03:00
Kirill Zakharenko
0d0f0c710c debian: Update deb deps to bionic 2019-07-03 21:17:30 +03:00
sergforce
f528fa442f Merge pull request #23 from pespin/pespin/fix-build
umtrx_monitor.cpp: Fix compilation against newer boost
2018-04-22 18:41:38 +03:00
Pau Espin Pedrol
132f8995ec umtrx_monitor.cpp: Fix compilation against newer boost
Related: github issue #22
2018-04-21 15:23:42 +02:00
satunnainen
93d4343d85 bump version to 1.0.15 2017-08-15 03:04:15 +03:00
Alexander Chemeris
1421327cfe host: Python 2 compatibility for umtrx_property_tree.py
bytes(u'something', 'utf-8') is only available in Python 3. A backwards
compatible version of it is u'something'.encode('utf-8').
2017-08-14 23:46:06 +03:00
Alexander Chemeris
1e0c879f53 utils: s/USRP/UmTRX/g in console output of umtrx_net_burner.py 2017-08-08 21:34:51 +03:00
42 changed files with 445 additions and 257 deletions

36
debian/changelog vendored
View File

@@ -1,3 +1,39 @@
umtrx (1.0.19) bionic; urgency=medium
* library now supports python3
* updated for latest UHD/libboost
-- Kirill Zakharenko <kirill.zakharenko@fairwaves.co> Tue, 26 May 2020 07:48:32 +0300
umtrx (1.0.18) bionic; urgency=medium
* umtrx status monitor now binds to localhost instead of 0.0.0.0
-- Kirill Zakharenko <earwin@gmail.com> Fri, 12 Jul 2019 13:39:48 +0300
umtrx (1.0.17) bionic; urgency=medium
* umtrx_auto_calibration: save result files to /var/lib/umtrx by default
-- Kirill Zakharenko <earwin@gmail.com> Wed, 20 Jun 2019 13:39:48 +0300
umtrx (1.0.16) bionic; urgency=medium
* first bionic build
* python libraries are now in PYTHONPATH and reusable
* minimized Boost build deps for faster builds
* dropped collectd integration
* fixed abrupt termination of umtrx_cal_*
-- Kirill Zakharenko <earwin@gmail.com> Wed, 19 Jun 2019 13:39:48 +0300
umtrx (1.0.15) trusty; urgency=medium
* host: Python 2 compatibility for umtrx_property_tree.py
* utils: s/USRP/UmTRX/g in console output of umtrx_net_burner.py
-- Rauf Gyulaliev <rauf.gyulaliev@fairwaves.co> Tue, 15 Aug 2017 03:03:23 +0300
umtrx (1.0.14) trusty; urgency=medium
* Quick build fix.

2
debian/compat vendored
View File

@@ -1 +1 @@
9
11

8
debian/control vendored
View File

@@ -3,9 +3,13 @@ Section: libs
Priority: optional
Maintainer: Josh Blum <josh@pothosware.com>
Build-Depends:
debhelper (>= 9.0.0),
debhelper (>= 11.0.0),
cmake (>= 2.8),
libboost-all-dev,
libboost-date-time-dev,
libboost-filesystem-dev,
libboost-system-dev,
libboost-thread-dev,
libboost-program-options-dev,
libuhd-dev (>= 3.7)
Standards-Version: 3.9.5
Homepage: http://umtrx.org/

View File

@@ -1,8 +1,4 @@
usr/bin
images/u2plus_umtrx_v2.bin images/umtrx_txrx_uhd.bin usr/share/umtrx/firmware
host/utils/umtrx_property_tree.py host/utils/umtrx_vswr.py usr/share/umtrx
host/utils/umtrx_query_sensors.py host/utils/umtrx_query_versions.py host/utils/umtrx_net_burner.py usr/share/umtrx
host/utils/collectd/umtrx.types.db usr/share/collectd
host/utils/collectd/umtrx2collectd.py usr/share/umtrx
host/utils/collectd/umtrx.conf etc/collectd/collectd.conf.d
host/utils/umtrx_property_tree.py host/utils/umtrx_vswr.py usr/lib/python2.7/dist-packages
host/utils/umtrx_property_tree.py host/utils/umtrx_vswr.py usr/lib/python3/dist-packages

3
debian/umtrx.links vendored
View File

@@ -1,3 +0,0 @@
/usr/share/umtrx/umtrx_net_burner.py /usr/bin/umtrx_net_burner
/usr/share/umtrx/umtrx_query_sensors.py /usr/bin/umtrx_query_sensors
/usr/share/umtrx/umtrx_query_versions.py /usr/bin/umtrx_query_versions

View File

@@ -77,6 +77,20 @@ list(APPEND UMTRX_LIBRARIES ${UHD_LIBRARIES})
MESSAGE(STATUS "UHD include directories: ${UHD_INCLUDE_DIRS}")
MESSAGE(STATUS "UHD libraries: ${UHD_LIBRARIES}")
if (EXISTS "${UHD_INCLUDE_DIRS}/uhd/utils/msg.hpp")
add_definitions(-DUHD_HAS_MSG_HPP)
message(STATUS " use msg.hpp for logging")
else()
message(STATUS " use log.hpp for logging")
endif()
if (EXISTS "${UHD_INCLUDE_DIRS}/uhd/utils/thread.hpp")
add_definitions(-DTHREAD_PRIORITY_HPP_DEPRECATED)
message(STATUS " use thread.hpp (new interface)")
else()
message(STATUS " use thread_priority.hpp (old interface)")
endif()
########################################################################
# Setup Boost
########################################################################

View File

@@ -18,9 +18,10 @@
#include "apply_corrections.hpp"
#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/utils/csv.hpp>
#include <uhd/types/dict.hpp>
#include <uhd/version.hpp>
#include <boost/filesystem.hpp>
#include <boost/foreach.hpp>
#include <boost/thread/mutex.hpp>
@@ -104,7 +105,13 @@ static void apply_fe_corrections(
const uhd::usrp::dboard_eeprom_t db_eeprom = sub_tree->access<uhd::usrp::dboard_eeprom_t>(db_path).get();
//make the calibration file path
//UHD4 deprecated get_app_path and uses designated calibration path (introduced earlier)
//Don't break existing UHD3 installs, so use cal path only on UHD4
#if UHD_VERSION >= 4000000
const fs::path cal_data_path = fs::path(uhd::get_cal_data_path()) / (file_prefix + db_eeprom.serial + ".csv");
#else
const fs::path cal_data_path = fs::path(uhd::get_app_path()) / ".uhd" / "cal" / (file_prefix + db_eeprom.serial + ".csv");
#endif
UHD_MSG(status) << "Looking for FE correction at: " << cal_data_path.c_str() << "... ";
if (not fs::exists(cal_data_path)) {
UHD_MSG(status) << "Not found" << std::endl;

View File

@@ -22,7 +22,7 @@
#include <uhd/transport/vrt_if_packet.hpp>
#include <uhd/types/metadata.hpp>
#include <uhd/utils/byteswap.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
namespace uhd{ namespace usrp{
@@ -55,14 +55,14 @@ namespace uhd{ namespace usrp{
if (metadata.event_code &
( async_metadata_t::EVENT_CODE_UNDERFLOW
| async_metadata_t::EVENT_CODE_UNDERFLOW_IN_PACKET)
) UHD_MSG(fastpath) << "U";
) {UHD_LOG_FASTPATH("U");}
else if (metadata.event_code &
( async_metadata_t::EVENT_CODE_SEQ_ERROR
| async_metadata_t::EVENT_CODE_SEQ_ERROR_IN_BURST)
) UHD_MSG(fastpath) << "S";
) {UHD_LOG_FASTPATH("S");}
else if (metadata.event_code &
async_metadata_t::EVENT_CODE_TIME_ERROR
) UHD_MSG(fastpath) << "L";
) {UHD_LOG_FASTPATH("L");}
}

View File

@@ -18,7 +18,7 @@
#include "rx_dsp_core_200.hpp"
#include <uhd/types/dict.hpp>
#include <uhd/exception.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/utils/safe_call.hpp>
#include <uhd/utils/algorithm.hpp>
#include <boost/assign/list_of.hpp>

View File

@@ -22,9 +22,8 @@
#include <uhd/exception.hpp>
#include <uhd/convert.hpp>
#include <uhd/stream.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/utils/tasks.hpp>
#include <uhd/utils/atomic.hpp>
#include <uhd/utils/byteswap.hpp>
#include <uhd/types/metadata.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
@@ -33,7 +32,7 @@
#include <boost/foreach.hpp>
#include <boost/function.hpp>
#include <boost/format.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/make_shared.hpp>
#include <boost/thread/barrier.hpp>
#include <iostream>
@@ -92,22 +91,14 @@ public:
}
~recv_packet_handler(void){
_task_barrier.interrupt();
_task_handlers.clear();
}
//! Resize the number of transport channels
void resize(const size_t size){
if (this->size() == size) return;
_task_handlers.clear();
_props.resize(size);
//re-initialize all buffers infos by re-creating the vector
_buffers_infos = std::vector<buffers_info_type>(4, buffers_info_type(size));
_task_barrier.resize(size);
_task_handlers.resize(size);
for (size_t i = 1/*skip 0*/; i < size; i++){
//_task_handlers[i] = task::make(boost::bind(&recv_packet_handler::converter_thread_task, this, i));
};
}
//! Get the channel width of this handler
@@ -559,7 +550,7 @@ private:
rx_metadata_t metadata = curr_info.metadata;
_props[index].handle_overflow();
curr_info.metadata = metadata;
UHD_MSG(fastpath) << "O";
UHD_LOG_FASTPATH("O");
}
return;
@@ -576,7 +567,7 @@ private:
prev_info[index].ifpi.num_payload_words32*sizeof(boost::uint32_t)/_bytes_per_otw_item, _samp_rate);
curr_info.metadata.out_of_sequence = true;
curr_info.metadata.error_code = rx_metadata_t::ERROR_CODE_OVERFLOW;
UHD_MSG(fastpath) << "D";
UHD_LOG_FASTPATH("D");
return;
}
@@ -666,8 +657,6 @@ private:
******************************************************************/
UHD_INLINE void converter_thread_task(const size_t index)
{
//_task_barrier.wait();
//shortcut references to local data structures
buffers_info_type &buff_info = get_curr_buffer_info();
per_buffer_info_type &info = buff_info[index];
@@ -691,13 +680,9 @@ private:
if (buff_info.data_bytes_to_copy == _convert_bytes_to_copy){
info.buff.reset(); //effectively a release
}
//if (index == 0) _task_barrier.wait_others();
}
//! Shared variables for the worker threads
reusable_barrier _task_barrier;
std::vector<task::sptr> _task_handlers;
size_t _convert_nsamps;
const rx_streamer::buffs_type *_convert_buffs;
size_t _convert_buffer_offset_bytes;

View File

@@ -22,9 +22,8 @@
#include <uhd/exception.hpp>
#include <uhd/convert.hpp>
#include <uhd/stream.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/utils/tasks.hpp>
#include <uhd/utils/atomic.hpp>
#include <uhd/utils/byteswap.hpp>
#include <uhd/types/metadata.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
@@ -74,22 +73,14 @@ public:
}
~send_packet_handler(void){
_task_barrier.interrupt();
_task_handlers.clear();
}
//! Resize the number of transport channels
void resize(const size_t size){
if (this->size() == size) return;
_task_handlers.clear();
_props.resize(size);
static const boost::uint64_t zero = 0;
_zero_buffs.resize(size, &zero);
_task_barrier.resize(size);
_task_handlers.resize(size);
for (size_t i = 1/*skip 0*/; i < size; i++){
//_task_handlers[i] = task::make(boost::bind(&send_packet_handler::converter_thread_task, this, i));
};
}
//! Get the channel width of this handler
@@ -390,8 +381,6 @@ private:
******************************************************************/
UHD_INLINE void converter_thread_task(const size_t index)
{
//_task_barrier.wait();
//shortcut references to local data structures
managed_send_buffer::sptr &buff = _props[index].buff;
vrt::if_packet_info_t if_packet_info = *_convert_if_packet_info;
@@ -419,13 +408,9 @@ private:
const size_t num_vita_words32 = _header_offset_words32+if_packet_info.num_packet_words32;
buff->commit(num_vita_words32*sizeof(boost::uint32_t));
buff.reset(); //effectively a release
//if (index == 0) _task_barrier.wait_others();
}
//! Shared variables for the worker threads
reusable_barrier _task_barrier;
std::vector<task::sptr> _task_handlers;
size_t _convert_nsamps;
const tx_streamer::buffs_type *_convert_buffs;
size_t _convert_buffer_offset_bytes;

View File

@@ -18,7 +18,7 @@
#include "tx_dsp_core_200.hpp"
#include <uhd/types/dict.hpp>
#include <uhd/exception.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/utils/algorithm.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/math/special_functions/round.hpp>

View File

@@ -118,7 +118,7 @@ double lms6002d_dev::txrx_pll_tune(uint8_t reg, double ref_clock, double out_fre
for (int i = 0; i < 64; i++) {
// Update VCOCAP
lms_write_bits(reg + 0x9, 0x3f, i);
usleep(50);
usleep(long(50));
int comp = read_reg(reg + 0x0a);
switch (comp >> 6) {
@@ -360,7 +360,7 @@ int lms6002d_dev::general_dc_calibration_loop(uint8_t dc_addr, uint8_t calibrati
if (verbosity > 1) printf("cnt=%d\n", try_cnt_limit);
// Wait for 6.4(1.6) us
usleep(6.4);
usleep(long(6.4));
// Read DC_CLBR_DONE
reg_val = read_reg(calibration_reg_base+0x01);

View File

@@ -10,7 +10,7 @@
#include <uhd/utils/static.hpp>
#include <uhd/utils/assert_has.hpp>
#include <uhd/utils/algorithm.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/types/ranges.hpp>
#include <uhd/types/sensors.hpp>
#include <uhd/types/dict.hpp>

View File

@@ -1,5 +1,5 @@
#include "power_amp.hpp"
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/exception.hpp>
#include <boost/assign/list_of.hpp>
#include <boost/foreach.hpp>

12
host/umtrx_common.hpp Normal file
View File

@@ -0,0 +1,12 @@
#ifndef INCLUDED_UMTRX_COMMON_HPP
#define INCLUDED_UMTRX_COMMON_HPP
#include <uhd/version.hpp>
#if UHD_VERSION >= 4000000
#define UMTRX_UHD_PTR_NAMESPACE std
#else
#define UMTRX_UHD_PTR_NAMESPACE boost
#endif
#endif /* INCLUDED_UMTRX_COMMON_HPP */

View File

@@ -17,6 +17,7 @@
#include <uhd/usrp/mboard_eeprom.hpp>
#include <uhd/types/mac_addr.hpp>
#include <uhd/types/byte_vector.hpp>
#include <uhd/utils/byteswap.hpp>
#include <boost/asio/ip/address_v4.hpp>
#include <boost/assign/list_of.hpp>
@@ -29,7 +30,9 @@
using namespace uhd;
using namespace uhd::usrp;
static const boost::uint8_t N100_EEPROM_ADDR = 0x50;
static const boost::uint8_t N200_EEPROM_ADDR = 0x50;
static const size_t SERIAL_LEN = 9;
static const size_t NAME_MAX_LEN = 32 - SERIAL_LEN;
//! convert a string to a byte vector to write to eeprom
static byte_vector_t string_to_uint16_bytes(const std::string &num_str){
@@ -45,6 +48,28 @@ static std::string uint16_bytes_to_string(const byte_vector_t &bytes){
return (num == 0 or num == 0xffff)? "" : boost::lexical_cast<std::string>(num);
}
struct n200_eeprom_map{
uint16_t hardware;
uint8_t mac_addr[6];
uint32_t subnet;
uint32_t ip_addr;
uint16_t _pad0;
uint16_t revision;
uint16_t product;
unsigned char _pad1;
unsigned char gpsdo;
unsigned char serial[SERIAL_LEN];
unsigned char name[NAME_MAX_LEN];
uint32_t gateway;
};
enum n200_gpsdo_type{
N200_GPSDO_NONE = 0,
N200_GPSDO_INTERNAL = 1,
N200_GPSDO_ONBOARD = 2
};
/***********************************************************************
* Implementation of UmTRX load/store - an extension for N100
**********************************************************************/
@@ -66,94 +91,228 @@ static const uhd::dict<std::string, boost::uint8_t> UMTRX_OFFSETS = boost::assig
#endif
void load_umtrx_eeprom(mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
//load all the N100 stuf first
mb_eeprom = mboard_eeprom_t(iface, "N100");
//clear the EEPROM dict
mb_eeprom = mboard_eeprom_t();
///////////////////////////////////////////////////////
// EEPROM values common between USRP N200 and UmTRX
///////////////////////////////////////////////////////
//extract the hardware number
mb_eeprom["hardware"] = uint16_bytes_to_string(
iface.read_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, hardware), 2)
);
//extract the revision number
mb_eeprom["revision"] = uint16_bytes_to_string(
iface.read_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, revision), 2)
);
//extract the product code
mb_eeprom["product"] = uint16_bytes_to_string(
iface.read_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, product), 2)
);
//extract the addresses
mb_eeprom["mac-addr"] = mac_addr_t::from_bytes(iface.read_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, mac_addr), 6
)).to_string();
boost::asio::ip::address_v4::bytes_type ip_addr_bytes;
byte_copy(iface.read_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, ip_addr), 4), ip_addr_bytes);
mb_eeprom["ip-addr"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
byte_copy(iface.read_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, subnet), 4), ip_addr_bytes);
mb_eeprom["subnet"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
byte_copy(iface.read_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, gateway), 4), ip_addr_bytes);
mb_eeprom["gateway"] = boost::asio::ip::address_v4(ip_addr_bytes).to_string();
//gpsdo capabilities
uint8_t gpsdo_byte = iface.read_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, gpsdo), 1).at(0);
switch(n200_gpsdo_type(gpsdo_byte)){
case N200_GPSDO_INTERNAL: mb_eeprom["gpsdo"] = "internal"; break;
case N200_GPSDO_ONBOARD: mb_eeprom["gpsdo"] = "onboard"; break;
default: mb_eeprom["gpsdo"] = "none";
}
//extract the serial
mb_eeprom["serial"] = bytes_to_string(iface.read_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, serial), SERIAL_LEN
));
//extract the name
mb_eeprom["name"] = bytes_to_string(iface.read_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, name), NAME_MAX_LEN
));
//Empty serial correction: use the mac address to determine serial.
//Older usrp2 models don't have a serial burned into EEPROM.
//The lower mac address bits will function as the serial number.
if (mb_eeprom["serial"].empty()){
byte_vector_t mac_addr_bytes = mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes();
unsigned serial = mac_addr_bytes.at(5) | (unsigned(mac_addr_bytes.at(4) & 0x0f) << 8);
mb_eeprom["serial"] = std::to_string(serial);
}
/////////////////////////////////////////////
// UmTRX specific EEPROM values
/////////////////////////////////////////////
//extract the Tx VGA1 DC I/Q offset values
{
uint8_t val = int(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-i"], 1).at(0));
uint8_t val = int(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-i"], 1).at(0));
mb_eeprom["tx1-vga1-dc-i"] = (val==255)?"":boost::lexical_cast<std::string>(int(val));
}
{
uint8_t val = int(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-q"], 1).at(0));
uint8_t val = int(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-q"], 1).at(0));
mb_eeprom["tx1-vga1-dc-q"] = (val==255)?"":boost::lexical_cast<std::string>(int(val));
}
{
uint8_t val = int(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-i"], 1).at(0));
uint8_t val = int(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-i"], 1).at(0));
mb_eeprom["tx2-vga1-dc-i"] = (val==255)?"":boost::lexical_cast<std::string>(int(val));
}
{
uint8_t val = int(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-q"], 1).at(0));
uint8_t val = int(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-q"], 1).at(0));
mb_eeprom["tx2-vga1-dc-q"] = (val==255)?"":boost::lexical_cast<std::string>(int(val));
}
//extract the TCXO DAC calibration value
mb_eeprom["tcxo-dac"] = uint16_bytes_to_string(
iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["tcxo-dac"], 2)
iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["tcxo-dac"], 2)
);
mb_eeprom["pa_dcdc_r"] =
boost::lexical_cast<std::string>(unsigned(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_dcdc_r"], 1).at(0)));
boost::lexical_cast<std::string>(unsigned(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_dcdc_r"], 1).at(0)));
{
uint8_t val = int(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_low"], 1).at(0));
uint8_t val = int(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_low"], 1).at(0));
mb_eeprom["pa_low"] = (val==255)?"":boost::lexical_cast<std::string>(int(val));
}
{
uint8_t val = int(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_en1"], 1).at(0));
uint8_t val = int(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_en1"], 1).at(0));
mb_eeprom["pa_en1"] = (val != 0) ?"1":"0";
}
{
uint8_t val = int(iface.read_eeprom(N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_en2"], 1).at(0));
uint8_t val = int(iface.read_eeprom(N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_en2"], 1).at(0));
mb_eeprom["pa_en2"] = (val != 0) ?"1":"0";
}
}
void store_umtrx_eeprom(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface){
mb_eeprom.commit(iface, "N100");
void store_umtrx_eeprom(const mboard_eeprom_t &mb_eeprom, i2c_iface &iface)
{
///////////////////////////////////////////////////////
// EEPROM values common between USRP N200 and UmTRX
///////////////////////////////////////////////////////
//parse the revision number
if (mb_eeprom.has_key("hardware")) iface.write_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, hardware),
string_to_uint16_bytes(mb_eeprom["hardware"])
);
//parse the revision number
if (mb_eeprom.has_key("revision")) iface.write_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, revision),
string_to_uint16_bytes(mb_eeprom["revision"])
);
//parse the product code
if (mb_eeprom.has_key("product")) iface.write_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, product),
string_to_uint16_bytes(mb_eeprom["product"])
);
//store the addresses
if (mb_eeprom.has_key("mac-addr")) iface.write_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, mac_addr),
mac_addr_t::from_string(mb_eeprom["mac-addr"]).to_bytes()
);
if (mb_eeprom.has_key("ip-addr")){
byte_vector_t ip_addr_bytes(4);
byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["ip-addr"]).to_bytes(), ip_addr_bytes);
iface.write_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, ip_addr), ip_addr_bytes);
}
if (mb_eeprom.has_key("subnet")){
byte_vector_t ip_addr_bytes(4);
byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["subnet"]).to_bytes(), ip_addr_bytes);
iface.write_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, subnet), ip_addr_bytes);
}
if (mb_eeprom.has_key("gateway")){
byte_vector_t ip_addr_bytes(4);
byte_copy(boost::asio::ip::address_v4::from_string(mb_eeprom["gateway"]).to_bytes(), ip_addr_bytes);
iface.write_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, gateway), ip_addr_bytes);
}
//gpsdo capabilities
if (mb_eeprom.has_key("gpsdo")){
uint8_t gpsdo_byte = N200_GPSDO_NONE;
if (mb_eeprom["gpsdo"] == "internal") gpsdo_byte = N200_GPSDO_INTERNAL;
if (mb_eeprom["gpsdo"] == "onboard") gpsdo_byte = N200_GPSDO_ONBOARD;
iface.write_eeprom(N200_EEPROM_ADDR, offsetof(n200_eeprom_map, gpsdo), byte_vector_t(1, gpsdo_byte));
}
//store the serial
if (mb_eeprom.has_key("serial")) iface.write_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, serial),
string_to_bytes(mb_eeprom["serial"], SERIAL_LEN)
);
//store the name
if (mb_eeprom.has_key("name")) iface.write_eeprom(
N200_EEPROM_ADDR, offsetof(n200_eeprom_map, name),
string_to_bytes(mb_eeprom["name"], NAME_MAX_LEN)
);
/////////////////////////////////////////////
// UmTRX specific EEPROM values
/////////////////////////////////////////////
//store the Tx VGA1 DC I/Q offset values
if (mb_eeprom.has_key("tx1-vga1-dc-i")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-i"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-i"],
byte_vector_t(1, boost::lexical_cast<int>(mb_eeprom["tx1-vga1-dc-i"]))
);
if (mb_eeprom.has_key("tx1-vga1-dc-q")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-q"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["tx1-vga1-dc-q"],
byte_vector_t(1, boost::lexical_cast<int>(mb_eeprom["tx1-vga1-dc-q"]))
);
if (mb_eeprom.has_key("tx2-vga1-dc-i")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-i"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-i"],
byte_vector_t(1, boost::lexical_cast<int>(mb_eeprom["tx2-vga1-dc-i"]))
);
if (mb_eeprom.has_key("tx2-vga1-dc-q")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-q"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["tx2-vga1-dc-q"],
byte_vector_t(1, boost::lexical_cast<int>(mb_eeprom["tx2-vga1-dc-q"]))
);
//extract the TCXO DAC calibration value
if (mb_eeprom.has_key("tcxo-dac")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["tcxo-dac"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["tcxo-dac"],
string_to_uint16_bytes(mb_eeprom["tcxo-dac"])
);
if (mb_eeprom.has_key("pa_dcdc_r")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_dcdc_r"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_dcdc_r"],
byte_vector_t(1, boost::lexical_cast<unsigned>(mb_eeprom["pa_dcdc_r"]))
);
if (mb_eeprom.has_key("pa_low")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_low"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_low"],
byte_vector_t(1, boost::lexical_cast<int>(mb_eeprom["pa_low"]))
);
if (mb_eeprom.has_key("pa_en1")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_en1"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_en1"],
byte_vector_t(1, boost::lexical_cast<int>(mb_eeprom["pa_en1"]))
);
if (mb_eeprom.has_key("pa_en2")) iface.write_eeprom(
N100_EEPROM_ADDR, UMTRX_OFFSETS["pa_en2"],
N200_EEPROM_ADDR, UMTRX_OFFSETS["pa_en2"],
byte_vector_t(1, boost::lexical_cast<int>(mb_eeprom["pa_en2"]))
);
}

View File

@@ -17,7 +17,7 @@
#include "umtrx_regs.hpp"
#include <uhd/exception.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/utils/safe_call.hpp>
#include <uhd/transport/vrt_if_packet.hpp>
#include "umtrx_fifo_ctrl.hpp"

View File

@@ -27,6 +27,8 @@
#include <uhd/types/wb_iface.hpp>
#include <string>
#include "umtrx_common.hpp"
/*!
* The umtrx FIFO control class:
* Provide high-speed peek/poke interface.
@@ -34,7 +36,7 @@
class umtrx_fifo_ctrl : public uhd::wb_iface, public uhd::spi_iface
{
public:
typedef boost::shared_ptr<umtrx_fifo_ctrl> sptr;
typedef UMTRX_UHD_PTR_NAMESPACE::shared_ptr<umtrx_fifo_ctrl> sptr;
//! Make a new FIFO control object
static sptr make(uhd::transport::zero_copy_if::sptr xport, const boost::uint32_t sid, const size_t window_size);

View File

@@ -17,13 +17,14 @@
#include "usrp2/fw_common.h"
#include "umtrx_iface.hpp"
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/utils/log.hpp>
#include <uhd/utils/byteswap.hpp>
#include <uhd/types/device_addr.hpp>
#include <uhd/transport/if_addrs.hpp>
#include <uhd/transport/udp_simple.hpp>
#include <boost/asio.hpp>
#include <boost/foreach.hpp>
using namespace uhd;
using namespace uhd::usrp;

View File

@@ -20,7 +20,7 @@
#include "umtrx_impl.hpp"
#include "umtrx_iface.hpp"
#include <uhd/exception.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include "missing/platform.hpp"
#include <uhd/utils/tasks.hpp>
#include <uhd/utils/safe_call.hpp>
@@ -30,7 +30,7 @@
#include <boost/asio.hpp> //used for htonl and ntohl
#include <boost/assign/list_of.hpp>
#include <boost/format.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/tokenizer.hpp>
#include <boost/functional/hash.hpp>
#include <algorithm>
@@ -60,7 +60,6 @@ static const boost::uint32_t MIN_PROTO_COMPAT_I2C = 7;
// The register compat number must reflect the protocol compatibility
// and the compatibility of the register mapping (more likely to change).
static const boost::uint32_t MIN_PROTO_COMPAT_REG = 10;
static const boost::uint32_t MIN_PROTO_COMPAT_UART = 7;
class umtrx_iface_impl : public umtrx_iface{
public:

View File

@@ -27,6 +27,8 @@
#include <boost/function.hpp>
#include <string>
#include "umtrx_common.hpp"
/*!
* The umtrx interface class:
* Provides a set of functions to implementation layer.
@@ -34,7 +36,7 @@
*/
class umtrx_iface : public uhd::wb_iface, public uhd::spi_iface, public uhd::i2c_iface{
public:
typedef boost::shared_ptr<umtrx_iface> sptr;
typedef UMTRX_UHD_PTR_NAMESPACE::shared_ptr<umtrx_iface> sptr;
/*!
* Make a new umtrx interface with the control transport.
* \param ctrl_transport the udp transport object

View File

@@ -18,13 +18,14 @@
#include "umtrx_impl.hpp"
#include "umtrx_regs.hpp"
#include "umtrx_version.hpp"
#include "umtrx_log_adapter.hpp"
#include "cores/apply_corrections.hpp"
#include <uhd/utils/log.hpp>
#include <uhd/utils/msg.hpp>
#include <boost/bind.hpp>
#include <boost/bind/bind.hpp>
#include <boost/thread.hpp> //sleep
#include <boost/assign/list_of.hpp>
#include <boost/utility.hpp>
#include <boost/foreach.hpp>
static int verbosity = 0;
@@ -106,7 +107,7 @@ template <typename T> property<T> &property_alias(uhd::property_tree::sptr &_tre
{
// By default route each chanel to its own antenna
return _tree->create<T>(alias)
.subscribe(boost::bind(&uhd::property<T>::set, boost::ref(_tree->access<T>(orig)), _1))
.subscribe(boost::bind(&uhd::property<T>::set, boost::ref(_tree->access<T>(orig)), boost::placeholders::_1))
.publish(boost::bind(&uhd::property<T>::get, boost::ref(_tree->access<T>(orig))));
}
@@ -265,23 +266,23 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
_ctrl = umtrx_fifo_ctrl::make(this->make_xport(UMTRX_CTRL_FRAMER, device_addr_t()), UMTRX_CTRL_SID, fifo_ctrl_window);
_ctrl->peek32(0); //test readback
_tree->create<time_spec_t>(mb_path / "time/cmd")
.subscribe(boost::bind(&umtrx_fifo_ctrl::set_time, _ctrl, _1));
.subscribe(boost::bind(&umtrx_fifo_ctrl::set_time, _ctrl, boost::placeholders::_1));
_tree->create<double>(mb_path / "tick_rate")
.subscribe(boost::bind(&umtrx_fifo_ctrl::set_tick_rate, _ctrl, _1));
.subscribe(boost::bind(&umtrx_fifo_ctrl::set_tick_rate, _ctrl, boost::placeholders::_1));
////////////////////////////////////////////////////////////////////
// setup the mboard eeprom
////////////////////////////////////////////////////////////////////
_tree->create<mboard_eeprom_t>(mb_path / "eeprom")
.set(_iface->mb_eeprom)
.subscribe(boost::bind(&umtrx_impl::set_mb_eeprom, this, _iface, _1));
.subscribe(boost::bind(&umtrx_impl::set_mb_eeprom, this, _iface, boost::placeholders::_1));
////////////////////////////////////////////////////////////////
// create clock control objects
////////////////////////////////////////////////////////////////
_tree->access<double>(mb_path / "tick_rate")
.publish(boost::bind(&umtrx_impl::get_master_clock_rate, this))
.subscribe(boost::bind(&umtrx_impl::update_tick_rate, this, _1));
.subscribe(boost::bind(&umtrx_impl::update_tick_rate, this, boost::placeholders::_1));
_tree->create<double>(mb_path / "dsp_rate")
.publish(boost::bind(&umtrx_impl::get_master_dsp_rate, this));
@@ -335,13 +336,13 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
// note: the control is also aliased to RF frontend later
_tree->create<bool>(mb_path / "divsw1")
.subscribe(boost::bind(&umtrx_impl::set_diversity, this, _1, 0))
.subscribe(boost::bind(&umtrx_impl::set_diversity, this, boost::placeholders::_1, 0))
.set(device_addr.cast<bool>("divsw1", false));
UHD_MSG(status) << "Diversity switch for channel 1: "
<< (_tree->access<bool>(mb_path / "divsw1").get()?"true":"false")
<< std::endl;
_tree->create<bool>(mb_path / "divsw2")
.subscribe(boost::bind(&umtrx_impl::set_diversity, this, _1, 1))
.subscribe(boost::bind(&umtrx_impl::set_diversity, this, boost::placeholders::_1, 1))
.set(device_addr.cast<bool>("divsw2", false));
UHD_MSG(status) << "Diversity switch for channel 2: "
<< (_tree->access<bool>(mb_path / "divsw2").get()?"true":"false")
@@ -424,9 +425,9 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
_tx_fes[1] = tx_frontend_core_200::make(_ctrl, U2_REG_SR_ADDR(SR_TX_FRONT1));
_tree->create<subdev_spec_t>(mb_path / "rx_subdev_spec")
.subscribe(boost::bind(&umtrx_impl::update_rx_subdev_spec, this, _1));
.subscribe(boost::bind(&umtrx_impl::update_rx_subdev_spec, this, boost::placeholders::_1));
_tree->create<subdev_spec_t>(mb_path / "tx_subdev_spec")
.subscribe(boost::bind(&umtrx_impl::update_tx_subdev_spec, this, _1));
.subscribe(boost::bind(&umtrx_impl::update_tx_subdev_spec, this, boost::placeholders::_1));
for (char name = 'A'; name <= 'B'; name++)
{
@@ -439,21 +440,21 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
tx_fe->set_mux("IQ");
rx_fe->set_mux(false/*no swap*/);
_tree->create<std::complex<double> >(rx_fe_path / "dc_offset" / "value")
.coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, rx_fe, _1))
.coerce(boost::bind(&rx_frontend_core_200::set_dc_offset, rx_fe, boost::placeholders::_1))
.set(std::complex<double>(0.0, 0.0));
_tree->create<bool>(rx_fe_path / "dc_offset" / "enable")
.subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, rx_fe, _1))
.subscribe(boost::bind(&rx_frontend_core_200::set_dc_offset_auto, rx_fe, boost::placeholders::_1))
.set(true);
_tree->create<std::complex<double> >(rx_fe_path / "iq_balance" / "value")
.subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, rx_fe, _1))
.subscribe(boost::bind(&rx_frontend_core_200::set_iq_balance, rx_fe, boost::placeholders::_1))
.set(std::polar<double>(0.0, 0.0));
/*
_tree->create<std::complex<double> >(tx_fe_path / "dc_offset" / "value")
.coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, tx_fe, _1))
.coerce(boost::bind(&tx_frontend_core_200::set_dc_offset, tx_fe, boost::placeholders::_1))
.set(std::complex<double>(0.0, 0.0));
*/
_tree->create<std::complex<double> >(tx_fe_path / "iq_balance" / "value")
.subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, tx_fe, _1))
.subscribe(boost::bind(&tx_frontend_core_200::set_iq_balance, tx_fe, boost::placeholders::_1))
.set(std::polar<double>(0.0, 0.0));
}
@@ -472,22 +473,22 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
_rx_dsps[dspno]->set_mux("IQ", false/*no swap*/);
_rx_dsps[dspno]->set_link_rate(UMTRX_LINK_RATE_BPS);
_tree->access<double>(mb_path / "dsp_rate")
.subscribe(boost::bind(&rx_dsp_core_200::set_tick_rate, _rx_dsps[dspno], _1));
.subscribe(boost::bind(&rx_dsp_core_200::set_tick_rate, _rx_dsps[dspno], boost::placeholders::_1));
_tree->access<double>(mb_path / "tick_rate")
.subscribe(boost::bind(&rx_dsp_core_200::set_vita_rate, _rx_dsps[dspno], _1));
.subscribe(boost::bind(&rx_dsp_core_200::set_vita_rate, _rx_dsps[dspno], boost::placeholders::_1));
fs_path rx_dsp_path = mb_path / str(boost::format("rx_dsps/%u") % dspno);
_tree->create<meta_range_t>(rx_dsp_path / "rate/range")
.publish(boost::bind(&rx_dsp_core_200::get_host_rates, _rx_dsps[dspno]));
_tree->create<double>(rx_dsp_path / "rate/value")
.set(this->get_master_clock_rate()/12) //some default
.coerce(boost::bind(&rx_dsp_core_200::set_host_rate, _rx_dsps[dspno], _1))
.subscribe(boost::bind(&umtrx_impl::update_rx_samp_rate, this, dspno, _1));
.coerce(boost::bind(&rx_dsp_core_200::set_host_rate, _rx_dsps[dspno], boost::placeholders::_1))
.subscribe(boost::bind(&umtrx_impl::update_rx_samp_rate, this, dspno, boost::placeholders::_1));
_tree->create<double>(rx_dsp_path / "freq/value")
.coerce(boost::bind(&rx_dsp_core_200::set_freq, _rx_dsps[dspno], _1));
.coerce(boost::bind(&rx_dsp_core_200::set_freq, _rx_dsps[dspno], boost::placeholders::_1));
_tree->create<meta_range_t>(rx_dsp_path / "freq/range")
.publish(boost::bind(&rx_dsp_core_200::get_freq_range, _rx_dsps[dspno]));
_tree->create<stream_cmd_t>(rx_dsp_path / "stream_cmd")
.subscribe(boost::bind(&rx_dsp_core_200::issue_stream_command, _rx_dsps[dspno], _1));
.subscribe(boost::bind(&rx_dsp_core_200::issue_stream_command, _rx_dsps[dspno], boost::placeholders::_1));
}
////////////////////////////////////////////////////////////////
@@ -502,16 +503,16 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
for (size_t dspno = 0; dspno < _tx_dsps.size(); dspno++){
_tx_dsps[dspno]->set_link_rate(UMTRX_LINK_RATE_BPS);
_tree->access<double>(mb_path / "dsp_rate")
.subscribe(boost::bind(&tx_dsp_core_200::set_tick_rate, _tx_dsps[dspno], _1));
.subscribe(boost::bind(&tx_dsp_core_200::set_tick_rate, _tx_dsps[dspno], boost::placeholders::_1));
fs_path tx_dsp_path = mb_path / str(boost::format("tx_dsps/%u") % dspno);
_tree->create<meta_range_t>(tx_dsp_path / "rate/range")
.publish(boost::bind(&tx_dsp_core_200::get_host_rates, _tx_dsps[dspno]));
_tree->create<double>(tx_dsp_path / "rate/value")
.set(this->get_master_clock_rate()/12) //some default
.coerce(boost::bind(&tx_dsp_core_200::set_host_rate, _tx_dsps[dspno], _1))
.subscribe(boost::bind(&umtrx_impl::update_tx_samp_rate, this, dspno, _1));
.coerce(boost::bind(&tx_dsp_core_200::set_host_rate, _tx_dsps[dspno], boost::placeholders::_1))
.subscribe(boost::bind(&umtrx_impl::update_tx_samp_rate, this, dspno, boost::placeholders::_1));
_tree->create<double>(tx_dsp_path / "freq/value")
.coerce(boost::bind(&tx_dsp_core_200::set_freq, _tx_dsps[dspno], _1));
.coerce(boost::bind(&tx_dsp_core_200::set_freq, _tx_dsps[dspno], boost::placeholders::_1));
_tree->create<meta_range_t>(tx_dsp_path / "freq/range")
.publish(boost::bind(&tx_dsp_core_200::get_freq_range, _tx_dsps[dspno]));
}
@@ -527,21 +528,21 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
_time64 = time64_core_200::make(_ctrl, U2_REG_SR_ADDR(SR_TIME64), time64_rb_bases);
_tree->access<double>(mb_path / "tick_rate")
.subscribe(boost::bind(&time64_core_200::set_tick_rate, _time64, _1));
.subscribe(boost::bind(&time64_core_200::set_tick_rate, _time64, boost::placeholders::_1));
_tree->create<time_spec_t>(mb_path / "time" / "now")
.publish(boost::bind(&time64_core_200::get_time_now, _time64))
.subscribe(boost::bind(&time64_core_200::set_time_now, _time64, _1));
.subscribe(boost::bind(&time64_core_200::set_time_now, _time64, boost::placeholders::_1));
_tree->create<time_spec_t>(mb_path / "time" / "pps")
.publish(boost::bind(&time64_core_200::get_time_last_pps, _time64))
.subscribe(boost::bind(&time64_core_200::set_time_next_pps, _time64, _1));
.subscribe(boost::bind(&time64_core_200::set_time_next_pps, _time64, boost::placeholders::_1));
//setup time source props
_tree->create<std::string>(mb_path / "time_source" / "value")
.subscribe(boost::bind(&time64_core_200::set_time_source, _time64, _1));
.subscribe(boost::bind(&time64_core_200::set_time_source, _time64, boost::placeholders::_1));
_tree->create<std::vector<std::string> >(mb_path / "time_source" / "options")
.publish(boost::bind(&time64_core_200::get_time_sources, _time64));
//setup reference source props
_tree->create<std::string>(mb_path / "clock_source" / "value")
.subscribe(boost::bind(&umtrx_impl::update_clock_source, this, _1));
.subscribe(boost::bind(&umtrx_impl::update_clock_source, this, boost::placeholders::_1));
static const std::vector<std::string> clock_sources = boost::assign::list_of("internal")("external");
_tree->create<std::vector<std::string> >(mb_path / "clock_source"/ "options").set(clock_sources);
@@ -593,7 +594,7 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
.publish(boost::bind(&lms6002d_ctrl::get_rx_gain_range, ctrl, name));
_tree->create<double>(rx_rf_fe_path / "gains" / name / "value")
.coerce(boost::bind(&lms6002d_ctrl::set_rx_gain, ctrl, _1, name))
.coerce(boost::bind(&lms6002d_ctrl::set_rx_gain, ctrl, boost::placeholders::_1, name))
.set((ctrl->get_rx_gain_range(name).start() + ctrl->get_rx_gain_range(name).stop())/2.0);
}
@@ -607,7 +608,7 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
.publish(boost::bind(&lms6002d_ctrl::get_tx_gain_range, ctrl, name));
_tree->create<double>(tx_rf_fe_path / "gains" / name / "value")
.coerce(boost::bind(&lms6002d_ctrl::set_tx_gain, ctrl, _1, name))
.coerce(boost::bind(&lms6002d_ctrl::set_tx_gain, ctrl, boost::placeholders::_1, name))
.set((ctrl->get_tx_gain_range(name).start() + ctrl->get_tx_gain_range(name).stop())/2.0);
}
} else {
@@ -622,7 +623,7 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
.publish(boost::bind(&umtrx_impl::get_tx_power_range, this, fe_name));
_tree->create<double>(tx_rf_fe_path / "gains" / "PA" / "value")
.coerce(boost::bind(&umtrx_impl::set_tx_power, this, _1, fe_name))
.coerce(boost::bind(&umtrx_impl::set_tx_power, this, boost::placeholders::_1, fe_name))
// Set default output power to maximum
.set(get_tx_power_range(fe_name).stop());
@@ -630,14 +631,14 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
//rx freq
_tree->create<double>(rx_rf_fe_path / "freq" / "value")
.coerce(boost::bind(&umtrx_impl::set_rx_freq, this, fe_name, _1));
.coerce(boost::bind(&umtrx_impl::set_rx_freq, this, fe_name, boost::placeholders::_1));
_tree->create<meta_range_t>(rx_rf_fe_path / "freq" / "range")
.publish(boost::bind(&umtrx_impl::get_rx_freq_range, this, fe_name));
_tree->create<bool>(rx_rf_fe_path / "use_lo_offset").set(false);
//tx freq
_tree->create<double>(tx_rf_fe_path / "freq" / "value")
.coerce(boost::bind(&lms6002d_ctrl::set_tx_freq, ctrl, _1));
.coerce(boost::bind(&lms6002d_ctrl::set_tx_freq, ctrl, boost::placeholders::_1));
_tree->create<meta_range_t>(tx_rf_fe_path / "freq" / "range")
.publish(boost::bind(&lms6002d_ctrl::get_tx_freq_range, ctrl));
_tree->create<bool>(tx_rf_fe_path / "use_lo_offset").set(false);
@@ -646,34 +647,34 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
_tree->create<std::vector<std::string> >(rx_rf_fe_path / "antenna" / "options")
.publish(boost::bind(&lms6002d_ctrl::get_rx_antennas, ctrl));
_tree->create<std::string>(rx_rf_fe_path / "antenna" / "value")
.subscribe(boost::bind(&lms6002d_ctrl::set_rx_ant, ctrl, _1))
.subscribe(boost::bind(&lms6002d_ctrl::set_rx_ant, ctrl, boost::placeholders::_1))
.set("RX1");
//tx ant
_tree->create<std::vector<std::string> >(tx_rf_fe_path / "antenna" / "options")
.publish(boost::bind(&lms6002d_ctrl::get_tx_antennas, ctrl));
_tree->create<std::string>(tx_rf_fe_path / "antenna" / "value")
.subscribe(boost::bind(&lms6002d_ctrl::set_tx_ant, ctrl, _1))
.subscribe(boost::bind(&lms6002d_ctrl::set_tx_ant, ctrl, boost::placeholders::_1))
.set("TX2");
//misc
_tree->create<std::string>(rx_rf_fe_path / "connection").set("IQ");
_tree->create<std::string>(tx_rf_fe_path / "connection").set("IQ");
_tree->create<bool>(rx_rf_fe_path / "enabled")
.coerce(boost::bind(&lms6002d_ctrl::set_rx_enabled, ctrl, _1));
.coerce(boost::bind(&lms6002d_ctrl::set_rx_enabled, ctrl, boost::placeholders::_1));
_tree->create<bool>(tx_rf_fe_path / "enabled")
.coerce(boost::bind(&lms6002d_ctrl::set_tx_enabled, ctrl, _1));
.coerce(boost::bind(&lms6002d_ctrl::set_tx_enabled, ctrl, boost::placeholders::_1));
//rx bw
_tree->create<double>(rx_rf_fe_path / "bandwidth" / "value")
.coerce(boost::bind(&lms6002d_ctrl::set_rx_bandwidth, ctrl, _1))
.coerce(boost::bind(&lms6002d_ctrl::set_rx_bandwidth, ctrl, boost::placeholders::_1))
.set(2*0.75e6);
_tree->create<meta_range_t>(rx_rf_fe_path / "bandwidth" / "range")
.publish(boost::bind(&lms6002d_ctrl::get_rx_bw_range, ctrl));
//tx bw
_tree->create<double>(tx_rf_fe_path / "bandwidth" / "value")
.coerce(boost::bind(&lms6002d_ctrl::set_tx_bandwidth, ctrl, _1))
.coerce(boost::bind(&lms6002d_ctrl::set_tx_bandwidth, ctrl, boost::placeholders::_1))
.set(2*0.75e6);
_tree->create<meta_range_t>(tx_rf_fe_path / "bandwidth" / "range")
.publish(boost::bind(&lms6002d_ctrl::get_tx_bw_range, ctrl));
@@ -681,17 +682,17 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
//bind frontend corrections to the dboard freq props
_tree->access<double>(tx_rf_fe_path / "freq" / "value")
.set(0.0) //default value
.subscribe(boost::bind(&umtrx_impl::set_tx_fe_corrections, this, "0", fe_name, _1));
.subscribe(boost::bind(&umtrx_impl::set_tx_fe_corrections, this, "0", fe_name, boost::placeholders::_1));
_tree->access<double>(rx_rf_fe_path / "freq" / "value")
.set(0.0) //default value
.subscribe(boost::bind(&umtrx_impl::set_rx_fe_corrections, this, "0", fe_name, _1));
.subscribe(boost::bind(&umtrx_impl::set_rx_fe_corrections, this, "0", fe_name, boost::placeholders::_1));
//tx cal props
_tree->create<uint8_t>(tx_rf_fe_path / "lms6002d" / "tx_dc_i" / "value")
.subscribe(boost::bind(&lms6002d_ctrl::_set_tx_vga1dc_i_int, ctrl, _1))
.subscribe(boost::bind(&lms6002d_ctrl::_set_tx_vga1dc_i_int, ctrl, boost::placeholders::_1))
.publish(boost::bind(&lms6002d_ctrl::get_tx_vga1dc_i_int, ctrl));
_tree->create<uint8_t>(tx_rf_fe_path / "lms6002d" / "tx_dc_q" / "value")
.subscribe(boost::bind(&lms6002d_ctrl::_set_tx_vga1dc_q_int, ctrl, _1))
.subscribe(boost::bind(&lms6002d_ctrl::_set_tx_vga1dc_q_int, ctrl, boost::placeholders::_1))
.publish(boost::bind(&lms6002d_ctrl::get_tx_vga1dc_q_int, ctrl));
//set Tx DC calibration values, which are read from mboard EEPROM
@@ -704,37 +705,37 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
//plugin dc_offset from lms into the frontend corrections
_tree->create<std::complex<double> >(mb_path / "tx_frontends" / fe_name / "dc_offset" / "value")
.publish(boost::bind(&umtrx_impl::get_dc_offset_correction, this, fe_name))
.subscribe(boost::bind(&umtrx_impl::set_dc_offset_correction, this, fe_name, _1))
.subscribe(boost::bind(&umtrx_impl::set_dc_offset_correction, this, fe_name, boost::placeholders::_1))
.set(std::complex<double>(dc_i, dc_q));
//rx cal props
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rx_fe_dc_i" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxfe_dc_i, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxfe_dc_i, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxfe_dc_i, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rx_fe_dc_q" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxfe_dc_q, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxfe_dc_q, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxfe_dc_q, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rx_lpf_dc_i" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxlpf_dc_i, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxlpf_dc_i, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxlpf_dc_i, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rx_lpf_dc_q" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxlpf_dc_q, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxlpf_dc_q, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxlpf_dc_q, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rxvga2_dc_reference" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxvga2_dc_reference, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2_dc_reference, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2_dc_reference, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rxvga2a_dc_i" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxvga2a_dc_i, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2a_dc_i, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2a_dc_i, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rxvga2a_dc_q" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxvga2a_dc_q, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2a_dc_q, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2a_dc_q, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rxvga2b_dc_i" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxvga2b_dc_i, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2b_dc_i, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2b_dc_i, ctrl, boost::placeholders::_1));
_tree->create<uint8_t>(rx_rf_fe_path / "lms6002d" / "rxvga2b_dc_q" / "value")
.publish(boost::bind(&lms6002d_ctrl::get_rxvga2b_dc_q, ctrl))
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2b_dc_q, ctrl, _1));
.subscribe(boost::bind(&lms6002d_ctrl::set_rxvga2b_dc_q, ctrl, boost::placeholders::_1));
// Alias diversity switch control from mb_path
property_alias<bool>(_tree, mb_path / "divsw"+(fe_name=="A"?"1":"2"), rx_rf_fe_path / "diversity");
@@ -742,7 +743,7 @@ umtrx_impl::umtrx_impl(const device_addr_t &device_addr)
//TCXO DAC calibration control
_tree->create<uint16_t>(mb_path / "tcxo_dac" / "value")
.subscribe(boost::bind(&umtrx_impl::set_tcxo_dac, this, _iface, _1));
.subscribe(boost::bind(&umtrx_impl::set_tcxo_dac, this, _iface, boost::placeholders::_1));
////////////////////////////////////////////////////////////////////
// post config tasks
@@ -1102,7 +1103,7 @@ void umtrx_impl::detect_hw_rev(const fs_path& mb_path)
_hw_rev = UMTRX_VER_2_3_1;
_tree->create<uint8_t>(mb_path / "pa_dcdc_r")
.subscribe(boost::bind(&umtrx_impl::set_pa_dcdc_r, this, _1));
.subscribe(boost::bind(&umtrx_impl::set_pa_dcdc_r, this, boost::placeholders::_1));
std::string pa_dcdc_r = _iface->mb_eeprom.get("pa_dcdc_r", "");
char* pa_dcdc_r_env = getenv("UMTRX_PA_DCDC_R");
@@ -1137,11 +1138,11 @@ void umtrx_impl::detect_hw_rev(const fs_path& mb_path)
_pa_nlow = (boost::lexical_cast<int>(pa_low) == 0);
_tree->create<bool>(mb_path / "pa_en1")
.subscribe(boost::bind(&umtrx_impl::set_enpa1, this, _1));
.subscribe(boost::bind(&umtrx_impl::set_enpa1, this, boost::placeholders::_1));
_tree->create<bool>(mb_path / "pa_en2")
.subscribe(boost::bind(&umtrx_impl::set_enpa2, this, _1));
.subscribe(boost::bind(&umtrx_impl::set_enpa2, this, boost::placeholders::_1));
_tree->create<bool>(mb_path / "pa_nlow")
.subscribe(boost::bind(&umtrx_impl::set_nlow, this, _1));
.subscribe(boost::bind(&umtrx_impl::set_nlow, this, boost::placeholders::_1));
commit_pa_state();
UHD_MSG(status) << "PA low=`" << pa_low.c_str()

View File

@@ -20,6 +20,7 @@
#define INCLUDED_UMTRX_IMPL_HPP
#include "usrp2/fw_common.h"
#include "umtrx_common.hpp"
#include "umtrx_iface.hpp"
#include "umtrx_fifo_ctrl.hpp"
#include "lms6002d_ctrl.hpp"
@@ -40,7 +41,6 @@
#include <uhd/types/dict.hpp>
#include <uhd/types/stream_cmd.hpp>
#include <uhd/types/sensors.hpp>
#include <uhd/types/clock_config.hpp>
#include <uhd/usrp/dboard_eeprom.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/function.hpp>
@@ -237,8 +237,8 @@ private:
void client_query_handle1(const boost::property_tree::ptree &request, boost::property_tree::ptree &response);
//streaming
std::vector<boost::weak_ptr<uhd::rx_streamer> > _rx_streamers;
std::vector<boost::weak_ptr<uhd::tx_streamer> > _tx_streamers;
std::vector<UMTRX_UHD_PTR_NAMESPACE::weak_ptr<uhd::rx_streamer> > _rx_streamers;
std::vector<UMTRX_UHD_PTR_NAMESPACE::weak_ptr<uhd::tx_streamer> > _tx_streamers;
boost::mutex _setupMutex;
};

View File

@@ -27,7 +27,11 @@
#include <boost/thread/thread.hpp>
#include <boost/thread/mutex.hpp>
#include <boost/thread/condition_variable.hpp>
#ifdef THREAD_PRIORITY_HPP_DEPRECATED
# include <uhd/utils/thread.hpp>
#else // THREAD_PRIORITY_HPP_DEPRECATED
# include <uhd/utils/thread_priority.hpp>
#endif // THREAD_PRIORITY_HPP_DEPRECATED
//A reasonable number of frames for send/recv and async/sync
static const size_t DEFAULT_NUM_FRAMES = 32;
@@ -35,7 +39,6 @@ static const size_t DEFAULT_NUM_FRAMES = 32;
using namespace uhd;
using namespace uhd::usrp;
using namespace uhd::transport;
namespace asio = boost::asio;
namespace pt = boost::posix_time;
/***********************************************************************
@@ -45,10 +48,6 @@ static UHD_INLINE pt::time_duration to_time_dur(double timeout){
return pt::microseconds(long(timeout*1e6));
}
static UHD_INLINE double from_time_dur(const pt::time_duration &time_dur){
return 1e-6*time_dur.total_microseconds();
}
/***********************************************************************
* constants
**********************************************************************/
@@ -106,8 +105,8 @@ void umtrx_impl::update_rates(void)
void umtrx_impl::update_rx_samp_rate(const size_t dsp, const double rate)
{
boost::shared_ptr<sph::recv_packet_streamer> my_streamer =
boost::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[dsp].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::recv_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[dsp].lock());
if (not my_streamer) return;
my_streamer->set_samp_rate(rate);
@@ -117,8 +116,8 @@ void umtrx_impl::update_rx_samp_rate(const size_t dsp, const double rate)
void umtrx_impl::update_tx_samp_rate(const size_t dsp, const double rate)
{
boost::shared_ptr<sph::send_packet_streamer> my_streamer =
boost::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[dsp].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::send_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[dsp].lock());
if (not my_streamer) return;
my_streamer->set_samp_rate(rate);
@@ -131,15 +130,15 @@ void umtrx_impl::update_tick_rate(const double rate)
//update the tick rate on all existing streamers -> thread safe
for (size_t i = 0; i < _rx_streamers.size(); i++)
{
boost::shared_ptr<sph::recv_packet_streamer> my_streamer =
boost::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[i].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::recv_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::recv_packet_streamer>(_rx_streamers[i].lock());
if (not my_streamer) continue;
my_streamer->set_tick_rate(rate);
}
for (size_t i = 0; i < _tx_streamers.size(); i++)
{
boost::shared_ptr<sph::send_packet_streamer> my_streamer =
boost::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[i].lock());
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::send_packet_streamer> my_streamer =
UMTRX_UHD_PTR_NAMESPACE::dynamic_pointer_cast<sph::send_packet_streamer>(_tx_streamers[i].lock());
if (not my_streamer) continue;
my_streamer->set_tick_rate(rate);
}
@@ -229,7 +228,7 @@ uhd::rx_streamer::sptr umtrx_impl::get_rx_stream(const uhd::stream_args_t &args_
const size_t spp = unsigned(args.args.cast<double>("spp", bpp/bpi));
//make the new streamer given the samples per packet
boost::shared_ptr<sph::recv_packet_streamer> my_streamer = boost::make_shared<sph::recv_packet_streamer>(spp);
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::recv_packet_streamer> my_streamer = UMTRX_UHD_PTR_NAMESPACE::make_shared<sph::recv_packet_streamer>(spp);
//init some streamer stuff
my_streamer->resize(args.channels.size());
@@ -250,10 +249,10 @@ uhd::rx_streamer::sptr umtrx_impl::get_rx_stream(const uhd::stream_args_t &args_
_rx_dsps[dsp]->set_nsamps_per_packet(spp); //seems to be a good place to set this
_rx_dsps[dsp]->setup(args);
my_streamer->set_xport_chan_get_buff(chan_i, boost::bind(
&zero_copy_if::get_recv_buff, xports[chan_i], _1
&zero_copy_if::get_recv_buff, xports[chan_i], boost::placeholders::_1
), true /*flush*/);
my_streamer->set_issue_stream_cmd(chan_i, boost::bind(
&rx_dsp_core_200::issue_stream_command, _rx_dsps[dsp], _1));
&rx_dsp_core_200::issue_stream_command, _rx_dsps[dsp], boost::placeholders::_1));
_rx_streamers[dsp] = my_streamer; //store weak pointer
}
@@ -455,7 +454,7 @@ uhd::tx_streamer::sptr umtrx_impl::get_tx_stream(const uhd::stream_args_t &args_
const size_t spp = bpp/convert::get_bytes_per_item(args.otw_format);
//make the new streamer given the samples per packet
boost::shared_ptr<sph::send_packet_streamer> my_streamer = boost::make_shared<sph::send_packet_streamer>(spp);
UMTRX_UHD_PTR_NAMESPACE::shared_ptr<sph::send_packet_streamer> my_streamer = UMTRX_UHD_PTR_NAMESPACE::make_shared<sph::send_packet_streamer>(spp);
//init some streamer stuff
my_streamer->resize(args.channels.size());
@@ -472,7 +471,7 @@ uhd::tx_streamer::sptr umtrx_impl::get_tx_stream(const uhd::stream_args_t &args_
//shared async queue for all channels in streamer
boost::shared_ptr<async_md_type> async_md(new async_md_type(1000/*messages deep*/));
if (not _old_async_queue) _old_async_queue.reset(new async_md_type(1000/*messages deep*/));
my_streamer->set_async_receiver(boost::bind(&async_md_type::pop_with_timed_wait, async_md, _1, _2));
my_streamer->set_async_receiver(boost::bind(&async_md_type::pop_with_timed_wait, async_md, boost::placeholders::_1, boost::placeholders::_2));
//bind callbacks for the handler
for (size_t chan_i = 0; chan_i < args.channels.size(); chan_i++)
@@ -507,7 +506,7 @@ uhd::tx_streamer::sptr umtrx_impl::get_tx_stream(const uhd::stream_args_t &args_
//buffer get method handles flow control and hold task reference count
my_streamer->set_xport_chan_get_buff(chan_i, boost::bind(
&get_send_buff, task, fc_mon, xports[chan_i], _1
&get_send_buff, task, fc_mon, xports[chan_i], boost::placeholders::_1
));
_tx_streamers[dsp] = my_streamer; //store weak pointer

View File

@@ -0,0 +1,24 @@
#ifndef UMTRX_LOG_ADAPTER_HPP
#define UMTRX_LOG_ADAPTER_HPP
#ifdef UHD_HAS_MSG_HPP
#include <uhd/utils/msg.hpp>
#define UHD_LOG_FASTPATH(message) UHD_MSG(fastpath) << (message)
#else // UHD_HAS_MSG_HPP
#include <uhd/utils/log.hpp>
enum {
_uhd_log_level_status,
_uhd_log_level_warning,
_uhd_log_level_error
};
#define UHD_MSG(severity) ((_uhd_log_level_##severity==_uhd_log_level_status)?UHD_LOGGER_INFO("UmTRX"): \
(_uhd_log_level_##severity==_uhd_log_level_warning)?UHD_LOGGER_WARNING("UmTRX"): \
UHD_LOGGER_ERROR("UmTRX"))
#endif // UHD_HAS_MSG_HPP
#endif // UMTRX_LOG_ADAPTER_HPP

View File

@@ -16,10 +16,11 @@
//
#include "umtrx_impl.hpp"
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/types/sensors.hpp>
#include <uhd/types/ranges.hpp>
#include <boost/asio.hpp>
#include <boost/foreach.hpp>
using namespace uhd;
using namespace uhd::usrp;
@@ -71,7 +72,7 @@ void umtrx_impl::status_monitor_start(const uhd::device_addr_t &device_addr)
{
UHD_MSG(status) << "Creating TCP monitor on port " << device_addr.get("status_port") << std::endl;
_server_query_tcp_acceptor.reset(new asio::ip::tcp::acceptor(
_server_query_io_service, asio::ip::tcp::endpoint(asio::ip::tcp::v4(), device_addr.cast<int>("status_port", 0))));
_server_query_io_service, asio::ip::tcp::endpoint(asio::ip::address::from_string("127.0.0.1"), device_addr.cast<int>("status_port", 0))));
_server_query_task = task::make(boost::bind(&umtrx_impl::server_query_handler, this));
}
_status_monitor_task = task::make(boost::bind(&umtrx_impl::status_monitor_handler, this));
@@ -118,7 +119,7 @@ void umtrx_impl::status_monitor_handler(void)
void umtrx_impl::server_query_handler(void)
{
//accept the client socket (timeout is 100 ms, task is called again)
if (not wait_read_sockfd(_server_query_tcp_acceptor->native(), 100)) return;
if (not wait_read_sockfd(_server_query_tcp_acceptor->native_handle(), 100)) return;
boost::shared_ptr<asio::ip::tcp::socket> socket(new asio::ip::tcp::socket(_server_query_io_service));
_server_query_tcp_acceptor->accept(*socket);

View File

@@ -6,6 +6,9 @@ INSTALL(PROGRAMS
umtrx_gps_coord
umtrx_auto_calibration
umtrx_firmware
umtrx_net_burner
umtrx_query_sensors
umtrx_query_versions
DESTINATION bin
)

View File

@@ -1,6 +0,0 @@
TypesDB "/usr/share/collectd/umtrx.types.db"
LoadPlugin exec
<Plugin exec>
Exec "fairwaves-monitoring" "/usr/share/umtrx/umtrx2collectd.py"
</Plugin>

View File

@@ -1 +0,0 @@
sensor value:GAUGE:U:U

View File

@@ -1,54 +0,0 @@
#!/usr/bin/python -u
# -*- coding: utf-8 -*-
import os
import sched, time
from umtrx_property_tree import umtrx_property_tree
from umtrx_vswr import umtrx_vswr
BOARD_ID = "0"
SENSORS_PATH = "/mboards/{id}/sensors".format(id=BOARD_ID)
VSWR_CALIBRATION = 0 # = TM10_VSWR_cal
HOSTNAME = os.environ['COLLECTD_HOSTNAME'] if 'COLLECTD_HOSTNAME' in os.environ else 'localhost'
INTERVAL = os.environ['COLLECTD_INTERVAL'] if 'COLLECTD_INTERVAL' in os.environ else '60'
umtrx = umtrx_property_tree()
umtrx.connect()
# typically this yields: ['tempA', 'tempB', 'voltagePR1', 'voltagePF1', 'voltagePR2', 'voltagePF2', 'voltagezero', 'voltageVin', 'voltageVinPA', 'voltageDCOUT']
sensors_list = umtrx.list_path_raw(SENSORS_PATH).get("result", [])
def publish():
now = time.time()
current_sensors = {sensor: umtrx.query_sensor_value(SENSORS_PATH + "/" + sensor) for sensor in sensors_list}
for channel in ["1", "2"]:
vpf_name = "voltagePF" + channel
vpr_name = "voltagePR" + channel
if vpf_name in current_sensors and vpr_name in current_sensors:
vswr = umtrx_vswr(float(current_sensors[vpf_name]), float(current_sensors[vpr_name]), VSWR_CALIBRATION)
current_sensors["VSWR" + channel] = vswr.vswr()
current_sensors["ReturnLoss" + channel] = vswr.return_loss()
for name, value in current_sensors.items():
print "PUTVAL {host}/umtrx-{id}/sensor-{name} interval={interval} {now}:{value}".format(
host=HOSTNAME, id=BOARD_ID, name=name.lower(), interval=INTERVAL, now=now, value=value)
s = sched.scheduler(time.time, time.sleep)
def timer_loop():
s.enter(float(INTERVAL), 1, timer_loop, ())
publish()
timer_loop()
s.run()
umtrx.close()

View File

@@ -12,16 +12,22 @@ if [ "$#" -lt "1" ] ; then
echo " - Tx DC offset calibration"
echo " - Tx IQ balance calibration"
echo
echo "The result of the calibration is stored in the DIR/.uhd/cal/ directory. DIR is one of the \$APPDATA, \$HOME and /tmp,"
echo "whichever is defined. Make sure you run calibration from the same user as the one who runs applications or define"
echo "\$APPDATA or \$HOME appropriately. Calibration files will be loaded by the application automatically on startup."
echo "Old calibration files are renamed when you run a calibration to avoid overwriting."
echo "The result of the calibration is stored in the \$UHD_CONFIG_DIR/.uhd/cal/ directory."
echo "If \$UHD_CONFIG_DIR is undefined, /var/lib/umtrx is used instead."
echo "When running UHD applications, make sure you set one of \$UHD_CONFIG_DIR, \$APPDATA or \$HOME to the same directory,"
echo "so the calibration files could be found and autoloaded by the application on startup."
echo "Existing calibration files are renamed when you run a calibration to avoid overwriting."
echo
echo "Calibration is permanent and only depends on temperature. If the temperature of the system is stable, you need to"
echo "run the calibration only once."
exit 1
fi
if [ -z "$UHD_CONFIG_DIR" ]; then
export UHD_CONFIG_DIR=/var/lib/umtrx
fi
mkdir -p $UHD_CONFIG_DIR
presets=$*
sides="A B"

View File

@@ -18,6 +18,7 @@
#include "usrp_cal_utils.hpp"
#include <uhd/utils/safe_main.hpp>
#include <boost/ref.hpp>
#include <boost/program_options.hpp>
#include <boost/format.hpp>
#include <boost/math/special_functions/round.hpp>
@@ -342,8 +343,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
//create a transmitter thread
std::atomic<bool> interrupted(false);
boost::thread_group threads;
threads.create_thread(boost::bind(&tx_thread, usrp, tx_wave_freq, tx_wave_ampl));
threads.create_thread(boost::bind(&tx_thread, usrp, tx_wave_freq, tx_wave_ampl, boost::ref(interrupted)));
//store the results here
std::vector<result_t> results;
@@ -403,7 +405,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << std::endl;
//stop the transmitter
threads.interrupt_all();
interrupted = true;
threads.join_all();
if (not vm.count("single_test"))

View File

@@ -18,6 +18,7 @@
#include "usrp_cal_utils.hpp"
#include <uhd/utils/safe_main.hpp>
#include <boost/ref.hpp>
#include <boost/program_options.hpp>
#include <boost/math/special_functions/round.hpp>
#include <iostream>
@@ -83,8 +84,9 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
uhd::rx_streamer::sptr rx_stream = usrp->get_rx_stream(stream_args);
//create a transmitter thread
std::atomic<bool> interrupted(false);
boost::thread_group threads;
threads.create_thread(boost::bind(&tx_thread, usrp, tx_wave_freq, tx_wave_ampl));
threads.create_thread(boost::bind(&tx_thread, usrp, tx_wave_freq, tx_wave_ampl, boost::ref(interrupted)));
//re-usable buffer for samples
std::vector<samp_type> buff;
@@ -177,7 +179,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){
std::cout << std::endl;
//stop the transmitter
threads.interrupt_all();
interrupted = true;
threads.join_all();
store_results(usrp, results, "tx", "iq", vm.count("append"));

View File

@@ -1,6 +1,7 @@
#!/usr/bin/env python
#
# Copyright 2010-2011 Ettus Research LLC
# Copyright 2013-2017 Fairwaves, Inc.
#
# 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
@@ -16,10 +17,7 @@
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# TODO: make it autodetect UHD devices
import optparse
import math
import os
import re
import struct
@@ -495,7 +493,7 @@ class burner_socket(object):
########################################################################
def get_options():
parser = optparse.OptionParser()
parser.add_option("--addr", type="string", help="USRP-N2XX device address", default='')
parser.add_option("--addr", type="string", help="UmTRX device address", default='')
parser.add_option("--fw", type="string", help="firmware image path (optional)", default='')
parser.add_option("--fpga", type="string", help="fpga image path (optional)", default='')
parser.add_option("--reset", action="store_true", help="reset the device after writing", default=False)
@@ -527,7 +525,7 @@ if __name__=='__main__':
if options.overwrite_safe and not options.read:
print("Are you REALLY, REALLY sure you want to overwrite the safe image? This is ALMOST ALWAYS a terrible idea.")
print("If your image is faulty, your USRP2+ will become a brick until reprogrammed via JTAG.")
print("If your image is faulty, your UmTRX will become a brick until reprogrammed via JTAG.")
response = raw_input("""Type "yes" to continue, or anything else to quit: """)
if response != "yes": sys.exit(0)

View File

@@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/algorithm.hpp>

View File

@@ -26,7 +26,7 @@ class umtrx_property_tree:
d = dict(action=action, path=path)
if value_type is not None: d['type'] = value_type
if value is not None: d['value'] = value
return self.s.send(bytes(json.dumps(d)+'\n', 'UTF-8'))
return self.s.send((json.dumps(d)+'\n').encode('UTF-8'))
def _recv_response(self):
resp = self.f.readline().strip()

View File

@@ -15,7 +15,11 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#ifdef THREAD_PRIORITY_HPP_DEPRECATED
# include <uhd/utils/thread.hpp>
#else // THREAD_PRIORITY_HPP_DEPRECATED
# include <uhd/utils/thread_priority.hpp>
#endif // THREAD_PRIORITY_HPP_DEPRECATED
#include <uhd/utils/safe_main.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <boost/program_options.hpp>

View File

@@ -15,7 +15,6 @@
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//
#include <uhd/utils/thread_priority.hpp>
#include <uhd/utils/safe_main.hpp>
#include <uhd/utils/paths.hpp>
#include <uhd/utils/algorithm.hpp>

View File

@@ -16,12 +16,17 @@
//
#include <uhd/utils/paths.hpp>
#ifdef THREAD_PRIORITY_HPP_DEPRECATED
# include <uhd/utils/thread.hpp>
#else // THREAD_PRIORITY_HPP_DEPRECATED
# include <uhd/utils/thread_priority.hpp>
#endif // THREAD_PRIORITY_HPP_DEPRECATED
#include <uhd/utils/algorithm.hpp>
#include <uhd/utils/msg.hpp>
#include "umtrx_log_adapter.hpp"
#include <uhd/property_tree.hpp>
#include <uhd/usrp/multi_usrp.hpp>
#include <uhd/usrp/dboard_eeprom.hpp>
#include <uhd/version.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <boost/thread/thread.hpp>
@@ -31,6 +36,7 @@
#include <complex>
#include <cmath>
#include <fstream>
#include <atomic>
namespace fs = boost::filesystem;
@@ -133,9 +139,15 @@ static void store_results(
std::string serial = get_serial(usrp, rx_tx);
//make the calibration file path
//UHD4 deprecated get_app_path and uses designated calibration path (introduced earlier)
//Don't break existing UHD3 installs, so use cal path only on UHD4
#if UHD_VERSION >= 4000000
fs::path cal_data_path = fs::path(uhd::get_cal_data_path());
#else
fs::path cal_data_path = fs::path(uhd::get_app_path()) / ".uhd";
fs::create_directory(cal_data_path);
cal_data_path = cal_data_path / "cal";
#endif
fs::create_directory(cal_data_path);
cal_data_path = cal_data_path / str(boost::format("%s_%s_cal_v0.2_%s.csv") % rx_tx % what % serial);
if (fs::exists(cal_data_path)){
@@ -227,7 +239,7 @@ static void capture_samples(
/***********************************************************************
* Transmit thread
**********************************************************************/
static void tx_thread(uhd::usrp::multi_usrp::sptr usrp, const double tx_wave_freq, const double tx_wave_ampl){
static void tx_thread(uhd::usrp::multi_usrp::sptr usrp, const double tx_wave_freq, const double tx_wave_ampl, std::atomic<bool> &interrupted){
uhd::set_thread_priority_safe();
//create a transmit streamer
@@ -246,7 +258,7 @@ static void tx_thread(uhd::usrp::multi_usrp::sptr usrp, const double tx_wave_fre
wave_table table(tx_wave_ampl);
//fill buff and send until interrupted
while (not boost::this_thread::interruption_requested()){
while (not interrupted){
for (size_t i = 0; i < buff.size(); i++){
buff[i] = table(index += step);
}