Enumerating Multiple RTL-SDR Dongles Deterministically for rtl_tcp in Linux
Thanks to user 'luma' on our forums for submitting his technique for managing multiple RTL-SDR dongles on a Linux system. The problem is that rtl_tcp tends to enumerate devices depending on the order they are plugged in. This can create problems like not knowing which dongle is connected to which antenna without physically checking. He writes:
I was looking to utilize a couple RTL dongles to monitor two ISM band frequencies commonly used in LoRa without buying an SDR with wide enough bandwidth to cover both ranges. I pretty quickly ran into issues with how SpyServer and rtl_tcp enumerate devices, which appears to be based mostly upon the order in which each device had been plugged in.
With some work, I think I've come upon a flexible and secure solution to handle an arbitrary number of dongles on one system while maintaining deterministic control of each device. This means I can label an individual dongle, connect it to the desired antenna, and then connect to that dongle on the assigned TCP port every time, without regard to the order in which things have been plugged in.
The rest of his post shows the steps which include creating an unprivileged service user, using rtl_eeprom to set device serial numbers and using a script that automatically runs on startup which will enumerate the dongles deterministically each time.
I’m surprised rtl_tcp doesn’t already take a serial number. Modify rtl_tcp.c to call the following method of librtlsdr:
int rtlsdr_get_index_by_serial(const char *serial)
to set dev_index of rtl_tcp.c
See rtl_433 for an example of how to do it.