Exemplo n.º 1
0
    }
    /* Send instructions. */
    $msg = "\nWelcome to the Chimaera Vehicle Control Server. \n" . "To quit, type 'quit'. To shut down the server type 'kill'.\n";
    socket_write($msgsock, $msg, strlen($msg));
    do {
        if (false === ($buf = socket_read($msgsock, 2048, PHP_NORMAL_READ))) {
            echo "socket_read() failed: reason: " . socket_strerror(socket_last_error($msgsock)) . "\n";
            break 2;
        }
        if (!($buf = trim($buf))) {
            continue;
        }
        if ($buf == 'quit') {
            break;
        }
        if ($buf == 'kill') {
            socket_close($msgsock);
            break 2;
        }
        $talkback = "PHP: You said '{$buf}'.\n";
        socket_write($msgsock, $talkback, strlen($talkback));
        $serial->sendMessage($buf);
        echo "{$buf}\n";
    } while (true);
    socket_close($msgsock);
} while (true);
socket_close($sock);
$serial->closePort();
?>
  
Exemplo n.º 2
0
<td><input type="text" name="message"></td>
</tr>
<tr>
<td>Output:</td>
<td><input type="text" name="output"></td>
</tr>
<tr>
<td>&nbsp;</td>
<td><input type="submit" name="Submit"
value="Send"></td>
</tr>
</table>
</form>
<?php 
} else {
    error_reporting(0);
    // Create the device;
    $serial = new serialPort();
    // Open the device.
    $serial->openPort("/dev/ttyS0");
    $serial->sendInit();
    $msg = stripslashes($_POST['message']);
    //$out=stripslashes($_POST['output']);
    $message = $msg . chr(10);
    $serial->sendMessage($message);
    $serial->closePort();
}
?>
</body>
</html>
Exemplo n.º 3
0
</head>

<body>
<?php 
//var $testing = true;
require_once "portDriver.php";
// Create the device;
$serial = new serialPort();
// Open the device.
$serial->openPort("/dev/ttyS0");
$serial->sendInit();
// Send a message.
//for($i=0;$i<100;$i++)
//{
//$serial->sendMessage(chr(0x48) . chr(0x01));
$serial->sendMessage("whats up mother f****r?" . chr(10));
//$serial->sendMessage("1234".chr(2).chr(4)."567".chr(48)."890".chr(10));
//$serial->sendMessage(chr(03).chr(04));
//$reader = $serial->getMessage();
//echo chr($reader);
//}
//$serial->sendMessage();
//$serial->sendMessage("C");
// Receive.
//$testing = $serial->getMessage();
//if($testing == false)
//{
//echo "Your request timed out!";
//}
/**
if(($testing = $serial->getMessage()) !== false)
Exemplo n.º 4
0
	<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";
            }
            if ($reader === chr(2)) {