|
| 1 | +# MIT License |
| 2 | + |
| 3 | +# Copyright (c) 2023 GvozdevLeonid |
| 4 | + |
| 5 | +# Permission is hereby granted, free of charge, to any person obtaining a copy |
| 6 | +# of this software and associated documentation files (the "Software"), to deal |
| 7 | +# in the Software without restriction, including without limitation the rights |
| 8 | +# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 9 | +# copies of the Software, and to permit persons to whom the Software is |
| 10 | +# furnished to do so, subject to the following conditions: |
| 11 | + |
| 12 | +# The above copyright notice and this permission notice shall be included in all |
| 13 | +# copies or substantial portions of the Software. |
| 14 | + |
| 15 | +# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 16 | +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 17 | +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 18 | +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 19 | +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 20 | +# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 21 | +# SOFTWARE. |
| 22 | + |
| 23 | +from python_hackrf import pyhackrf |
| 24 | + |
| 25 | +from queue import Queue |
| 26 | +import numpy as np |
| 27 | +import datetime |
| 28 | +import signal |
| 29 | +import struct |
| 30 | +import time |
| 31 | +import sys |
| 32 | + |
| 33 | + |
| 34 | +AVAILABLE_SAMPLING_RATES = (2_000_000, 4_000_000, 6_000_000, 8_000_000, 10_000_000, 12_000_000, 14_000_000, 16_000_000, 18_000_000, 20_000_000) |
| 35 | +AVAILABLE_BASEBAND_FILTER_BANDWIDTHS = (1_750_000, 2_500_000, 3_500_000, 5_000_000, 5_500_000, 6_000_000, 7_000_000, 8_000_000, 9_000_000, 10_000_000, 12_000_000, 14_000_000, 15_000_000, 20_000_000, 24_000_000, 28_000_000) |
| 36 | +INTERLEAVED_OFFSET_RATIO = 0.375 |
| 37 | +LINEAR_OFFSET_RATIO = 0.5 |
| 38 | + |
| 39 | +PY_FREQ_MIN_MHZ = 0 # 0 MHz |
| 40 | +PY_FREQ_MAX_MHZ = 7_250 # 7250 MHz |
| 41 | +PY_FREQ_MAX_HZ = PY_FREQ_MAX_MHZ * 1e6 # Hz |
| 42 | +PY_BLOCKS_PER_TRANSFER = 16 |
| 43 | + |
| 44 | +run_available = True |
| 45 | + |
| 46 | +repeat_tx = False |
| 47 | + |
| 48 | + |
| 49 | +def sigint_callback_handler(sig, frame): |
| 50 | + global run_available |
| 51 | + run_available = False |
| 52 | + sys.stderr.write('\n') |
| 53 | + |
| 54 | + |
| 55 | +def init_signals(): |
| 56 | + try: |
| 57 | + signal.signal(signal.SIGINT, sigint_callback_handler) |
| 58 | + signal.signal(signal.SIGILL, sigint_callback_handler) |
| 59 | + signal.signal(signal.SIGFPE, sigint_callback_handler) |
| 60 | + signal.signal(signal.SIGTERM, sigint_callback_handler) |
| 61 | + signal.signal(signal.SIGABRT, sigint_callback_handler) |
| 62 | + except Exception: |
| 63 | + pass |
| 64 | + |
| 65 | + |
| 66 | +def rx_callback(buffer: np.ndarray[:], buffer_length: int, valid_length: int): |
| 67 | + pass |
| 68 | + |
| 69 | + |
| 70 | +def tx_callback(buffer: np.ndarray[:], buffer_length: int, valid_length: int): |
| 71 | + pass |
| 72 | + |
| 73 | + |
| 74 | +def tx_complete_callback(buffer: np.ndarray[:], buffer_length: int, valid_length: int): |
| 75 | + pass |
| 76 | + |
| 77 | + |
| 78 | +def flush_callback(): |
| 79 | + pass |
| 80 | + |
| 81 | + |
| 82 | +def pyhackrf_transfer(): |
| 83 | + pass |
0 commit comments