Open com port in php

Leonid picture Leonid · May 7, 2011 · Viewed 12k times · Source

I have a usb 3G modem Huawei E1550 and Windows XP. I want to send sms with this modem trhow php.

I use this function to open a modem com port:

$fp = fopen ("COM3:", "wb+");
if (!$fp) {
    echo "Not open";
} else {
    echo "Open";
}

And every time I get a error:

Warning: fopen(COM3:) [function.fopen]: failed to open stream: Invalid argument in D:\Apache\htdocs\z91.ru\audio\test.php on line 3

Answer

Vinícius picture Vinícius · Sep 14, 2011

You can also try removing the colon next to the COMn for this to work

exec("mode COM3 BAUD=9600 PARITY=N data=8 stop=1 xon=off");

$fp = fopen ("COM3", "w");
if (!$fp) {
   echo "Not open";
} else {
   echo "Open";
}