<?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. */
<?php //var $testing = true; require_once "portDriver.php"; // Create the device; $serial = new serialPort(); // Open the device. $serial->openPort("/dev/ttyS1"); $serial->sendInit(); // Send a message. //$serial->sendMessage(chr(0x00) . chr(0x01)); // Receive. //$testing = $serial->getMessage(); //do{ //if(($testing = $serial->getMessage()) === false) //{ // echo "\nYour request timed out!\n"; //} //else //{ $reader = ""; $message = ""; $myArray = ""; //echo "\nYou have a message \n"; //if($testing !== chr(10) ) //{ //echo "\n".(chr($testing))."\n"; /* do{ $message.= $reader; $reader = $serial->getMessage();
<html> <head> <title>SERIAL SENDER</title> </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!";
<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";