本文介绍了在 PHP 中读取 COM(串行调制解调器)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在 PHP 中读取 COM(串行调制解调器)
我需要一个 COM 接口(Windows、COM2)来使用 PHP 读取.
这个演示正在进行中.阅读是一个问题,它有时会运行.
有没有其他方法(没有 dio,没有 C++)也许 w32api_register_function()
更好?
解决方案
com2 设备应该被引用为 'COM2:'
Reading COM (Serial Modem) in PHP
I'd need a COM interface (Windows,COM2) to read with PHP.
This Demo is going on.Reading is a problem, it's running sometimes.
Is there an other way (no dio,no C++) maybe w32api_register_function()
is better?
function rs232init($com,$bautrate) { `mode $com: BAUD=$bautrate PARITY=N data=8 stop=1 xon=off`; } function send($comport,$char) { $fp = fopen ("$comport", "w+"); if (!$fp) { echo "not open for read"; } else { fputs ($fp, $char); fclose ($fp); } } function read($comport2,$sek) { $buffer = ""; $fp2 = fopen ("$comport2", "r+"); if (!$fp2) { echo "port is open for read"; } else { sleep($sek); $buffer .= fgets($fp2, 4096); } return $buffer; fclose ($fp2); } rs232init("com2","9600"); send("com2","3"); $a = read("com2","2"); echo $a;
解决方案
The com2 device should be referenced as 'COM2:'
这篇关于在 PHP 中读取 COM(串行调制解调器)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!