tvelu77/php-serial
Composer 安装命令:
composer require tvelu77/php-serial
包简介
Multi-platform convenience class to access the serial port from PHP for PHP 8+
README 文档
README
This project was created for a project at my work where a Symfony project needs to communicate to a machine through the COM port on Windows.
After a long time, surfing the web, I found PHP-Serial made by Xowap.
However, when I found out that the project wasn't longer maintened and the pull requests weren't accepted, I decided to share some fixes and improvements !
Especially, a Windows fix, a PHP 8+ compatibility and a cleaner code (I think so, I don't know, Java is better :P).
I really hope it will help someone !
Of course, I am not the main author, all credits goes to Xowap.
Example
<?php include 'PhpSerial.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("COM1"); // We can change the baud rate, parity, length, stop bits, flow control $serial->confBaudRate(2400); $serial->confParity("none"); $serial->confCharacterLength(8); $serial->confStopBits(1); $serial->confFlowControl("none"); // Then we need to open it $serial->deviceOpen(); // To write into $serial->sendMessage("Hello !"); // To read $serial->readLine();
State of the project
Bugs
There is lots of bugs. I know there is. I just don't know which are they.
Platform support
- Linux: need to be tested !
- MacOS: need to be tested !
- Windows: it should work, at least on a Windows server, it works :) !
Concerns
I have a few concerns regarding the behaviour of this code.
- Inter-platform consistency. I seriously doubt that all operations go the same way across all platforms.
- Auto-closing the device. There is an auto-close function that is registered at PHP shutdown. This sounds quite ridiculous, something has to be done about that.
- Use exceptions.
Call for contribution
As in all open-source projects, I need people to fit this to their needs and to contribute back their code.
If you feel like doing any of those, do not hesitate to create an issue or a pull-request, I'll gladly consider consider it :)
tvelu77/php-serial 适用场景与选型建议
tvelu77/php-serial 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 37 次下载、GitHub Stars 达 1, 最近一次更新时间为 2024 年 06 月 21 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 tvelu77/php-serial 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 tvelu77/php-serial 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 37
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 7
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-only
- 更新时间: 2024-06-21