Commit graph

39 commits

Author SHA1 Message Date
Aaron Rossetto
463dbf9ac3 python: Add DDC RFNoC block controller bindings 2020-06-09 07:09:34 -05:00
Martin Braun
e62c93fe15 python: cal: Improve meas_device.py
- Remove some PyLint issues by aligning the argument list for
  SignalGeneratorBase.enable()
- Improve an assertion: Since a valid power level is 0 dBm, we need to
  explicitly check max power against None, not 0
- Improve the error message for when no device is found ("signal
  generator" instead of "RX measurement device", since the latter is
  confusing/ambiguous)
2020-06-03 15:15:14 -05:00
Martin Braun
65fbf053c0 utils/python: Add uhd_power_cal script
This is a tool for running power calibration.
2020-05-28 15:05:19 -05:00
Martin Braun
d9e8e82617 python: Add dsp sub-module
This lets you do

>>> from uhd import dsp
>>> s = dsp.signals.get_continuous_tone(...)
>>> pwr = dsp.signals.get_power_dbfs(s)

...and so on. This module is for UHD-based utilities to have some
additional signal processing functions to tap into.
2020-05-19 13:30:20 -05:00
Martin Braun
5edb92536f rfnoc: Remove 'six' dependency from image builder
Also fixes a few minor PyLint complaints.
2020-05-12 12:04:11 -05:00
Martin Braun
1bba62a75a Remove remaining Python 2 references
This changes two things in all applicable files:
- Remove imports from __future__
- Change default shebangs from /usr/bin/env python to /usr/bin/env
  python3
2020-05-07 15:10:41 -05:00
Martin Braun
75b7991378 python: Fix RPATH for the Python library
On UNIX systems, CMake will set the RPATH of the Python library to the
build directory, which is very helpful because it allows unit and other
tests to be executed from within the build directory.
On installation, the RPATH is removed, but only if install(TARGETS) is
used, which we were not, thus resulting in incorrect RPATHs.

This would surface as a bug, too. Calling uhd.get_lib_path() would
always point to the build directory, thus resulting in no FPGA images
being found automatically, e.g. when running a B200 through the Python
API.

This change installs the Python .so file separately, using the correct
CMake mechanisms.
2020-05-07 10:30:58 -05:00
Martin Braun
6a488d32eb python: Move the rfnoc image builder module under the uhd module
Note: This commit changes nothing to the way the image builder is being
called. One can still run

    rfnoc_image_builder [...]

as before. The difference is in the Python guts:
Where previously one had to do

    import rfnoc

now the incantation becomes:

    from uhd import imgbuilder

(Note that the submodule uhd.rfnoc already exists for wrapping the RFNoC
API into Python, hence the renaming from rfnoc to imgbuilder).

This is done for a variety of reasons:

- Now, there is only one and exactly one Python module for UHD that
  contains all the things, as opposed to before where there were two.
- The rfnoc and uhd modules were installed in different ways (setuptools
  vs. CMake); that is now harmonized. This also removes a lot of CMake
  plumbing.
- It is not common to import the rfnoc module for anyone other than
  rfnoc_image_builder
2020-05-05 08:04:50 -05:00
Martin Braun
1a19bc653e cal: Add pwr_cal container
This is a cal container for all types of power cal (RX or TX) that rely
on a single, overall gain value.

Includes Python API.
2020-04-17 07:58:19 -05:00
Martin Braun
3fe5ccf700 uhd: cal: Add iq_cal calibration data container class
This class can be used to store calibration coefficients for the X300
DC offset and IQ imbalance calibration.

Note: This also modifies Doxyfile.in to not document files generated by
flatc.
2020-04-02 11:55:17 -05:00
Martin Braun
f13615ec14 uhd: cal: Add database class
This class contains methods to store and retrieve data from the local
calibration database. Note that in this case, the "database" is just a
bunch of files on the local filesystem.
2020-03-26 07:46:03 -05:00
Martin Braun
e806238b27 python: Export UHD paths utility functions
All of the functions defined in uhd/utils/paths.hpp are now available in
Python, with the exception of get_module_paths().

    #!/usr/bin/env python3
    import uhd
    print(uhd.get_lib_path()) # Prints location of libuhd
2020-03-12 07:27:46 -05:00
Martin Braun
f8d3fe4109 python: Remove Python2-specific code 2020-03-12 07:27:46 -05:00
Martin Braun
932bab1eae python: Arrange file in Python module into uhd/ subdirectory
This adds the host/python/uhd subdirectory, which will add all files
that go into the actual Python module once installed. Before, all Python
files were directly in host/python and got sorted into their appropriate
destination folders during configuration and installation.

This change doesn't change anything (Python modules will look the same
as they do now), except that it makes the source tree a tad neater, but
more importantly, it creates a consistent directory structure when
adding submodules to the uhd module. Apart from the PyBind11-generated
shared object file (which gets generated during build time), the uhd/
subdirectory in host/python exactly resembles the Python module once
installed, so it's more obvious where to add new submodules and files.
2020-03-10 07:15:08 -05:00
Martin Braun
876d4150aa uhd: Apply clang-format against all .cpp and .hpp files in host/
Note: template_lvbitx.{cpp,hpp} need to be excluded from the list of
files that clang-format gets applied against.
2020-03-03 08:51:32 -06:00
Ryan Volz
2fab118bdc python: Set python module suffix to conform with PEP 3149.
This adds the python implementation, major and minor version numbers,
and any additional flags (debug, pymalloc, wide unicode) to the
extension module suffix as specified in PEP 3149.

Hat tip to @isuruf:
https://github.com/conda-forge/staged-recipes/pull/10076#discussion_r348721448
2020-02-07 09:12:15 -06:00
Ryan Volz
488a33cd9c python: Do not link against python lib for building an extension module.
This fixes a segmentation fault when trying to use the python module on
OSX when built with conda (unsure why it doesn't arise otherwise).
Instead of linking against the python library, it is proper to not link
against the library and, for OSX builds, add linker options for
"-undefined" and "dynamic_lookup". This is precisely what the CMake
FindPython module does for linking against the Python::Module target.

See https://blog.tim-smith.us/2015/09/python-extension-modules-os-x
and https://bugs.python.org/issue36721
2020-02-07 09:12:15 -06:00
Ryan Volz
ec96cc37a2 python: Fix internal library name (incl. suffix) to match filename.
Instead of renaming the library file, this sets the suffix in CMake so
that the filename turns out as desired and also linker references know
the correct name.
2020-02-07 09:12:15 -06:00
Brent Stapleton
c6a7bd6c52 python: rfnoc: finishing noc_block_base::get_mtu
Adding bindings for res_source_info, which allows us to use
noc_block_base::get_mtu.

Fixes: 400b00c343 ("rfnoc: adding RFNoC Python API")
2020-01-06 14:42:33 -08:00
Brent Stapleton
400b00c343 rfnoc: adding RFNoC Python API
Adding Python bindings for the RFNoC API. This includes the
rfnoc_graph, noc_block_base, and several other supporting classes.

Templated functions are not currently supported. For example,
`rfnoc_graph::get_block` can only return the basic block controller.
2020-01-02 15:38:56 -08:00
Martin Braun
1fe98e8701 uhd: Replace usage of boost smart pointers with C++11 counterparts
This removes the following Boost constructs:
- boost::shared_ptr, boost::weak_ptr
- boost::enable_shared_from_this
- boost::static_pointer_cast, boost::dynamic_pointer_cast

The appropriate includes were also removed. All C++11 versions of these
require #include <memory>.
Note that the stdlib and Boost versions have the exact same syntax, they
only differ in the namespace (boost vs. std). The modifications were all
done using sed, with the exception of boost::scoped_ptr, which was
replaced by std::unique_ptr.

References to boost::smart_ptr were also removed.

boost::intrusive_ptr is not removed in this commit, since it does not
have a 1:1 mapping to a C++11 construct.
2019-11-26 12:21:32 -08:00
iprivit
eb448043a9 python: MultiUSRP: Fix send_waveforms()
The send_waveform() function takes the waveform_proto array and if it
has only 1 channel, explicitly reshapes it to be
(1, waveform_proto.size), or uses np.tile to replicate the
waveform_proto array over X channels. It then proceeds to loop over the
waveform_proto array, but attempts to do so over the channel dimension
instead of looping over the actual samples. This results in sending the
entire waveform_proto array regardless of the duration specified.

The fix is to specify the dimension in which it crops, and not crop in
dimension of the channels.
2019-11-13 14:07:15 -08:00
erickshepherdNI
ebb06c983a python: Included complex.h to allow pybind to convert that data type 2019-11-01 16:35:33 -07:00
Martin Braun
f83faf28b3 cmake: Remove ENABLE_PYTHON3 flag and simplify Python detection
- Makes use of more modern find_package(Python2/3) if available
- Moves almost all Python-related code to UHDPython.cmake
- ENABLE_PYTHON3 is no longer necessary
2019-05-24 14:17:13 -07:00
Martin Braun
422b55f2bf cmake: python: Remove stray message() 2019-05-21 09:40:05 -07:00
Brent Stapleton
f258d72e25 python: change CMake variable for library ext
Changing the CMake variable used in determining the extension of the 
Python API library for better cross-platform support.

Specifically, `CMAKE_SHARED_MODULE_SUFFIX` corresponds to .so for *nix
and MacOS, which is the extension Python expects.
2019-03-06 16:01:10 -08:00
Trung Tran
1dbc0229b7 python: cmake: Use native format for setup.py
setuptools isn't compatible with Unix style path on Windows 10
machines. We need to convert any path before running setuptools.

Signed-off-by: Trung Tran <trung.tran@ettus.com>
2019-02-25 15:20:47 -08:00
Martin Braun
692ddc71b1 python: Replace Boost.Python with PyBind11
This does not change the Python API itself, but it is still
a significant change. Most importantly, it removes the dependency on
Boost.Python.
2019-02-22 16:56:52 -08:00
Brent Stapleton
32457928dd python: Add sync source to Python API
Exposing getters, setters, and options for multi_usrp sync source.
2018-11-29 09:50:02 -08:00
Brent Stapleton
388bc5229f python: adding device_addr_t to Python API
Add support for device_addr_t to the Python API. Most functions are
exposed normally. The main exception is the constructor from a map of
strings, which is replaced by a factory function called
`make_device_addr`.
2018-11-14 18:01:51 -08:00
Martin Braun
a69ab0c23a cmake: Update coding style to use lowercase commands
Also updates our coding style file.

Ancient CMake versions required upper-case commands.  Later command
names became case-insensitive.  Now the preferred style is lower-case.

Run the following shell code (with GNU compliant sed):

cmake --help-command-list | grep -v "cmake version" | while read c; do
  echo 's/\b'"$(echo $c | tr '[:lower:]' '[:upper:]')"'\(\s*\)(/'"$c"'\1(/g'
done > convert.sed \
&& git ls-files -z -- bootstrap '*.cmake' '*.cmake.in' \
'*CMakeLists.txt' | xargs -0 gsed -i -f convert.sed && rm convert.sed

(Make sure the backslashes don't get mangled!)
2018-11-14 14:10:09 -08:00
Marcus Müllr
89eac133ea python: Fixing Boost.Python initializer visibility
With Boost 1.64 to 1.65 (which, of course, Ubuntu LTS ships), the
`PyInit_Libraryname` are invisible when one sets the default visibility
to "hidden" (which is reasonable, and which we do).
2018-08-03 16:26:33 -07:00
Trung Tran
9805775200 uhd: python: CMakeLists.txt change dll to pyd
To support python api installer
2018-08-01 17:35:40 -07:00
Brent Stapleton
508023e0c7 python: Fixup for Python API install directory
The Python API should now be installed to
    `PREFIX/lib/pythonVER/dist-packages/uhd`
where the PREFIX is set by CMake and the Python version is determined
by the Python module `distutils`. This should match user expectations
much more than the previous behavior.

Behavior in Virtualenvs is unchanged.
2018-07-27 11:07:19 -07:00
Trung Tran
04987da515 cmake: add support to make python api installer on windows 2018-07-13 11:45:41 -07:00
Vidush
11074ebcb4 Python: Remove Unnecessary Metadata Assignment 2018-06-20 19:02:32 -05:00
Thibaud Marazano
dc5b37126e python: removing unnecessary configuration
Removed "set_tx_rate" that sets all channels initially, because the
channel loop handles this.

Reviewed-by: Brent Stapleton <brent.stapleton@ettus.com>
2018-06-20 19:02:32 -05:00
Paul David
e74cf7635b python: Separating exposed Python data structures
- Separating exposed Python data structures into logical sections
- Exposes all of the multi_usrp API
- Adds a layer of Python for documentation and adding helper methods
- Adds improvements and fixes to the MultiUSRP object
- Includes additional exposed data structures (like time_spec_t, etc.)
- Add code to release the Python GIL during long C++ calls
2018-06-20 19:02:32 -05:00
Andrej Rode
22e24497a5 python: Initial commit of Python API
Initial commit of the Python API using Boost.Python. Bind the
MultiUSRP API for use in Python. Bindings intended to provide as
complete coverage as possible.
- Wrap most multi_usrp calls
- Adding multi channel send/recv examples in examples/python
- Adding setuptools support
- Initial attempt at binding the UHD types and filters
2018-06-20 19:02:32 -05:00