我正在使用phpSerial在COM端口(COM10)上进行通信。
这是我的代码:(非常类似于example code)
<?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>
这是我得到它的响应:
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
知道为什么这不起作用吗?
我的设备连接到COM10并显示为 Silicon Labs CP210x USB转UART桥接器(COM10)