Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/fawno/php-serial
Serial port access convenience class
https://github.com/fawno/php-serial
php serial serial-communication serial-port serialport
Last synced: about 5 hours ago
JSON representation
Serial port access convenience class
- Host: GitHub
- URL: https://github.com/fawno/php-serial
- Owner: fawno
- License: mit
- Created: 2021-10-10T06:12:21.000Z (about 3 years ago)
- Default Branch: master
- Last Pushed: 2022-03-06T22:39:40.000Z (over 2 years ago)
- Last Synced: 2024-11-09T03:45:27.748Z (7 days ago)
- Topics: php, serial, serial-communication, serial-port, serialport
- Language: PHP
- Homepage:
- Size: 46.9 KB
- Stars: 1
- Watchers: 2
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# PHP-Serial
[![GitHub license](https://img.shields.io/github/license/fawno/PHP-Serial)](https://github.com/fawno/PHP-serial/blob/master/LICENSE)
[![GitHub release](https://img.shields.io/github/release/fawno/PHP-Serial)](https://github.com/fawno/PHP-serial/releases)
[![Packagist](https://img.shields.io/packagist/v/fawno/php-serial)](https://packagist.org/packages/fawno/php-serial)
[![PHP](https://img.shields.io/packagist/php-v/fawno/php-serial)](https://php.net)Serial port access convenience class
## Requirements
- PHP Pecl dio extension (>= 0.2.1) for SerialDio.## Installation
You can install this plugin into your application using
[composer](https://getcomposer.org):```
composer require fawno/php-serial
```## Usage
```php
require 'vendor/autoload.php';use Fawno\PhpSerial\SerialDio;
use Fawno\PhpSerial\SerialConfig;
use Fawno\PhpSerial\SerialBaudRates;
use Fawno\PhpSerial\SerialStopBits;
use Fawno\PhpSerial\SerialParity;
use Fawno\PhpSerial\SerialDataBits;// Create default serial config
$config = new SerialConfig;// Set Data Rate
$config->setBaudRate(SerialBaudRates::B9600);// Set Data Bits
$config->setDataBits(SerialDataBits::CS8);// Set Stop Bits
$config->setStopBits(SerialStopBits::ONE);// Set Parity
$config->setParity(SerialParity::NONE);// Set Flow Control
$config->setFlowControl(true);// Create SerialDio object with COM3 as device
$serial = new SerialDio('COM3', $config);// Open device
$serial->open('r+b');// Set Blocking
$serial->setBlocking(0);// Set Timeout
$serial->setTimeout(0, 0);// Send data
$serial->send($data);// Read data
$data = $serial->read();
```