예제 #1
1
 public function getSerial()
 {
     if (!isset(self::$_serial)) {
         $this->displayDebug('Création de l\'interface série sur le port : ' . $this->getConfiguration('port'));
         $serial = new phpSerial();
         $serial->deviceSet($this->getConfiguration('port'));
         $serial->confBaudRate(9600);
         $serial->confParity('none');
         $serial->confStopBits(1);
         $serial->confCharacterLength(8);
         $serial->confFlowControl('none');
         $serial->sendParameters("-ignbrk -hupcl -onlcr -echo -echok -echoctl -echoke");
         $serial->setValidOutputs(array('OK', 'ERROR', '+CPIN: SIM PIN', '+CPIN: READY', '>', 'COMMAND NOT SUPPORT', '+CMS ERROR: 305'));
         self::$_serial = $serial;
         $this->cleanDevice();
     }
     return self::$_serial;
 }
예제 #2
0
 function MySensorMasterCom($device)
 {
     $serial = new phpSerial();
     $serial->deviceSet($device);
     $serial->confBaudRate(115200);
     $serial->confCharacterLength(8);
     $serial->confParity("none");
     $serial->confStopBits(1);
     $serial->confFlowControl("none");
     $this->Serial = $serial;
 }
예제 #3
0
파일: index.php 프로젝트: fuho12/bochovj
function sendCommand($n)
{
    $serial = new phpSerial();
    $serial->deviceSet("/dev/ttyUSB0");
    $serial->confBaudRate(9600);
    $serial->confParity("none");
    $serial->confCharacterLength(8);
    $serial->confStopBits(1);
    $serial->confFlowControl("none");
    $serial->deviceOpen();
    $serial->sendMessage($n);
    // $read = $serial->readPort();
    $serial->deviceClose();
}
예제 #4
0
파일: dylos.php 프로젝트: woolf-wen/dylos
 function init()
 {
     $this->port = $serial = new phpSerial();
     $p = DylosReaderConf::$serialPort;
     $this->log("Opening {$p}");
     $serial->deviceSet($p);
     $serial->confBaudRate(9600);
     $serial->confParity("none");
     $serial->confCharacterLength(8);
     $serial->confStopBits(1);
     $serial->confFlowControl("none");
     // Then we need to open it
     $serial->deviceOpen();
 }
예제 #5
0
function setupSerial($device)
{
    $serial = new phpSerial();
    $serial->deviceSet($device);
    $serial->confBaudRate(9600);
    //Baud rate: 9600
    $serial->confParity("none");
    //Parity (this is the "N" in "8-N-1")
    $serial->confCharacterLength(8);
    //Character length     (this is the "8" in "8-N-1")
    $serial->confStopBits(1);
    //Stop bits (this is the "1" in "8-N-1")
    $serial->confFlowControl("none");
    $serial->deviceOpen();
    return $serial;
}
예제 #6
0
파일: example.php 프로젝트: rxcoder/human
<?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("COM2");
// 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(9600);
// etc...
예제 #7
0
<?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...
예제 #8
0
    file_put_contents($logfilename, $newLog, FILE_APPEND);
    echo $logEvent;
}
//
// main
//
// $device = '/dev/ttyUSB0';
// $write = 'w+';
// sleep(3);
//
// $handle = fopen( $device, $write ); # Write +
include "php_serial.class.php";
$serial = new phpSerial();
#$serial->deviceSet("/dev/ttyACM0");
$serial->deviceSet("/dev/ttyUSB0");
$serial->confBaudRate("9600");
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confFlowControl("none");
$serial->confStopBits(2);
$serial->deviceOpen();
sleep(3);
// Or to read from
$strAllLog = "";
while (true) {
    // $strLog = fgets( $handle ); # Read data from device
    $strLog = $serial->readPort();
    //echo $strLog;
    if ($strLog != "") {
        $strAllLog .= $strLog;
        sleep(5);
예제 #9
0
파일: tree.php 프로젝트: kofeve/robidouille
<?php

include "php_serial.class.php";
include "common.php";
$command = "";
$cmd = $_GET["cmd"];
if ($cmd != "" && array_key_exists($cmd, $gCommands)) {
    $command = $gCommands[$cmd];
} else {
    echo "error";
    return;
}
$serial = new phpSerial();
$serial->deviceSet("/dev/ttyACM0");
$serial->confBaudRate(115200);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
$serial->deviceOpen();
sleep(1);
for ($i = 0; $i < strlen($command); $i++) {
    $serial->sendMessage($command[$i]);
}
$serial->deviceClose();
header('Refresh: 1; URL=/');
echo "Done " . $command;
예제 #10
0
//                <input type="file" name="dat2"/>
//                <input type="submit" name="file" value="Odpri"/>
//             </form>';
// First we must specify the device. This works on both linux and windows (if
// your linux serial device is /dev/ttyS0 for COM1, etc)
//Z klikom na gumb "Odpri" odpremo COM port na določenih vratih z določeno "baud rate"
//TO-DO dodaj še ostale parametre kot so: stop bit, pariteto itd...
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
    if ($_POST['comm'] == 'None') {
        echo 'There\'s no active comm-port that can be used. Please check the connection<br />
		(Right Click on My Computer->Select Properties->Hardware->Device Manager->Ports (COM & LPT))<br />
		If there is a comm-port is active, make sure that it is not being used';
    } else {
        if (isset($_POST['comm'])) {
            $serial->deviceSet($_POST['comm']);
            $serial->confBaudRate($_POST['baud']);
            $serial->confParity("none");
            $serial->confCharacterLength(7);
            $serial->confStopBits(1);
            $serial->confFlowControl("none");
            // Then we need to open it
            $serial->deviceOpen();
            $odprto = true;
            $podatki;
            $cas = time();
            $minute = $cas + 1.5 * 60;
            $time = date('m-d-Y H:i:s', $cas);
            $finish_time = date('m-d-Y H:i:s', $minute);
            $tmp;
            $f = fopen("textfile.txt", "w", "a") or die("Unable to open file!");
            while ($time < $finish_time) {
예제 #11
0
$argv = $_SERVER["argv"];
//$argv is an array
if ($argc == 0) {
    error(usage());
}
$args = parse_args($argc, $argv);
if (isset($args['d'])) {
    $debug = $args['d'];
} elseif (isset($args['debug'])) {
    $debug = $args['debug'];
} else {
    $debug = 0;
}
$dmx = new phpSerial();
$dmx->deviceSet(DMX_DEV);
$dmx->confBaudRate(SERIAL_BAUD);
if (!$dmx->deviceOpen()) {
    die("Could not open DMX Interface on " . DMX_DEV . "\n");
}
$f = 0;
if ($sn = dmx_request_serial_number()) {
    printf("Found DMX Interface with Serial Number: %s\n", $sn);
    if ($fw = dmx_request_parameters()) {
        printf("Firmware Version: %s\n", $fw['FW_VER']);
        printf("DMX Output Break Time: %s x 10.67 = %.02f us\n", $fw['DMX_BR_TIME'], $fw['DMX_BR_TIME'] * 10.67);
        printf("DMX Mark After Break Time: %s x 10.67 = %.02f us\n", $fw['DMX_MABR_TIME'], $fw['DMX_MABR_TIME'] * 10.67);
        printf("DMX Output Rate: %s packets/sec\n", $fw['DMX_OUTPUT_RATE']);
    }
    $f = 1;
}
if (!$f) {
    }
}
if (!$SWITCHER_FOUND) {
    logEntry("switcher command not found: exiting");
    exit(0);
}
$cmd = explode(",", $SWITCHER_CMD);
//print_r($cmd);
$i = 0;
for ($i = 0; $i <= count($cmd); $i++) {
    $switcher_cmd .= chr($cmd[$i]);
}
$SWITCHER_CMD = $switcher_cmd;
logEntry("-------");
logEntry("Sending command");
logEntry("Switcher cmd: " . $SWITCHER_CMD);
logEntry("Sending SERIAL COMMAND");
logEntry("SERIAL DEVICE: " . $SERIAL_DEVICE);
$serial = new phpSerial();
$serial->deviceSet($SERIAL_DEVICE);
$serial->confBaudRate($SWITCHER_BAUD);
$serial->confParity($SWITCHER_PARITY);
//        $serial->confFlowControl("none");
$serial->confCharacterLength($SWITCHER_CHAR_BITS);
$serial->confStopBits($SWITCHER_STOP_BITS);
$serial->deviceOpen();
$serial->sendMessage($SWITCHER_CMD);
sleep(1);
logEntry("RETURN DATA: " . hex_dump($serial->readPort()));
logEntry("RETURN DATA: " . $serial->readPort());
$serial->deviceClose();
예제 #13
0
#!/usr/bin/php
<?php 
include "lib/php_serial.class.php";
$s = new phpSerial();
$s->deviceSet("/dev/ttyUSB0");
$s->confBaudRate(9600);
$s->deviceOpen();
$s->sendMessage("Hello!");
$r = $s->readPort();
print $r;
$s->deviceClose();
예제 #14
0
파일: jog.php 프로젝트: tjankovic/FAB-UI
$feed = 1000;
$raspi_still = false;
if ($_SERVER['REQUEST_METHOD'] == 'POST') {
    include "php_serial.class.php";
    $value = isset($_POST['c']) && $_POST['c'] != '' ? $_POST['c'] : '';
    $feed = isset($_POST['feed']) && $_POST['feed'] != '' ? $_POST['feed'] : $feed;
    if ($value != '') {
        if ($value == 'mdi') {
            $value = isset($_POST['mdi-code']) && $_POST['mdi-code'] != '' ? strtoupper($_POST['mdi-code']) : '';
        }
        if (strpos($value, 'G0') !== false) {
            $value .= ' F' . $feed;
        }
        $serial = new phpSerial();
        $serial->deviceSet(PORT_NAME);
        $serial->confBaudRate(BOUD_RATE);
        $serial->confParity("none");
        $serial->confCharacterLength(8);
        $serial->confStopBits(1);
        $serial->deviceOpen();
        $serial->sendMessage($value . "\r\n");
        $reply = $serial->readPort();
        $serial->deviceClose();
    }
    if (isset($_POST['s']) && $_POST['s'] == 1) {
        $raspi_still = true;
        exec('sudo raspistill -hf -w 512 -h 320 -o /var/www/temp/picture.jpg -t 1');
        $filename = "/var/www/temp/picture.jpg";
        $handle = fopen($filename, "rb");
        $contents = fread($handle, filesize($filename));
        fclose($handle);
예제 #15
-5
function getSerialConnection()
{
    static $serial = null;
    if (!$serial) {
        print "Opening serial connection .. ";
        $serial = new phpSerial();
        if ($serial->deviceSet('/dev/ttyACM0')) {
            $serial->confBaudRate(9600);
            $serial->deviceOpen();
        } else {
            print "ERROR\n";
            exit(1);
        }
        print "OK\n";
    }
    return $serial;
}