lepiaf/serialport
最新稳定版本:v1.1.0
Composer 安装命令:
composer require lepiaf/serialport
包简介
Serial port access convenience class
README 文档
README
Connect to serial port with PHP
Inspired by PHP-Serial, I simplify it and include composer.json to install via composer.
Actually, it works on linux. This library is suitable for working with Arduino.
Install via composer
composer require "lepiaf/serialport"
How to use
You can check a full example in example folder. It contains a basic Arduino sketch and php file to read it.
Instantiate a new SerialPort object with a parser and configure tty.
<?php use lepiaf\SerialPort\SerialPort; use lepiaf\SerialPort\Parser\SeparatorParser; use lepiaf\SerialPort\Configure\TTYConfigure; $serialPort = new SerialPort(new SeparatorParser(), new TTYConfigure()); $serialPort->open("/dev/ttyACM0"); while ($data = $serialPort->read()) { echo $data."\n"; if ($data === "OK") { $serialPort->write("1\n"); $serialPort->close(); } }
For mac os, you must use TTYMacConfigure. It will use stty -f instead of stty -F.
统计信息
- 总下载量: 10.34k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 54
- 点击次数: 1
- 依赖项目数: 2
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2016-10-31