PHP Classes

File: example.php

Recommend this page to a friend!
  Classes of Rémy Sanchez   PHP Serial   example.php   Download  
File: example.php
Role: Example script
Content type: text/plain
Description: A small example
Class: PHP Serial
Communicate with a serial port
Author: By
Last change: New version compatible with new class
Date: 17 years ago
Size: 601 bytes
 

Contents

Class file image Download
<?php
include "php_serial.class.php";

// Let's start the class
$serial = new phpSerial;

// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
$serial->deviceSet("COM1");

// Then we need to open it
$serial->deviceOpen();

// To write into
$serial->sendMessage("Hello !");

// Or to read from
$read = $serial->readPort();

// If you want to change the configuration, the device must be closed
$serial->deviceClose();

// We can change the baud rate
$serial->confBaudRate(2400);

// etc...
?>