>>
> I wait for the WAV file to finish transmitting (it's only about 10
> seconds), then I kill the flowgraph with the red X. Also, I added some
> debug statements, so I know that the TX stream is deactivated once file is
> sent. Here is the output:
> [DEBUG] Init
> [DEBUG] Exit
> [DEBUG] Init
> [INFO] Opening HackRF device instance {device=HackRF One, driver=hackrf,
> part_id=a000cb3c005d475a, serial=0000000000000000909864c8343e0ecf, soapy=0,
> version=2015.07.2}...
> [DEBUG] Using format CF32.
> [DEBUG] Start TX
> [DEBUG] Stop TX
>
> Some curious things:
> a) I don't know why it calls Init & Exit & then Init again
Its probably the discovery routine finding the available devices first.
The hackrf init/exit is also called for finding the device.
https://github.com/pothosware/SoapyHackRF/blob/master/HackRF_Registation.cpp#L29
And then once again in the actual device instance:
https://github.com/pothosware/SoapyHackRF/blob/master/SoapyHackRF.hpp#L379
> b) There is no closing Exit
So the kill "with the red X" is killing the process, so it has no chance
to properly shutdown.
Are you able to close the gui or command like app nicely with the close
button? Or does it hang?
I think I see whats happening. So the code really only got tested with
transmitting once single burst from the sink side. It doesnt stay in
continuous tx when more data shows up:
It seems the way it works is that aquireWriteBuffer() calls
activateStream(tx) when the hackrf is currently in receive mode. There
is this _tx_stream->burst_end variable floating around that is used in
the tx thread to block exiting back to the rx'ing state.
more on that below
>
>>
>>> So first, is this the right place to ask for help? To me it looks like an
>>> issue with the implementation of hackrf in SoapyHackrf, and if that's
>>> correct, is there a place to file a bug report?
>>
>> I saw the the issue on the hackrf github, but I sort of lost track.
>> Sorry about that. The mailing list if perfectly fine for this. I think
>> the
https://github.com/pothosware/SoapyHackRF issue tracker may have a
>> few more relevant eyes on it too if that helps.
>>
>>>
>>> Also, I see a few examples using SoapyHackrf in Pothos; but I would love
>> to
>>> see some examples in gnuradio & gr-osmosdr.
>>
>> Its funny, gr-osmosdr blocks in GRC was actually the first test case for
>> this. So I didnt expect there to be a problem.
>>
>
> If you still have the GRC file, perhaps you could send it to me and I'll
> see if I can get that to work.
>
It wasnt my work, sorry I cant find it.
>
>>
>>>
>>> Also, any suggestions, or workarounds, or alternatives would be helpful.
>>>
>>
>> I suspect the logic behind the switching. Could be a logic bug or just
>> something that could be implemented better especially in regards to the
>> second issue. It may be worthwhile just adding a few prints. The code is
>> literally just calling activateStream() and checking an internal
>> variable called _current_mode to do the switchover:
>>
https://github.com/pothosware/SoapyHackRF/blob/master/HackRF
>> _Streaming.cpp#L269
>>
>> I used SoapySDR_logf rather than prints; but I can't figure out what
> triggers a switchover. The code that calls activateStream is either
> acquireReadBuffer or acquireWriteBuffer, and those are called from
> readStream or writeStream, but it isn't clear what controls those routines.
readStream and writeStream get called by the scheduler (gr-osmosdr work
function). Internally readStream calls acquire/releaseReadBuffer() and
writeStream calls acquire/releaseWriteBuffer(). Technically an API user
could directly use the acquire/release calls to get direct access to the
ring buffer -- depends which API fits best.
The activateStream(tx and rx) call typically gets called once when the
gr-osmosdr blocks get the start() hook called. However, the acquire
implementations will also call activateStream() when the current
transmit/receive mode does not match the function that was just called.
And then activateStream() handles the thread switchover.
I think that the right pieces are there but that the metric for
switching isnt quite right. I think that rx acquire should wait to
switch with a timeout on a condition variable triggered by the tx
callback underflowing. A tx underflow would mean that we switched into
tx mode but drained all of the data available from the caller.
This is where rx should wait properly before switching:
https://github.com/pothosware/SoapyHackRF/blob/master/HackRF_Streaming.cpp#L692
And where the tx callback could underflow and notify the condition
variable:
https://github.com/pothosware/SoapyHackRF/blob/master/HackRF_Streaming.cpp#L60
In this case, Im thinking that underflow would clear the
_tx_stream->burst_end variable. The use of _tx_stream->burst_samps as
sort of a sample count down doesnt work here since its not being set to
any particular number of samples anyway.
-josh