rtl_sdr and OpenWRT

Using a TP-Link WR703N and a RTLSDR I decided to make a small dedicate SDR box. Using rtl_tcp I can set up the box and a suitable antenna and use it to receive IQ values over a wifi or ethernet link. Using the wifi means I can do this without pluggin a ton of crap into my laptop.

WR703N

The WR703N has been really well documented, with a full section of mods on its wiki page. I have add serial console headers and a rp-sma antenna connector on the box I used for this project.

These were fun to do, the serial connector makes debricking the WR703N a lot easer, the rp-sma connector allows different antennas to be used with the router. With some more gain behind it, I should be able to place the sdr box somewhere high and out of the way and still be able to connect to it.

For getting OpenWRT onto the WR703N you can follow the generic flashing instructions. Make sure to install Barrier Breaker or later, BB has a prebuilt package for rtl_sdr.

I installed the rtl_sdr software via the web interface, but it can be done from the command line with something like the following.

# opkg update
# opkg install rtl_sdr

rtl_tcp

Once you have the rtl sdr packages installed, connect your rtl sdr dongle to the usb port then run the following.

$ rtl_tcp -a 192.168.1.1 -n 8 -b 8

This command will start rtl_tcp and have it listen on the 192.168.1.1 address for external connections, without this it will only listen on localhost. If you have configured your network differently you will want to change the listen address.

I had a lot of trouble running rtl tcp for more than a few seconds with a client connected, this was fixed by configuring the buffer options. The -n option configures the number of linked lists rtl tcp will use, -b configures the number of buffers it will use. I have had a quick look at the rtl_tcp source, but I couldn't really figure out why this helped so much.

Viewing the data

The last thing to do to test this is connect a client. The rtl sdr tools can't connect to a rtl tcp source, but we can connect and grab some data using netcat.

$ nc 192.168.1.1 > capture.iq

This might be enough if you have a process for dealing with iq data, but I like to look at things. The GrOsmoSDR package comes with a couple of tools for viewing ffts and waterfalls using GNURadio.

$ osmocom_fft -W -s 2000000 -f 144000000 -a 'rtl_tcp=192.168.4.1:1234'

        Without any of the following it will show an fft
-W      Show a waterfall
-S      Show a scope
-F      Show the cool fosphor display

Screenshotting in i3

It took me a while to find a screenshot tool as useful as the built in screenshotting tool in OS X. I looked again today and found the import tool that comes as part of ImageMagick.

$ import screenshot.png

You can use it to capture an area on the screen with the above command or you can capture a whole window.

$ import -window root screenshot.png

I will probably throw this into a script and bind it to a key for ease of use.

Adding a TrueType font

I needed to add a .ttf font for a presentation I was working on, it turned out to be a lot more hassle than it needed to be.

$ mkdir ~/.font  
$ cp font.ttf ~/.font/
$ mkfontdir ~/.font  
$ fc-cache

I read a lot about editing xorg.conf to change font paths, in the end it was a matter of refreshing the font cache and restarting evince.

wait_on

I have been working on stuff in latex recently and wanted something to trigger regeneration of pdfs without manual intervention. At first I thought about doing so in a loop every so often, but it didn't seem like the best approach.

Knowing about the cool kqueue framework I looked to see if there was a utility to watch files for me. I found the wait_on command via a FreeBSD forums post.

The wait on command will wait until the watched file has been changed and then exit. It is meant to be used within a loop. I through this together in zsh. Now when I :wq in vim wait on exists and my document rebuilds, evinces picks up on this and refreshes the display.

$ while true; do wait_on pres.tex; xelatex pres.tex; sleep 5; done

I have the sleep at the end to stop the document being built too often.

Controlling keyboard leds

I have just finished reading Cryptonomicon , without any spoilers I can say that at a certain point a character controls the led's on his keyboard. This morning I found the kbdled utility via a forum post. It looks like a nice simple way to make the keyboard do something useful.