Exemplo n.º 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;
 }
Exemplo n.º 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;
 }
Exemplo n.º 3
0
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();
}
Exemplo n.º 4
0
 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();
 }
Exemplo n.º 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;
}
//GLOBAL tachitita gia stop
$DIYrodastop = "050";
// ************************************************
// ***************** include **********************
// ************************************************
// vriski tin thessi tou auto
require_once "/root/phpscripts/position.php";
// ************************************************
// ***************** fopen **********************
// ************************************************
//fopen motor write
$serial = new phpSerial();
$serial->deviceSet($DIYmotors);
$serial->confBaudRate(9600);
$serial->confParity("none");
$serial->confCharacterLength(8);
$serial->confStopBits(1);
$serial->confFlowControl("none");
// fopen for write data cloud
if (!($DIYpipecloud = fopen("/root/arduinocloud", "r+"))) {
    echo "Cannot link with sonar, wrong usb connected";
    exit;
}
// fopen for read sonar data
if (!($sensors = fopen("/dev/ttysonar", "r"))) {
    echo "Cannot link with sonar, wrong usb connected";
    exit;
}
// ************************************************
// ***************** function cloud *********
// ************************************************
Exemplo n.º 7
0
//             </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) {
                $time = date('m-d-Y H:i:s', time());
                //Pobiramo podatke iz serijskega porta
    }
}
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();