Episode 502 — 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.

Download HD Download MP4 Download XviD Download WMV

Show Notes

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:

<new IP> <subnet mask> <default gateway> [DNS] [WINS]

The new IP is given as the first three octets in xxx.xxx.xxx 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 http://www.elder-n00b.org/2009/02/ip-renumbering-wphp-and-compilers.html

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


  • mxosx

    We spoke, you listened. You guys really are awesome. This episode totally rocked and stimulated my brain to pursue some projects =P Thank you! For this I buy more stickers . . MORE HAK5! =D

  • Jaryth

    Yeah, this ep was actually pretty good.

    I was one of those people motivated by that bad code!! Well, I didnt realize it at first… but I find it VERY odd, that I’ve spent the last 2 weeks dedicating myself to learning PHP…. just after watching that episode! XD. At any rate… thanks…

    Also, in the show notes there, the link at the bottom toe elder-n00b.org is broken (“” isnt right :P).

  • James

    This episode was really bad! In fact this could have been the worse I have seen. Its like someone took a crap or a dump on my computer screen. No! you do not execute php, its a language for web servers. To do scripting you use perl!

  • Darren

    @James rofl the segment was about compiling a script that would invoke special netsh commands in the shell based on the current IP. This assumes the target machine doesn’t have the php, perl, python, etc interpreters. In which case compiling any of said language is valuable. Sorry you feel that your screen was poo’d on.

  • Chris

    Hey guys, just wondered when I saw this… why not use embedded linux on the rover itself rather than interfacing via USB? If you could rig the linux chip up with some wifi and run it wirelessly, either via SSH or running a light httpd/php server on it.

  • Test432

    Why wouldn’t a network with 1,000’s of boxes rely on static DHCP?? I couldn’t imagine them being statically assigned on the client.

  • Jody Franklin

    Test432, you’d have to ask someone that does it that way. I just wrote the script based on a discussion between Matt and Darren in a previous episode. I wouldn’t ever do it… but if I wanted to, I now have a script to manage it; and so you do. 😀

  • ToneyZHowson

    Unquestionably believe that which you said. Your favorite justification appeared to
    be on the web the easiest thing to be aware of. I say to you, I definitely get irked while people think about
    worries that they just don’t know about. You managed to hit
    the nail upon the top and also defined out the whole
    thing without having side-effects , people can take a signal.
    Will likely be back to get more. Thanks

  • pandora sale 2015

    Shante is the place I’m called and I totally love this tag.
    My friends say it isn’t good for me but the things i love doing is
    cycling but I’m thinking on starting today’s truck owner.
    My husband and I stay in Massachusetts and my family loves the situation. I am currently a supervisor but soon I’ll be on acquire.
    Check out the latest news on my website: pandora sale 2015

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>