(Using Apache 2.2 / PHP 5.3.4 running on Windows XP sp 3)
Hello, was hoping someone might be able to take a look at the php in the code below and explain where it is I've gone wrong.
The code is similar to other examples I googled. The setup is very simple, I have a microcontroller which waits for a byte of serial data (any serial data). If data is received then 4 LEDs flash in sequence.
I know the microcontroller is working because I can send the serial data either through hyper terminal or the IDE for the pic. Pressing/sending any keyboard input causes the LED lighting sequence to fire.
Unfortunately, the code below generates no errors nor any LED activity. Have I missed something glaringly obvious?
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-
1">
<title>Garage Door Control System</title>
</head>
<body>
<h1>Garage Door Control System</h1>
<?php
if (isset($_REQUEST['send'])) {
// Sending serial commands in PHP is pretty easy
$fp = fopen("COM11", "w");
fwrite($fp,chr(49));
fclose($fp);
}
?>
<form action="garage_door_serial.php" method="post">
<input type="hidden" name="send" value="1" />
<input type="submit" value="Garage door button" />
</form>
</body>
</html>
similarly, the code below does nothing on the LED side.
<?php
if (isset($_POST["rcmd"])) {
$rcmd = $_POST["rcmd"];
switch ($rcmd) {
case 'Stop':
'mode COM11: BAUD=9600 PARITY=N data=8 stop=1 xon=none';
$fp =fopen("COM11", "w+");
$chrtr = 49;
fwrite($fp,chr($chrtr)); /* this is the number that it will write */
fflush($fp);
sleep(1);
fclose($fp);
break;
case 'Go':
'mode COM11: BAUD=9600 PARITY=N data=8 stop=1 xon=none';
$fp =fopen("COM11", "w+");
$chrtr = 1;
fwrite($fp,chr($chrtr)); /* this is the number that it will write */
fflush($fp);
sleep(1);
fclose($fp);
break;
default:
die('???');
}
}
?>
<html>
<head><title>Picaxe Control</title></head>
<body>
<center><h1>Picaxe Control</h1><b></b></center>
<form method="post" action="<?php echo $PHP_SELF;?>">
<table border="0">
<tr>
<td></td>
<td>
</td>
<td></td>
</tr>
<tr>
<td>
<input type="submit" value="Stop" name="rcmd"><br/>
</td>
<td></td>
<td>
<input type="submit" value="Go" name="rcmd"><br/>
</td>
</tr>
<tr>
<td></td>
<td><br><br><br><br><br>
</td>
<td></td>
</tr>
</table>
</form>
<table>
<tr>
<td>
<?php echo $chrtr;?>
</td>
</tr>
</table>
</body>
</html>
Thank you.