Evenin'... I found the code below (made a few modifications to get past the errors which were generated colons, apostrophe's etc...
my gut feeling is that PHP isn't really the best solution for serial control (that could well be factually incorrect). It seems to be the case for a noob because there doesn't seem to be many in depth guides/tutorials to follow. The easiest on the eye so far being
http://www.arduinoprojects.com/?q=node/10
Below is my latest effort.. which generates no errors in google chrome on win xp (ooh mental note.. maybe try a different browser).
At the end of this post is the simple 18M2 code, it just listens (serrxd) waiting for ascii code 49. When tested in the PE terminal... the LEDs lights as expected when the '1' key is pressed.
In the PHP code I used '1' and '49' for the stop and go buttons.. as in '1' or '49' should be sent via serial to com11 when either the 'Go' or 'Stop' buttons are pressed. I thought it best to try this way in case I was getting in a pickle with...
serrxd [100,main],b0
or
serrxd [100,main],#b0
The PHP code was amended to echo the value which should be sent serially (1 or 49)
I was hoping that something obvious would jump out at me so I could delete and post a working solution.. alas.. this feels exactly the same if not worse than over 2 years ago, when a dodgy soldering job was preventing that first 18X from accepting a download.. I hate feeling this lost.
As no error messages are generated, does anyone know of a way to see what (if anything) is being sent to com11 when the button(s) are pressed? (probably another self-instruction to check google there).
I will try next with the DIO extension...
Code:
<?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>
and the 18M2 prog...
Code:
;comport 11
setfreq M8
symbol LED_Pause = 100
main:
'sertxd ("waiting for data...")
serrxd [100,main],b0
if b0=49 then Goto LED_Flash
Goto Main
LED_Flash:
sertxd ("echo...",b0)
for b1 = 1 to 10
High B.4
pause LED_Pause
High B.5
pause LED_Pause
High B.6
pause LED_Pause
High B.7
pause LED_Pause
Low B.4,B.5,B.6,B.7
pause LED_Pause
next b1
goto main