Commit graph

100 commits

Author SHA1 Message Date
mattprost
0cf8a60a4e types: filters: Add python support for digital filters
Signed-off-by: mattprost <matt.prost@ni.com>
2022-04-07 13:28:02 -07:00
Wade Fife
246b725195 rfnoc: Update image builder to check for deprecated port names 2022-03-31 13:51:23 -07:00
Lars Amsel
99ad89609b tools: Add general purpose tool for USRP configuration
Over the years the UHD code base got a whole bunch of tools to
control and configure devices. This is an attempt to unify these
tools into one.

Co-authored-by: Alexander Weber <alexander.weber@ni.com>
2022-03-23 16:27:04 -05:00
Martin Braun
850ff3b2bf python: Add __init__ to uhd.utils
Without this, the following code fails:

>>> import uhd
>>> U = uhd.usrp.MultiUSRP("type=x4xx")
>>> M = U.get_mpm_client()
Traceback (most recent call last):
  File "<input>", line 1, in <module>
    M = U.get_mpm_client()
  File ".../uhd/usrp/multi_usrp.py", line 37, in <lambda>
    setattr(self,
        'get_mpm_client', lambda: _get_mpm_client(token, mb_args))
  File ".../uhd/usrp/multi_usrp.py", line 19, in _get_mpm_client
    from uhd.utils import mpmtools
ModuleNotFoundError: No module named 'uhd.utils'
2022-03-14 15:50:57 -05:00
Martin Braun
bcdb8a1b8f python: rfnoc: Add connect_through_blocks() and get_block_chain()
These RFNoC C++ API calls were previously not exported into Python.
2022-02-24 13:39:56 -06:00
André Apitzsch
0db4d4124f python: Read number of ports from grc file in image builder 2022-02-24 13:33:22 -06:00
André Apitzsch
8b19791f37 python: Fix RuntimeError: dictionary changed size during iteration
Iterate over copy and delete from original dictionary.
2022-02-24 13:33:22 -06:00
Steven Koo
396ed0c8af fixup! cmake: Replace distutils.sysconfig with sysconfig
The original commit incorrectly fails the build
uhd in the meta-ettus context. This uses prefix
instead to get the base path.

Signed-off-by: Steven Koo <steven.koo@ni.com>
2022-01-20 08:31:50 -06:00
Aaron Rossetto
87bc7c1bde cmake: Replace distutils.sysconfig with sysconfig
This commit replaces uses of distutils.sysconfig's get_python_lib()
function with sysconfig's near-equivalent get_path() function to get the
directory for site-specific, platform-specific files. Unfortunately,
get_path() does not have a way to easily modify or strip the prefix
applied to the path like get_python_lib() does, so the code must
manually modify the path to get the same effect:

- First, the platlib path is retrieved from the get_path() call.
- Next, the default base that is used to form the pathlib path is
queried via the get_config_var('base') call.
- Next, the portion of the platlib path that matches the default base is
stripped, and any leading path separator remaining is stripped. This
fundamentally replicates the behavior of get_python_lib() with an empty
prefix (i.e., the prefix positional parameter is specified as '').
- If a different prefix is desired, then the os.path.join() function is
used to combine the new prefix with the stripped pathlib path, ensuring
that the platform-specific path separator is used in crafting the path.
2022-01-14 14:36:39 -06:00
Aaron Rossetto
6d746fd296 cmake: Replace distutils with CMake for version checks
This commit replaces the use of distutils.version.LooseVersion() with
CMake's version comparison operator, which implements relational version
string checking in the same manner (i.e., comparing numeric components
of a version string numerically).
2022-01-14 14:36:39 -06:00
Lars Amsel
9ad4bedd86 fixup! uhd: Allow pass raw IQ data array to tone generator 2022-01-13 14:32:31 -06:00
Lars Amsel
d33deb3cae uhd: Allow pass raw IQ data array to tone generator
Instead of calculating a tone from its parameter it is also useful
to pass an precalculated signal to be played. This change modifies
the __init__ to take an iq_data as parameter for the internal buffer
and moves the generation of the tone from rate, frequency and amplitude
into a class method. The streamer parameter was deleted (never used).
2022-01-10 13:31:44 -06:00
Lars Amsel
f59f3c2490 tools: Add check for SEP with ctrl enabled to rfnoc_image_builder
When creating RFNoC images at least one SEP needs to have ctrl enabled
otherwise one will end up with a non-functional image.

This commit adds a method to the image builder to do plausibility checks
on the configuration. The only check done for now is to verify that there
is at least one SEP with ctrl enabled.
2021-12-16 09:26:46 -06:00
Martin Braun
4e1068671f python: multi_usrp: Fix issues in send_waveform()
- Like with RX, this now allows passing in stream time and existing
  streamer
- There was no EOB being sent at the end (now there is)
- Fixed some linter issues
2021-10-06 11:57:25 -07:00
Martin Braun
9650342c12 python: multi_usrp: Fix issues with recv_num_samps()
- This function didn't set the time properly for multi-chan rx
- There was no way to set a start time manually
- It relied on garbage collection and correct destruction of streamers
  when being called multiple times. Addressed this by adding an option
  to pass in an existing streamer object.
- Linter wasn't too happy with this function.
2021-10-06 11:57:25 -07:00
Martin Braun
09d94529e5 cmake: Replace CMAKE_{SOURCE,BINARY}_DIR with UHD_*_DIR
See the CMake 3.8 documentation on these two variables:
https://cmake.org/cmake/help/v3.8/variable/PROJECT-NAME_SOURCE_DIR.html
https://cmake.org/cmake/help/v3.8/variable/CMAKE_SOURCE_DIR.html

Under normal circumstances, these two are identical. For sub-projects
(i.e., when building UHD as part of something else that is also a CMake
project), only the former is useful. There is no discernible downside of
using UHD_SOURCE_DIR over CMAKE_SOURCE_DIR.

This was changed using sed:

$ sed -i "s/CMAKE_SOURCE_DIR/UHD_SOURCE_DIR/g" \
    `ag -l CMAKE_SOURCE_DIR **/{CMakeLists.txt,*.cmake}`
$ sed -i "s/CMAKE_BINARY_DIR/UHD_BINARY_DIR/g" \
    `ag -l CMAKE_BINARY_DIR **/{CMakeLists.txt,*.cmake}`

At the same time, we also replace the CMake variable UHD_HOST_ROOT (used
in MPM) with UHD_SOURCE_DIR. There's no reason to have two variables
with the same meaning and different names, but more importantly, this
means that UHD_SOURCE_DIR is defined even in those cases where MPM calls
into CMake files from UHD without any additional patches.

Shoutout to GitHub user marcobergamin for bringing this up.
2021-09-10 15:08:10 -05:00
Wade Fife
3d7d5668fb rfnoc: Add vivado-path to rfnoc_image_builder
Adds a --vivado-path option to rfnoc_image_builder that, if present,
gets passed to setupenv.sh for the target device. This can be used to
specify the location of Vivado if it is not installed in one of the
default search locations.
2021-09-10 15:07:05 -05:00
Martin Braun
8708164ac8 cal: Add tune-settling time
This is a device-specific parameter to allow for the tune to settle
before proceeding with the calibration. On X410, we set this time to 500
ms. On other devices, we leave it at 0.
2021-06-24 12:05:49 -05:00
Lars Amsel
abcaa3f6a9 cal: ensure proper range handling
* frequency range adapts the lower limit to align with the step size
  the lower limit will be set to step size if it s smaller than the
  step size and not explicitly set. This prevents uneven measurment
  spots
* aranges upper limit is always increased by step size to ensure the
  upper limit is part of the range
* rearranged gain range calculation, create the range once and reverse
  it for RX
2021-06-23 13:57:15 -05:00
Lars Amsel
067411a352 cal: Remove silent capture of TypeError
Remove the silent capture of TypeError because it would also
catch TypeErrors is initilization errors in class creation. Instead
check obj to be a class first to ensure issubclass wont throw a
TypeError.
2021-06-23 13:57:15 -05:00
Lars Amsel
7efa398272 cal: add more error number for ADC overload
also added short comment which erro originates from which driver
2021-06-23 13:57:15 -05:00
Martin Braun
1ca9a45ff5 cal: Add support for X410 2021-06-23 13:57:15 -05:00
Lars Amsel
2a575bf9b5 uhd: Add support for the USRP X410
Co-authored-by: Lars Amsel <lars.amsel@ni.com>
Co-authored-by: Michael Auchter <michael.auchter@ni.com>
Co-authored-by: Martin Braun <martin.braun@ettus.com>
Co-authored-by: Paul Butler <paul.butler@ni.com>
Co-authored-by: Cristina Fuentes <cristina.fuentes-curiel@ni.com>
Co-authored-by: Humberto Jimenez <humberto.jimenez@ni.com>
Co-authored-by: Virendra Kakade <virendra.kakade@ni.com>
Co-authored-by: Lane Kolbly <lane.kolbly@ni.com>
Co-authored-by: Max Köhler <max.koehler@ni.com>
Co-authored-by: Andrew Lynch <andrew.lynch@ni.com>
Co-authored-by: Grant Meyerhoff <grant.meyerhoff@ni.com>
Co-authored-by: Ciro Nishiguchi <ciro.nishiguchi@ni.com>
Co-authored-by: Thomas Vogel <thomas.vogel@ni.com>
2021-06-10 12:01:53 -05:00
Martin Braun
4fd3bfe203 cal: Add min_freq and max_freq attributes to USRPCalibratorBase
These allow specifying a min/max frequency on a device basis, instead of
querying those from get_?x_freq_range(). The trouble with those methods
is, they include the tune range provided by DSP tuning, which is not
what we want for this calibration.
2021-06-10 08:12:45 -05:00
Martin Braun
a04e0c2d30 cal: Fix minor issues in the calibration utilities
- Whitespace issues
- Unclear help messages
- Unnecessary derive-from-object
2021-06-10 08:12:45 -05:00
Wade Fife
ca21048bd2 fpga: Change RFNoC YAML version numbers to strings
Change version from a numeric to a string, in order to
differentiate between versions like "1.1" and "1.10".
2021-06-08 15:48:59 -05:00
Lars Amsel
1f001f2c29 python: Add graceful exit of claim loop on SIGTERM 2021-06-03 09:34:20 -05:00
Wade Fife
4ac80a4312 rfnoc: Add image_core_name option to rfnoc_image_builder
This change adds the ability to specify in the YAML description for
your RFNoC image what the rfnoc_image_core should be named. This allows
you to have multiple RFNoC image cores generated for the same target.
2021-06-02 22:00:40 -07:00
Wade Fife
fcb44a0618 python: Add rfnoc_image_core.vh generation
This causes a header file, rfnoc_image_core.vh, to be generated along
with rfnoc_image_core.v so that parameters like the CHDR width can be
shared betweend RFNoC and the BSP.
2021-06-02 22:00:40 -07:00
Wade Fife
51295c42bc python: Update RFNoC image builder to use CHDR_W parameter
CHDR_W was previosly hard coded to be 64, regardless of what the YAML
indicated. This updates to code to pull in the chdr_width from the YAML
image configuration file.
2021-06-02 22:00:40 -07:00
Lars Amsel
73462501f0 mpm: add unit tests for EEPROM readers 2021-05-31 05:28:47 -07:00
Martin Braun
60fb5d5f13 python: Add find() to the Python API
This a mapping of uhd::device::find() into uhd.find() on the Python
side. The uhd::device is intentionally not mapped into Python (prefer
MultiUSRP or RfnocGraph instead), so the namespace is moved up one
level.

Example:
>>> import uhd
>>> # Now print the device args for all found B200s:
>>> for dev_args in uhd.find("type=b200")): print(dev_args.to_string())
2020-12-07 11:53:35 -08:00
Martin Braun
fc2fc14b1a python: multi_usrp: Add get_mpm_client() API call
This is a new API call, only available on Python, and only available for
MPM devices (it is added dynamically). It returns an object that allows
calling RPC calls in a Pythonic manner.

Example:
>>> rpcc = usrp.get_mpm_client()
>>> print(rpcc.get_device_info()) # Will print device info, as returned
                                  # by uhd_find_devices
2020-12-04 12:06:14 -08:00
Martin Braun
31c544650f python: Add mpmtools module
This adds tools to create MPM clients and talk to MPM through Python
scripts.
2020-12-04 12:06:14 -08:00
Wade Fife
328c7a1fce python: Clean up image builder generated code
This updates the RFNoC image to generate code that's a bit more tidy,
with consistent spacing and better alignment.
2020-11-06 15:20:26 -06:00
Martin Braun
7ee106187e python: Add access to the property_tree from Python
Example:
>>> usrp = uhd.usrp.multi_usrp("")
>>> tree = usrp.get_tree()
>>> print(tree.access_int("/name").get())
2020-10-16 14:58:15 -05:00
Martin Braun
77511533a6 python: Move multi_usrp_python to its own module
This helps with recompilation times of UHD.
No functional changes.
2020-10-12 15:10:47 -05:00
Samuel O'Brien
f54a22c60a sim: Embed MPM into libpyuhd
When ENABLE_SIM and ENABLE_PYTHON_API are set, this commit embeds MPM
(Built with -DMPM_DEVICE=sim) into the pyuhd package.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-10-07 15:29:19 -05:00
Aaron Rossetto
c68977cffa cmake: Use relative path to Python lib location for Windows installer 2020-08-28 14:34:32 -05:00
Martin Braun
86ab211b84 python: power cal: Minor fixes to power cal code
- Fix some typos
- Fix incorrect arg name for RFSGPowerGenerator.enable()
- Fix case where incorrect args would cause an uncaught TypeError. Now,
  if USRP is chose as signal generator, but fails to find one, a proper
  error is shown.
2020-08-17 16:23:46 -05:00
Wade Fife
de8b6fcd71 python: Change default name for rfnoc_image_core
This changes the default name of the image core file to
<DEVICE>_rfnoc_image_core.v instead of naming it after the YAML file.
This ensures that when you use a custom YAML file, the resulting
FPGA build will use the generated rfnoc_image_core and static_router
files, rather than just the generated static_router file.
2020-08-10 15:18:46 -05:00
Aaron Rossetto
cf614ae5e0 python: Add Keep One in N block controller bindings 2020-08-05 07:47:22 -05:00
mattprost
6d4c07d09a python: Add replay RFNoC block controller bindings
Signed-off-by: mattprost <matt.prost@ni.com>
2020-08-04 15:40:30 -05:00
Samuel O'Brien
83ff556a54 python: Fix pyuhd to include subpackages
Originally, the setup.py file for pyuhd listed only one package

	packages=['uhd']

the setuptools docs: https://setuptools.readthedocs.io/en/latest/setuptools.html#using-find-packages
specify that this should also include subpackages, i.e uhd.dsp,
uhd.usrp, etc. Currently, when packaging libpyuhd, we are not including
the subpackages, and then when you run `import uhd`, it fails because
uhd.usrp and uhd.dsp don't exist.

This commit alleviates this issue by using setuptools.find_packages like
the docs recommend.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-08-04 07:43:48 -05:00
steviez
b5575603e1 utils: Use absolute paths in image builder build()
A segment of the build() function updates the working directory. This
change converts several paths to absolute paths to avoid having a
relative path (such as one containing up-level references) deviate from
its' intended meaning after the directory change.
2020-07-31 14:32:54 -05:00
Aaron Rossetto
fec41cd6a1 python: Add siggen RFNoC block controller bindings 2020-07-30 13:03:16 -05:00
Jesse Zhang
aca52b7002 python: Add Switchboard block python bindings 2020-07-30 12:51:11 -05:00
mattprost
1ec7380cf7 python: Add moving average RFNoC block controller bindings
Signed-off-by: mattprost <matt.prost@ni.com>
2020-07-16 12:14:49 -05:00
Samuel O'Brien
51bf7717e2 python: Add payload agnostic methods to CHDR API
In the c++ api, methods like chdr_packet#set_payload() and
chdr_packet#get_payload() are templated over the payload type
(payload_t). For methods like set_payload, they are overloaded by the
type of an argument, so in pybind we can just explicitly instaniate the
template for each payload_t and register it with pybind under the same
name. At runtime, pybind looks at the type of the argument and decides
which to call.

The problem arose with methods like get_payload, which are overloaded by
return type. In C++, the compiler can infer the template type by the
type of the target at the call site. In python, there is no way for the
pybind to determine which variant of get_payload to call, and it would
crash. Previously, the workaround for this was to declare
get_payload_ctrl, get_payload_mgmt, etc, but this was rather
anti-pythonic. This commit utilizes the fact that python methods don't
have a constrained return type to resolve this. Now, get_payload will
call a python method which looks at the chdr_packet#header#pkt_type
field to determine which variant of get_payload to call and returns that
type of payload_t.

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-16 09:59:25 -05:00
Samuel O'Brien
919a147afc python: Add bindings for C++ CHDR Parser
This commit adds pybind11 glue code for the userland chdr parsing code
introduced in the uhd::utils::chdr namespace. Additionally, it moves
some pybind11 adapter code to a common pybind_adaptors.hpp file which
originally existed in the cal_python.hpp file.

This commit also adds unit tests for the python bindings using a
captured wireshark trace which is located in rfnoc_packets_*.py and some
handwritten packets in hardcoded_packets.py

Signed-off-by: Samuel O'Brien <sam.obrien@ni.com>
2020-07-16 09:59:25 -05:00