Giving PHP permission to access the COM port

I am creating a php script that connects to a 3G modem connected through a serial connection on COM5.

I get the following error, and I believe that this is because php does not have access to the r / w COM interface:

Warning: fopen (COM5 :) [function.fopen]: could not open the stream: there is no such file or directory in C: \ xampp \ htdocs \ SMStest \ test2.php on line 9

// mode com1: BAUD=9600 PARITY=N data=8 stop=1 xon=off
$fp = fopen ("COM5:", "w+");
if (!$fp) {
    echo "Uh-oh. Port not opened.";
} else {
    $e = chr(27);
    $string  = $e . "A" . $e . "H300";
    $string .= $e . "V100" . $e . "XL1SATO";
    $string .= $e . "Q1" . $e . "Z";
    echo $string;
    fputs ($fp, $string );
    fclose ($fp);
}
+5
source share
1 answer

There are many ways to access COM ports on Windows; alternatives to your method open it with the following paths:

\Device\00000123 (You can find the correct value in the device manager, properties, details, object name of the physical device)

\\.\com5 ( , C - )

+1

All Articles