ZMQ virtual radio driver
hududed opened this issue · comments
Hi, I wanted to see if I can generate synthetic signal in gnuradio and connect to a ZMQ PUB sink and receive the signal with soapySDR. Since I have no hardware, I used "null" but it doesn't seem to work
context = zmq.Context()
socket = context.socket(zmq.SUB)
socket.connect("tcp://localhost:5555")
socket.setsockopt_string(zmq.SUBSCRIBE, '')
args = dict(driver="null")
sdr = SoapySDR.Device(args)
rxStream = sdr.setupStream(SOAPY_SDR_RX, SOAPY_SDR_CF32)
sdr.activateStream(rxStream)
while True:
# Receive samples from ZMQ
message = socket.recv()
samples = np.frombuffer(message, dtype=np.complex64)
# Simulate streaming data from SoapySDR
sr = sdr.readStream(rxStream, [samples], len(samples))
if sr.ret > 0:
print("Samples received from SoapySDR stream:")
for sample in samples[:sr.ret]:
print(sample)
Is this possible?
You need to handle error checking.
The null device, from https://github.com/pothosware/SoapySDR/blob/master/lib/NullDevice.cpp will only offer the default/fallback default implementation i.e. from https://github.com/pothosware/SoapySDR/blob/master/lib/Device.cpp
E.g. 0 channels, no supported formats unsupported activate, deactivate, read, write.
I don't fully understand the goal though. Why is Soapy involved at all? You read samples with socket.recv() and not with readStream() right? I.e. you do get samples but sr from readStream() will be -1.
Maybe look into rtl_tcp a TCP based protocol for transmitting samples with good support in SoapySDR (https://github.com/pothosware/SoapyRTLTCP/) and many SDR UI clients. You can generate a (synthetic) compliant rtl_tcp sender (source) easily (e.g. see https://github.com/merbanan/rtl_433/blob/master/src/output_rtltcp.c) it's mostly unidirectional. A rtl_tcp receiver (sink) is even easier (socat - tcp:localhost:1234 |hexdump -C), connect to the port and accept the data stream (sending commands is optional).