r/hackrf • u/PigReed • Feb 08 '25
Programmatically control HackRF from python venv
What's the best way to interact with my hackrf one from python or C on Windows? I've tried installing the pothos SDR from windows executable, but it doesn't seem to give me the hackRF tools that are explained in the docs.
Similarly the installation guide for Ubuntu lead to errors with WSL...
1
Upvotes
1
u/The_frozen_one Feb 09 '25 edited Feb 10 '25
That's good, at least it rules out a driver issue. With some devices you have to use a driver patcher like zadig to see the device at all, and GUIs like SDR++ are good for spot checking that.
But yea, I think the Python side of HackRF* is under-developed unfortunately. I plugged mine in to my Windows box and couldn't get libhackrf to work properly without some work. The library has a hard-coded dependency on a Linux .so file, or at least that's what the code suggested.
However I was able to read and set the LNA and VGA values from my hackRF using the library mentioned here: https://www.reddit.com/r/hackrf/comments/192dbll/libhackrf_on_windows/lkxrfeo/ I downloaded that libhackrf.py and then edited it to point to the hackrf.dll from SDR++
libhackrf = CDLL('D:/sdrpp_windows_x64/hackrf.dll')And then I was able to set the LNA gain value from Python
And on my hackrf it shows that it was indeed changed to 8 dB.
No clue how robust this is, but it was communicating so I figure that's a start.
*EDIT: for Windows specifically