Simple Raspberry Pi kernel to flash an LED with a preset pattern

After playing with a PiFace extension board on one of my Raspberry Pi computers, and getting it to flash Knight Rider-style patterns [Python v3 code here], I decided to try flashing LEDs from bare metal.  While I am very familiar with Intel x86 assembly language, this was my first forage into the ARM assembly language, and this Raspberry Pi kernel is my first purely home-made kernel.

The source and binary for my kernel may be found in battlesnake/pi-kernel-led-flasher on GitHub.  By default it flashes the following pattern, although the pattern can be changed easily (see the README).


As for the ARM architecture and assembly language:  the ability to set condition execution flags on almost any instruction is a lovely idea, which presumably make for better pipeline usage by requiring less conditional branching (although my kernel doesn’t bother enabling branch prediction).  The Intel-like syntax is also a nice touch, since I was initially expecting to be forced into the grotesque AT&T syntax that the Linux world seems to bizarrely like.

Javascript: hierarchy and inheritance in a prototypal paradigm

While seen by many as some messy little web page language, Javascript has a fairly unique elegance to it when put alongside other object-orientated programming languages (C#/Delphi/Python/Java/C++).  This uniqueness is part of the reason for the generally negative stigma towards the language. The prototypal inheritance model is unintuitive to those (such as myself) who have come from a classical inheritance background, and the weak dynamic typing allows beginners with little OOP knowledge to rapidly produce working but extremely messy, inconsistent, hackish code that reciprocally convinces them (and others) that Javascript is a messy, inconsistent, hackish language.

One only has to look at the booming node.js movement to see that this strange little language must have some positive side though.  To illustrate the object model and inheritance in Javascript, I put together a little script (on to demonstrate the prototypal model by example (specifically, by emulating a traditional hierarchical paradigm), which may be viewed and run here.  When run, the script creates a list of Javascript built-in classes, in addition to some classes “derived” within the script.  A tree of these is then displayed in the console, showing the inheritance hierarchy:




Wake-on-lan remote interface

This software provides a way to wake (via wake-on-lan) machines on a remote network.

After making my home PC accessible externally via Dynamic DNS, I needed a way to remotely power it on and off, since leaving it on 24/7 would run up a large energy bill.  I took one of my (many) Raspberry Pi computers and set up a script to log the MAC addresses of all machines detected on the network, along with corresponding IP addresses and hostnames.  This script runs periodically as a cron job, providing a list of machines by name or last known IP, and their associated MAC addresses.

A web interface allows any PC from this database to be chosen, and for a wake-on-lan magic packet to be dispatched to it.  Provided the PC is connected to the network via an ethernet cable and wake-on-lan is enabled on the associated adapter, the end result is that the chosen PC will turn on in response to me clicking a button in my web browser from 40 miles away.

The PC must be wired into the network in order to receive wake-on-lan packets, but there can be wireless links between the router/switch that the PC is wired to and the Raspberry Pi.  Wake-on-LAN magic packets are sent as UDP broadcasts in my script, although they could be in any type of container that will get routed to the target PC’s ethernet port.

Download: Remote Wake-on-LAN, MAC database scripts and web interface
Latest version (github): battlesnake/macs