I am trying to talk to a motor connected to comm1 of my computer. I want to send it the command "MA 25600". It is connected to Comm1. I am using fsockopen and fwrite. The code is as follows. <?php $a=""; $b=""; $c="localhost"; if (!$fp=fsockopen($c,1, $a, $b , 15)) { echo 'this did not work'; } $out = "MA 256000"; if(fwrite($fp, $out)) { echo 'this worked'; } ?> Please help to fix this.
I also tried this <?php $a=""; $b=""; $c="localhost"; if (!$fp=fopen("COM1:", "w")) { echo 'this does not work'; } $out = "MA 256000"; if(fwrite($fp, $out)) { echo 'this is working'; } ?> This gives me the error Warning: fopen(COM1: failed to open stream: Permission denied in c:\program files\easyphp1-8\www\sim\run.php on line 6 and Warning: fwrite(): supplied argument is not a valid stream resource in c:\program files\easyphp1-8\www\sim\run.php on line 15
I haven't tried direct IO using PHP. But these may be useful http://in.php.net/manual/en/function.fopen.php#20935 http://www.codecomments.com/archive228-2005-3-412694.html http://www.phpcs.com/code.aspx?ID=36224 http://www.weberdev.com/get_example-4347.html Thomas