views:

111

answers:

2

I am trying to dial a phone 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);
+1  A: 

Try

$comport = fopen($device, "w+");
...
$atcmd = "ATDT222222222222\r\n";
Michael
same thing, modem clicks, no dialing
bumperbox
A: 

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

bumperbox