Guile on an Openmoko Freerunner

I recently got hold of a bunch of Openmoko Freerunners. I needed a distribution which installs to Flash (NAND) so I chose SHR.

I am very impressed how things have progressed especially in terms of being a phone!

Anyway, this gave me a chance to try out some Guile packages I built. If you have a recent version of SHR unstable the following should work:

http://zedstar.org/guile/

Happy Scheming!


Simple example of accessing gpsd from C code

Code:

http://zedstar.org/tarballs/gpstest-0.1.tar.gz

From the README:

A simple GLib based program which periodically reads coordinates from gpsd.

The logs directory contains a sample gps log which can be fed to gpsfake:

gpsfake 1334-N-20071129-GTA01-A3.log

Make sure gpsd is not running before attempting to run gpsfake.

The data was taken from a Neo 1973 in central London. It will take a moment
to start showing coordinates.

** edit ** This example needs updating to work on newer GPSD versions


Adding back cdt support to eclipse (karmic koala)

Currently the eclipse-cdt package is missing from Ubuntu 9.10. To install cdt support do the following:

Fire up eclipse:

  1. Help->Install New Software
  2. Click Add
  3. In location add: http://download.eclipse.org/tools/cdt/releases/galileo

You should be able to select this now from the drop down box titled “Work with:”

Follow it through and it will install what you need. My previous C/C++ view was ghosted so I added it again.


btlogger update

I finally got around to fixing btlogger. It broke after an Ubuntu upgrade which contained BlueZ changes. Anyway, I have moved the code over to Gitorious and made a new tarball and Debian package.

Binary: http://zedstar.org/deb/btlogger_0.3.3-1_i386.deb

Tarball: http://zedstar.org/tarballs/btlogger-0.3.3.tar.gz

Repo: git clone git://gitorious.org/btlogger/btlogger.git

Take a look at the README for further information.


Tweeting from an IRC bot

I have made a Guile module which is capable of being used by the IRC bot bobot++. The code is available here:

http://zedstar.org/tarballs/sneektweet-0.1.tar.gz

The readme:

sneektweet 0.1:

Wraps some C/GLib code which posts to Twitter.

setup:

Edit configure.ac to set twitter account details.

from REPL:

john@thinkpad:~/workspace/sneektweet$ guile
guile> (use-modules (twitter sneektweet))
guile> (tweet "foobar")
guile> ** Message: posted update to Twitter

todo:

Add reading updates and posting back to IRC channel. 

bobot example code:

(use-modules (twitter sneektweet))

(define (sneektweet channel message)
  (if (> (string-length message) 140)
    (bot:say channel "Your message needs to be under 140 characters in length!")
    (tweet message)))

(bot:addcommand "tweet" sneektweet #t 2 0)

shakeyshakey

When accelerometers meet Twitter.

This programs calculates the covariance of data sampled from a Thinkpad’s accelerometers. If the covariance is over a certain threshold it posts the result to Twitter. Or more simply put, shake your laptop and make it tweet!

It is a command line program which requires a Twitter username and password to be supplied e.g.

shakeyshakey -u foo -p bar

Built and tested on Ubuntu (Jaunty Jackalope).

http://zedstar.org/tarballs/shakeyshakey_0.1.orig.tar.gz

http://zedstar.org/deb/shakeyshakey_0.1-1_i386.deb


geotwitta

geotwitta lets you see how far you are from other twitter users running the program. It will post to your twitter account letting you know the distance in kilometers from those users. It is based on a bunch of technologies I wanted to try out. As a result it is somewhat over-engineered for what it does. For those that are interested it uses Guile to script a binary network protocol that happens to be encoded efficiently over UDP packets.

It is a command line program. An example of usage is:

geotwitta -u foo -p bar --lat=55.55 --long=-0.25

This would authenticate against the Twitter account ‘foo’ with password ‘bar’ and ping in those coordinates. These account details are only exchanged securely with Twitter and not sent over the network protocol. The protocol also does not provide coordinates back of other users. It simply shows a relative distance. The full source of the client is available. If there is an interest I will also tidy up the server code and release it.

To get started you need two packages: The program itself and the Guile module which does the network protocol work. The following tarballs are availble for those who want to build from source.

http://zedstar.org/tarballs/packedobjects-0.1.tar.gz

http://zedstar.org/tarballs/geotwitta-0.1.tar.gz

http://zedstar.org/tarballs/geotwitta-0.2.tar.gz

Untar and do the usual ./configure… routine. The configure script will let you know which dependencies are required to compile. If you don’t feel like building from source I have also built some Debian packages. I have tested these on Ubuntu (Intrepid Ibex).

http://zedstar.org/deb/packedobjects_0.1-1_i386.deb

http://zedstar.org/deb/geotwitta_0.1-1_i386.deb

http://zedstar.org/deb/geotwitta_0.2-1_i386.deb

If you manage to get the software running I will see you on Twitter!

All the usual disclaimers about the software apply.

**update**

Version 0.2 of geotwitta added: ignores UDP packet loss on pings


btlogger debian package

I packaged up the tarball into a debian package:

http://zedstar.org/deb/btlogger_0.3.2-1_i386.deb

After installing run btlogger –help


Bluetooth logging to Twitter with btlogger

I decided to hack my Bluetooth logger so that it could post any new devices it saw to my Twitter account. This should be interesting once I get it setup on my desk at work! After moving to Intrepid Ibex I realised the changes in BlueZ versions borked my software. It took me a while to figure out what needed to be fixed. Anyway, these changes and Twitter hack are available as a tarball here:

zedstar.org/tarballs/btlogger-0.3.2.tar.gz

The tarball should install an sqlite db file in /var/lib/misc but you can move it else where if you don’t want to run as root. If you supply a username and password on the command line it will try and post the scan results to Twitter like:

http://twitter.com/jptmoore

To see the command line options run btlogger –help


Building a Guile extension on an embedded device

Thanks to OpenEmbedded building extensions for Guile that run on embedded devices such as the BeagleBoard is fairly painless. As I have previously mentioned, Guile is already supported by OpenEmbedded. If you have an extension which is made up of some C code and some Scheme code you first should automate building it with autoconf. This might install a shared library and install some Scheme files into Guile specific locations. The next step is to write a bitbake recipe which will work with this autoconf based project. Typically this recipe will download a tarball or checkout some code from version control and then begin its magic. The end product hopefully is a binary package which can be easily installed onto the device. As an example I built packedobjects as a Guile extension for my BeagleBoard. The bitbake recipe is availabe here:

http://packedobjects.cvs.sourceforge.net/viewvc/packedobjects/packedobjects_project/openembedded/

This works by getting the latest code from CVS. It builds the code and is told which files need to be part of the package. So if you have OpenEmbedded setup you just need to issue the command:

bitbake packedobjects

This will build and package the lastest code as an ipk.

We should test the built ipk on the device to see if it works:

root@beagleboard:~# opkg install http://zedstar.org/ipk/libpackedobjects0_0.1-r0.1_armv7a.ipk
Downloading http://zedstar.org/ipk/libpackedobjects0_0.1-r0.1_armv7a.ipk
Installing libpackedobjects0 (0.1-r0.1) to root...
Configuring libpackedobjects0
root@beagleboard:~# guile
guile> (use-modules (packedobjects))
guile> (exit)