Skip to content

Commit 69f31b2

Browse files
committed
Merge branch 'release/1.0.1'
2 parents f3e6a64 + e37668a commit 69f31b2

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

Readme.md

+29-1
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,34 @@ created a convenience class to access the serial port though the Linux file.
1111
Afterwards, I posted it to [PHP Classes](http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html),
1212
and this probably is what brought it any visibility.
1313

14+
Example
15+
-------
16+
17+
```php
18+
<?php
19+
include 'PhpSerial.php';
20+
21+
// Let's start the class
22+
$serial = new PhpSerial;
23+
24+
// First we must specify the device. This works on both linux and windows (if
25+
// your linux serial device is /dev/ttyS0 for COM1, etc)
26+
$serial->deviceSet("COM1");
27+
28+
// We can change the baud rate, parity, length, stop bits, flow control
29+
$serial->confBaudRate(2400);
30+
$serial->confParity("none");
31+
$serial->confCharacterLength(8);
32+
$serial->confStopBits(1);
33+
$serial->confFlowControl("none");
34+
35+
// Then we need to open it
36+
$serial->deviceOpen();
37+
38+
// To write into
39+
$serial->sendMessage("Hello !");
40+
```
41+
1442
State of the project
1543
--------------------
1644

@@ -91,4 +119,4 @@ GNU General Public License for more details.
91119

92120
You should have received a copy of the GNU General Public License along
93121
with this program; if not, write to the Free Software Foundation, Inc.,
94-
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
122+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.

src/PhpSerial.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ public function PhpSerial()
4747
if (substr($sysName, 0, 5) === "Linux") {
4848
$this->_os = "linux";
4949

50-
if ($this->_exec("stty --version") === 0) {
50+
if ($this->_exec("stty") === 0) {
5151
register_shutdown_function(array($this, "deviceClose"));
5252
} else {
5353
trigger_error(

0 commit comments

Comments
 (0)