diff options
64 files changed, 507 insertions, 178 deletions
diff --git a/host/CMakeLists.txt b/host/CMakeLists.txt index 304ce8361..8bc761c42 100644 --- a/host/CMakeLists.txt +++ b/host/CMakeLists.txt @@ -43,7 +43,7 @@ SET(LIBRARY_DIR lib${LIB_SUFFIX}) SET(INCLUDE_DIR include) SET(PKG_DATA_DIR share/uhd) IF(NOT DEFINED PKG_LIB_DIR) - SET(PKG_LIB_DIR ${PKG_DATA_DIR}) + SET(PKG_LIB_DIR ${LIBRARY_DIR}/uhd) ENDIF() SET(PKG_DOC_DIR share/doc/uhd) diff --git a/host/cmake/Modules/FindORC.cmake b/host/cmake/Modules/FindORC.cmake new file mode 100644 index 000000000..bb212fb1b --- /dev/null +++ b/host/cmake/Modules/FindORC.cmake @@ -0,0 +1,28 @@ +######################################################################## +# Find the library for ORC development files +######################################################################## + +INCLUDE(FindPkgConfig) +PKG_CHECK_MODULES(PC_ORC "orc-0.4 > 0.4.11") + +FIND_PATH( + ORC_INCLUDE_DIRS + NAMES orc/orc.h + HINTS $ENV{ORC_DIR}/include/orc-0.4 + ${PC_ORC_INCLUDEDIR} + PATHS /usr/local/include/orc-0.4 + /usr/include/orc-0.4 +) + +FIND_LIBRARY( + ORC_LIBRARIES + NAMES orc-0.4 + HINTS $ENV{ORC_DIR}/lib + ${PC_ORC_LIBDIR} + PATHS /usr/local/lib + /usr/lib +) + +INCLUDE(FindPackageHandleStandardArgs) +FIND_PACKAGE_HANDLE_STANDARD_ARGS(ORC DEFAULT_MSG ORC_LIBRARIES ORC_INCLUDE_DIRS) +MARK_AS_ADVANCED(ORC_LIBRARIES ORC_INCLUDE_DIRS) diff --git a/host/cmake/Modules/FindUSB1.cmake b/host/cmake/Modules/FindUSB1.cmake index 8bfc2f975..626d06cc1 100644 --- a/host/cmake/Modules/FindUSB1.cmake +++ b/host/cmake/Modules/FindUSB1.cmake @@ -32,7 +32,20 @@ FIND_LIBRARY(LIBUSB_LIBRARIES PATHS /usr/local/lib /usr/lib /opt/local/lib ) +enable_language(C) #needs C support for check below +include(CheckFunctionExists) +if(LIBUSB_INCLUDE_DIRS) + set(CMAKE_REQUIRED_INCLUDES ${LIBUSB_INCLUDE_DIRS}) +endif() +if(LIBUSB_LIBRARIES) + set(CMAKE_REQUIRED_LIBRARIES ${LIBUSB_LIBRARIES}) +endif() +CHECK_FUNCTION_EXISTS("libusb_handle_events_timeout_completed" HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + +if(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + list(APPEND LIBUSB_DEFINITIONS "HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED=1") +endif(HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED) + include(FindPackageHandleStandardArgs) FIND_PACKAGE_HANDLE_STANDARD_ARGS(LIBUSB DEFAULT_MSG LIBUSB_LIBRARIES LIBUSB_INCLUDE_DIRS) MARK_AS_ADVANCED(LIBUSB_INCLUDE_DIRS LIBUSB_LIBRARIES) - diff --git a/host/cmake/Modules/UHDPackage.cmake b/host/cmake/Modules/UHDPackage.cmake index a535241a7..ae11c5042 100644 --- a/host/cmake/Modules/UHDPackage.cmake +++ b/host/cmake/Modules/UHDPackage.cmake @@ -109,7 +109,6 @@ SET(CPACK_COMPONENT_LIBRARIES_GROUP "Development") SET(CPACK_COMPONENT_HEADERS_GROUP "Development") SET(CPACK_COMPONENT_UTILITIES_GROUP "Runtime") SET(CPACK_COMPONENT_EXAMPLES_GROUP "Runtime") -SET(CPACK_COMPONENT_TESTS_GROUP "Runtime") SET(CPACK_COMPONENT_MANUAL_GROUP "Documentation") SET(CPACK_COMPONENT_DOXYGEN_GROUP "Documentation") SET(CPACK_COMPONENT_README_GROUP "Documentation") @@ -118,7 +117,6 @@ SET(CPACK_COMPONENT_LIBRARIES_DISPLAY_NAME "Libraries") SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ Headers") SET(CPACK_COMPONENT_UTILITIES_DISPLAY_NAME "Utilities") SET(CPACK_COMPONENT_EXAMPLES_DISPLAY_NAME "Examples") -SET(CPACK_COMPONENT_TESTS_DISPLAY_NAME "Unit Tests") SET(CPACK_COMPONENT_MANUAL_DISPLAY_NAME "Manual") SET(CPACK_COMPONENT_DOXYGEN_DISPLAY_NAME "Doxygen") SET(CPACK_COMPONENT_README_DISPLAY_NAME "Readme") @@ -128,7 +126,6 @@ SET(CPACK_COMPONENT_LIBRARIES_DESCRIPTION "Dynamic link library") SET(CPACK_COMPONENT_HEADERS_DESCRIPTION "C++ development headers") SET(CPACK_COMPONENT_UTILITIES_DESCRIPTION "Utility executables and python scripts") SET(CPACK_COMPONENT_EXAMPLES_DESCRIPTION "Example executables") -SET(CPACK_COMPONENT_TESTS_DESCRIPTION "Unit test executables") SET(CPACK_COMPONENT_MANUAL_DESCRIPTION "Manual/application notes (rst and html)") SET(CPACK_COMPONENT_DOXYGEN_DESCRIPTION "API documentation (html)") SET(CPACK_COMPONENT_README_DESCRIPTION "Readme files (txt)") @@ -140,7 +137,7 @@ SET(CPACK_COMPONENT_UTILITIES_DEPENDS libraries) SET(CPACK_COMPONENT_EXAMPLES_DEPENDS libraries) SET(CPACK_COMPONENT_TESTS_DEPENDS libraries) -SET(CPACK_COMPONENTS_ALL libraries headers utilities examples tests manual doxygen readme images) +SET(CPACK_COMPONENTS_ALL libraries headers utilities examples manual doxygen readme images) ######################################################################## # Setup CPack Debian @@ -179,11 +176,11 @@ SET(CPACK_NSIS_MODIFY_PATH ON) SET(HLKM_ENV "\\\"SYSTEM\\\\CurrentControlSet\\\\Control\\\\Session Manager\\\\Environment\\\"") SET(CPACK_NSIS_EXTRA_INSTALL_COMMANDS " - WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" \\\"$INSTDIR\\\\share\\\\uhd\\\" + WriteRegStr HKLM ${HLKM_ENV} \\\"UHD_PKG_PATH\\\" \\\"$INSTDIR\\\" ") SET(CPACK_NSIS_EXTRA_UNINSTALL_COMMANDS " - DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_DATA_PATH\\\" + DeleteRegValue HKLM ${HLKM_ENV} \\\"UHD_PKG_PATH\\\" ") ######################################################################## diff --git a/host/cmake/Modules/UHDUnitTest.cmake b/host/cmake/Modules/UHDUnitTest.cmake new file mode 100644 index 000000000..47cddc521 --- /dev/null +++ b/host/cmake/Modules/UHDUnitTest.cmake @@ -0,0 +1,110 @@ +# +# Copyright 2010-2012 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/>. +# + +######################################################################## +# Add a unit test and setup the environment for a unit test. +# Takes the same arguments as the ADD_TEST function. +# +# Before calling set the following variables: +# UHD_TEST_TARGET_DEPS - built targets for the library path +# UHD_TEST_LIBRARY_DIRS - directories for the library path +######################################################################## +function(UHD_ADD_TEST test_name) + + #Ensure that the build exe also appears in the PATH. + list(APPEND UHD_TEST_TARGET_DEPS ${ARGN}) + + #In the land of windows, all libraries must be in the PATH. + #Since the dependent libraries are not yet installed, + #we must manually set them in the PATH to run tests. + #The following appends the path of a target dependency. + foreach(target ${UHD_TEST_TARGET_DEPS}) + get_target_property(location ${target} LOCATION) + if(location) + get_filename_component(path ${location} PATH) + string(REGEX REPLACE "\\$\\(.*\\)" ${CMAKE_BUILD_TYPE} path ${path}) + list(APPEND UHD_TEST_LIBRARY_DIRS ${path}) + endif(location) + endforeach(target) + + file(TO_NATIVE_PATH ${CMAKE_CURRENT_SOURCE_DIR} srcdir) + file(TO_NATIVE_PATH "${UHD_TEST_LIBRARY_DIRS}" libpath) #ok to use on dir list? + + #http://www.cmake.org/pipermail/cmake/2009-May/029464.html + #Replaced this add test + set environs code with the shell script generation. + #Its nicer to be able to manually run the shell script to diagnose problems. + #ADD_TEST(${ARGV}) + #SET_TESTS_PROPERTIES(${test_name} PROPERTIES ENVIRONMENT "${environs}") + + if(UNIX) + set(LD_PATH_VAR "LD_LIBRARY_PATH") + if(APPLE) + set(LD_PATH_VAR "DYLD_LIBRARY_PATH") + endif() + + set(binpath "${CMAKE_CURRENT_BINARY_DIR}:$PATH") + list(APPEND libpath "$${LD_PATH_VAR}") + + #replace list separator with the path separator + string(REPLACE ";" ":" libpath "${libpath}") + list(APPEND environs "PATH=${binpath}" "${LD_PATH_VAR}=${libpath}") + + #generate a bat file that sets the environment and runs the test + find_program(SHELL sh) + set(sh_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.sh) + file(WRITE ${sh_file} "#!${SHELL}\n") + #each line sets an environment variable + foreach(environ ${environs}) + file(APPEND ${sh_file} "export ${environ}\n") + endforeach(environ) + #load the command to run with its arguments + foreach(arg ${ARGN}) + file(APPEND ${sh_file} "${arg} ") + endforeach(arg) + file(APPEND ${sh_file} "\n") + + #make the shell file executable + execute_process(COMMAND chmod +x ${sh_file}) + + add_test(${test_name} ${SHELL} ${sh_file}) + + endif(UNIX) + + if(WIN32) + list(APPEND libpath ${DLL_PATHS} "%PATH%") + + #replace list separator with the path separator (escaped) + string(REPLACE ";" "\\;" libpath "${libpath}") + list(APPEND environs "PATH=${libpath}") + + #generate a bat file that sets the environment and runs the test + set(bat_file ${CMAKE_CURRENT_BINARY_DIR}/${test_name}_test.bat) + file(WRITE ${bat_file} "@echo off\n") + #each line sets an environment variable + foreach(environ ${environs}) + file(APPEND ${bat_file} "SET ${environ}\n") + endforeach(environ) + #load the command to run with its arguments + foreach(arg ${ARGN}) + file(APPEND ${bat_file} "${arg} ") + endforeach(arg) + file(APPEND ${bat_file} "\n") + + add_test(${test_name} ${bat_file}) + endif(WIN32) + +endfunction(UHD_ADD_TEST) diff --git a/host/cmake/debian/postinst.in b/host/cmake/debian/postinst.in index eaca15394..bc27c46f0 100755 --- a/host/cmake/debian/postinst.in +++ b/host/cmake/debian/postinst.in @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2011 Ettus Research LLC +# Copyright 2011,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 @@ -17,7 +17,7 @@ # if [ "$1" = "configure" ]; then - cp @CMAKE_INSTALL_PREFIX@/share/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules + cp @CMAKE_INSTALL_PREFIX@/lib/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules udevadm control --reload-rules ldconfig fi diff --git a/host/cmake/redhat/post_install.in b/host/cmake/redhat/post_install.in index 01fd3338f..25864e0ec 100755 --- a/host/cmake/redhat/post_install.in +++ b/host/cmake/redhat/post_install.in @@ -1,6 +1,6 @@ #!/bin/sh # -# Copyright 2011 Ettus Research LLC +# Copyright 2011,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 @@ -16,6 +16,6 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # -cp @CMAKE_INSTALL_PREFIX@/share/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules +cp @CMAKE_INSTALL_PREFIX@/lib/uhd/utils/uhd-usrp.rules /etc/udev/rules.d/uhd-usrp.rules udevadm control --reload-rules ldconfig diff --git a/host/docs/build.rst b/host/docs/build.rst index 0a18e9e9a..00f79aaaa 100644 --- a/host/docs/build.rst +++ b/host/docs/build.rst @@ -1,5 +1,5 @@ ======================================================================== -UHD - Build Guide +UHD Software - Build Guide ======================================================================== .. contents:: Table of Contents diff --git a/host/docs/calibration.rst b/host/docs/calibration.rst index 1468a9c2a..3f7ea005e 100644 --- a/host/docs/calibration.rst +++ b/host/docs/calibration.rst @@ -7,11 +7,11 @@ UHD - Calibration Application Notes ------------------------------------------------------------------------ Self-calibration ------------------------------------------------------------------------ -UHD comes with several self-calibration utilities for minimizing IQ imbalance and DC offset. +UHD software comes with several self-calibration utilities for minimizing IQ imbalance and DC offset. These utilities perform calibration sweeps using transmit leakage into the receive path (special equipment is not required). The results from a calibration are written to a CSV file in the user's home directory. -UHD will automatically apply corrections at runtime when the user re-tunes the daughterboard LO. +UHD software will automatically apply corrections at runtime when the user re-tunes the daughterboard LO. Calibration results are specific to an individual RF board. **Note:** @@ -19,7 +19,7 @@ When a calibration table is present, and the user wishes to override the calibration settings through the API: the user should re-apply the desired setting every time the LO is re-tuned. -UHD comes with the following calibration utilities: +UHD software comes with the following calibration utilities: * **uhd_cal_rx_iq_balance:** - mimimizes RX IQ imbalance vs. LO frequency * **uhd_cal_tx_dc_offset:** - mimimizes TX DC offset vs. LO frequency @@ -34,7 +34,7 @@ The following RF frontends are supported by the self-calibration utilities: ******************************************** Calibration Utilities ******************************************** -UHD installs the calibration utilities into **<install-path>/bin**. +UHD software installs the calibration utilities into **<install-path>/bin**. **Disconnect** any external hardware from the RF antenna ports, and run the following from the command line. Each utility will take several minutes to complete. diff --git a/host/docs/coding.rst b/host/docs/coding.rst index ef8cb5fe2..432307cca 100644 --- a/host/docs/coding.rst +++ b/host/docs/coding.rst @@ -11,7 +11,7 @@ Various API interfaces Low-Level: The device API ^^^^^^^^^^^^^^^^^^^^^^^^^^^ A device is an abstraction for hardware that is connected to the host system. -For a USRP, this means that the motherboard and everything on it would be +For a USRP device, this means that the motherboard and everything on it would be considered to be a "device". The device API provides ways to: * Discover devices that are physically connected to the host system. @@ -25,6 +25,6 @@ See the documentation in *device.hpp* for reference. ^^^^^^^^^^^^^^^^^^^^^^^^^^^ High-Level: The Multi-USRP ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The Multi-USRP class provides a fat interface to a single USRP with -one or more channels, or multiple USRPs in a homogeneous setup. +The Multi-USRP class provides a fat interface to a single USRP device with +one or more channels, or multiple USRP devicess in a homogeneous setup. See the documentation in *usrp/multi_usrp.hpp* for reference. diff --git a/host/docs/dboards.rst b/host/docs/dboards.rst index 29812592f..3f4875c4c 100644 --- a/host/docs/dboards.rst +++ b/host/docs/dboards.rst @@ -1,5 +1,5 @@ ======================================================================== -UHD - Daughterboard Application Notes +UHD Daughterboard Application Notes ======================================================================== .. contents:: Table of Contents @@ -335,14 +335,14 @@ With the daughterboard plugged-in, run the following commands: cd <install-path>/share/uhd/utils ./usrp_burn_db_eeprom --id=0x000d --unit=RX --args=<args> --slot=<slot> -* **<args>** are device address arguments (optional if only one USRP is on your machine) -* **<slot>** is the name of the daughterboard slot (optional if the USRP has only one slot) +* **<args>** are device address arguments (optional if only one USRP device is on your machine) +* **<slot>** is the name of the daughterboard slot (optional if the USRP device has only one slot) ^^^^^^^^^^^^^^^^^^^^^^^^^^^ RFX - Mod ^^^^^^^^^^^^^^^^^^^^^^^^^^^ Older RFX boards require modifications to use the motherboard oscillator. -If this is the case, UHD will print a warning about the modification. +If this is the case, UHD software will print a warning about the modification. Please follow the modification procedures below: **Step 1: Disable the daughterboard clocks** @@ -377,5 +377,5 @@ With the daughterboard plugged-in, run the following commands: * **RFX1800:** 0x0035 * **RFX1200:** 0x002a * **RFX2400:** 0x002b -* **<args>** are device address arguments (optional if only one USRP is on your machine) -* **<slot>** is the name of the daughterboard slot (optional if the USRP has only one slot) +* **<args>** are device address arguments (optional if only one USRP device is on your machine) +* **<slot>** is the name of the daughterboard slot (optional if the USRP device has only one slot) diff --git a/host/docs/general.rst b/host/docs/general.rst index fc7caff3c..fc2735c46 100644 --- a/host/docs/general.rst +++ b/host/docs/general.rst @@ -23,10 +23,10 @@ frequency and actual frequency. The user may also explicitly control both stages of tuning through through the **tune_request_t** object, which allows for more advanced tuning. -In general, Using UHD's advanced tuning is highly recommended as it makes it +In general, Using UHD software's advanced tuning is highly recommended as it makes it easy to move the DC component out of your band-of-interest. This can be done by -passing your desired LO offset to the **tune_request_t** object, and letting UHD -handle the rest. +passing your desired LO offset to the **tune_request_t** object, and letting the UHD +software handle the rest. Tuning the receive chain: :: @@ -125,13 +125,13 @@ Overflow notes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When receiving, the device produces samples at a constant rate. Overflows occurs when the host does not consume data fast enough. -When UHD detects the overflow, it prints an "O" to stdout, +When UHD software detects the overflow, it prints an "O" to stdout, and pushes an inline message packet into the receive stream. **Network-based devices**: The host does not back-pressure the receive stream. When the kernel's socket buffer becomes full, it will drop subsequent packets. -UHD detects the overflow as a discontinuity in the packet's sequence numbers, +UHD software detects the overflow as a discontinuity in the packet's sequence numbers, and pushes an inline message packet into the receive stream. **Other devices**: @@ -140,14 +140,14 @@ Therefore, overflows always occur in the device itself. When the device's internal buffers become full, streaming is shut off, and an inline message packet is sent to the host. If the device was in continuous streaming mode, -UHD will automatically restart streaming. +the UHD software will automatically restart streaming. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Underflow notes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ When transmitting, the device consumes samples at a constant rate. Underflow occurs when the host does not produce data fast enough. -When UHD detects underflow, it prints a "U" to stdout, +When UHD software detects the underflow, it prints a "U" to stdout, and pushes a message packet into the async message stream. ------------------------------------------------------------------------ @@ -157,7 +157,7 @@ Threading Notes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thread safety notes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -For the most part, UHD is thread-safe. +For the most part, UHD software is thread-safe. Please observe the following limitations: **Fast-path thread requirements:** @@ -177,8 +177,8 @@ It is recommended to use at most one thread context for manipulating device sett Thread priority scheduling ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -When UHD spawns a new thread it may try to boost the thread's scheduling priority. -When setting the priority fails, UHD prints out an error. +When UHD software spawns a new thread it may try to boost the thread's scheduling priority. +When setting the priority fails, the UHD software prints out an error. This error is harmless; it simply means that the thread will have a normal scheduling priority. **Linux Notes:** @@ -211,7 +211,7 @@ Disabling or redirecting prints to stdout The user can disable the UHD library from printing directly to stdout by registering a custom message handler. The handler will intercept all messages, which can be dropped or redirected. Only one handler can be registered at a time. -Make **register_handler** your first call into UHD: +Make **register_handler** your first call into the UHD library: :: diff --git a/host/docs/identification.rst b/host/docs/identification.rst index a5e60e7f9..ba9b30898 100644 --- a/host/docs/identification.rst +++ b/host/docs/identification.rst @@ -5,7 +5,7 @@ UHD - Device Identification Notes .. contents:: Table of Contents ------------------------------------------------------------------------ -Identifying USRPs +Identifying USRP Devices ------------------------------------------------------------------------ Devices are addressed through key/value string pairs. These string pairs can be used to narrow down the search for a specific device or group of devices. @@ -89,10 +89,10 @@ such as detected daughterboards, frequency range, gain ranges, etc... uhd_usrp_probe --args <device-specific-address-args> ------------------------------------------------------------------------ -Naming a USRP +Naming a USRP Device ------------------------------------------------------------------------ -For convenience purposes, users may assign a custom name to their USRPs. -The USRP can then be identified via name, rather than a difficult to remember serial or address. +For convenience purposes, users may assign a custom name to their USRP device. +The USRP device can then be identified via name, rather than a difficult to remember serial or address. A name has the following properties: diff --git a/host/docs/images.rst b/host/docs/images.rst index dc9770460..95e2d96b0 100644 --- a/host/docs/images.rst +++ b/host/docs/images.rst @@ -29,7 +29,7 @@ See the UHD wiki for the download link. The pre-built images come in two forms: -* bundled with UHD in a platform-specific installer +* bundled with UHD software in a platform-specific installer * stand-alone platform-independent archive files ^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +59,7 @@ When installing images from an archive, there are two options: **Option 1:** Unpack the archive into the UHD installation prefix. -UHD will always search **<install-path>/share/uhd/images** for image files. +UHD software will always search **<install-path>/share/uhd/images** for image files. Where **<install-path>** was set by the **CMAKE_INSTALL_PREFIX** at configure-time. **Option 2:** diff --git a/host/docs/index.rst b/host/docs/index.rst index 00b1c9618..5e3d08fb4 100644 --- a/host/docs/index.rst +++ b/host/docs/index.rst @@ -2,17 +2,17 @@ UHD - USRP Hardware Driver ======================================================================== -UHD is the "Universal Software Radio Peripheral" hardware driver. -The goal of UHD is to provide a host driver and API for current and future Ettus Research products. +UHD software is the "Universal Software Radio Peripheral" Hardware Driver software. +The goal of UHD software is to provide a host driver and API for current and future Ettus Research products. Users will be able to use the UHD driver standalone or with third-party applications. ------------------------------------------------------------------------ Contents ------------------------------------------------------------------------ -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -Building and Installing UHD -^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +Building and Installing UHD Software +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ * `Build Guide <./build.html>`_ * `Installation Guide (Linux) <http://code.ettus.com/redmine/ettus/projects/uhd/wiki/UHD_Linux>`_ * `Installation Guide (Windows) <http://code.ettus.com/redmine/ettus/projects/uhd/wiki/UHD_Windows>`_ diff --git a/host/docs/sync.rst b/host/docs/sync.rst index 8622dc642..a1f6cb7df 100644 --- a/host/docs/sync.rst +++ b/host/docs/sync.rst @@ -4,9 +4,9 @@ UHD - Synchronization Application Notes .. contents:: Table of Contents -The following application notes explain how to synchronize multiple USRPs -with the goal of transmitting or receiving time-aligned samples for MIMO -or other applications requiring multiple USRPs operating synchronously. +The following application notes explain how to synchronize multiple USRP +devices with the goal of transmitting or receiving time-aligned samples for MIMO +or other applications requiring multiple USRP devices operating synchronously. **Note:** The following synchronization notes do not apply to USRP1, which does not support the advanced features available in newer products. @@ -14,7 +14,7 @@ which does not support the advanced features available in newer products. ------------------------------------------------------------------------ Common Reference Signals ------------------------------------------------------------------------ -USRPs take two reference signals in order to synchronize clocks and time: +USRP devices take two reference signals in order to synchronize clocks and time: * A 10MHz reference to provide a single frequency reference for both devices. * A pulse-per-second (PPS) to synchronize the sample time across devices. @@ -103,16 +103,16 @@ and the user can also parse this string to determine GPS time: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Method 3 - internal GPSDO ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -USRPs with internal GPSDOs properly configured will automatically +USRP devices with internal GPSDOs properly configured will automatically configure themselves to set the VITA time to current UTC time. See the `GPSDO Application Notes <./gpsdo.html>`_ for more details. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Method 4 - MIMO cable ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A USRP can synchronize its time to another USRP via the MIMO cable. +A USRP device can synchronize its time to another USRP device via the MIMO cable. Unlike the other methods, this does not use a real "pulse per second". -Rather, the USRP sends an encoded time message over the MIMO cable. +Rather, the USRP device sends an encoded time message over the MIMO cable. The slave device will automatically synchronize to the time on the master device. See the `MIMO Cable Application Notes <./usrp2.html#using-the-mimo-cable>`_ for more detail. @@ -123,7 +123,7 @@ Synchronizing Channel Phase ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Align CORDICs in the DSP ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -In order to achieve phase alignment between USRPs, the CORDICS in both +In order to achieve phase alignment between USRP devices, the CORDICS in both devices must be aligned with respect to each other. This is easily achieved by issuing stream commands with a time spec property, which instructs the streaming to begin at a specified time. Since the devices are already diff --git a/host/docs/transport.rst b/host/docs/transport.rst index 2e39e75d1..db89c8db9 100644 --- a/host/docs/transport.rst +++ b/host/docs/transport.rst @@ -14,7 +14,7 @@ These optional parameters control how the transport object allocates memory, resizes kernel buffers, spawns threads, etc. When not spcified, the transport layer will use values for these parameters that are known to perform well on a variety of systems. -The transport parameters are defined below for the various transports in the UHD: +The transport parameters are defined below for the various transports in the UHD software: ------------------------------------------------------------------------ UDP Transport (Sockets) @@ -154,11 +154,11 @@ so that non-root users may access the device: ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Install USB driver (Windows) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -A driver package must be installed to use a USB-based product with UHD: +A driver package must be installed to use a USB-based product with UHD software: * Download the driver from the UHD wiki page `here <http://files.ettus.com/binaries/misc/erllc_uhd_winusb_driver.zip>`_. * Unzip the file into a known location. We will refer to this as the **<directory>**. -* Open the device manager and plug in the USRP. You will see an unrecognized USB device in the device manager. +* Open the device manager and plug in the USRP device. You will see an unrecognized USB device in the device manager. * Right click on the unrecognized USB device and select update/install driver software (may vary for your OS). * In the driver installation wizard, select "browse for driver", browse to the **<directory>**, and select the **.inf** file. * Continue through the installation wizard until the driver is installed. diff --git a/host/docs/usrp1.rst b/host/docs/usrp1.rst index c1fdec146..b6fd24b09 100644 --- a/host/docs/usrp1.rst +++ b/host/docs/usrp1.rst @@ -79,7 +79,7 @@ Hardware Setup Notes ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ External clock modification ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The USRP can be modified to accept an external clock reference instead of the 64MHz onboard reference. +The USRP device can be modified to accept an external clock reference instead of the 64MHz onboard reference. * Solder SMA (**LTI-SASF54GT**) connector to **J2001**. * Move 0 ohm 0603 resistor **R2029** to **R2030**. * Move 0.01uF 0603 capacitor **C925** to **C926**. @@ -89,7 +89,7 @@ The new external clock needs to be a square wave between +7dBm and +15dBm After the hardware modification, the user should burn the setting into the EEPROM, -so UHD can initialize with the correct clock rate. +so UHD software can initialize with the correct clock rate. Run the following commands to record the setting into the EEPROM: :: diff --git a/host/docs/usrp2.rst b/host/docs/usrp2.rst index e675e61ba..5f1e51ea9 100644 --- a/host/docs/usrp2.rst +++ b/host/docs/usrp2.rst @@ -148,7 +148,7 @@ any parameters: ifconfig -a **Note:** -When using UHD, if an IP address for the USRP2 is not specified, +When using UHD software, if an IP address for the USRP2 is not specified, the software will use UDP broadcast packets to locate the USRP2. On some systems, the firewall will block UDP broadcast packets. It is recommended that you change or disable your firewall settings. @@ -213,13 +213,13 @@ The following tips are designed to help narrow down and diagnose the problem. RuntimeError: no control response ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ This is a common error that occurs when you have set the subnet of your network -interface to a different subnet than the network interface of the USRP. For -example, if your network interface is set to **192.168.20.1**, and the USRP is +interface to a different subnet than the network interface of the USRP device. For +example, if your network interface is set to **192.168.20.1**, and the USRP device is **192.168.10.2** (note the difference in the third numbers of the IP addresses), you will likely see a 'no control response' error message. Fixing this is simple - just set the your host PC's IP address to the same -subnet as that of your USRP. Instructions for setting your IP address are in the +subnet as that of your USRP device. Instructions for setting your IP address are in the previous section of this documentation. @@ -238,7 +238,7 @@ or create a rule to allow all incoming packets with UDP source port **49152**. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Ping the device ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -The USRP will reply to ICMP echo requests. +The USRP device will reply to ICMP echo requests. A successful ping response means that the device has booted properly and that it is using the expected IP address. @@ -346,7 +346,7 @@ the following clock configuration must be set on the slave device: ------------------------------------------------------------------------ Alternative stream destination ------------------------------------------------------------------------ -It is possible to program the USRP to send RX packets to an alternative IP/UDP destination. +It is possible to program the USRP device to send RX packets to an alternative IP/UDP destination. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Set the subnet and gateway @@ -429,7 +429,7 @@ Using a PPS signal for timestamp synchronization requires a square wave signal w Test the PPS input with the following app: -* **<args>** are device address arguments (optional if only one USRP is on your machine) +* **<args>** are device address arguments (optional if only one USRP device is on your machine) :: diff --git a/host/docs/usrp_b100.rst b/host/docs/usrp_b100.rst index cdb853b61..b5dc79b50 100644 --- a/host/docs/usrp_b100.rst +++ b/host/docs/usrp_b100.rst @@ -21,7 +21,7 @@ Comparative features list ------------------------------------------------------------------------ Specify a Non-standard Image ------------------------------------------------------------------------ -UHD will automatically select the USRP B-Series images from the installed images package. +UHD software will automatically select the USRP B-Series images from the installed images package. The image selection can be overridden with the **--fpga=** and **--fw=** device address parameters. Example device address string representations to specify non-standard images: @@ -54,7 +54,7 @@ and X4 must be populated with a 61.44 MHz oscillator. * **J15** is a three pin header, move the jumper to (pin1, pin2) * **357LB3I061M4400** is the recommended oscillator for X4 -**Note:** See instructions below to communicate the desired clock rate into UHD. +**Note:** See instructions below to communicate the desired clock rate into UHD software. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Set other rates - uses internal VCO @@ -63,7 +63,7 @@ To use other clock rates, the jumper will need to be in the default position. * **J15** is a three pin header, move the jumper to (pin2, pin3) -To communicate the desired clock rate into UHD, +To communicate the desired clock rate into UHD software, specify the a special device address argument, where the key is **master_clock_rate** and the value is a rate in Hz. Example: diff --git a/host/docs/usrp_e1x0.rst b/host/docs/usrp_e1x0.rst index 189cbb86b..fc929e639 100644 --- a/host/docs/usrp_e1x0.rst +++ b/host/docs/usrp_e1x0.rst @@ -22,7 +22,7 @@ Comparative features list ------------------------------------------------------------------------ Specify a Non-standard Image ------------------------------------------------------------------------ -UHD will automatically select the USRP-Embedded FPGA image from the +UHD software will automatically select the USRP-Embedded FPGA image from the installed images package. The FPGA image selection can be overridden with the **--fpga=** device address parameter. @@ -53,7 +53,7 @@ on the device. * **J16** is a two pin header; remove the jumper (or leave it on pin1 only). * **J15** is a three pin header; move the jumper to (pin1, pin2). -**Note:** See instructions below to communicate the desired clock rate UHD. +**Note:** See instructions below to communicate the desired clock rate to UHD software. ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Set other rates - uses internal VCO @@ -63,7 +63,7 @@ To use other clock rates, the jumpers will need to be in the default position. * **J16** is a two pin header; move the jumper to (pin1, pin2). * **J15** is a three pin header; move the jumper to (pin2, pin3). -To communicate the desired clock rate into UHD, +To communicate the desired clock rate into UHD software, specify the a special device address argument, where the key is **master_clock_rate** and the value is a rate in Hz. Example: @@ -103,7 +103,7 @@ a connector. Test the PPS input with the following app: -* **<args** are device address arguments (optional if only one USRP is on your machine). +* **<args** are device address arguments (optional if only one USRP device is on your machine). :: @@ -116,7 +116,7 @@ Internal GPSDO Please see the `Internal GPSDO Application Notes <./gpsdo.html>`_ for information on configuring and using the internal GPSDO. -UHD will always try to detect an installed GPSDO at runtime. +UHD software will always try to detect an installed GPSDO at runtime. There is not a special EEPROM value to burn for GPSDO detection. ------------------------------------------------------------------------ diff --git a/host/examples/benchmark_rate.cpp b/host/examples/benchmark_rate.cpp index 8a000f6c3..ed3a8580a 100644 --- a/host/examples/benchmark_rate.cpp +++ b/host/examples/benchmark_rate.cpp @@ -25,6 +25,7 @@ #include <boost/math/special_functions/round.hpp> #include <iostream> #include <complex> +#include <cstdlib> namespace po = boost::program_options; @@ -264,5 +265,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/latency_test.cpp b/host/examples/latency_test.cpp index 518d2383a..461ac9bf8 100644 --- a/host/examples/latency_test.cpp +++ b/host/examples/latency_test.cpp @@ -164,5 +164,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ **************************************************************/ std::cout << boost::format("\nACK %d, UNDERFLOW %d, TIME_ERR %d, other %d") % ack % underflow % time_error % other << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/network_relay.cpp b/host/examples/network_relay.cpp index e8f9e667f..bb09296b3 100644 --- a/host/examples/network_relay.cpp +++ b/host/examples/network_relay.cpp @@ -24,6 +24,7 @@ #include <iostream> #include <csignal> #include <vector> +#include <cstdlib> namespace po = boost::program_options; namespace asio = boost::asio; @@ -202,7 +203,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ << "Runs a network relay between UHD on one computer and a USRP on the network.\n" << "This example is basically for test purposes. Use at your own convenience.\n" << std::endl; - return ~0; + return EXIT_FAILURE; } { @@ -223,5 +224,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/rx_ascii_art_dft.cpp b/host/examples/rx_ascii_art_dft.cpp index fe8fb0347..1aede51a4 100644 --- a/host/examples/rx_ascii_art_dft.cpp +++ b/host/examples/rx_ascii_art_dft.cpp @@ -25,6 +25,7 @@ #include <curses.h> #include <iostream> #include <complex> +#include <cstdlib> namespace po = boost::program_options; @@ -63,7 +64,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //print the help message if (vm.count("help") or not vm.count("rate")){ std::cout << boost::format("UHD RX ASCII Art DFT %s") % desc << std::endl; - return ~0; + return EXIT_FAILURE; } //create a usrp device @@ -82,7 +83,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //set the sample rate if (not vm.count("rate")){ std::cerr << "Please specify the sample rate with --rate" << std::endl; - return ~0; + return EXIT_FAILURE; } std::cout << boost::format("Setting RX Rate: %f Msps...") % (rate/1e6) << std::endl; usrp->set_rx_rate(rate); @@ -91,7 +92,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //set the center frequency if (not vm.count("freq")){ std::cerr << "Please specify the center frequency with --freq" << std::endl; - return ~0; + return EXIT_FAILURE; } std::cout << boost::format("Setting RX Freq: %f MHz...") % (freq/1e6) << std::endl; usrp->set_rx_freq(freq); @@ -194,5 +195,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/rx_multi_samples.cpp b/host/examples/rx_multi_samples.cpp index 42ef33d70..83d648eb5 100644 --- a/host/examples/rx_multi_samples.cpp +++ b/host/examples/rx_multi_samples.cpp @@ -174,5 +174,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/rx_samples_to_file.cpp b/host/examples/rx_samples_to_file.cpp index 5197bfe69..d0a02a6c1 100644 --- a/host/examples/rx_samples_to_file.cpp +++ b/host/examples/rx_samples_to_file.cpp @@ -214,5 +214,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/rx_samples_to_udp.cpp b/host/examples/rx_samples_to_udp.cpp index 2acaa5d8b..f637f9313 100644 --- a/host/examples/rx_samples_to_udp.cpp +++ b/host/examples/rx_samples_to_udp.cpp @@ -168,5 +168,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/rx_timed_samples.cpp b/host/examples/rx_timed_samples.cpp index 143bceb03..f0d49b4bd 100644 --- a/host/examples/rx_timed_samples.cpp +++ b/host/examples/rx_timed_samples.cpp @@ -124,5 +124,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/test_dboard_coercion.cpp b/host/examples/test_dboard_coercion.cpp index 5b1e9f0e2..cfc745147 100644 --- a/host/examples/test_dboard_coercion.cpp +++ b/host/examples/test_dboard_coercion.cpp @@ -573,5 +573,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if(test_tx and test_rx) std::cout << std::endl; if(test_rx) std::cout << rx_results << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/test_messages.cpp b/host/examples/test_messages.cpp index afb092092..6f2ddfe28 100644 --- a/host/examples/test_messages.cpp +++ b/host/examples/test_messages.cpp @@ -350,5 +350,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/test_pps_input.cpp b/host/examples/test_pps_input.cpp index 994b7ca87..c07f2fffd 100644 --- a/host/examples/test_pps_input.cpp +++ b/host/examples/test_pps_input.cpp @@ -58,5 +58,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << std::endl << "Attempt to detect the PPS and set the time..." << std::endl << std::endl; usrp->set_time_unknown_pps(uhd::time_spec_t(0.0)); std::cout << std::endl << "Success!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/test_timed_commands.cpp b/host/examples/test_timed_commands.cpp index 34c83dfd6..cecf1607c 100644 --- a/host/examples/test_timed_commands.cpp +++ b/host/examples/test_timed_commands.cpp @@ -125,5 +125,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/transport_hammer.cpp b/host/examples/transport_hammer.cpp index e32912eaa..ff35ceb21 100644 --- a/host/examples/transport_hammer.cpp +++ b/host/examples/transport_hammer.cpp @@ -272,5 +272,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/tx_bursts.cpp b/host/examples/tx_bursts.cpp index 4cf5f2fd1..8dd4a002c 100644 --- a/host/examples/tx_bursts.cpp +++ b/host/examples/tx_bursts.cpp @@ -156,5 +156,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/tx_samples_from_file.cpp b/host/examples/tx_samples_from_file.cpp index 04a6a63d4..f9447c25d 100644 --- a/host/examples/tx_samples_from_file.cpp +++ b/host/examples/tx_samples_from_file.cpp @@ -192,5 +192,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/tx_timed_samples.cpp b/host/examples/tx_timed_samples.cpp index 3b8cc75d4..4cc31a7c0 100644 --- a/host/examples/tx_timed_samples.cpp +++ b/host/examples/tx_timed_samples.cpp @@ -124,5 +124,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/tx_waveforms.cpp b/host/examples/tx_waveforms.cpp index 3c5eecd65..40326ae93 100644 --- a/host/examples/tx_waveforms.cpp +++ b/host/examples/tx_waveforms.cpp @@ -260,5 +260,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/examples/txrx_loopback_to_file.cpp b/host/examples/txrx_loopback_to_file.cpp index 495c9f7e4..9dc348da8 100644 --- a/host/examples/txrx_loopback_to_file.cpp +++ b/host/examples/txrx_loopback_to_file.cpp @@ -443,5 +443,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //finished std::cout << std::endl << "Done!" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/include/uhd/types/tune_request.hpp b/host/include/uhd/types/tune_request.hpp index 9c498bfe9..dd6123a9f 100644 --- a/host/include/uhd/types/tune_request.hpp +++ b/host/include/uhd/types/tune_request.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010 Ettus Research LLC +// Copyright 2010-2012 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 @@ -19,6 +19,7 @@ #define INCLUDED_UHD_TYPES_TUNE_REQUEST_HPP #include <uhd/config.hpp> +#include <uhd/types/device_addr.hpp> namespace uhd{ @@ -88,6 +89,18 @@ namespace uhd{ */ double dsp_freq; + /*! + * The args parameter is used to pass arbitrary key/value pairs. + * Possible keys used by args (depends on implementation): + * + * - mode_n: Allows the user to tell the daughterboard tune code + * to choose between an integer N diviver or fractional N divider. + * Default is fractional N on boards that support fractional N tuning. + * Fractional N provides greater tuning acuracy at the expense of spurs. + * Possible options for this key: "integer" or "fractional". + */ + device_addr_t args; + }; } //namespace uhd diff --git a/host/include/uhd/utils/paths.hpp b/host/include/uhd/utils/paths.hpp index f5a40b2c9..e0f455e92 100644 --- a/host/include/uhd/utils/paths.hpp +++ b/host/include/uhd/utils/paths.hpp @@ -29,8 +29,8 @@ namespace uhd{ //! Get a string representing the system's appdata directory UHD_API std::string get_app_path(void); - //! Get a string representing the system's pkg data directory - UHD_API std::string get_pkg_data_path(void); + //! Get a string representing the system's pkg directory + UHD_API std::string get_pkg_path(void); } //namespace uhd diff --git a/host/include/uhd/version.hpp b/host/include/uhd/version.hpp index ab693f2b0..01e5c3cdb 100644 --- a/host/include/uhd/version.hpp +++ b/host/include/uhd/version.hpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2012 Ettus Research LLC +// Copyright 2010-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 @@ -27,7 +27,7 @@ * The format is oldest API compatible release - ABI compat number. * The compatibility number allows pre-release ABI to be versioned. */ -#define UHD_VERSION_ABI_STRING "3.4.0-3" +#define UHD_VERSION_ABI_STRING "3.6.0-0" namespace uhd{ diff --git a/host/lib/convert/CMakeLists.txt b/host/lib/convert/CMakeLists.txt index 0d9d0983f..28defa8bc 100644 --- a/host/lib/convert/CMakeLists.txt +++ b/host/lib/convert/CMakeLists.txt @@ -24,12 +24,11 @@ MESSAGE(STATUS "") ######################################################################## # Look for Orc support ######################################################################## -FIND_PACKAGE(PkgConfig) -IF(PKG_CONFIG_FOUND) -PKG_CHECK_MODULES(ORC "orc-0.4 > 0.4.11") -ENDIF(PKG_CONFIG_FOUND) +FIND_PACKAGE(ORC) -FIND_PROGRAM(ORCC_EXECUTABLE orcc) +IF(NOT ORCC_EXECUTABLE) + FIND_PROGRAM(ORCC_EXECUTABLE orcc) +ENDIF() LIBUHD_REGISTER_COMPONENT("ORC" ENABLE_ORC ON "ENABLE_LIBUHD;ORC_FOUND;ORCC_EXECUTABLE" OFF) diff --git a/host/lib/transport/CMakeLists.txt b/host/lib/transport/CMakeLists.txt index 6524a8412..4eb7c8c92 100644 --- a/host/lib/transport/CMakeLists.txt +++ b/host/lib/transport/CMakeLists.txt @@ -37,6 +37,10 @@ IF(ENABLE_USB) ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.cpp ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_base.hpp ) + SET_SOURCE_FILES_PROPERTIES( + ${CMAKE_CURRENT_SOURCE_DIR}/libusb1_zero_copy.cpp + PROPERTIES COMPILE_DEFINITIONS "${LIBUSB_DEFINITIONS}" + ) ELSE(ENABLE_USB) LIBUHD_APPEND_SOURCES( ${CMAKE_CURRENT_SOURCE_DIR}/usb_dummy_impl.cpp diff --git a/host/lib/transport/libusb1_zero_copy.cpp b/host/lib/transport/libusb1_zero_copy.cpp index 28bff9709..3532dc4aa 100644 --- a/host/lib/transport/libusb1_zero_copy.cpp +++ b/host/lib/transport/libusb1_zero_copy.cpp @@ -1,5 +1,5 @@ // -// Copyright 2010-2012 Ettus Research LLC +// Copyright 2010-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 @@ -36,6 +36,12 @@ static const size_t DEFAULT_XFER_SIZE = 32*512; //bytes #define LIBUSB_CALL #endif /*LIBUSB_CALL*/ +//! libusb_handle_events_timeout_completed is only in newer API +#ifndef HAVE_LIBUSB_HANDLE_EVENTS_TIMEOUT_COMPLETED + #define libusb_handle_events_timeout_completed(ctx, tx, completed)\ + libusb_handle_events_timeout(ctx, tx) +#endif + /*! * All libusb callback functions should be marked with the LIBUSB_CALL macro * to ensure that they are compiled with the same calling convention as libusb. @@ -43,7 +49,8 @@ static const size_t DEFAULT_XFER_SIZE = 32*512; //bytes //! helper function: handles all async callbacks static void LIBUSB_CALL libusb_async_cb(libusb_transfer *lut){ - *(static_cast<bool *>(lut->user_data)) = true; + int *completed = (int *)lut->user_data; + *completed = 1; } /*! @@ -61,7 +68,7 @@ static void LIBUSB_CALL libusb_async_cb(libusb_transfer *lut){ * \param completed a reference to the completed flag * \return true for completion, false for timeout */ -UHD_INLINE bool wait_for_completion(libusb_context *ctx, const double timeout, bool &completed){ +UHD_INLINE bool wait_for_completion(libusb_context *ctx, const double timeout, int &completed){ //already completed by a previous call? if (completed) return true; @@ -69,7 +76,7 @@ UHD_INLINE bool wait_for_completion(libusb_context *ctx, const double timeout, b timeval tv; tv.tv_sec = 0; tv.tv_usec = 0; - libusb_handle_events_timeout(ctx, &tv); + libusb_handle_events_timeout_completed(ctx, &tv, &completed); if (completed) return true; //finish the rest with a timeout loop @@ -78,7 +85,7 @@ UHD_INLINE bool wait_for_completion(libusb_context *ctx, const double timeout, b timeval tv; tv.tv_sec = 0; tv.tv_usec = 10000; /*10ms*/ - libusb_handle_events_timeout(ctx, &tv); + libusb_handle_events_timeout_completed(ctx, &tv, &completed); } return completed; @@ -96,7 +103,7 @@ public: _lut(lut), _frame_size(frame_size) { /* NOP */ } void release(void){ - completed = false; + completed = 0; _lut->length = _frame_size; //always reset length UHD_ASSERT_THROW(libusb_submit_transfer(_lut) == 0); } @@ -109,7 +116,7 @@ public: return managed_recv_buffer::sptr(); } - bool completed; + int completed; private: libusb_context *_ctx; @@ -129,7 +136,7 @@ public: _lut(lut), _frame_size(frame_size) { completed = true; } void release(void){ - completed = false; + completed = 0; _lut->length = size(); UHD_ASSERT_THROW(libusb_submit_transfer(_lut) == 0); } @@ -142,7 +149,7 @@ public: return managed_send_buffer::sptr(); } - bool completed; + int completed; private: libusb_context *_ctx; @@ -249,7 +256,7 @@ public: } //process all transfers until timeout occurs - bool completed = false; + int completed = 0; wait_for_completion(ctx, 0.01, completed); //free all transfers diff --git a/host/lib/transport/usb_zero_copy_wrapper.cpp b/host/lib/transport/usb_zero_copy_wrapper.cpp index d04244ca9..ec5667020 100644 --- a/host/lib/transport/usb_zero_copy_wrapper.cpp +++ b/host/lib/transport/usb_zero_copy_wrapper.cpp @@ -176,6 +176,14 @@ public: } managed_recv_buffer::sptr get_recv_buff(double timeout){ + //lazy flush mechanism - negative timeout + if (timeout < 0.0) + { + _last_recv_buff.reset(); + while (_internal_zc->get_recv_buff()){} + return managed_recv_buffer::sptr(); + } + //attempt to get a managed recv buffer if (not _last_recv_buff){ _last_recv_buff = _internal_zc->get_recv_buff(timeout); diff --git a/host/lib/usrp/b100/b100_impl.cpp b/host/lib/usrp/b100/b100_impl.cpp index c4d050242..b3237d547 100644 --- a/host/lib/usrp/b100/b100_impl.cpp +++ b/host/lib/usrp/b100/b100_impl.cpp @@ -516,6 +516,7 @@ void b100_impl::check_fw_compat(void){ "%s" ) % B100_FW_COMPAT_NUM % fw_compat_num % print_images_error())); } + _tree->create<std::string>("/mboards/0/fw_version").set(str(boost::format("%u.0") % fw_compat_num)); } void b100_impl::check_fpga_compat(void){ diff --git a/host/lib/usrp/b100/io_impl.cpp b/host/lib/usrp/b100/io_impl.cpp index 723756dcc..bcf712cd9 100644 --- a/host/lib/usrp/b100/io_impl.cpp +++ b/host/lib/usrp/b100/io_impl.cpp @@ -153,6 +153,10 @@ rx_streamer::sptr b100_impl::get_rx_stream(const uhd::stream_args_t &args_){ id.num_outputs = 1; my_streamer->set_converter(id); + //flush stuff + _data_transport->get_recv_buff(-1.0); //negative flushes!! + _recv_demuxer = recv_packet_demuxer::make(_data_transport, _rx_dsps.size(), B100_RX_SID_BASE); + //bind callbacks for the handler for (size_t chan_i = 0; chan_i < args.channels.size(); chan_i++){ const size_t dsp = args.channels[chan_i]; diff --git a/host/lib/usrp/common/recv_packet_demuxer.cpp b/host/lib/usrp/common/recv_packet_demuxer.cpp index f2cfe3bb0..fe606213c 100644 --- a/host/lib/usrp/common/recv_packet_demuxer.cpp +++ b/host/lib/usrp/common/recv_packet_demuxer.cpp @@ -19,6 +19,8 @@ #include <uhd/utils/msg.hpp> #include <uhd/utils/byteswap.hpp> #include <boost/thread/mutex.hpp> +#include <uhd/transport/vrt_if_packet.hpp> +#include <uhd/types/metadata.hpp> #include <queue> #include <deque> #include <vector> @@ -27,6 +29,19 @@ using namespace uhd; using namespace uhd::usrp; using namespace uhd::transport; +struct recv_pkt_demux_mrb : public managed_recv_buffer +{ +public: + recv_pkt_demux_mrb(void){/*NOP*/} + + void release(void) + { + delete this; + } + + boost::uint32_t buff[10]; +}; + static UHD_INLINE boost::uint32_t extract_sid(managed_recv_buffer::sptr &buff){ //ASSUME that the data is in little endian format return uhd::wtohx(buff->cast<const boost::uint32_t *>()[1]); @@ -66,7 +81,20 @@ public: //otherwise queue and try again if (rx_index < _queues.size()) _queues[rx_index].wrapper.push(buff); - else UHD_MSG(error) << "Got a data packet with unknown SID " << extract_sid(buff) << std::endl; + else + { + UHD_MSG(error) << "Got a data packet with unknown SID " << extract_sid(buff) << std::endl; + recv_pkt_demux_mrb *mrb = new recv_pkt_demux_mrb(); + vrt::if_packet_info_t info; + info.packet_type = vrt::if_packet_info_t::PACKET_TYPE_DATA; + info.num_payload_words32 = 1; + info.num_payload_bytes = info.num_payload_words32*sizeof(boost::uint32_t); + info.has_sid = true; + info.sid = _sid_base + index; + vrt::if_hdr_pack_le(mrb->buff, info); + mrb->buff[info.num_header_words32] = rx_metadata_t::ERROR_CODE_OVERFLOW; + return mrb->make(mrb, mrb->buff, info.num_packet_words32*sizeof(boost::uint32_t)); + } } } diff --git a/host/lib/usrp/gps_ctrl.cpp b/host/lib/usrp/gps_ctrl.cpp index f3bdded60..917f115f3 100644 --- a/host/lib/usrp/gps_ctrl.cpp +++ b/host/lib/usrp/gps_ctrl.cpp @@ -26,6 +26,10 @@ #include <boost/thread/thread.hpp> #include <boost/tokenizer.hpp> #include <boost/format.hpp> +#include <boost/regex.hpp> + +#include "boost/tuple/tuple.hpp" +#include "boost/foreach.hpp" using namespace uhd; using namespace boost::gregorian; @@ -38,14 +42,69 @@ using namespace boost::this_thread; */ class gps_ctrl_impl : public gps_ctrl{ +private: + std::map<std::string, boost::tuple<std::string, boost::system_time, bool> > sensors; + + std::string get_cached_sensor(const std::string sensor, const int freshness, const bool once, const bool touch=true) { + boost::system_time time = boost::get_system_time(); + try { + // this is nasty ... + //std::cout << boost::format("Requested %s - seen? ") % sensor << sensors[sensor].get<2>() << " once? " << once << std::endl; + if(time - sensors[sensor].get<1>() < milliseconds(freshness) && (!once or !sensors[sensor].get<2>())) { + sensors[sensor] = boost::make_tuple(sensors[sensor].get<0>(), sensors[sensor].get<1>(), touch); + return sensors[sensor].get<0>(); + } else { + return update_cached_sensors(sensor); + } + } catch(std::exception &e) { + UHD_MSG(warning) << "get_cached_sensor: " << e.what(); + } + return std::string(); + } + + std::string update_cached_sensors(const std::string sensor) { + if(not gps_detected() || (gps_type != GPS_TYPE_JACKSON_LABS)) { + UHD_MSG(error) << "get_stat(): unsupported GPS or no GPS detected"; + return std::string(); + } + + std::string msg = _recv(); + static const boost::regex status_regex("\\d\\d-\\d\\d-\\d\\d"); + boost::system_time time = boost::get_system_time(); + if(msg.size() < 6) + return std::string(); + + std::string nmea = msg.substr(1,5); + const std::list<std::string> list = boost::assign::list_of("GPGGA")("GPRMC"); + BOOST_FOREACH(std::string key, list) { + // beginning matches one of the NMEA keys + if(!nmea.compare(key)) { + sensors[key] = boost::make_tuple(msg, time, !sensor.compare(key)); + // if this was what we're looking for return it + return (!sensor.compare(key))? msg : std::string(); + } + } + + //We're still here so it's not one of the NMEA strings from above + if(boost::regex_search(msg, status_regex, boost::regex_constants::match_continuous)) { + trim(msg); + sensors["SERVO"] = boost::make_tuple(msg, time, false); + if(!sensor.compare("SERVO")) + return msg; + else + return std::string(); + } + return std::string(); + } public: gps_ctrl_impl(uart_iface::sptr uart){ _uart = uart; + std::string reply; bool i_heard_some_nmea = false, i_heard_something_weird = false; gps_type = GPS_TYPE_NONE; - + //first we look for a Jackson Labs Firefly (since that's what we provide...) _flush(); //get whatever junk is in the rx buffer right now, and throw it away _send("HAAAY GUYYYYS\n"); //to elicit a response from the Firefly @@ -60,7 +119,7 @@ public: if(reply.find("Command Error") != std::string::npos) { gps_type = GPS_TYPE_JACKSON_LABS; break; - } + } else if(reply.substr(0, 3) == "$GP") i_heard_some_nmea = true; //but keep looking for that "Command Error" response else if(reply.length() != 0) i_heard_something_weird = true; //probably wrong baud rate sleep(milliseconds(GPS_TIMEOUT_DELAY_MS)); @@ -99,7 +158,8 @@ public: ("gps_gpgga") ("gps_gprmc") ("gps_time") - ("gps_locked"); + ("gps_locked") + ("gps_servo"); return ret; } @@ -108,7 +168,7 @@ public: or key == "gps_gprmc") { return sensor_value_t( boost::to_upper_copy(key), - get_nmea(boost::to_upper_copy(key.substr(4,8))), + get_cached_sensor(boost::to_upper_copy(key.substr(4,8)), GPS_NMEA_NORMAL_FRESHNESS, false, false), ""); } else if(key == "gps_time") { @@ -117,6 +177,9 @@ public: else if(key == "gps_locked") { return sensor_value_t("GPS lock status", locked(), "locked", "unlocked"); } + else if(key == "gps_servo") { + return sensor_value_t("GPS servo status", get_servo(), ""); + } else { throw uhd::value_error("gps ctrl get_sensor unknown key: " + key); } @@ -138,24 +201,25 @@ private: sleep(milliseconds(FIREFLY_STUPID_DELAY_MS)); _send("GPS:GPRMC 1\n"); sleep(milliseconds(FIREFLY_STUPID_DELAY_MS)); + _send("SERV:TRAC 1\n"); // enable servo trace message + sleep(milliseconds(FIREFLY_STUPID_DELAY_MS)); } - + //retrieve a raw NMEA sentence std::string get_nmea(std::string msgtype) { - msgtype.insert(0, "$"); std::string reply; - if(not gps_detected()) { - UHD_MSG(error) << "get_nmea(): unsupported GPS or no GPS detected"; - return std::string(); - } - - _flush(); //flush all input before waiting for a message const boost::system_time comm_timeout = boost::get_system_time() + milliseconds(GPS_COMM_TIMEOUT_MS); while(boost::get_system_time() < comm_timeout) { - reply = _recv(); - if(reply.substr(0, 6) == msgtype) - return reply; + if(!msgtype.compare("GPRMC")) { + reply = get_cached_sensor(msgtype, GPS_NMEA_FRESHNESS, true); + } + else { + reply = get_cached_sensor(msgtype, GPS_NMEA_LOW_FRESHNESS, false); + } + if(reply.size()) { + if(reply.substr(1, 5) == msgtype) return reply; + } boost::this_thread::sleep(milliseconds(GPS_TIMEOUT_DELAY_MS)); } throw uhd::value_error(str(boost::format("get_nmea(): no %s message found") % msgtype)); @@ -178,7 +242,7 @@ private: ptime get_time(void) { int error_cnt = 0; ptime gps_time; - while(error_cnt < 3) { + while(error_cnt < 2) { try { std::string reply = get_nmea("GPRMC"); @@ -188,29 +252,30 @@ private: if(datestr.size() == 0 or timestr.size() == 0) { throw uhd::value_error(str(boost::format("Invalid response \"%s\"") % reply)); } - + //just trust me on this one - gps_time = ptime( date( + gps_time = ptime( date( greg_year(boost::lexical_cast<int>(datestr.substr(4, 2)) + 2000), - greg_month(boost::lexical_cast<int>(datestr.substr(2, 2))), - greg_day(boost::lexical_cast<int>(datestr.substr(0, 2))) + greg_month(boost::lexical_cast<int>(datestr.substr(2, 2))), + greg_day(boost::lexical_cast<int>(datestr.substr(0, 2))) ), hours( boost::lexical_cast<int>(timestr.substr(0, 2))) + minutes(boost::lexical_cast<int>(timestr.substr(2, 2))) + seconds(boost::lexical_cast<int>(timestr.substr(4, 2))) ); return gps_time; - + } catch(std::exception &e) { UHD_MSG(warning) << "get_time: " << e.what(); + _flush(); error_cnt++; } } throw uhd::value_error("Timeout after no valid message found"); - + return gps_time; //keep gcc from complaining } - + time_t get_epoch_time(void) { return (get_time() - from_time_t(0)).total_seconds(); } @@ -223,7 +288,7 @@ private: int error_cnt = 0; while(error_cnt < 3) { try { - std::string reply = get_nmea("GPGGA"); + std::string reply = get_cached_sensor("GPGGA", GPS_LOCK_FRESHNESS, false, false); if(reply.size() <= 1) return false; return (get_token(reply, 6) != "0"); @@ -236,6 +301,20 @@ private: return false; } + std::string get_servo(void) { + std::string reply; + + const boost::system_time comm_timeout = boost::get_system_time() + milliseconds(GPS_COMM_TIMEOUT_MS); + while(boost::get_system_time() < comm_timeout) { + reply = get_cached_sensor("SERVO", GPS_SERVO_FRESHNESS, false); + if(reply.size()) + return reply; + boost::this_thread::sleep(milliseconds(GPS_TIMEOUT_DELAY_MS)); + } + throw uhd::value_error("get_stat(): no servo message found"); + return std::string(); + } + uart_iface::sptr _uart; void _flush(void){ @@ -258,7 +337,12 @@ private: GPS_TYPE_NONE } gps_type; - static const int GPS_COMM_TIMEOUT_MS = 1500; + static const int GPS_COMM_TIMEOUT_MS = 1300; + static const int GPS_NMEA_FRESHNESS = 10; + static const int GPS_NMEA_LOW_FRESHNESS = 2500; + static const int GPS_NMEA_NORMAL_FRESHNESS = 1000; + static const int GPS_SERVO_FRESHNESS = 2500; + static const int GPS_LOCK_FRESHNESS = 2500; static const int GPS_TIMEOUT_DELAY_MS = 200; static const int FIREFLY_STUPID_DELAY_MS = 200; }; diff --git a/host/lib/usrp/multi_usrp.cpp b/host/lib/usrp/multi_usrp.cpp index 0331cf93a..46dd8b670 100644 --- a/host/lib/usrp/multi_usrp.cpp +++ b/host/lib/usrp/multi_usrp.cpp @@ -140,6 +140,14 @@ static tune_result_t tune_xx_subdev_and_dsp( } //------------------------------------------------------------------ + //-- poke the tune request args into the dboard + //------------------------------------------------------------------ + if (rf_fe_subtree->exists("tune_args")) + { + rf_fe_subtree->access<device_addr_t>("tune_args").set(tune_request.args); + } + + //------------------------------------------------------------------ //-- set the RF frequency depending upon the policy //------------------------------------------------------------------ double target_rf_freq = 0.0; diff --git a/host/lib/utils/CMakeLists.txt b/host/lib/utils/CMakeLists.txt index 95105f917..a28e1f9ef 100644 --- a/host/lib/utils/CMakeLists.txt +++ b/host/lib/utils/CMakeLists.txt @@ -115,14 +115,14 @@ SET_SOURCE_FILES_PROPERTIES( ######################################################################## # Define UHD_PKG_DATA_PATH for paths.cpp ######################################################################## -FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX}/${PKG_DATA_DIR} UHD_PKG_DATA_PATH) -STRING(REPLACE "\\" "\\\\" UHD_PKG_DATA_PATH ${UHD_PKG_DATA_PATH}) -MESSAGE(STATUS "Full package data directory: ${UHD_PKG_DATA_PATH}") +FILE(TO_NATIVE_PATH ${CMAKE_INSTALL_PREFIX} UHD_PKG_PATH) +STRING(REPLACE "\\" "\\\\" UHD_PKG_PATH ${UHD_PKG_PATH}) SET_SOURCE_FILES_PROPERTIES( ${CMAKE_CURRENT_SOURCE_DIR}/paths.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/images.cpp PROPERTIES COMPILE_DEFINITIONS - "UHD_PKG_DATA_PATH=\"${UHD_PKG_DATA_PATH}\"" + "UHD_PKG_PATH=\"${UHD_PKG_PATH}\";UHD_LIB_DIR=\"lib${LIB_SUFFIX}\"" ) ######################################################################## diff --git a/host/lib/utils/images.cpp b/host/lib/utils/images.cpp index 251cadeaa..1ba2f81e6 100644 --- a/host/lib/utils/images.cpp +++ b/host/lib/utils/images.cpp @@ -42,7 +42,7 @@ std::string uhd::find_image_path(const std::string &image_name){ } std::string uhd::find_images_downloader(void){ - return fs::path((fs::path(get_pkg_data_path()) / "utils" / "uhd_images_downloader.py")).string(); + return fs::path(fs::path(uhd::get_pkg_path()) / UHD_LIB_DIR / "uhd" / "utils" / "uhd_images_downloader.py").string(); } std::string uhd::print_images_error(void){ diff --git a/host/lib/utils/paths.cpp b/host/lib/utils/paths.cpp index 26fa6d1c7..53055314b 100644 --- a/host/lib/utils/paths.cpp +++ b/host/lib/utils/paths.cpp @@ -71,20 +71,20 @@ static std::vector<fs::path> get_env_paths(const std::string &var_name){ /*********************************************************************** * Get a list of special purpose paths **********************************************************************/ -std::string uhd::get_pkg_data_path(void) +std::string uhd::get_pkg_path(void) { - return get_env_var("UHD_PKG_DATA_PATH", UHD_PKG_DATA_PATH); + return get_env_var("UHD_PKG_PATH", UHD_PKG_PATH); } std::vector<fs::path> get_image_paths(void){ std::vector<fs::path> paths = get_env_paths("UHD_IMAGE_PATH"); - paths.push_back(fs::path(uhd::get_pkg_data_path()) / "images"); + paths.push_back(fs::path(uhd::get_pkg_path()) / "share" / "uhd" / "images"); return paths; } std::vector<fs::path> get_module_paths(void){ std::vector<fs::path> paths = get_env_paths("UHD_MODULE_PATH"); - paths.push_back(fs::path(uhd::get_pkg_data_path()) / "modules"); + paths.push_back(fs::path(uhd::get_pkg_path()) / UHD_LIB_DIR / "uhd" / "modules"); return paths; } diff --git a/host/tests/CMakeLists.txt b/host/tests/CMakeLists.txt index 67e99941b..f5cead184 100644 --- a/host/tests/CMakeLists.txt +++ b/host/tests/CMakeLists.txt @@ -16,6 +16,11 @@ # ######################################################################## +# unit test support +######################################################################## +include(UHDUnitTest) + +######################################################################## # unit test suite ######################################################################## SET(test_sources @@ -39,13 +44,15 @@ SET(test_sources #turn each test cpp file into an executable with an int main() function ADD_DEFINITIONS(-DBOOST_TEST_DYN_LINK -DBOOST_TEST_MAIN) -#for each source: build an executable, register it as a test, and install +SET(UHD_TEST_TARGET_DEPS uhd) +SET(UHD_TEST_LIBRARY_DIRS ${Boost_LIBRARY_DIRS}) + +#for each source: build an executable, register it as a test FOREACH(test_source ${test_sources}) GET_FILENAME_COMPONENT(test_name ${test_source} NAME_WE) ADD_EXECUTABLE(${test_name} ${test_source}) TARGET_LINK_LIBRARIES(${test_name} uhd) - ADD_TEST(${test_name} ${test_name}) - INSTALL(TARGETS ${test_name} RUNTIME DESTINATION ${PKG_LIB_DIR}/tests COMPONENT tests) + UHD_ADD_TEST(${test_name} ${test_name}) ENDFOREACH(test_source) ######################################################################## diff --git a/host/tests/time_spec_test.cpp b/host/tests/time_spec_test.cpp index 102b7cda3..139a113af 100644 --- a/host/tests/time_spec_test.cpp +++ b/host/tests/time_spec_test.cpp @@ -97,3 +97,14 @@ BOOST_AUTO_TEST_CASE(test_time_spec_neg_values){ BOOST_CHECK(tsa > tsb); BOOST_CHECK(tsc > tsd); } + +BOOST_AUTO_TEST_CASE(test_time_large_ticks_to_time_spec) +{ + std::cout << "sizeof(time_t) " << sizeof(time_t) << std::endl; + const boost::uint64_t ticks0 = boost::uint64_t(100e6*1360217663.739296); + const uhd::time_spec_t t0 = uhd::time_spec_t::from_ticks(ticks0, 100e6); + std::cout << "t0.get_real_secs() " << t0.get_real_secs() << std::endl; + std::cout << "t0.get_full_secs() " << t0.get_full_secs() << std::endl; + std::cout << "t0.get_frac_secs() " << t0.get_frac_secs() << std::endl; + BOOST_CHECK_EQUAL(t0.get_full_secs(), time_t(1360217663)); +} diff --git a/host/utils/fx2_init_eeprom.cpp b/host/utils/fx2_init_eeprom.cpp index c210ae575..701092a5d 100644 --- a/host/utils/fx2_init_eeprom.cpp +++ b/host/utils/fx2_init_eeprom.cpp @@ -41,12 +41,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ po::variables_map vm; po::store(po::parse_command_line(argc, argv, desc), vm); - po::notify(vm); + po::notify(vm); //print the help message if (vm.count("help")){ std::cout << boost::format("USRP EEPROM initialization %s") % desc << std::endl; - return ~0; + return EXIT_FAILURE; } //cant find a uninitialized usrp with this mystery module in the way... @@ -76,7 +76,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if (found_addrs.size() == 0){ std::cerr << "No USRP devices found" << std::endl; - return ~0; + return EXIT_FAILURE; } for (size_t i = 0; i < found_addrs.size(); i++){ @@ -89,5 +89,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "Power-cycle the usrp for the changes to take effect." << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/utils/uhd_cal_rx_iq_balance.cpp b/host/utils/uhd_cal_rx_iq_balance.cpp index 68d0443da..5fb494114 100644 --- a/host/utils/uhd_cal_rx_iq_balance.cpp +++ b/host/utils/uhd_cal_rx_iq_balance.cpp @@ -29,6 +29,7 @@ #include <complex> #include <cmath> #include <ctime> +#include <cstdlib> namespace po = boost::program_options; @@ -120,7 +121,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "This application measures leakage between RX and TX on an XCVR daughterboard to self-calibrate.\n" << std::endl; - return ~0; + return EXIT_FAILURE; } //create a usrp device @@ -239,5 +240,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ store_results(usrp, results, "RX", "rx", "iq"); - return 0; + return EXIT_SUCCESS; } diff --git a/host/utils/uhd_cal_tx_dc_offset.cpp b/host/utils/uhd_cal_tx_dc_offset.cpp index 8f69b3ce1..c9cf757f4 100644 --- a/host/utils/uhd_cal_tx_dc_offset.cpp +++ b/host/utils/uhd_cal_tx_dc_offset.cpp @@ -123,7 +123,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "This application measures leakage between RX and TX on an XCVR daughterboard to self-calibrate.\n" << std::endl; - return ~0; + return EXIT_FAILURE; } //create a usrp device @@ -237,5 +237,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ store_results(usrp, results, "TX", "tx", "dc"); - return 0; + return EXIT_SUCCESS; } diff --git a/host/utils/uhd_cal_tx_iq_balance.cpp b/host/utils/uhd_cal_tx_iq_balance.cpp index 5478b07e3..20d018edf 100644 --- a/host/utils/uhd_cal_tx_iq_balance.cpp +++ b/host/utils/uhd_cal_tx_iq_balance.cpp @@ -28,6 +28,7 @@ #include <iostream> #include <complex> #include <ctime> +#include <cstdlib> namespace po = boost::program_options; @@ -123,7 +124,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << "This application measures leakage between RX and TX on an XCVR daughterboard to self-calibrate.\n" << std::endl; - return ~0; + return EXIT_FAILURE; } //create a usrp device @@ -242,5 +243,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ store_results(usrp, results, "TX", "tx", "iq"); - return 0; + return EXIT_SUCCESS; } diff --git a/host/utils/uhd_find_devices.cpp b/host/utils/uhd_find_devices.cpp index b778eeb68..c258c580e 100644 --- a/host/utils/uhd_find_devices.cpp +++ b/host/utils/uhd_find_devices.cpp @@ -20,6 +20,7 @@ #include <boost/program_options.hpp> #include <boost/format.hpp> #include <iostream> +#include <cstdlib> namespace po = boost::program_options; @@ -37,7 +38,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //print the help message if (vm.count("help")){ std::cout << boost::format("UHD Find Devices %s") % desc << std::endl; - return ~0; + return EXIT_FAILURE; } //discover the usrps and print the results @@ -45,7 +46,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if (device_addrs.size() == 0){ std::cerr << "No UHD Devices Found" << std::endl; - return ~0; + return EXIT_FAILURE; } for (size_t i = 0; i < device_addrs.size(); i++){ @@ -56,5 +57,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //uhd::device::make(device_addrs[i]); //test make } - return 0; + return EXIT_SUCCESS; } diff --git a/host/utils/uhd_usrp_probe.cpp b/host/utils/uhd_usrp_probe.cpp index 5b3702fb4..736490f19 100644 --- a/host/utils/uhd_usrp_probe.cpp +++ b/host/utils/uhd_usrp_probe.cpp @@ -30,6 +30,7 @@ #include <iostream> #include <sstream> #include <vector> +#include <cstdlib> namespace po = boost::program_options; using namespace uhd; @@ -197,12 +198,12 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ //print the help message if (vm.count("help")){ std::cout << boost::format("UHD USRP Probe %s") % desc << std::endl; - return ~0; + return EXIT_FAILURE; } if (vm.count("version")){ std::cout << uhd::get_version_string() << std::endl; - return 0; + return EXIT_SUCCESS; } device::sptr dev = device::make(vm["args"].as<std::string>()); @@ -210,11 +211,11 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ if (vm.count("string")){ std::cout << tree->access<std::string>(vm["string"].as<std::string>()).get() << std::endl; - return 0; + return EXIT_SUCCESS; } if (vm.count("tree") != 0) print_tree("/", tree); else std::cout << make_border(get_device_pp_string(tree)) << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/utils/usrp_burn_db_eeprom.cpp b/host/utils/usrp_burn_db_eeprom.cpp index b6b2dc4d6..3ca953115 100644 --- a/host/utils/usrp_burn_db_eeprom.cpp +++ b/host/utils/usrp_burn_db_eeprom.cpp @@ -58,7 +58,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ "Omit the ID argument to perform readback,\n" "Or specify a new ID to burn into the EEPROM.\n" ) << std::endl; - return ~0; + return EXIT_FAILURE; } //make the device and extract the dboard w/ property @@ -96,5 +96,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ std::cout << boost::format(" Current revision: \"%s\"") % db_eeprom.revision << std::endl; std::cout << " Done" << std::endl << std::endl; - return 0; + return EXIT_SUCCESS; } diff --git a/host/utils/usrp_burn_mb_eeprom.cpp b/host/utils/usrp_burn_mb_eeprom.cpp index ca9a6c8ba..1b13fb615 100644 --- a/host/utils/usrp_burn_mb_eeprom.cpp +++ b/host/utils/usrp_burn_mb_eeprom.cpp @@ -47,7 +47,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ "Omit the value argument to perform a readback,\n" "Or specify a new value to burn into the EEPROM.\n" ) << std::endl; - return ~0; + return EXIT_FAILURE; } std::cout << "Creating USRP device from address: " + args << std::endl; @@ -60,7 +60,7 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ uhd::usrp::mboard_eeprom_t mb_eeprom = tree->access<uhd::usrp::mboard_eeprom_t>("/mboards/0/eeprom").get(); if (not mb_eeprom.has_key(key)){ std::cerr << boost::format("Cannot find value for EEPROM[%s]") % key << std::endl; - return ~0; + return EXIT_FAILURE; } std::cout << boost::format(" EEPROM [\"%s\"] is \"%s\"") % key % mb_eeprom[key] << std::endl; std::cout << std::endl; @@ -74,5 +74,5 @@ int UHD_SAFE_MAIN(int argc, char *argv[]){ } std::cout << "Done" << std::endl; - return 0; + return EXIT_SUCCESS; } |