Skip to content

Commit e6e6c0d

Browse files
committed
Add RTL-TCP.
1 parent 66fb5da commit e6e6c0d

File tree

4 files changed

+130
-0
lines changed

4 files changed

+130
-0
lines changed

rtl-tcp/Dockerfile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
FROM alpine
2+
3+
LABEL maintainer="[email protected]"
4+
EXPOSE 1234
5+
HEALTHCHECK --interval=30s --timeout=30s --start-period=5s --retries=3 CMD pgrep -f rtl_tcp
6+
7+
RUN apk add --no-cache bash rtl-sdr
8+
9+
RUN echo 'blacklist dvb_usb_rtl28xxu' > /etc/modprobe.d/dvb_usb_rtl28xxu.conf
10+
11+
ADD /library.sh /
12+
ADD /rtl-tcp/rtl-tcp.sh /
13+
14+
ENTRYPOINT ["/rtl-tcp.sh"]

rtl-tcp/README.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# RTL TCP (SDR)
2+
3+
Repository for a docker image that runs the rtl_tcp program.
4+
Originally leveraging the `erben22/rpi-rtlsdr-base` image, this image has been overhauled and runs an instance of the rtl_tcp program.
5+
6+
## Environment Variables
7+
8+
| Variable | Type | Description |
9+
| ------------ | ------- | --------------------------------------------------------- |
10+
| DEVICE | integer | Set the device index. *Default 0*. |
11+
| GAIN | integer | Set the device gain. *Default 0 (auto)*. |
12+
| BUFFERS | integer | Set the number of buffers. *Default 15*. |
13+
| LIST_BUFFERS | integer | Max number of linked list buffers to keep. *Default 500*. |
14+
| PPM_ERROR | integer | PPM Error. *Default 0*. |
15+
| FREQUENCY | integer | Frequency to tune to (Hz). |
16+
| SAMPLE_RATE | integer | Sample rate (Hz). *Default 2048000 Hz*. |
17+
| BIAS_T | boolean | Enable bias-T on GPIO PIN 0. |
18+
19+
> All the variables above also support the `_FILE` suffix to load their values from a file.
20+
21+
## Usage
22+
23+
Run rtl_tcp in a container, exposing connections to it via port 1234.
24+
Using `--privileged` and mapping the `/dev/bus/usb` volume, an RTL dongle is made available to the container.
25+
Clients will be able to connect via port 1234 to the docker hosts's address.
26+
27+
```sh
28+
sudo docker run -d -it -p 1234:1234 --device /dev/bus/usb:/dev/bus/usb kosdk/rtl-tcp
29+
```
30+
31+
## Building this Image
32+
33+
Use the [unified build tool](/README.md#building-images).
34+
There are no additional parameters to configure.
35+
36+
## Health check
37+
38+
This image checks to ensure that the script is running.

rtl-tcp/build.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
PLATFORM=linux/arm/v6,linux/arm/v7,linux/arm64,linux/386,linux/amd64,linux/ppc64le,linux/s390x
2+
DOCKERFILE=./Dockerfile

rtl-tcp/rtl-tcp.sh

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
#!/bin/bash
2+
3+
# RTL TCP Entrypoint script
4+
# Copyright (C) 2022 Stewart Cossey
5+
6+
. ./library.sh
7+
8+
extraparams=""
9+
10+
file_env "DEVICE"
11+
file_env "GAIN"
12+
file_env "BUFFERS"
13+
file_env "LIST_BUFFERS"
14+
file_env "PPM_ERROR"
15+
file_env "FREQUENCY"
16+
file_env "SAMPLE_RATE"
17+
file_env "BIAS_T"
18+
19+
validate_env "DEVICE" int
20+
validate_env "GAIN" int
21+
validate_env "BUFFERS" int
22+
validate_env "LIST_BUFFERS" int
23+
validate_env "PPM_ERROR" int
24+
validate_env "FREQUENCY" int
25+
validate_env "SAMPLE_RATE" int
26+
validate_env "BIAS_T" bool
27+
28+
if [ -n "$DEVICE" ]
29+
then
30+
echo "Using device index ${DEVICE}"
31+
extraparams+="-d ${DEVICE} "
32+
fi
33+
34+
if [ -n "$GAIN" ]
35+
then
36+
echo "Using gain ${GAIN}"
37+
extraparams+="-g ${GAIN} "
38+
fi
39+
40+
if [ -n "$BUFFERS" ]
41+
then
42+
echo "Using ${BUFFERS} buffers"
43+
extraparams+="-b ${BUFFERS} "
44+
fi
45+
46+
if [ -n "$LIST_BUFFERS" ]
47+
then
48+
echo "Using ${LIST_BUFFERS} max linked list buffers"
49+
extraparams+="-n ${LIST_BUFFERS} "
50+
fi
51+
52+
if [ -n "$PPM_ERROR" ]
53+
then
54+
echo "Using ppm ${PPM_ERROR}"
55+
extraparams+="-P ${PPM_ERROR} "
56+
fi
57+
58+
if [ -n "$FREQUENCY" ]
59+
then
60+
echo "Using frequency ${FREQUENCY}"
61+
extraparams+="-f ${FREQUENCY} "
62+
fi
63+
64+
if [ -n "$SAMPLE_RATE" ]
65+
then
66+
echo "Using sample rate ${SAMPLE_RATE}"
67+
extraparams+="-s ${SAMPLE_RATE} "
68+
fi
69+
70+
if [ -n "$BIAS_T" ] && [ "$BIAS_T" == "true" ]
71+
then
72+
echo "Using bias-T"
73+
extraparams+="-T "
74+
fi
75+
76+
rtl_tcp -a ${LISTEN_IP:-$(hostname -i)} $extraparams

0 commit comments

Comments
 (0)