内容详情 您现在的位置是: 首页> PHP

php在linux串口读写操作

发布时间:2021-03-01 18:37 已围观:892

摘要php在linux串口读写操作

php_serial.class.php 源码地址:https://github.com/Jxzssy/PHP-Serial

<?php  
include "php_serial.class.php";  
// Let's start the class
$serial = new phpSerial;
// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("/dev/ttyS1");
// We can change the baud rate, parity, length, stop bits, flow control
$serial->confBaudRate(19200);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
// Then we need to open it
$serial->deviceOpen();  
// read from serial port
$read = $serial->readPort();
//Determine if a variable is set and is not NULL
// If you want to change the configuration, the device must be closed
$serial->deviceClose();

?>  



声明:本文内容摘自网络,版权归原作者所有。如有侵权,请联系处理,谢谢~
转发:https://ask.csdn.net/questions/967159

赞一个 (7)