I am trying to construct an automatic gain controller for my HackRF when in receive mode. I am using the gr-osmosdr block in GNU Radio to interface with the HackRF. I am then running my received I and Q signal into a squaring block, and then an integrator set to a thousand samples. I then have a unitless estimate of the power received by the system. I then would like to set the Hack RF gain higher or lower based on the received power level estimate. I have a custom embedded python block that is measuring the received power level, compares to an ideal, and then could send a message or set a value for which direction the gain needs to go. However, I cannot figure out a single easy way to connect my embedded python block to actually change the Hack RFs gain.
My options seem to be
- Attempt to use the command port on the gr-osmosdr block to update the gain of the Hack RF. This solution is impossible because I cannot find any documentation on how to use the command port. No syntax examples, no references to it in the documentation. I even dug through the source code and couldn't find anything.
- Update the variables in the gnuradio flowgraph. This does not work, because I need a callback or a reference to the gnuradio flowgraph variables. There is zero documentation on how to do that from GNU Radio. I've found a few threads suggesting it might be possible, but none showing how to do it.
- Somehow send USB commands directly from my python implementation to the Hack RF directly. The command line tools for the Hack RF, provided by Great Scott, use USB commands to control the Hack RF. I could theoretically call these Hack RF command line tools from my GNU Radio application, to control the Hack RF, but that seems like it may cause problems with the GNU Radio control of the device.
I've also asked this question here: https://www.reddit.com/r/hackrf/comments/15m0fg9/gnu_radio_and_osmosdr_agc/
And the best previous replies I have seen is https://dsp.stackexchange.com/questions/60035/how-to-adjust-receiver-gains-to-avoid-saturation-and-quantization-noise-to-optim The above focuses on the theory of how to do this, and I am interested in the actual mechanism to control the gain from GNU Radio that one might use.
Have any of you solved this problem? Or know somewhere I might look to find the answer?