开发者

dial windows serial modem from php

开发者 https://www.devze.com 2022-12-27 07:18 出处:网络
I am trying to dial a phon开发者_开发问答e number from php (i have a client list in a database, and thought i could use it to ring them when i click on their name

I am trying to dial a phon开发者_开发问答e number from php (i have a client list in a database, and thought i could use it to ring them when i click on their name

here is my code, it doesn't seem to work. I can hear the phone line click, but it doesn't seem to dial. maybe i am missing some command that needs to be sent prior to atdt?

$device = "COM4";

exec("mode $device BAUD=9600 PARITY=n DATA=8 STOP=1 xon=off octs=off rts=on");

$comport = fopen($device, "r+b");

if ($comport === false) {
    die ("Failed opening com port");
} else {
    echo "Com Port Open";
}

stream_set_blocking($comport, 0);

$atcmd = "ATDT222222222222\r"; // dial fake number
if (fwrite($comport, $atcmd ) === false) {
    die ("Failed writing to com port"); 
} else {
    echo "Wrote $atcmd to com port";
}

sleep(10); // added fix to make program work, was closing port too soon for it to dial

fclose($comport);


solved, silly me

all that is needed is a sleep() before the fclose it was just closing the port before it could actually do any dialing apart from that it seems to work fine


Try

$comport = fopen($device, "w+");
...
$atcmd = "ATDT222222222222\r\n";
0

精彩评论

暂无评论...
验证码 换一张
取 消