Skip to content

Commit

Permalink
Merge pull request #13 from lepiaf/update-readme
Browse files Browse the repository at this point in the history
update readme with link to example folder
  • Loading branch information
lepiaf authored Oct 31, 2020
2 parents 17e9ff0 + 43c809c commit 36c4356
Showing 1 changed file with 2 additions and 20 deletions.
22 changes: 2 additions & 20 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ 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
Expand All @@ -37,23 +39,3 @@ while ($data = $serialPort->read()) {
```

For mac os, you must use `TTYMacConfigure`. It will use `stty -f` instead of `stty -F`.

```php
<?php

use lepiaf\SerialPort\SerialPort;
use lepiaf\SerialPort\Parser\SeparatorParser;
use lepiaf\SerialPort\Configure\TTYMacConfigure;

$serialPort = new SerialPort(new SeparatorParser(), new TTYMacConfigure());

$serialPort->open("/dev/ttyACM0");
while ($data = $serialPort->read()) {
echo $data."\n";

if ($data === "OK") {
$serialPort->write("1\n");
$serialPort->close();
}
}
```

0 comments on commit 36c4356

Please sign in to comment.