The Clashing Rocks

Posted: August 19th, 2011 | Author: | Filed under: nanonote, packedobjects, The Clashing Rocks | Tags: , , , | No Comments »

This project is about using embedded Linux devices to detect, record and react to seismic events. The idea is to use accelerometers to detect shaking and then communicate this event to all other devices connected to the same broadcast group. We are developing the technology using OpenWrt which allows us to use a range of hardware including routers and pocket computing devices. We really like the idea of exploring emerging low-powered, low-bandwidth mesh networks in developing countries. In this video you can see some early work using a network of Ben NanoNote computers fitted with WPAN hardware. Three devices are connected to a Spread daemon running on a co-ordinating device. Because our current hardware lacks accelerometers we run a program on one device to send fake accelerometer data onto the network. Each device should then pick up this data across our wireless network. We are currently able to get some basic support for IP networking using a hack by Werner Almesberger who also developed the WPAN hardware.  In the video you can see the devices display a bar graph indicating it received data. Only one bar is registered as only one device is transmitting. This bar graph could act as a finger print for deciding the scale of seismic activity in a larger network. We intend to add some more intelligence to this part by building a some kind of knowledge system. Currently the project is at a very early stage with some basic infrastructure developed in C. The aim is to extend this infrastructure by embedding GNU Guile. This will allow us to dynamically control how we communicate, store and process the structured data shared amongst devices. Part of this system will involve trying to minimise the quantity of structured data exchanged on the network by serialising to bit-level using Packedobjects.

Further details of the project can be found at The Clashing Rocks wiki.


GNU Guile on a Ben NanoNote with command line history (readline support)

Posted: May 2nd, 2010 | Author: | Filed under: Handhelds | Tags: , , | No Comments »

I have been hacking at the OpenWrt Makefile and now have command line history working within the REPL.

opkg install http://zedstar.org/guile/libgmp_4.3.1-2_xburst.ipk
opkg install http://zedstar.org/guile/libltdl_1.5.26-1_xburst.ipk
opkg install http://zedstar.org/guile/guile_1.8.7_xburst.ipk

Once installed setup a .guile file:

root@BenNanoNote:~# cat /root/.guile
(use-modules (ice-9 readline))
(activate-readline)

When you run guile now you should be able to use the up and down cursor keys to go through your command history etc.


A minimal OpenWrt image for the Openmoko Freerunner containing GNU Guile

Posted: May 2nd, 2010 | Author: | Filed under: Handhelds | Tags: , , | No Comments »

To experiment some more with OpenWrt I dusted out a Freerunner and built a minimal image containing GNU Guile. The image is built with glibc and an IP 192.168.254.101 to match my Nanonote settings.

** UPDATE: GNU Guile now has readline support and root image now contains GLib **

Flash the following:

http://zedstar.org/freerunner/openwrt-s3c24xx-2.6-uImage

http://zedstar.org/freerunner/openwrt-s3c24xx-root.jffs2-128k

Boot the device then:
john@thinkpad:~$ telnet 192.168.254.101
Trying 192.168.254.101…
Connected to 192.168.254.101.
Escape character is ‘^]’.

=== IMPORTANT ============================
Use ‘passwd’ to set your login password
this will disable telnet and enable SSH
——————————————

BusyBox v1.16.1 (2010-05-02 14:45:14 BST) built-in shell (ash)
Enter ‘help’ for a list of built-in commands.

_______ ________ __
| |.—–.—–.—–.| | | |.—-.| |_
| – || _ | -__| || | | || _|| _|
|_______|| __|_____|__|__||________||__| |____|
|__| W I R E L E S S F R E E D O M
KAMIKAZE (bleeding edge, r21293) ——————
* 10 oz Vodka Shake well with ice and strain
* 10 oz Triple sec mixture into 10 shot glasses.
* 10 oz lime juice Salute!
—————————————————
root@OpenWrt:/# uname -a
Linux OpenWrt 2.6.30.10 #1 PREEMPT Sun May 2 14:59:31 BST 2010 armv4tl GNU/Linux
root@OpenWrt:/# guile
guile> (string-tokenize “hello world”)
(“hello” “world”)
guile>


A dynamic data encoder for embedded systems

Posted: April 3rd, 2010 | Author: | Filed under: packedobjects | Tags: , , | No Comments »

I personally view Scheme as a good extension language. Something that can be embedded into C code to ease the pain of doing everything in C. I am interested in exploiting this concept on embedded systems where there is a lot of fooling about to make a binary. I still intend to produce binaries and reuse the large amount of existing C code out there. However, I want to script the network communication and in particular the structure of the network packets. I have periodically been working on a tool that attempts to support this. This summer I intend to get rid of the old C code in this project and rewrite it entirely in Scheme apart from the low-level encoder/decoder which will remain in C. In this white paper I attempt to describe the work.

**update**

This white paper has now be superseded by the paper “Everything counts in small amounts“.


Guile on a Ben NanoNote

Posted: February 25th, 2010 | Author: | Filed under: Handhelds | Tags: , | 2 Comments »

Received a Ben NanoNote today. It is a really natty little device with a lot of potential.

My standard test on how hackable a device is involves getting Guile running. Anyway, it was pretty easy to accomplish this despite not using openWrt before.


root@BenNanoNote:~#
root@BenNanoNote:~# guile
guile> (map (lambda (x) (+ x 1)) '(1 2 3 4 5))
(2 3 4 5 6)
guile>

To install get the 3 xburst packages from here.

Happy Scheming!


Scripting with Guile on Openmoko

Posted: December 5th, 2009 | Author: | Filed under: Handhelds | Tags: , , | No Comments »

Having Guile running on an embedded device is very powerful. You can add scripting capabilities to a C program and avoid some of the cross compilation -> deploy cycles by simply editing the script to change some functionality. As an example I have taken the code from the excellent introductory article Scripting with Guile. I packaged the code so that if you install the tarball or the ipk it will install both the binary and script to a suitable place.

Tarball: http://zedstar.org/tarballs/square-0.1.tar.gz

ipk: http://zedstar.org/ipk/square_0.1-r0_armv4t.ipk

After installing Guile do:

root@om-gta02 ~/ipks $ opkg install square_0.1-r0_armv4t.ipk
Installing square (0.1-r0) to root...
Configuring square
root@om-gta02 ~/ipks $ square
result of square is 49
result of square2 is 81


Guile on an Openmoko Freerunner

Posted: December 4th, 2009 | Author: | Filed under: Handhelds | Tags: , , | No Comments »

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!


Tweeting from an IRC bot

Posted: June 26th, 2009 | Author: | Filed under: twitter | Tags: , , , | No Comments »

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)

geotwitta

Posted: May 2nd, 2009 | Author: | Filed under: packedobjects, thumbtribes | Tags: , , | 2 Comments »

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


Building a Guile extension on an embedded device

Posted: January 25th, 2009 | Author: | Filed under: General, packedobjects | Tags: , , , | No Comments »

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)