doupa2871 2010-04-14 01:48 采纳率: 100%
浏览 83
已采纳

从php拨打Windows串口调制解调器

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"; // 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条回答 默认 最新

  • dongxiaoxing3058 2010-04-14 03:35
    关注

    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

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?