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

kar*_*nan 5 html javascript php mysql

我正在使用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 in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 234

Warning: Unable to set parity : the device is either not set or opened in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 288

Warning: Unable to set length of a character : the device is either not set or opened in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 336

Warning: Unable to set the length of a stop bit : the device is either not set or opened in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 377

Warning: The device must be set before to be open in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 167

Warning: Device must be opened in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 608

Warning: Device must be opened to read it in D:\xampp\htdocs\Serialport\PHP-Serial-develop\PHP-Serial-develop\php_serial.class.php on line 522

here it ishere it was
Run Code Online (Sandbox Code Playgroud)

知道为什么这不起作用吗?

我的设备已连接到 COM10,并显示为Silicon Labs CP210x USB 转 UART 桥接器 (COM10)