{"id":15018841,"url":"https://github.com/ntia/tekrsa-api-wrap","last_synced_at":"2025-10-24T00:31:22.875Z","repository":{"id":49520998,"uuid":"434000415","full_name":"NTIA/tekrsa-api-wrap","owner":"NTIA","description":"A wrapper for the Tektronix RSA API for Linux, which streamlines control of Tektronix RSA devices using Python.","archived":false,"fork":false,"pushed_at":"2024-04-30T17:17:40.000Z","size":183,"stargazers_count":5,"open_issues_count":1,"forks_count":2,"subscribers_count":0,"default_branch":"main","last_synced_at":"2024-09-26T20:53:23.249Z","etag":null,"topics":["api-wrapper","linux","python","rf","scos","scos-sensor","sdr","software-defined-radio","spectrum-analysis","spectrum-analyzer","spectrum-management","tektronix","tektronix-products"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/NTIA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-12-01T22:07:07.000Z","updated_at":"2024-07-26T17:10:54.000Z","dependencies_parsed_at":"2024-04-29T16:40:39.998Z","dependency_job_id":"f956f4ba-d754-4aa6-940c-e13feaaae920","html_url":"https://github.com/NTIA/tekrsa-api-wrap","commit_stats":{"total_commits":116,"total_committers":5,"mean_commits":23.2,"dds":"0.31034482758620685","last_synced_commit":"cc70b86b8ec4b66d184ea73f735c6a0e0df7910d"},"previous_names":[],"tags_count":16,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NTIA%2Ftekrsa-api-wrap","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NTIA%2Ftekrsa-api-wrap/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NTIA%2Ftekrsa-api-wrap/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/NTIA%2Ftekrsa-api-wrap/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/NTIA","download_url":"https://codeload.github.com/NTIA/tekrsa-api-wrap/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219867315,"owners_count":16555821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api-wrapper","linux","python","rf","scos","scos-sensor","sdr","software-defined-radio","spectrum-analysis","spectrum-analyzer","spectrum-management","tektronix","tektronix-products"],"created_at":"2024-09-24T19:52:31.447Z","updated_at":"2025-10-24T00:31:22.512Z","avatar_url":"https://github.com/NTIA.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# NTIA/ITS Python Wrapper for Tektronix® RSA API for Linux\n\n![GitHub release (latest SemVer)](https://img.shields.io/github/v/release/NTIA/tekrsa-api-wrap?display_name=tag\u0026sort=semver)\n![PyPI - Downloads](https://img.shields.io/pypi/dm/tekrsa-api-wrap)\n![GitHub issues](https://img.shields.io/github/issues/NTIA/tekrsa-api-wrap)\n[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black)\n\nThis Python package provides a module which wraps the\n[Tektronix Python/Ctypes RSA API](https://github.com/tektronix/RSA_API/tree/master/Python),\nwith the goal of masking the Ctypes dependency and streamlining use of the API in a\nPython development environment. It implements most of the available RSA API functionality\n(see below for more information). Basic documentation is included in docstrings for quick\nreference during development, but this is not meant as a substitute for the comprehensive\n[RSA API Programming Reference manual](https://www.tek.com/spectrum-analyzer/rsa306-manual/rsa306-rsa306b-and-rsa500a-600a-0)\noffered by Tektronix. The manual details many peculiarities in API or device behavior\nwhich are not immediately obvious, and yet are important for developing software to\ncontrol an RSA device.\n\nThis wrapper was developed for applications involving programmatic control of Tektronix\nRSA devices from Linux. Depending on your use case, and especially if you plan to run\nyour program from Microsoft Windows®, it may be worth looking into the\n[Tektronix Python/Cython RSA API](https://github.com/tektronix/RSA_API/tree/master/Python/Cython%20Version)\ninstead of using this wrapper.\n\n## Table of Contents\n\n- [Installation](#installation)\n- [Usage](#usage)\n- [Development](#development)\n- [License](#license)\n- [Contact](#contact)\n- [Disclaimer](#disclaimer)\n\n## Installation\n\nRequires `python\u003e=3.9`, `numpy\u003e=1.25`, and the Tektronix RSA API for Linux.\n\nFirst, download and install the\n[RSA API for Linux](https://www.tek.com/spectrum-analyzer/rsa306-software/rsa-application-programming-interface--api-for-64bit-linux--v100014)\nfrom Tektronix. Follow the included installation instructions, then copy the\n`libRSA_API.so` and `libcyusb_shared.so` files into your project.\n\nThese shared object files are required, and this API wrapper by default expects to find\nthem in the [SCOS Sensor](https://github.com/NTIA/scos-sensor/) drivers directory\n(`/drivers/`). If you are running without SCOS Sensor, you will need to specify your\ndrivers directory when instantiating the API wrapper. See the [Usage section](#usage)\nbelow for an example of how to do this.\n\nNext download and install this API wrapper using `pip`:\n\n```bash\npip install tekrsa-api-wrap\n```\n\n## Usage\n\nInterface with a supported Tektronix RSA device using Python as follows:\n\n```python\nimport rsa_api\n\n# Directory which contains both libRSA_API.so and libcyusb_shared.so\ndrivers_path = '/path/to/shared_objects/'\n\n# Initialize an RSA device using the API wrapper\nrsa = rsa_api.RSA(so_dir=drivers_path)\n\n# Example usage: connect, print current center frequency, then disconnect\nrsa.DEVICE_SearchAndConnect()\nprint(f\"Current Center Frequency (Hz): {rsa.CONFIG_GetCenterFreq()}\")\nrsa.DEVICE_Disconnect()\n\n# Print docstrings for any implemented API function\nhelp(rsa.IQSTREAM_Acquire) # Requires initialized RSA device\nhelp(rsa_api.RSA.IQSTREAM_Acquire)  # Does not require initalized RSA device\n```\n\n### List of API functions NOT implemented\n\n- All functions not supported by the RSA API for Linux (see \"Known Issues\" below)\n- All `DPX`, `PLAYBACK`, `IFSTREAM` and `TRKGEN` functions\n- `DEVICE_GetErrorString()`\n  - Alternate error handling is implemented.\n- `DEVICE_GetNomenclatureW()` and `IQSTREAM_SetDiskFilenameBaseW()`\n  - `DEVICE_GetNomenclature()` and `IQSTREAM_SetDiskFilenameBase()` are used instead.\n- `IQBLK_GetIQDataCplx()`\n  - `IQBLK_GetIQData()` and `IQBLK_GetIQDataDeinterleaved()` are used instead.\n\n### List of API \"Helper\" functions\n\nA handful of useful functions are included in this wrapper which streamline some common\ntasks. These \"helper functions\" include:\n\n- `IQSTREAM_Acquire()`\n- `IQBLK_Acquire()`\n- `IQBLK_Configure()`\n- `SPECTRUM_Acquire()`\n- `IQSTREAMFileInfo_StatusParser()`\n- `IQSTREAMIQInfo_StatusParser()`\n- `IQSTREAM_Tempfile()`\n- `IQSTREAM_Tempfile_NoConfig()`\n- `DEVICE_SearchAndConnect()`\n- `DEVICE_GetTemperature()`\n\nTo read more about these functions, check their docstrings with `help()`.\n\n### Known Issues\n\nKnown issues exist in the underlying Tektronix RSA API for Linux, and therefore this\nwrapper is limited in certain ways. The list of known issues is provided by Tektronix in\nthe [Tektronix RSA API for Linux release notes](https://download.tek.com/software/supporting_files/ReleaseNotes_1_0_0014_64bit_066207701.txt)\n(up-to-date as of version 1.0.0014).\n\n### TODO: Update this section after resolving\n\nAdditionally, a known issue exists with parsing IQ streaming status data structures.\nThere appears to be a discrepancy between the documented status message encoding scheme\nand the implemented encoding scheme. In its current implementation, this API wrapper has\nbeen tested to ensure that ADC overrange events are properly flagged when using\n`IQSTREAM_Tempfile`, `IQSTREAM_Tempfile_NoConfig` or `IQSTREAM_Acquire` methods. Buffer\noverflow warnings and errors should work, but have not been tested. The USB data\ndiscontinuity status is unable to be parsed. Unknown IQ stream status codes are treated\nas errors and handled as configured in `IQSTREAM_StatusParser`.\n\n## Development\n\n### Development Environment\n\nSet up a development environment using a tool like\n[Conda](https://docs.conda.io/en/latest/)\nor [venv](https://docs.python.org/3/library/venv.html#module-venv).\nThen, from the cloned directory, install the development dependencies by running:\n\n```bash\npip install .[dev]\n```\n\nThis will install the project itself, along with development dependencies for pre-commit\nhooks, building distributions, and running tests. Set up pre-commit, which runs\nauto-formatting and code-checking automatically when you make a commit, by running:\n\n```bash\npre-commit install\n```\n\nThe pre-commit tool will auto-format Python code using [Black](https://github.com/psf/black)\nand [isort](https://github.com/pycqa/isort). Other pre-commit hooks are also enabled, and\ncan be found in [`.pre-commit-config.yaml`](.pre-commit-config.yaml).\n\n### Building New Releases\n\nThis project uses [Hatchling](https://github.com/pypa/hatch/tree/master/backend) as a\nbackend. Hatchling makes version control and building new releases easy. The package\nversion can be updated easily using any of the following commands.\n\n```bash\nhatchling version major  # 1.0.0 -\u003e 2.0.0\nhatchling version minor  # 1.0.0 -\u003e 1.1.0\nhatchling version micro  # 1.0.0 -\u003e 1.0.1\nhatchling version \"X.X.X\"  # 1.0.0 -\u003e X.X.X\n```\n\nTo build a wheel and source distribution, run:\n\n```bash\nhatchling build\n```\n\n### Running Tests\n\nA testing file is included in the `tests` directory of this repository. The test uses\n`unittest` to test supported API functions. Running a test requires an RSA device to be\nconnected. The same test is used for any supported RSA device, with some tests being\nenabled, disabled, or modified as needed depending on the device's specific supported\nAPI functions. For example, tests of the preamp configuration are not run when testing\nwith an RSA which does not have a preamp.\n\nFrom the top-level directory of this repository, run the test by running:\n\n  ```bash\n  export SO_DIR=/path/to/drivers\n  python -X faulthandler -m unittest\n  ```\n\nReplacing `\u003cpath-to-shared-objects\u003e` with the path to a directory containing both\n`libRSA_API.so` and `libcyusb_shared.so`.\n\nThis testing code was been adapted from the\n[Tektronix Cython RSA API testing code for the 306B](https://github.com/tektronix/RSA_API/blob/master/Python/Cython%20Version/test_rsa306b.py)\nand [for the 500A/600A series devices](https://github.com/tektronix/RSA_API/blob/master/Python/Cython%20Version/test_rsa500-600.py).\nIn addition to adapting this code to work with this API wrapper, various tests were also\nadded which were not present in the original versions, and the test was made to be\nuniversal for all supported RSA devices.\n\n## License\n\nSee [LICENSE](LICENSE.md)\n\nTEKTRONIX and TEK are registered trademarks of Tektronix, Inc.\n\nMicrosoft and Windows are trademarks of the Microsoft group of companies.\n\n## Contact\n\nFor technical questions, contact [the ITS Spectrum Monitoring Team](mailto:spectrummonitoring@ntia.gov).\n\n## Disclaimer\n\nCertain commercial equipment, instruments, or materials are identified in this project\nwere used for the convenience of the developers. In no case does such identification\nimply recommendation or endorsement by the National Telecommunications and Information\nAdministration, nor does it imply that the material or equipment identified is necessarily\nthe best available for the purpose.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntia%2Ftekrsa-api-wrap","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fntia%2Ftekrsa-api-wrap","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fntia%2Ftekrsa-api-wrap/lists"}