Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/lepiaf/serialport
PHP Serial Port
https://github.com/lepiaf/serialport
arduino php php-serial serial-ports serialport
Last synced: 2 months ago
JSON representation
PHP Serial Port
- Host: GitHub
- URL: https://github.com/lepiaf/serialport
- Owner: lepiaf
- License: mit
- Created: 2016-10-31T18:41:17.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2020-12-10T12:06:11.000Z (about 4 years ago)
- Last Synced: 2024-10-22T10:03:27.124Z (3 months ago)
- Topics: arduino, php, php-serial, serial-ports, serialport
- Language: PHP
- Size: 27.3 KB
- Stars: 53
- Watchers: 7
- Forks: 14
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# SerialPort
Connect to serial port with PHP
Inspired by [PHP-Serial](https://github.com/Xowap/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](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
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`.