小编kar*_*nan的帖子

无法使用 phpSerial 和 XAMPP 打开 COM 端口

我正在使用phpSerial在 COM 端口 (COM10) 上进行通信。

这是我的代码:(与示例代码非常相似)

<?php
require('php_serial.class.php');

echo "<html>
      <head><title>Test MySQL</title></head>
      <body>";

// Let's start the class
$serial = new phpSerial;

$serial->deviceSet("COM10");

$serial->confBaudRate(1200);
$serial->confParity("none");
$serial->confCharacterLength(7);
$serial->confStopBits(1);
$serial->deviceOpen();

$serial->sendMessage("Hello !");

$read = $serial->readPort();

echo "here it is";
echo $read;
echo "here it was";

sleep(1);

$serial->deviceClose();

?>
</body></html>
Run Code Online (Sandbox Code Playgroud)

这是我得到它运行的响应:

Warning: Specified serial port is not valid in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 141

Warning: Unable to set the baud rate : the device is either not set or opened …
Run Code Online (Sandbox Code Playgroud)

html javascript php mysql

5
推荐指数
0
解决办法
3235
查看次数

标签 统计

html ×1

javascript ×1

mysql ×1

php ×1