sanchescom / php-serial
跨平台串行端口访问便利类
2.0.3
2019-07-22 20:58 UTC
Requires
- php: ^7.2
Requires (Dev)
- mockery/mockery: ^1.2
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-09-23 08:35:33 UTC
README
PHP访问串行端口的跨平台便利类。这是从源库 PHP-Serial 重新构建的版本。当前版本基于PHP 7重写。
入门指南
以下说明将帮助您在本地机器上获取项目的副本并运行,以便进行开发和测试。有关如何在生产系统上部署项目的说明,请参阅部署部分。
安装
在项目的根目录中,使用 Composer 需要此包。
$ composer require sanchescom/php-serial
用法
<?php use Sanchescom\Serial\Serial; try { $serial = new Serial(); // First we must specify the device. This works on both linux and windows (if // your linux serial device is /dev/ttyS0 for COM1, etc) $device = $serial->setDevice('COM5'); // We can change the baud rate, parity, length, stop bits, flow control $device->setBaudRate(2400); $device->setParity("none"); $device->setCharacterLength(8); $device->setStopBits(1); $device->setFlowControl("none"); // Then we need to open it $device->open(); // To write into $device->send('Hello!'); // Or to read from $read = $device->read(); // If you want to change the configuration, the device must be closed $device->close(); // We can change the baud rate $device->setBaudRate(2400); } catch (Exception $e) { }
贡献
请阅读 CONTRIBUTING.md 了解我们的行为准则以及向我们的提交拉取请求的过程。
版本控制
我们使用 SemVer 进行版本控制。有关可用的版本,请参阅此存储库上的 标签。
作者
- Efimov Aleksandr - 重构和支持工作 - Sanchescom
- Rémy Sanchez - 初始工作 - Xowap
有关参与此项目的 贡献者 列表,请参阅。
许可证
本项目采用 MIT 许可证 - 有关详细信息,请参阅 LICENSE.md 文件。
平台支持
- Linux:最初支持的平台,我使用的平台。可能是最少错误的平台。
- MacOS:尽管我从未在 MacOS 上尝试过,但它与 Linux 类似,并且有人向我提交了一些补丁,所以我想它是可以工作的。
- Windows:它似乎对某些人有效,对某些人无效。理论上应该有一种方法可以使它工作。