sdrnative 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. sdrnative-0.1.0/.clang-format +5 -0
  2. sdrnative-0.1.0/.github/workflows/pypi.yml +102 -0
  3. sdrnative-0.1.0/.gitignore +20 -0
  4. sdrnative-0.1.0/CMakeLists.txt +211 -0
  5. sdrnative-0.1.0/CONTRIBUTING.md +14 -0
  6. sdrnative-0.1.0/Changelog +3 -0
  7. sdrnative-0.1.0/INSTALL.md +54 -0
  8. sdrnative-0.1.0/LICENSE +373 -0
  9. sdrnative-0.1.0/NOTICE +13 -0
  10. sdrnative-0.1.0/PKG-INFO +99 -0
  11. sdrnative-0.1.0/README.md +29 -0
  12. sdrnative-0.1.0/bindings/node/CMakeLists.txt +83 -0
  13. sdrnative-0.1.0/bindings/node/LICENSE +373 -0
  14. sdrnative-0.1.0/bindings/node/NOTICE +10 -0
  15. sdrnative-0.1.0/bindings/node/README.md +76 -0
  16. sdrnative-0.1.0/bindings/node/index.d.ts +229 -0
  17. sdrnative-0.1.0/bindings/node/index.js +298 -0
  18. sdrnative-0.1.0/bindings/node/package.json +41 -0
  19. sdrnative-0.1.0/bindings/node/scripts/build.js +34 -0
  20. sdrnative-0.1.0/bindings/node/src/addon.cc +1247 -0
  21. sdrnative-0.1.0/bindings/node/test/contract.test.js +107 -0
  22. sdrnative-0.1.0/bindings/node/test/types.ts +49 -0
  23. sdrnative-0.1.0/bindings/python/LICENSE +373 -0
  24. sdrnative-0.1.0/bindings/python/README.md +78 -0
  25. sdrnative-0.1.0/bindings/python/sdrnative/__init__.py +115 -0
  26. sdrnative-0.1.0/bindings/python/sdrnative/__main__.py +33 -0
  27. sdrnative-0.1.0/bindings/python/sdrnative/_native.py +1514 -0
  28. sdrnative-0.1.0/bindings/python/sdrnative/py.typed +0 -0
  29. sdrnative-0.1.0/bindings/python/tests/test_async_binding.py +126 -0
  30. sdrnative-0.1.0/bindings/python/tests/test_python_ergonomics.py +158 -0
  31. sdrnative-0.1.0/bindings/python/tests/wheel_smoke.py +14 -0
  32. sdrnative-0.1.0/cmake/FindLibUSB1.cmake +45 -0
  33. sdrnative-0.1.0/cmake/SDRNativeConfig.cmake.in +20 -0
  34. sdrnative-0.1.0/doc/hardware.md +14 -0
  35. sdrnative-0.1.0/doc/streaming.md +39 -0
  36. sdrnative-0.1.0/examples/c/dvbt.c +135 -0
  37. sdrnative-0.1.0/examples/c/iq.c +123 -0
  38. sdrnative-0.1.0/examples/c/probe.c +123 -0
  39. sdrnative-0.1.0/examples/node/dvbt.js +41 -0
  40. sdrnative-0.1.0/examples/node/iq.js +24 -0
  41. sdrnative-0.1.0/examples/python/dvbt.py +40 -0
  42. sdrnative-0.1.0/examples/python/iq.py +43 -0
  43. sdrnative-0.1.0/examples/python/probe.py +15 -0
  44. sdrnative-0.1.0/include/sdrnative.h +665 -0
  45. sdrnative-0.1.0/licenses/libusb-LGPL-2.1.txt +501 -0
  46. sdrnative-0.1.0/pyproject.toml +65 -0
  47. sdrnative-0.1.0/scripts/build_linux.sh +18 -0
  48. sdrnative-0.1.0/scripts/build_macos.sh +39 -0
  49. sdrnative-0.1.0/scripts/build_windows.ps1 +86 -0
  50. sdrnative-0.1.0/src/abi.c +80 -0
  51. sdrnative-0.1.0/src/async_stream.c +845 -0
  52. sdrnative-0.1.0/src/device.c +1329 -0
  53. sdrnative-0.1.0/src/error.c +250 -0
  54. sdrnative-0.1.0/src/internal.h +435 -0
  55. sdrnative-0.1.0/src/platform.c +73 -0
  56. sdrnative-0.1.0/src/r820t.c +703 -0
  57. sdrnative-0.1.0/src/rtl2832.c +387 -0
  58. sdrnative-0.1.0/src/rtl2832_iq.c +266 -0
  59. sdrnative-0.1.0/src/rtl28xx.c +719 -0
  60. sdrnative-0.1.0/src/threading.c +264 -0
  61. sdrnative-0.1.0/src/usb_libusb.c +934 -0
  62. sdrnative-0.1.0/tests/abi.c +67 -0
  63. sdrnative-0.1.0/tests/async.c +241 -0
  64. sdrnative-0.1.0/tests/async_errors.c +368 -0
  65. sdrnative-0.1.0/tests/device.c +334 -0
  66. sdrnative-0.1.0/tests/hardware/smoke.sh +58 -0
  67. sdrnative-0.1.0/tests/mock_usb.c +759 -0
  68. sdrnative-0.1.0/tests/mock_usb.h +42 -0
@@ -0,0 +1,5 @@
1
+ BasedOnStyle: LLVM
2
+ IndentWidth: 4
3
+ ColumnLimit: 100
4
+ AllowShortIfStatementsOnASingleLine: false
5
+ AllowShortFunctionsOnASingleLine: Inline
@@ -0,0 +1,102 @@
1
+ name: Python distrobution
2
+
3
+ on:
4
+ push:
5
+ branches: [main]
6
+ pull_request:
7
+ workflow_dispatch:
8
+ inputs:
9
+ publish:
10
+ description: Publish validated wheels to PyPI
11
+ type: boolean
12
+ default: false
13
+
14
+ permissions:
15
+ contents: read
16
+
17
+ jobs:
18
+ native-tests:
19
+ runs-on: ubuntu-24.04
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ with:
23
+ persist-credentials: false
24
+ - name: Build and test native library
25
+ run: |
26
+ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release
27
+ cmake --build build --parallel
28
+ ctest --test-dir build --output-on-failure
29
+
30
+ wheels:
31
+ name: Wheels (${{ matrix.os }})
32
+ runs-on: ${{ matrix.os }}
33
+ strategy:
34
+ fail-fast: false
35
+ matrix:
36
+ os: [ubuntu-24.04, macos-15, macos-15-intel, windows-2022]
37
+ include:
38
+ - os: macos-15
39
+ deployment_target: '15.0'
40
+ - os: macos-15-intel
41
+ deployment_target: '14.0'
42
+ steps:
43
+ - uses: actions/checkout@v4
44
+ with:
45
+ persist-credentials: false
46
+ - uses: actions/setup-python@v5
47
+ with:
48
+ python-version: '3.12'
49
+ - name: Build and test wheels
50
+ run: |
51
+ python -m pip install 'cibuildwheel==4.3.4'
52
+ python -m cibuildwheel --output-dir wheelhouse
53
+ env:
54
+ CIBW_ARCHS: auto64
55
+ MACOSX_DEPLOYMENT_TARGET: ${{ matrix.deployment_target }}
56
+ CIBW_ENVIRONMENT_MACOS: 'MACOSX_DEPLOYMENT_TARGET=${{ matrix.deployment_target }}'
57
+ CIBW_ENVIRONMENT_WINDOWS: 'CMAKE_ARGS="-DCMAKE_TOOLCHAIN_FILE=C:/vcpkg/scripts/buildsystems/vcpkg.cmake -DVCPKG_TARGET_TRIPLET=x64-windows"'
58
+ - uses: actions/upload-artifact@v4
59
+ with:
60
+ name: wheels-${{ matrix.os }}
61
+ path: wheelhouse/*.whl
62
+ if-no-files-found: error
63
+
64
+ sdist:
65
+ runs-on: ubuntu-24.04
66
+ steps:
67
+ - uses: actions/checkout@v4
68
+ with:
69
+ persist-credentials: false
70
+ - uses: actions/setup-python@v5
71
+ with:
72
+ python-version: '3.12'
73
+ - name: Build and inspect source distribution
74
+ run: |
75
+ python -m pip install build twine
76
+ python -m build --sdist
77
+ python -m twine check dist/*
78
+ - uses: actions/upload-artifact@v4
79
+ with:
80
+ name: sdist
81
+ path: dist/*.tar.gz
82
+ if-no-files-found: error
83
+
84
+ publish:
85
+ if: github.event_name == 'workflow_dispatch' && inputs.publish && startsWith(github.ref, 'refs/tags/v')
86
+ needs: [native-tests, wheels, sdist]
87
+ runs-on: ubuntu-24.04
88
+ environment: pypi
89
+ permissions:
90
+ id-token: write
91
+ steps:
92
+ - uses: actions/download-artifact@v4
93
+ with:
94
+ pattern: wheels-*
95
+ path: dist
96
+ merge-multiple: true
97
+ - uses: actions/download-artifact@v4
98
+ with:
99
+ name: sdist
100
+ path: dist
101
+ - name: Publish to PyPI
102
+ uses: pypa/gh-action-pypi-publish@release/v1
@@ -0,0 +1,20 @@
1
+ .vscode/
2
+ .idea/
3
+ build/
4
+ build-*/
5
+ dist/
6
+ CMakeUserPresets.json
7
+ cmake-build/
8
+ bindings/node/.node-sdk/
9
+ node_modules/
10
+ __pycache__/
11
+ *.tgz
12
+ *.py[cod]
13
+ *.egg-info/
14
+ .venv/
15
+ *.tsbuildinfo
16
+ *.iq
17
+ *.bin
18
+ .DS_Store
19
+ __MACOSX/
20
+ ._*
@@ -0,0 +1,211 @@
1
+ # SDRNative
2
+ # Build configuration
3
+ #
4
+ # Copyright (c) 2026 Ruben Roy
5
+ # SPDX-License-Identifier: MPL-2.0
6
+ cmake_minimum_required(VERSION 3.20)
7
+ project(sdrnative VERSION 0.1.0 LANGUAGES C)
8
+
9
+ include(GNUInstallDirs)
10
+ include(CMakePackageConfigHelpers)
11
+ list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
12
+
13
+ option(SDRNATIVE_BUILD_TESTS "Build mock backed tests" ON)
14
+ option(SDRNATIVE_BUILD_EXAMPLES "Build C examples" ON)
15
+ option(SDRNATIVE_REQUIRE_LIBUSB "Fail configure when libusb is unavailable" OFF)
16
+ option(SDRNATIVE_PYTHON_WHEEL "Build the native library for a Python wheel" OFF)
17
+
18
+ if(SDRNATIVE_PYTHON_WHEEL)
19
+ set(SDRNATIVE_REQUIRE_LIBUSB ON)
20
+ set(SDRNATIVE_BUILD_TESTS OFF)
21
+ set(SDRNATIVE_BUILD_EXAMPLES OFF)
22
+ set(BUILD_SHARED_LIBS ON)
23
+ endif()
24
+
25
+ set(CMAKE_C_STANDARD 11)
26
+ set(CMAKE_C_STANDARD_REQUIRED ON)
27
+ set(CMAKE_C_EXTENSIONS OFF)
28
+
29
+ find_package(LibUSB1 QUIET)
30
+ find_package(Threads REQUIRED)
31
+ if(SDRNATIVE_REQUIRE_LIBUSB AND NOT LibUSB1_FOUND)
32
+ message(FATAL_ERROR "libusb-1.0 is required but was not found")
33
+ endif()
34
+
35
+ set(SDRNATIVE_CORE_SOURCES
36
+ src/abi.c
37
+ src/async_stream.c
38
+ src/device.c
39
+ src/error.c
40
+ src/platform.c
41
+ src/threading.c
42
+ src/rtl28xx.c
43
+ src/rtl2832.c
44
+ src/rtl2832_iq.c
45
+ src/r820t.c
46
+ )
47
+
48
+ add_library(sdrnative
49
+ ${SDRNATIVE_CORE_SOURCES}
50
+ src/usb_libusb.c
51
+ )
52
+ add_library(SDRNative::sdrnative ALIAS sdrnative)
53
+
54
+ target_include_directories(sdrnative
55
+ PUBLIC
56
+ $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
57
+ $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
58
+ PRIVATE
59
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
60
+ )
61
+
62
+ target_compile_definitions(sdrnative PRIVATE SDRNATIVE_BUILD)
63
+ if(BUILD_SHARED_LIBS)
64
+ target_compile_definitions(sdrnative PUBLIC SDRNATIVE_SHARED)
65
+ endif()
66
+
67
+ target_link_libraries(sdrnative PRIVATE Threads::Threads)
68
+
69
+ if(LibUSB1_FOUND)
70
+ target_compile_definitions(sdrnative PRIVATE SDRNATIVE_HAVE_LIBUSB=1)
71
+ target_link_libraries(sdrnative PRIVATE LibUSB1::LibUSB1)
72
+ message(STATUS "libusb backend enabled")
73
+ else()
74
+ message(WARNING "libusb not found; USB hardware support disabled")
75
+ endif()
76
+
77
+ if(NOT WIN32)
78
+ target_link_libraries(sdrnative PRIVATE m)
79
+ endif()
80
+
81
+ if(MSVC)
82
+ target_compile_options(sdrnative PRIVATE /W4)
83
+ else()
84
+ target_compile_options(sdrnative PRIVATE -Wall -Wextra -Wpedantic -Wconversion -Wshadow)
85
+ endif()
86
+
87
+ set_target_properties(sdrnative PROPERTIES
88
+ OUTPUT_NAME sdrnative
89
+ VERSION ${PROJECT_VERSION}
90
+ SOVERSION 0
91
+ POSITION_INDEPENDENT_CODE ON
92
+ )
93
+
94
+ if(BUILD_SHARED_LIBS AND NOT MSVC)
95
+ set_target_properties(sdrnative PROPERTIES
96
+ C_VISIBILITY_PRESET hidden
97
+ VISIBILITY_INLINES_HIDDEN YES
98
+ )
99
+ endif()
100
+
101
+ if(SDRNATIVE_PYTHON_WHEEL)
102
+ set_target_properties(sdrnative PROPERTIES VERSION "" SOVERSION "" NO_SONAME ON)
103
+ endif()
104
+
105
+ if(SDRNATIVE_BUILD_EXAMPLES)
106
+ add_executable(sdrn_probe examples/c/probe.c)
107
+ target_link_libraries(sdrn_probe PRIVATE SDRNative::sdrnative)
108
+
109
+ add_executable(sdrn_dvbt_capture examples/c/dvbt.c)
110
+ target_link_libraries(sdrn_dvbt_capture PRIVATE SDRNative::sdrnative)
111
+
112
+ add_executable(sdrn_iq_capture examples/c/iq.c)
113
+ target_link_libraries(sdrn_iq_capture PRIVATE SDRNative::sdrnative)
114
+ endif()
115
+
116
+ if(SDRNATIVE_BUILD_TESTS)
117
+ enable_testing()
118
+
119
+ function(sdrn_add_mock_test target source)
120
+ add_executable(${target}
121
+ ${source}
122
+ tests/mock_usb.c
123
+ ${SDRNATIVE_CORE_SOURCES}
124
+ )
125
+ target_include_directories(${target} PRIVATE
126
+ ${CMAKE_CURRENT_SOURCE_DIR}/include
127
+ ${CMAKE_CURRENT_SOURCE_DIR}/src
128
+ ${CMAKE_CURRENT_SOURCE_DIR}/tests
129
+ )
130
+ target_link_libraries(${target} PRIVATE Threads::Threads)
131
+ if(MSVC)
132
+ target_compile_options(${target} PRIVATE /W4)
133
+ else()
134
+ target_compile_options(${target} PRIVATE
135
+ -Wall -Wextra -Wpedantic -Wconversion -Wshadow
136
+ )
137
+ target_link_libraries(${target} PRIVATE m)
138
+ endif()
139
+ endfunction()
140
+
141
+ sdrn_add_mock_test(sdrnative_device_test tests/device.c)
142
+ add_test(NAME sdrnative_device COMMAND sdrnative_device_test)
143
+
144
+
145
+ add_executable(sdrnative_abi_test tests/abi.c)
146
+ target_link_libraries(sdrnative_abi_test PRIVATE SDRNative::sdrnative)
147
+ if(MSVC)
148
+ target_compile_options(sdrnative_abi_test PRIVATE /W4)
149
+ else()
150
+ target_compile_options(sdrnative_abi_test PRIVATE
151
+ -Wall -Wextra -Wpedantic -Wconversion -Wshadow
152
+ )
153
+ endif()
154
+ add_test(NAME sdrnative_abi COMMAND sdrnative_abi_test)
155
+
156
+ sdrn_add_mock_test(sdrnative_async_test tests/async.c)
157
+ add_test(NAME sdrnative_async COMMAND sdrnative_async_test)
158
+
159
+
160
+ sdrn_add_mock_test(sdrnative_async_errors_test tests/async_errors.c)
161
+ add_test(NAME sdrnative_async_errors COMMAND sdrnative_async_errors_test)
162
+
163
+ endif()
164
+
165
+ if(SDRNATIVE_PYTHON_WHEEL)
166
+ install(TARGETS sdrnative
167
+ RUNTIME DESTINATION sdrnative
168
+ LIBRARY DESTINATION sdrnative
169
+ ARCHIVE DESTINATION sdrnative
170
+ )
171
+ else()
172
+ install(TARGETS sdrnative
173
+ EXPORT SDRNativeTargets
174
+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
175
+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
176
+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
177
+ )
178
+ install(FILES include/sdrnative.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR})
179
+ install(EXPORT SDRNativeTargets
180
+ FILE SDRNativeTargets.cmake
181
+ NAMESPACE SDRNative::
182
+ DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SDRNative
183
+ )
184
+
185
+ set(SDRNATIVE_CONFIG_NEEDS_LIBUSB OFF)
186
+ if(LibUSB1_FOUND AND NOT BUILD_SHARED_LIBS)
187
+ set(SDRNATIVE_CONFIG_NEEDS_LIBUSB ON)
188
+ endif()
189
+
190
+ configure_package_config_file(
191
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/SDRNativeConfig.cmake.in"
192
+ "${CMAKE_CURRENT_BINARY_DIR}/SDRNativeConfig.cmake"
193
+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SDRNative"
194
+ )
195
+ write_basic_package_version_file(
196
+ "${CMAKE_CURRENT_BINARY_DIR}/SDRNativeConfigVersion.cmake"
197
+ VERSION "${PROJECT_VERSION}"
198
+ COMPATIBILITY SameMinorVersion
199
+ )
200
+ install(FILES
201
+ "${CMAKE_CURRENT_BINARY_DIR}/SDRNativeConfig.cmake"
202
+ "${CMAKE_CURRENT_BINARY_DIR}/SDRNativeConfigVersion.cmake"
203
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SDRNative"
204
+ )
205
+ if(SDRNATIVE_CONFIG_NEEDS_LIBUSB)
206
+ install(FILES
207
+ "${CMAKE_CURRENT_SOURCE_DIR}/cmake/FindLibUSB1.cmake"
208
+ DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SDRNative"
209
+ )
210
+ endif()
211
+ endif()
@@ -0,0 +1,14 @@
1
+ # Contributing
2
+
3
+ Include the OS, receiver model, and reproduction steps with hardware bug
4
+ reports. Run the mock-backed C tests before submitting patches:
5
+
6
+ ```sh
7
+ cmake -S . -B build -DSDRNATIVE_BUILD_TESTS=ON
8
+ cmake --build build
9
+ ctest --test-dir build --output-on-failure
10
+ ```
11
+
12
+ For hardware changes, check device enumeration and capture IQ and DVB-T data
13
+ on a receiver. The programs are in `examples/c/`. Record the OS, hardware,
14
+ frequencies and any failures.
@@ -0,0 +1,3 @@
1
+ version 0.1.0 @ 24 Oct 2026
2
+
3
+ - initial public release.
@@ -0,0 +1,54 @@
1
+ # Build
2
+
3
+ The library requires CMake 3.20+, a C11 compiler and libusb 1.0 development
4
+ files for hardware access.
5
+
6
+ On Windows x64, install Visual Studio C++ Build Tools, CMake and vcpkg, set
7
+ `VCPKG_ROOT`, then run `scripts\build_windows.ps1` in PowerShell. A
8
+ WinUSB-compatible driver is needed for the receiver interface.
9
+
10
+ On macOS:
11
+
12
+ ```sh
13
+ brew install cmake libusb pkg-config
14
+ ./scripts/build_macos.sh
15
+ ```
16
+
17
+ On Linux (experimental):
18
+
19
+ ```sh
20
+ ./scripts/build_linux.sh
21
+ ```
22
+
23
+ To build and install manually:
24
+
25
+ ```sh
26
+ cmake -S . -B build -DBUILD_SHARED_LIBS=ON -DSDRNATIVE_REQUIRE_LIBUSB=ON
27
+ cmake --build build
28
+ cmake --install build --prefix ./_install
29
+ ```
30
+
31
+ CMake consumers can use `find_package(SDRNative 0.1 CONFIG REQUIRED)` and link
32
+ `SDRNative::sdrnative`. Set `CMAKE_PREFIX_PATH` to the installation prefix
33
+ if necessary. The shared library must be on the system's library search path.
34
+
35
+ ## Python
36
+
37
+ ```sh
38
+ python -m pip install sdrnative
39
+ ```
40
+
41
+ Requires Python 3.10+. See [bindings/python/README.md](bindings/python/README.md)
42
+ for usage.
43
+
44
+ ## Node.js
45
+
46
+ ```sh
47
+ npm install sdrnative
48
+ ```
49
+
50
+ Requires Node.js 18+. TypeScript declarations are included. See
51
+ [bindings/node/README.md](bindings/node/README.md).
52
+
53
+ USB drivers and device permissions are platform-specific and aren't configured
54
+ by the package managers.