Turning a Raspberry Pi 2 into a packet station

March 31, 2016

I keep thinking it’s a good idea for emergency communications to have a packet station. Since I’m cheap, I didn’t want to get extra hardware – instead I wanted to use what I had. Luckily, Dire Wolf is better than any hardware packet decoder out there. Here’s how I got a working packet station on a Pi 2 running Raspbian Jessie Lite.

  1. Connect the radio to the Pi. In my case, I had a spare Signalink SL1+ hanging around which made things easier. I  bought a Syba CMedia USB sound card to talk from the Pi to the Signalink, and a Kenwood speaker mic cable to talk from the Signalink to the radio. Here’s a useful hint: the diameter of the wires in the speaker mic cable are roughly the same as the diameter of the wires in regular Ethernet cable – meaning that you can (if you’re careful) strip the outer jacket, put the inner wires in the right places of an RJ-45 connector and crimp direct to them with no soldering at all.
  2. Download and build Dire Wolf. Instructions for doing so on a Pi are here. I mounted my home directory on a networked drive to make life easier.
  3. Configure Dire Wolf with your callsign (I used the SSID -15 after my call) and sound card. Be sure to avoid the “# ADEVICE – plughw:1,0” line – it looks a lot like the correct “ADEVICE  plughw:1,0” line, but takes input from stdin instead of the sound card.
  4. Run “direwolf” and tune the radio to 144.390 (APRS). Make sure you’re decoding packets. You might have to go to alsamixer and adjust input/output. Mine ended up being 51 for speaker, 29 and 12 for mic. Also adjust the radio volume so it’s not too high or too low. (Hit F6 to get your sound card, then F5 to see all devices. I’m not sure which mic I was using; I had two – a stereo and a mono one. The mono one was 29, the stereo one was 12.) It’s probably a good idea to turn off the squelch on the radio as well.
  5. sudo apt-get install ax25-tools ax25-apps
  6. Edit /etc/ax25/axports and set one line to:
    vhf   mycall-15 1200 255 2 VHF link (1200 bps)
  7. Make sure all the other lines in axports have # in front of them (it doesn’t like blank lines).
  8. Run “direwolf -p” to get the KISS port. It will show up as something like /dev/pts/2. Once it’s running, move to another terminal window.
  9. Change frequency to the freq that you’re going to use.
  10. sudo /usr/sbin/kissattach /dev/pts/2 vhf (your IP address in AMPR
  11. sudo /usr/sbin/kissparms -p vhf -t 200 -s 20 -r 64 -l 50 -f n
    These parameters took a little tweaking. If the transmit delay (-t) was too big, things timed out. If it was too small, things stepped on each other. I had to adjust transmit tail delay as well (-l). I found this page useful for some values.
  12. sudo route del -net netmask
    (because I’d set up a route beforehand and needed to nuke it)
  13. sudo /sbin/route add -net netmask dev ax0
  14. ping -i 10 (someone else’s IP who also has a machine on the AMPR net)
  15. Assuming that works, you might want to apt-get install telnet telnetd talk talkd and try to log into your friend’s machine or have your friend log into yours.
  16. Last but not least: I ran into problems with arp. I increased the arp timeout in /etc/sysctl.d/local.conf:net.ipv4.neigh.default.base_reachable_time_ms=1200000

Turning a Raspberry Pi 3 into an iBeacon

March 29, 2016

Wow, that was easy. Straight out of the box, you can turn your Raspberry Pi 3 into an iBeacon. All you need is Raspbian Jessie – it’s got hcitool installed.

Here’s how to do it. First, decide on your iBeacon UUID and major/minor. For instance, I picked at random:

UUID: c9407f30-f5f8-466e-aff9-25556b57fe6d
Major: 179
Minor: 3

Next, convert the UUID to 16 byte big-endian hex, and convert major/minor to 4 byte big-endian hex:

UUID: C9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D
Major: 00 B3
Minor: 00 03

Plug those numbers into the magic command:

sudo hcitool cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 UUID Major Minor C8

For example:

sudo hcitool cmd 0x08 0x0008 1E 02 01 1A 1A FF 4C 00 02 15 C9 40 7F 30 F5 F8 46 6E AF F9 25 55 6B 57 FE 6D 00 B3 00 03 C8

Finally, turn advertising on with:

sudo hcitool cmd 0x08 0x000A 01

or turn it off with

sudo hcitool cmd 0x08 0x000A 00

That was too easy!

Incidentally, the 4C 00 is the magic bit that says it’s an Apple product, 02 means iBeacon, 15 is the (hex) length of the remaining data. The trailing C8 is the two’s complement of the transmit power at 1m, so c8 is -56. More details can be found at:

Controlling T-Series Vector Impedance Analyzer from a netbook

March 21, 2016

I’ve been using the T-Series Vector Impedance Analyzer program from Times Technology Company to control my dad’s MFJ-226 antenna analyzer (aka Times Technology T200). Both he and I ran into problems with it on a netbook with a screen size of 1024×600. Most of the “interesting” buttons were off screen!

The right solution for Windows 7 and higher appears to be to allow scaling of the netbook’s screen. That’s documented here. But for those unfortunates who are stuck on Windows XP or for some other reason can’t increase the screen size, here’s what I ended up doing.

To start/stop the connection to the analyzer:

  • Click the “SWR” button
  • Press [Tab] [Tab] [Cursor back <-] [Space]

To load a file from the analyzer:

  • Click the “Save to File” button
  • Click “Cancel”
  • Press [Tab] [Tab] [Tab] – you are now on the file to load
  • Press [Backspace] [Backspace] [Backspace] [Del] [Del] [Del]
  • Enter the file you want to load from the analyzer (1, 3, 12, etc.)
  • Press [Shift-Tab]
  • Press [Enter]
  • Now you can click the “Save to file” button and save the data.

Increasing Netbook Screen Size

March 21, 2016

I’ve got an old Acer Aspire One 521 netbook that I’ve had for ages. One of the downsides of netbooks is that their screen resolution is 1024×600 – which is too low for a lot of programs. In particular, all the interesting buttons of the MFJ-226 control program “T-Series Vector Impedance Analyzer” are below the bottom of the screen.

I found a workaround that appears to work on Windows 7 and higher. I found it here: http://www.tlbhd.com/how-to-get-better-resolution-on-your-standard-10-inch-netbook-2772/

The solution: use regedit to search for all instances of “Display1_DownScalingSupported” and change the value 0 to 1. (According to various things I’ve read, you’ll need to do that for all instances, not just one.) Then reboot. When I did this, I ended up in 1024×768 (which looks strange).

Strange isn’t bad, though. Now I can change resolutions to 1024×768 or 1152×864 if an inconsiderate programmer decides he wants to use more than my screen.


Setting up Raspian Jessie on a Pi

March 15, 2016

There are a few changes to setting up Raspian Jessie on a Pi. Here’s what I do:

Burn the image

  1. Get the Raspbian image from the Raspberry Pi downloads page. I’ve been using Jessie Lite, since I don’t need the full package.
  2. Unzip it on a Linux box (mine saw the SD card as /dev/sdb, use your SD card device and don’t wipe your hard drive)
  3. Pop the card out of the Linux box and into the Pi

The command to write that I used:

sudo dd if=2015-01-31-raspbian.img of=/dev/sdb bs=4M

Configure the Pi

When the Pi boots into raspi-config, do the following:

  1. Expand Filesystem
  2. Change User Password
  3. Internationalisation Options / Change Locale, pick en_US UTF-8
  4. Internationalisation Options / Change timezones, pick yours
  5. Internationalisation Options / Change Keyboard Layout, pick US PC 104, accept defaults

Set up the network

I have my Pi configured with a static IP. The first time I boot I attach a network cable.

  1. Edit /etc/dhcpcd.conf (not /etc/network/interfaces) so the wired interface is static
  2. My /etc/resolv.conf was configured automatically by dhcp and was mostly right (missing domain and search, but I guess I can live with that)
  3. Now would be a good time to edit /etc/hostname as well
  4. Edit /etc/hosts to use the new hostname and hostname.domainname

(Thanks to https://pi-hole.net/faq/how-do-i-set-a-static-ip-address-in-raspbian-jessie-using-etcdhcpcd-conf/ for the revised instructions for a static IP.)

I added the following to the end of my /etc/dhcpcd.conf:

# Configure eth0 to be static
interface eth0
static ip_address=
static routers=
static domain_name_servers=
static domain_name=mydomain.foo

Install an editor

I can do a few things like adding users while updates are happening. So:

sudo aptitude update
sudo aptitude install zile

Update the OS

This takes a while, but you can continue on while this is happening.

sudo apt-get install rpi-update
sudo aptitude dist-upgrade

Add my user

I don’t like to use the default user, so I add my own.

  1. sudo addgroup –gid 3009 myshare
  2. sudo adduser –uid 3000 myuser
  3. sudo usermod -a –groups adm,dialout,cdrom,sudo,audio,video,plugdev,games,users,input,netdev,spi,i2c,gpio,myshare myuser
    log out, log in – make sure I can sudo with the new user
  4. prevent login as pi

To prevent the pi login, I do:

sudo vipw -s

and replace the password for pi with *.

Update everything else

Once the dist-upgrade has completed and it’s time to reboot:

sudo /sbin/shutdown -r now

Now you can log in again and upgrade the firmware:

sudo rpi-update
sudo /sbin/shutdown -r now

Get things I know I’ll need

I like to have an emacs clone:

zile ~/.bash_aliases
alias emacs='zile'

I also like tightvncserver on non-Lite images:

sudo aptitude install tightvncserver
(set password)

Finally, make emacs the default editor by appending this to ~/.bashrc:

export EDITOR=/usr/bin/zile

Mounting a CIFS drive

I don’t like to do more writing than I have to, so:

sudo mkdir /etc/samba/credentials
sudo chmod 700 /etc/samba/credentials
sudo chown root.root /etc/samba/credentials
sudo mkdir /shared
sudo zile /etc/fstab
sudo zile /etc/samba/credentials/myserver

In /etc/fstab, I add:

//myserver/shared /shared cifs credentials=/etc/samba/credentials/myserver 0 0

While in /etc/fstab, I change the following to reduce wear on the SD card:

/dev/mmcblk0p1  /boot           vfat    noatime 0 0
/dev/mmcblk0p2  /               ext4    defaults,noatime 0 2

{Edit} I used to have ro,noatime on /boot but the Pi gets really unhappy when you try to upgrade the OS if /boot isn’t writable. So out it came.

In /etc/samba/credentials/myserver, I add:


That’s about it.