Serial modem to dial from php

I am trying to dial a phone number from php (I have a list of clients in the database and I thought I could use it to call them when I click on their name

here is my code, it doesn't seem to work. I can hear the click of the phone line, but it doesn't seem to dial the number. perhaps I am missing some command to be sent before 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);

      

+2


a source to share


2 answers


decided, stupid me



all that is needed is a sleep () before fclose is just closing the port before it can actually dial the number besides it works fine

+2


a source


Try



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

      

+1


a source







All Articles