The External Loopback does not seems to work

Hello.
I trying to use the ch.A external loopback. However, I not receiving anything. I also tried to activate it with the LimeSuite GUI and transmitted with GNU Radio. In none of these tries I got something on the RX. What am I doing wrong?
My code is below:

import SoapySDR
from SoapySDR import Device
import time
import numpy as np
import threading

def Modify_SPI_Reg(sdr, addr , msb, lsb, value):
spiDataReg = sdr.readRegister(“BBIC”, addr)
spiMask = (~(~0 << (msb - lsb + 1))) << (lsb)
spiDataReg = (spiDataReg & (~spiMask)) | ((value << lsb) & spiMask)
return sdr.writeRegister(“BBIC”, addr, spiDataReg)

def LoopBack(sdr):

Modify_SPI_Reg(sdr, 0x17, 0 , 0 , 1)
Modify_SPI_Reg(sdr, 0x17, 1 , 1 , 1)
Modify_SPI_Reg(sdr, 0x17, 2 , 2 , 0)

def tx():

i = 0
global tx_time_0
LimeSDR1.activateStream(txStream1)
tx_time_0 = int(LimeSDR1.getHardwareTime() + 0.1e9)
while i < 100:
    status = LimeSDR1.writeStream(txStream1, [iq0], len(iq0), tx_flags, tx_time_0)
    if status.ret != len(iq0):
        raise Exception('transmit failed %s' % str(status))
    i= i+1
LimeSDR1.deactivateStream(txStream1)
LimeSDR1.closeStream(txStream1)

def rx():
i = 0
receive_time = int(tx_time_0 - (num_rx_samps/samp_rate) * 1e9/2)
LimeSDR1.activateStream(rxStream1, rx_flags, receive_time, num_rx_samps)
rx_buff = np.array([0]*1024, np.complex64)
timeout_us = int(5e5) #500 ms >> stream time

while i < 100:
    status = LimeSDR1.readStream(rxStream1, [rx_buff], len(rx_buff), timeoutUs=timeout_us)
    i = i +1


LimeSDR1.deactivateStream(rxStream1)
LimeSDR1.closeStream(rxStream1)
np.savetxt('IQ rx.txt', rx_buff)

######################################################
#Variables
samp_rate = 20e6
bandwidth = 5e6
rx_lo = 2e9
gain = 30
burstSize = 1024

ts = 1/samp_rate
N = 2 ** 16
t = np.arange(0, N*ts, ts)
i0 = np.cos(2 * np.pi * t * 200e3) * 2 ** 14
q0 = np.sin(2 * np.pi * t * 200e3) * 2 ** 14
iq0 = i0 +1j * q0

iq0 = iq0.astype(np.complex64)

np.savetxt(‘IQ.txt’, iq0)

devices = Device.enumerate()
print(devices)

LimeSDR1 = Device(devices[0])
LimeSDR1.boardName = “LimeSDR”

LimeSDR1.setMasterClockRate(30.72e6)

LimeSDR1.setSampleRate(SoapySDR.SOAPY_SDR_TX, 0, int(samp_rate))
LimeSDR1.setAntenna(SoapySDR.SOAPY_SDR_TX, 0,‘BAND2’)
LimeSDR1.setGain(SoapySDR.SOAPY_SDR_TX, 0, gain)
LimeSDR1.setFrequency(SoapySDR.SOAPY_SDR_TX, 0,int(rx_lo))
LimeSDR1.setBandwidth(SoapySDR.SOAPY_SDR_TX, 0, int(bandwidth))

time.sleep(1)

LimeSDR1.setSampleRate(SoapySDR.SOAPY_SDR_RX, 0, int(samp_rate))
LimeSDR1.setAntenna(SoapySDR.SOAPY_SDR_RX, 0,‘LNAH’)
LimeSDR1.setGain(SoapySDR.SOAPY_SDR_RX, 0, gain)
LimeSDR1.setFrequency(SoapySDR.SOAPY_SDR_RX, 0,int(rx_lo))
LimeSDR1.setBandwidth(SoapySDR.SOAPY_SDR_RX, 0, int(bandwidth))

time.sleep(1)

rxStream1 = LimeSDR1.setupStream(SoapySDR.SOAPY_SDR_RX, SoapySDR.SOAPY_SDR_CF32, [0])
txStream1 = LimeSDR1.setupStream(SoapySDR.SOAPY_SDR_TX, SoapySDR.SOAPY_SDR_CF32, [0])

time.sleep(1)

LoopBack(LimeSDR1)
time.sleep(1)

num_rx_samps = len(iq0)

tx_time_0 = int(LimeSDR1.getHardwareTime() + 0.1e9)
receive_time = int(tx_time_0 - (num_rx_samps/samp_rate) * 1e9/2)

tx_flags = SoapySDR.SOAPY_SDR_HAS_TIME | SoapySDR.SOAPY_SDR_END_BURST

rx_buffs = np.array(, np.complex64)
rx_flags = SoapySDR.SOAPY_SDR_HAS_TIME | SoapySDR.SOAPY_SDR_END_BURST

t1 = threading.Thread(target=tx)
t2 = threading.Thread(target=rx)

t2.start()
t1.start()

t1.join()
t2.join()

If you look at this video -

A Software Defined Radio Python Starter Kit

it points out some problems that may affect your program.

Another things is that “threads” in python are not actually threads - the processes run one at a time. You have to use shared memory like gnuradio does to actually get more than one process to run at the same time.

BAND2 will be weak at that LO frequency.
BAND2 is for around 30 MHz - 1.9 GHz
BAND1 is for around 2 GHz - 2.6 GHz

I suggest checking if you’re getting anything while continuously transmitting, instead of transmitting one burst.