GNU-Radio – Mike Richards G4WNC https://photobyte.org Freelance Technical Author, Illustrator & Photographer Wed, 25 Aug 2021 18:30:38 +0000 en-GB hourly 1 https://wordpress.org/?v=6.4.3 RTL-SDR Server as a service on Raspberry Pi https://photobyte.org/rtl-sdr-server-as-a-service-on-raspberry-pi/ https://photobyte.org/rtl-sdr-server-as-a-service-on-raspberry-pi/#comments Wed, 21 Mar 2018 00:31:51 +0000 https://photobyte.org/?p=1696 Updated 25th Aug 2021 Clarified RTL-SDR build requirements

NB: This post assumes that you have already built the RTL-SDR server from source using the following instructions. 

Install RTL-SDR server 

These instructions will not work if you install RTL-SDR via the repository, i.e. sudo apt install…

Now that Raspbian has changed to Systemd for managing auto-starting programs and daemons, I thought it was about time I moved away from using rc.local to start the rtl-sdr server.

If you ‘re currently using the rc.local file to start the server, begin by removing the server commands from that file.

The next job is to create a unit file to provide Systemd with the essential information for the management of the service. To create the unit file, use nano as follows.

Enter: sudo nano /etc/systemd/system/rtlsdr.service

Once nano opens, populate it with the following lines:

[Unit]
Description=RTL-SDR Server

Wants=network-online.target
After=network-online.target

[Service]

ExecStartPre=/bin/sleep 15
ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I)’
WorkingDirectory=/home/pi
StandardOutput=inherit
StandardError=inherit
Restart=always

[Install]
WantedBy=multi-user.target

When you’ve entered the lines above, press ctl x then y and Enter to save the file.

To test the service, make sure the RTL dongle and network are connected and enter: sudo systemctl start rtlsdr.service. If that proceeds without error, you can check the status of the service with sudo systemctl status rtlsdr.service. If all is well, you should see a message showing that the RTL-SDR dongle has been found. You can stop the service with sudo systemctl stop rtlsdr.service. If you’re happy that all is working ok, you can enable the service so it automatically starts at boot time. Enter the following: sudo systemctl enable rtlsdr. To disable the auto-start service it’s sudo systemctl disable rtlsdr.service

Time Saving Tip: When entering systemctl commands, you can omit the .service suffix.

You can find out more about Systemd at: https://fedoramagazine.org/what-is-an-init-system/

ExecStart Explanation

ExecStartPre=/bin/sleep 15

This line adds a 15 second delay between completion of the network setup and starting the Spy Server. This is included as a precaution to allow time for a slow router to allocate an IP address for the Pi. If the start-up delay is a problem for you try reducing the sleep time or eliminating this line completely.

ExecStart=/bin/sh -c ‘/usr/local/bin/rtl_tcp -a $(hostname -I)’

This line starts the server but warrants some explanation. One of the problems with starting the rtl-sdr server as a service is the lack of a system variable to provide the Pi IP address. We need this because we have to pass the IP address to the server when it’s started. In this solution, I’ve called sh first and used the -c option. This tells sh to get the command line instruction from the quoted string that follows. That way we can use our standard call to rtl_tcp and combine it with the command line $(hostname -I) instruction to retrieve the IP address.

Mike – G4WNC

]]>
https://photobyte.org/rtl-sdr-server-as-a-service-on-raspberry-pi/feed/ 11
GNU Radio https://photobyte.org/gnu-radio/ https://photobyte.org/gnu-radio/#respond Mon, 17 Jun 2013 07:44:53 +0000 https://photobyte.org/?p=32 Watch this space for details of pre-configured Virtual Machines (VMs) that you can use to get started with GNU Radio projects.

]]>
https://photobyte.org/gnu-radio/feed/ 0