Skip to content
Iggy Krajci edited this page Aug 5, 2013 · 2 revisions

Functions:

This section will cover all of the functions exposed in the py-hackrf library.

Getting Started:

Import to HackRf Library, so that you can do things with it. This is the first step.

from py-hackrf import HackRf

The first thing that you need to do is, create a instance of the HackRf Object. This will only ilitialize the object, the HackRF devices does not need to be connected as this time.

hackrf = HackRf()

The next step is to setup the library. This will query the device for the device ID, and create the USB connection that will let you continue to interact with the device.

hackrf.setup()

Core:

These are all of the core functions that can be called on the hackrf instance that we created in Getting Started.

hackrf.get_board_id ( )

This will get the ID from the connected HackRf board, and return it in integer format

hackrf.get_version_string ( )

This will get the version string for the HackRf board, and return it in string format

hackrf.get_board_serial_number ( )

This will get the serial number for the HackRf board, and return it in a tuple format as follows

( 'FIRST_SERIAL' , 'SECOND_SERIAL', 'THIRD_SERIAL', 'FOURTH_SERIAL' )

hackrf.set_baseband_filter_bandwidth ( Bandwith_In_Hz )

This will set the baseband filter bandwidth in MHz.

Possible values: 1.75/2.5/3.5/5/5.5/6/7/8/9/10/12/14/15/20/24/28MHz,

Example: hackrf.set_baseband_filter_bandwidth(500000)

For 50 Mhz of bandeband filter

hackrf.set_frequency ( Frequency_in_Hz )

This will set the operating frequency for the HackRf board in Hz. This would be between 30Mhz and 6000 Mhz

Example: hackrf.set_frequency(500000)

Sets the operating frequency to 50 Mhz

hackrf.set_sample_rate ( Frequency_in_Hz, Divider )

This will set the sample rate of the HackRf device.

hackrf.set_lna_gain ( LNA_Gain )

This will set the LNA Gain of the Hack Rf, this must be in 8 Db steps, with a maximum value of 40.

hackrf.set_vga_gain ( VGA_Gain )

This will set the VGA Gain of the Hack Rf, this must be in 2 Db steps, with a maximum value of 62.

hackrf.set_txvga_gain ( TXVGA_Gain )

This will set the TXVGA Gain of the Hack Rf, this must be in 1 Db steps, with a maximum value of 47.

hackrf.enable_amp ( )

This will enable the amp for the Hack Rf device.

hackrf.disable_amp ( )

This will disable the amp for the Hack Rf device.

hackrf.set_rx_mode ( )

This will set the Hack Rf device in recieve mode.

hackrf.set_tx_mode ( )

This will set the Hack Rf device in transmit mode.

MAX2837:

hackrf.max2837.write_register ( Register_Number, New_Value )

This will set the provided register to the value provided. The Register_Number must be within 1-32.

hackrf.max2837.read_register ( Register_Number )

This will get the provided register and return it in int format. The Register_Number must be within 1-32.

hackrf.max2837.display_registers ( )

This will iterate over all registers and print the values.

RFFC5071:

hackrf.rffc5071.write_register ( Register_Number, New_Value )

This will set the provided register to the value provided. The Register_Number must be within 1-30.

hackrf.rffc5071.read_register ( Register_Number )

This will get the provided register and return it in int format. The Register_Number must be within 1-30.

hackrf.rffc5071.display_registers ( )

This will iterate over all registers and print the values.

SI5351C:

hackrf.si5351c.write_register ( Register_Number, New_Value )

This will set the provided register to the value provided. The Register_Number must be within 1-255.

hackrf.si5351c.read_register ( Register_Number )

This will get the provided register and return it in int format. The Register_Number must be within 1-255.

hackrf.si5351c.display_registers ( )

This will iterate over all registers and print the values.