Beispiel #1
0
 <?php 
require_once "portDriver.php";
error_reporting(E_ALL);
/* Allow the script to hang around waiting for connections. */
set_time_limit(0);
/* Turn on implicit output flushing so we see what we're getting
 * as it comes in. */
ob_implicit_flush();
// Create the device;
$serial = new serialPort();
// Open the device.
$serial->openPort("/dev/ttyS0");
$serial->sendInit();
//$address = '158.83.200.115';
$address = '192.168.0.1';
$port = 10000;
if (($sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP)) === false) {
    echo "socket_create() failed: reason: " . socket_strerror(socket_last_error()) . "\n";
}
if (socket_bind($sock, $address, $port) === false) {
    echo "socket_bind() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}
if (socket_listen($sock, 5) === false) {
    echo "socket_listen() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
}
do {
    if (($msgsock = socket_accept($sock)) === false) {
        echo "socket_accept() failed: reason: " . socket_strerror(socket_last_error($sock)) . "\n";
        break;
    }
    /* Send instructions. */
Beispiel #2
0
<HTML>
<HEAD>
	<TITLE>SERIAL PORT ACCESS</TITLE>
</HEAD>

<BODY>

<?php 
// Include the serial port class file;
require_once "portDriver.php";
// Create the device;
$serial = new serialPort();
// Open the device.
if ($serial->openPort("/dev/ttyS0")) {
    if ($serial->sendInit() === true) {
        $newCommand = false;
        $quit = false;
        $serial->sendMessage(chr(1));
        do {
            if ($newCommand === true) {
            }
            $reader = $serial->getMessage();
            echo $reader;
            if ($reader === chr(3)) {
                echo "etx";
            }
            if ($reader === chr(4)) {
                echo "eot";
            }
            if ($reader === chr(1)) {
                echo "soh";