I'm creating a php script that connects to a 3G modem connected via serial connection on COM5.
I'm getting the following error and I believe it is because php does not have r/w access to COM5:
Warning: fopen(COM5:) [function.fopen]: failed to open stream: 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);
}
There are many ways to access COM ports on windows, alternatives to your method are opening it with the following paths:
\Device\00000123
(You can find the correct value in device manager, properties, details, physical device object name)
\\.\com5
(This is how I would open the port as a file if I was writing a program in C or something)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With