GPS Dongle on Raspberry Pi

Firstly install gpsd, gpsd-clients and navit:

sudo apt-get install gpsd gpsd-clients navit

When the gps dongle is connected you should be able to see it when you do “lsusb”. My DealExtreme dongle appeared as “Prolific Technology, Inc. PL2303 Serial Port”, you can take out the USB device, run lsusb, and then reconnect if you’re unsure about what’s what.

pi@raspberrypi ~ $ lsusb
Bus 001 Device 002: ID 0424:9512 Standard Microsystems Corp. 
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0424:ec00 Standard Microsystems Corp. 
Bus 001 Device 005: ID 067b:2303 Prolific Technology, Inc. PL2303 Serial Port

Then if we look at the output of dmesg we can see where that USB device was mounted:

[ 100.854930] usb 1-1.3: new full-speed USB device number 5 using dwc_otg
[ 100.960633] usb 1-1.3: New USB device found, idVendor=067b, idProduct=2303
[ 100.960666] usb 1-1.3: New USB device strings: Mfr=1, Product=2, SerialNumber=0
[ 100.960682] usb 1-1.3: Product: USB-Serial Controller D
[ 100.960697] usb 1-1.3: Manufacturer: Prolific Technology Inc. 
[ 101.019665] usbcore: registered new interface driver usbserial
[ 101.021846] usbcore: registered new interface driver usbserial_generic
[ 101.022601] USB Serial support registered for generic
[ 101.022648] usbserial: USB Serial Driver core
[ 101.031944] usbcore: registered new interface driver pl2303
[ 101.032134] USB Serial support registered for pl2303
[ 101.032277] pl2303 1-1.3:1.0: pl2303 converter detected
[ 101.044257] usb 1-1.3: pl2303 converter now attached to ttyUSB0

Now that we know the GPS dongle is connected to ttyUSB0, we can go ahead and configure gpsd by running:

sudo dpkg-reconfigure gpsd

You can enter the path to the GPS device as the full path (/dev/ttyUSB0), no options are necessary, but have a look at “man gpsd” if you want to see what options are available.

Now you should have a working gps dongle – the output of which you can see with “gpspipe -r”

I followed the instructions from here to configure navit and download binary files for the maps.

Navit on Raspberry Pi

Things to try:
Track your position with Google Earth
Find nicer fonts…

Re-flashing from custom install of OpenWRT

I have acquired a collection of Linksys WRT54GL routers to use as wireless bridges – with only one seemingly small task to do – reflash them with a firmware of my choice. Easy, I thought!

It turns out that the routers had a custom firmware on, that even after a 30/30/30 reset, they didn’t allow the facility to flash the firmware through the UI.

OpenWRT no support for flash firmware

Most interaction had to be done through the command line – here is the procedure I followed:

  1. 1. Perform 30/30/30 reset as described here.
  2. When the router is booting up after only a second or two, repeatedly press the Cisco Systems button on the front – for several seconds. This will enable Failsafe mode.
  3. Telnet into the router (after having manually set your IP address to (If this doesn’t work you probably aren’t in Failsafe mode).
  4. Run “firstboot”.
  5. Reset the root password with “passwd”.
  6. Reboot “reboot -f”.
  7. When the router reboots, you can connect with ssh with the root user, and the password specified previously. From here you can transfer the bin file and flash (as described here or below).
  8. Use scp to transfer the bin file to the temp file system. “scp ~/Downloads/dd-wrt.v24_mini_generic.bin root@”.
  9. Log in to router with ssh, and change into the /tmp/ directory.
  10. Rename the file, to make it a trx. “mv dd-wrt.v24_mini_generic.bin dd-wrt.v24_mini_generic.trx”.
  11. Write to linux fs and reboot “mtd write dd-wrt.v24_mini_generic.trx linux && reboot”.
  12. The router will now boot back up in dd-wrt. Yay!


Salesforce MIXED_DML_OPERATION error on PostInstall script in Managed Package

We’re having another strange bug in work today – we distribute our product as a Managed Package, and constantly have problems with this that only show up when we upload the package.

This week’s issue is a MIXED_DML_OPERATION exception that we are getting, due to updating data in two objects, a custom setting and some PermissionSetAssignments.

We have been using the install scripts as a good way of getting around some restrictions in Salesforce (dml operations in constructors, etc.), and when shipping an updated package we need to update some data – easily done in a PostInstall script.

However, despite following the best practice of code separation using the @future annotation on functions, we are still getting a bug.

Here is the code I have built to set up the PermissionSetAssignments in the future context (which should be in a different context to the custom setting updates):

private static void insertPermissionSetAssignments(Map<Id, Id> psaAssignment){
  List permissionSetAssignments = new List();
    for(Id userId: psaAssignment.keySet()){
      PermissionSetAssignment psa = new PermissionSetAssignment(AssigneeId = userId, PermissionSetId = psaAssignment.get(userId));

As this is a PostInstall script we can’t use some of the usual hacks (system.runas) to avoid this error …



Well, this turned out to be a bit different to what I expected. It was a test class that was causing the error – the postinstall script was fine. So to fix it, we had to write code that would check if you were inside a test or not, and react accordingly…

  User adminuser = [select Id from User where Profile.Name = 'System Administrator' and IsActive = true limit 1];


Getting PS2 EyeToy working on Raspberry Pi

Finally got the EyeToy working on Raspberry Pi

Found the fix here, which disables fiq_split – to allow this USB1.1 device to work correctly.

Next challenge is to get the Logitech QuickCam Pro 4000 – which seems to timeout when accessed – possibly a power supply issue:

pi@raspberrypi ~ $ sudo fswebcam -d /dev/video0 -r 160x120 test3.jpeg
--- Opening /dev/video0...
Trying source module v4l2...
/dev/video0 opened.
No input was specified, using the first.
--- Capturing frame...
Timed out waiting for frame!
No frames captured.

SNES emulators

Firstly, tried installing EmulationStation – got errors when trying to start it.

Then tried making a RetroPie SD card to boot from – worked – but wanted a more elegant solution.

Installed pisnes – a SNES emulator specifically designed for the Raspberry Pi. Installed fine, however when trying to run a few roms it stalled. Mario Kart works ok (but I didn’t remember MK’s graphics being that bad!)

Setup of Raspberry Pi

I’m setting up this blog to keep track of some Raspberry Pi projects I’m doing.

I’ve chosen Rasbian-Wheezy for my OS. Writing to the SD card was simple (once the write switch was enabled on the card (oops)).

Three commands to write the image onto the card:

diskutil list
diskutil unmountDisk /dev/disk3
sudo dd if=/Users/ais/Downloads/2013-09-25-wheezy-raspbian.img of=/dev/rdisk3

When the Pi is started up, you are presented with the raspi-config screen – which lets you configure a few things like default startup environment (which I changed to a graphical desktop environment), and resize the partition to use all available space on the card.

Some of the projects I hope to complete:

  • Setup an emulator for SNES games (guide)
  • Setup Shairport to stream music to stereo
  • Motion Detection webcam (link)
  • Navigation system with USB-GPS device