Skip to content

Hackrf

pysdrlib.hackrf

HackRF One through libhackrf: receive and transmit, half-duplex.

Specs

  • Frequency (1Mhz - 6 GHz)
  • Sample rate (2 MHz - 20 Mhz)
  • Samples (complex int 8)
  • Amplifiers
  • Receive
    • RF [amp] (0 or 11, default=0)
    • IF [lna] (0-40:8, default=30)
    • baseband [vga] (0-62:2, default=50)
  • Transmit
    • RF [amp] (0 or 11, default=0)
    • IF [txvga] (0-47:1, default=0)

The RF amp is one switch used both ways: the receive and transmit RF gains are kept apart, and the one of the direction being started is applied (start_rx, start_tx). While neither streams, the switch follows the last one set.

There is one baseband filter. libhackrf chooses its width at each sample rate change; once set_rx_bandwidth or set_tx_bandwidth has been called, the width chosen last is put back after a rate change.

Transmit

HackRF is half-duplex: it receives or transmits, never both. start_tx raises err.Busy while receiving (and start_rx while transmitting). Samples are complex64 in [-1, 1]; the transmit callback converts to int8. If write falls behind, silence is sent and counted in tx_stats["underruns"].

sdr.initialize(cf=915e6, Fs=2e6, tx_gain=0)   # raise the TX gain gradually, into an antenna or load you intend
sdr.start_tx()
sdr.write(samples)        # complex64; blocks while the 0.25 s queue is full
sdr.stop_tx()

Modules:

Name Description
hackrf

Functions:

Name Description
find

[DeviceInfo] of the HackRFs attached

find

find()

[DeviceInfo] of the HackRFs attached

Source code in src/pysdrlib/hackrf/__init__.py
def find():
    """[DeviceInfo] of the HackRFs attached"""
    from ..devices import DeviceInfo
    from . import lib
    found = []
    devices = lib.hackrf.device_list()
    try:
        for i, (serial, board) in enumerate(zip(devices.serial_numbers, devices.usb_board_ids)):
            found.append(DeviceInfo("hackrf", _BOARDS.get(board, f"HackRF (USB id {board:#06x})"), serial, i,
                                    {"serial": serial}, {"usb_board_id": board}))
    finally:
        devices.close()
    return found

hackrf