Linux RC Rovers, PHP Compiled and Napera

Darren's got a soldering iron and knows how to use it. In this episode we kick off the HakHouse Rover project and web enable an inexpensive RC Tank using a Phidget USB Interface Kit. Then Jody Franklin joins us to talk about compiling PHP and using Netsh to renumber IP addresses in Windows. And Matt has a follow up to your questions about Napera. Plus our weekly trivia, LAN Party and a ton of fun.

HakHouse Rover - Web Enabling a RC Tank

There comes a time in every geeks life when building a web enabled, crowd sourced, remote controlled vehicle is an imperative. For us that time is now.

The HakHouse rover project kicks off this week with the basics of controlling our inexpensive RC Tank. The toy itself was a mere $15 locally and this is important because cheap RC toys usually have cheap controls. Namely micro switches to control forwards, backwards, left and right. In this segment we break open the controller and solder leads to the board that correspond to movement.

Next we connect the leads with a Phidget Interface Kit. This little board talks to our PC via USB and has programming APIs for C/C++, Python and Java.

With a little hacked together C code in Linux weíre able to control the vehicle. If youíre a C coder weíd greatly appreciate your input on the code. Itís not very pretty at the moment.

Next we toss in a little PHP on Apache and control it from the web. I had originally slapped together a simple page with a form directed at php_self with an if isset and a case switch that initiated exec but itís already been replaced by jzmanís sweet ajaxy code.

This projected is intended to be open source so Iíve got all the code, hardware and other details on our wiki. If youíd like to build one yourself or contribute ideas, code or otherwise itís appreciated.

In the next installment of the HakHouse Rover project weíll be installing a wireless web camera and laser turret to annoy our cat Kerby.

--Darren Kitchen

IP Renumbering w/PHP And A Compiler

In episode 424 a viewer question led to Darren and Matt discussing renumbering a whole subnet of Windows machines using the netsh command in a script, but how would you specify an IP for each machine with only one script? PHP to the rescue, because it's not just for web pages anymore.

Since most Windows workstations don't have PHP installed a compiler will let you prepare your code to run on systems that don't have PHP installed.

First we have Roadsend PHP, which is available for Linux, FreeBSD, Mac OS X and Microsoft Windows. It's released under GNU GPL, and it's runtime libraries are GNU LGPL so compiled programs may be used for both open source and commercial projects.

Roadsend PHP is not just to package up your PHP into nice friendly bundles, it comes with Roadsend Studio, a full development environment (IDE) with support for the Glade interface builder (*nix/Win32), to give your PHP a GUI front end.

It supports PHP 4 and 5, and so far all the code I've compiled with it runs just as it would if launched from the command line using the php command. The only drawback to it is the compile process seems to take a while even on relatively small projects, and the file sizes are a little large (simple scripts weighing in at over 3MB); but if you want to stay in one environment from start to finish Roadsend will do the job.

Second is the Bambalam PHP EXE Compiler/Embedder, which as the name implies is for Windows only. Like Roadsend PHP, Bambalam PHP is free to use as it's released under the PHP license, generates code that will run without a full PHP install, and with the use of the WindBinder library can produce programs with GUI front ends. That is about where the similarities end.

Bambalam is small, consisting of a hand full of files, and is only for the actual building of the executable code. Bring your own editor, debugger, GUI builder, and project manager. That's not what Bambalam is for. What it is for, though, is producing small, fast programs out of any PHP that will run under PHP 4.4.4. The same +3MB code that Roadsend produced came in at just over 1MB with Bambalam, and under 700KB with compression turned on.

The problem my code solves is how to write one script to renumber a whole group of machines without having to issue a different version of the script to each machine. As this is more of a proof of concept we will assume that only the last octet of the IP address will be changing.

The command is issued with the following options:

The new IP is given as the first three octets in format, subnet and gateway will be a full four octets a peice. IP, DNS, and WINS can each be assigned as DHCP (using DHCP for IP preclueds the need for subnet and gateway). DNS and WINS can also be assigned as NONE so long as IP is not DHCP. Furthermore specifying WINS requires that some value be given for DNS.

If a new first three octets are given without specifying DNS or WINS and those values were already staticly assigned then the new first three octets will be used for those values as well. Also if IP is currently assigned via DHCP that can't not be changed at this time.

Full source and future updates are available at

Thanks to those who've contributed to the success of Hak5. Your donations are greatly appreciated!