STATUS March 2012: Working Blink, Partially working Analog and Serial
I spend lots of time writing embedded code. Mostly in C. Beagle Board and Beagle Bone have done some great stuff, and although I still write my code in C to run there, I often want to do something small to the hardware in Perl.
Bonescript is a system using NodeJS that is similar to Arduino. You can use commands like "digitalWrite(pin, HIGH);". But it is in Javascript and NodeJS - which is very cool.
So here is my first attempt at PerlBone.
use PerlBone;
my $ledPin = mapPin('P8_3');
pinMode($ledPin, OUTPUT);
while(1) {
digitalWrite($ledPin, HIGH);
delay(1000);
digitalWrite($ledPin, LOW);
delay(1000);
}
You can even do it the setup/lopp way...
use PerlBone;
my $ledPin = mapPin('P8_3');
sub setup {
pinMode($ledPin, OUTPUT);
}
sub loop {
digitalWrite($ledPin, HIGH);
delay(1000);
digitalWrite($ledPin, LOW);
delay(1000);
}
run();
How does it work:
- Firstly... sorry but it pollutes your name space - to be worked on.
- Exports useful functions (delay is just usleep from Timer::HiRes)
- Writes the necessary commands to /sys/ to update the pins.
Obviously there is a lot more I can do... but considering this has taken less than an hour, it's a good start.
Installation
Zip
GIT
git clone git://github.com/scottp/PerlBone.git
CPAN
(not yet released)
opkg
(not yet released)
The Plan
Part 1 - Release basic system
Using the file writes of the GPIO Linux kernel module, write a basic output and reproduce some of the examples from Arduino, working on a BeagleBone.
Part 2 - Integrate to Beagle Bone
- Create the package, get it distributed
- Integrate into Cloud 9
Part 3 - More advanced code
- Interrupts. There are a few ways to make this better
- Direct Kernel code - bypass the GPIO file interface, which is very slow (a couple of ways to do this already).
See Also
- Cloud9 for embedded Run and Debug from within Cloud9
