I’ve tried to go back to basics on this problem and reverted to the simple MeasureDelay.py example provided at:
https://github.com/pothosware/SoapySDR/blob/master/python/apps/MeasureDelay.py
The default examples works and I even plotted the received signal to check it had the transmitted sinc in it. I then went back to the original copy of MeasureDelay.py but changed the “break” on line 120 that triggers when status.ret from readstream is <=0. I also print out the status.ret value i.e. line 120 and 121 are now:
else:
pass # Was break
print(status.ret)
This showed the receiver stopped receiving after a total of 10,000 samples had been transmitted. This led me to re-examine the documentation for activateStream(…) which by chance in MeasureDelay has a parameter called num_rx_samples which has value of 10,000. Therefore I changed the call to activate stream on line 101 to not specify any timing info:
sdr.activateStream(rx_stream) # Was sdr.activateStream(rx_stream, rx_flags, receive_time, num_rx_samps)
This let the receiver continually stream data in - so all good up to this point.
I’ve now gone back to trying to get a multiprocessing version going but keeping it as simple as possible. I stripped out all the tx code/process and just tried to receive continuously. The readStream fell over on its own at this stage - so the Tx chain has nothing to do with this. It seems to just be having a separate process to call readStream(…) that causes it to fall over?
To check this I called the code that was in the target function for the multiprocess logic directly (i.e. no multiprocessing going on). This code was as follows:
#create a re-usable buffer for rx samples
buff = np.array([0]*2040,
np.complex64)
# Receive samples, find pilot tone, put in neural network queue.
totalRead = 0;
while True:
print("The buffer length is {}".format(len(buff)))
sr = self.sdr.readStream(self.rxStream, [buff], len(buff), timeoutUs=int(5e5))
print("Number rx samples {}".format(sr.ret)) #num samples or error code
if sr.ret == -1:
break
totalRead += sr.ret
print("Total samples read {}".format(totalRead))
This worked fine! So I am now completely lost why I can’t put the above code in a function and kick it off as a separate process - is there something in readStream that is not thread safe?
My code to call the above process wrapped in a function called recvSamples was:
# Create a RX process.
rxID = 1;
rxProcess= multiprocessing.Process(name='rx',
target=trans.recvSamples,
args=(rxID,))
# Start the TX and RX processes.
rxProcess.start()
How are we meant to simultaneously transmit and receive data from the limeSDR mini if we can’t call readStream and writeStream in separate threads/processes?
Any help/pointers appreciated as I’m running out of ideas here.
Thanks