Well folks as stated above I made a little control panel for my X10 Ninja Pan/Tilt VK74A unit. The code is fairly simple and have kept it that way and added a few minor things to show how you could expand it.

 Starting right off, #!perl or where ever your perl interpretper is.  From “use string;” through in sub get form at “my($msg) = @_;” should stay fairly standard. Continuing at  “print (<<END);” from there through END after “</html> is the actual webpage. is uses ‘form get’ structure which inputs House Code, then the UnitCode and finally the Command. On the Unit Code it is my understanding that using the CR14A remote control unit that the 4 cameras it sontrols is devided into a set of 4 unit cides, hence 1,4,8,16 as a choice.  This assumption could be wrong since I only have only one VK74A to test with and I am not changing things to test with for right now.  The code that is output from my Apache WebServer in my cgi-bin directory outputs a clean webpage with little coding.  I modeled this code from ahp-cgi.pl that comes with the X10 ActiveHome SDK.

 The only changes I’ve made in my webpage is I start off with a framset for the top and a seperate one for the bottom. This code was taken from the bottom cgi-bin/content2.pl I hope you find this enjoyable and usable.

 

#!perl
############################################################
####### Code modified from ahp-cgi.pl by: Benny D. Miller Jr ARS  W4QED #######
####### Date: Febuary 8th, 2009 ###################################
############################################################
use strict;
use CGI;
my($q,$msg);
$q = new CGI->new();
print “Content-type: text/html\n\n”;
if($q->param(‘cmd’) ne “” && $q->param(‘uc’) ne “” && $q->param(‘hc’) ne “”) {
sendCommand($q->param(‘hc’),$q->param(‘uc’),$q->param(‘cmd’));

$msg = $q->param(‘hc’).$q->param(‘uc’).” “.$q->param(‘cmd’);

}

getForm($msg);

######################################################################

sub sendCommand

{

my($hc,$uc,$cmd) = @_;

system(“ahcmd.exe sendrf “.$hc.$uc.” “.$cmd);

system(“ahcmd.exe sendrf “.$hc.$uc.” “.$cmd);

system(“ahcmd.exe sendrf “.$hc.$uc.” “.$cmd);

# print “ahcmd.exe sendrf “.$hc.$uc.” “.$cmd.”\n”;

}

######################################################################

sub getForm

{

my($msg) = @_;

print(<<END);

<html>

<head>

<title>X10 VK74A Webpage Control Panel</title>

</head>

<body>

<style type=”text/css”>

A {text-decoration: none; font-weight: bold;}

A:hover {text-decoration: underline; color: //FF0000;}

</style>

<center>

<form method=”get”>

<table cellpadding=”1″ cellspacing=”0″ border=”1″ width=”175″>

<tr>

<th bgcolor=”#d3c8a7″>VK74A Control Panel </th>

</tr>

<tr>

<td bgcolor=”#ffffff”>

<table cellpadding=”2″ cellspacing=”0″ border=”0″ width=”100%”>

<tr>

<td align=”left”>

<b>Camera</b>

</td>

<td align=”right”>

<select name=”hc”>

<option value=”C”>C</option>

<option value=”D”>D</option>

</select>

<select name=”uc”>

<option value=”1″>1</option>

<option value=”4″>4</option>

<option value=”8″>8</option>

<option value=”12″>12</option>

<option value=”16″>16</option>

</select>

</td>

</tr>

<tr>

<td align=”left”>

<B>Command</b>

</td>

<td align=”right”>

<select name=”cmd”>

<option value=”PanUp”>up</option>

<option value=”PanDown”>down</option>

<option value=”PanLeft”>left</option>

<option value=”PanRight”>right</option>

<option value=”CamCenter”>center</option>

<option value=”CamSweep”>sweep</option><br>

<option value=”CamGoPosition1″>Position 1</option>

<option value=”CamGoPosition2″>Position 2</option>

<option value=”CamGoPosition3″>Position 3</option>

 

 

 

 

<option value=”CamGoPosition4″>Position 4</option>

<option value=”On”>On</option>

<option value=”Off”>Off</option>

</select>

</td>

</tr>

</table>

</td>

</tr>

<tr>

<td align=”right” bgcolor=”#ffffff”>

<input type=”text” size=”17″ value=”$msg”>

<input type=”submit” value=”Run”/>

</td>

</tr>

</table>

</center>

</form>

</center>

<center>Your IP is: <B>$ENV{‘REMOTE_ADDR’}</B></center>

</body>

</html>

END

}

1;

__END__

Advertisements