Writing

Feed Software, technology, sysadmin war stories, and more.

Tuesday, October 11, 2011

Scanner part two: hardware order and discovering GNU Radio

(This is the second post in a series. You might want to start from the beginning for context.)

Part two: Ordering the hardware and starting with GNU Radio.

I decided to go for it. One morning, I hopped on the Ettus web site and ordered a bunch of hardware. One thing I hadn't noticed last time around was their original USB-based USRP which "only" cost $700. It looked capable of what I needed to do, so I bought that instead of the bigger Ethernet-linked device. That plus the DBSRX2 board and an antenna completed my order.

Then I had to wait. Due to the hub-and-spoke nature of FedEx, my order had to go up to Oakland and back down this way before I could get started. While this was going on, I started playing with the software.

Having discovered jQuery this summer, it wasn't much of a stretch to find jPlayer, which uses either a Flash object or HTML5 audio tags to play media. It looked like the perfect handler for a page which would need to play back a bunch of WAV or MP3 files. I put together a mock-up which didn't look too bad. It had a couple of phony calls with some WAVs I cooked up for the occasion, and it got the job done.

Now I turned to the backend. I started by trying to build gr-smartnet. It turned out to need GNU Radio installed already. Okay then, I went and snagged the latest release of that in tarball form. GNU Radio had the dependency of cppunit, and that wasn't building from source cleanly. I had to do a lot of bashing on that to get past that part. Having installed that, I had to fetch some other deps, but at least those were available as stock packages. Did I mention I run Slackware?

After trying a build, I found out that GR turns off a lot of itself if you don't have GSL installed, but it doesn't break at configure time. Again with the building and installing, then I rebuilt GR, and this time it yielded something usable.

The GNU Radio equivalent of "hello world" seems to be a dial tone. That is, you set up a pair of tone generators (350 and 440 Hz), mix in a little noise to keep from going mad with a pure tone, and send it to your sound card with an audio sink. I had to figure out that it needed 48 kHz output instead of the default 44.1 kHz, but that was it. It sounded good, and it proved that this stuff was for real.

This little 44.1 vs. 48 thing exposed an error in a YouTube video where someone sets up the dial tone demo. If you ever stumble across it, you should notice that it's just a little "off". I suspect it's from the same sampling rate mismatch. I'm guessing most people above a certain age in the US have heard that particular dial tone, so you'll know something is wrong when you hear it, even if you don't know why.

Anyway, I was still waiting on my shipment and decided to buy an antenna which would not make me solder anything so I could get started right away when it did arrive. After a fruitless trip to Fry's, I popped over to a ham radio shop in Sunnyvale and found a decent little thing which looked good. Trouble is, they didn't have any right-angle adapters, and I sure didn't want a 2' antenna sticking straight out of the USRP on my desk.

For that small yet important connector I had to go down the road a little more to Halted and dig through dozens of boxes of junk. Finally, after rummaging around for far too long, I got lucky and found a box of the things way up above my eye level. I don't know how I found it, but I did.

Now I just needed to wait. While waiting, it seemed appropriate to put together some notes on why I was bothering to do this, for future reference:

First, the city's system is trunked, so listening to any one frequency is no good. They jump around any time things go idle. In order to follow a conversation, you need to track all of their channels and pay attention to the metadata on their control channel.

Second, even though I own a trunking scanner, it's of limited use since the city system went through "rebanding" in the past year or so. In short, it means the frequencies they actually use don't line up with the hard-coded ones in my scanner's firmware.

There's no way to edit these frequencies on my model, so I was stuck. I had to just brute-force scan their channels and lock out the control channel. That control channel changes at least once a day, and when it does, you're treated to an ear-splitting buzzsaw sound until you leap up and fix it.

Third, I'm very interested in what's going around me in my little city. Now that I'm spending more time in it by virtue of working on my own business here (and not commuting to Mountain View every day), it only makes sense to stay on top of things. It's just another form of gossip when you come down to it.

Fourth, I found myself wondering what was going on at times when I couldn't possibly tune in. Maybe I was in the car, or at a movie, or otherwise engaged in some activity where it would be improper or impossible to listen. Then a fire engine would fly by, or a bunch of police cars would swarm an area, and I'd be left wondering why. I wanted the ability to "go back in time" to hear what I had missed.

Fifth, calls overlap. With a normal scanner, trunking or otherwise, if you're locked onto the fire department listening to them deal with a pot that's boiled over, you don't get to hear the police chase someone for "failure to yield". Oh sure, eventually the fire department unit stops talking and you click over to the PD, but by then you've missed a lot of the context. I wanted to hear all of it even if they happened at the same time.

Finally, I had read a comment on Hacker News earlier this summer. It was something about how you could take a source of data that's badly formatted or otherwise inaccessible and make it accessible. If enough people found it useful, then you could probably turn it into a business. I considered the radio signals to be exactly that. There are ways to listen to them, but none of them are really good. They're just okay. I knew I could do better.

Next: part three: assembling the USRP and making GNU Radio work with it.