@@ -11,6 +11,34 @@ created a convenience class to access the serial port though the Linux file.
11
11
Afterwards, I posted it to [ PHP Classes] ( http://www.phpclasses.org/package/3679-PHP-Communicate-with-a-serial-port.html ) ,
12
12
and this probably is what brought it any visibility.
13
13
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
+
14
42
State of the project
15
43
--------------------
16
44
@@ -91,4 +119,4 @@ GNU General Public License for more details.
91
119
92
120
You should have received a copy of the GNU General Public License along
93
121
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.
0 commit comments