Monday, August 03, 2026

Re: comms/rtl-sdr fix rtl_tcp

without and with your patch, I can run rtl_sdr -a 127.0.0.1 and connect gqrx to it, to listen to radio.
So what does the patch fix for you?

Do you have something I could reproduce?

Sebastian


On Sat, Aug 1, 2026 at 7:10 PM Sebastian Reitenbach <sebastia@l00-bugdead-prods.de> wrote:
I'll give ti a try hopefully later Today or tomorrow.

On Sat, Aug 1, 2026 at 3:54 AM SASANO Takayoshi <uaa@mx5.nisiq.net> wrote:
Hello,

here is a diff to rtlsdr_read_async() -> rtlsdr_read_sync().
I use this modified rtl_tcp with Airspy SDR# on Windows box. work fine.

--
SASANO Takayoshi (JG1UAA) <uaa@mx5.nisiq.net>

Index: Makefile
===================================================================
RCS file: /cvs/ports/comms/rtl-sdr/Makefile,v
diff -u -p -r1.12 Makefile
--- Makefile    22 Oct 2024 19:03:17 -0000      1.12
+++ Makefile    1 Aug 2026 01:50:16 -0000
@@ -1,5 +1,6 @@
 COMMENT=       software to turn RTL2832U into an SDR

+REVISION =     0
 GH_ACCOUNT =   osmocom
 GH_PROJECT =   rtl-sdr
 GH_TAGNAME =   v2.0.2
Index: patches/patch-src_rtl_tcp_c
===================================================================
RCS file: patches/patch-src_rtl_tcp_c
diff -N patches/patch-src_rtl_tcp_c
--- /dev/null   1 Jan 1970 00:00:00 -0000
+++ patches/patch-src_rtl_tcp_c 1 Aug 2026 01:50:16 -0000
@@ -0,0 +1,123 @@
+--- src/rtl_tcp.c.orig.port    Tue Apr 23 18:42:58 2024
++++ src/rtl_tcp.c      Sat Aug  1 10:43:56 2026
+@@ -22,6 +22,7 @@
+ #include <string.h>
+ #include <stdio.h>
+ #include <stdlib.h>
++#include <stdatomic.h>
+
+ #ifndef _WIN32
+ #include <unistd.h>
+@@ -59,9 +60,11 @@ typedef int socklen_t;
+ #define DEFAULT_PORT_STR "1234"
+ #define DEFAULT_SAMPLE_RATE_HZ 2048000
+ #define DEFAULT_MAX_NUM_BUFFERS 500
++#define DEFAULT_RXBUFFER_SIZE 262144  // see "rtl-sdr.h"
+
+ static SOCKET s;
+
++static pthread_t reader_thread;
+ static pthread_t tcp_worker_thread;
+ static pthread_t command_thread;
+ static pthread_cond_t exit_cond;
+@@ -88,8 +91,9 @@ static int enable_biastee = 0;
+ static int global_numq = 0;
+ static struct llist *ll_buffers = 0;
+ static int llbuf_num = DEFAULT_MAX_NUM_BUFFERS;
++static int rxbuffer_size = DEFAULT_RXBUFFER_SIZE;
+
+-static volatile int do_exit = 0;
++static atomic_int do_exit = 0;
+
+
+ void usage(void)
+@@ -100,6 +104,7 @@ void usage(void)
+       printf("\t[-f frequency to tune to [Hz]]\n");
+       printf("\t[-g gain (default: 0 for auto)]\n");
+       printf("\t[-s samplerate in Hz (default: %d Hz)]\n", DEFAULT_SAMPLE_RATE_HZ);
++      printf("\t[-B size of buffer (default: %d kB)]\n", DEFAULT_RXBUFFER_SIZE / 1024);
+       printf("\t[-b number of buffers (default: 15, set by library)]\n");
+       printf("\t[-n max number of linked list buffers to keep (default: %d)]\n", DEFAULT_MAX_NUM_BUFFERS);
+       printf("\t[-d device index or serial (default: 0)]\n");
+@@ -137,7 +142,6 @@ sighandler(int signum)
+       if (CTRL_C_EVENT == signum) {
+               fprintf(stderr, "Signal caught, exiting!\n");
+               do_exit = 1;
+-              rtlsdr_cancel_async(dev);
+               return TRUE;
+       }
+       return FALSE;
+@@ -147,7 +151,6 @@ static void sighandler(int signum)
+ {
+       signal(SIGPIPE, SIG_IGN);
+       fprintf(stderr, "Signal caught, exiting!\n");
+-      rtlsdr_cancel_async(dev);
+       do_exit = 1;
+ }
+

No comments:

Post a Comment