Home:ALL Converter>Linux Serial disable DTR PHP

Linux Serial disable DTR PHP

Ask Time:2016-03-19T18:26:26         Author:LFS96

Json Formatter

I'm trying to work with an Arduino on Linux with PHP I have a working script, but the (DTR option is enabled. This let the Arduino restart on open the connection, so the question is how to disable DTR.

I have run this once

stty -F /dev/ttyACM0 cs8 9600 ignbrk -brkint -imaxbel -opost -onlcr -isig -icanon -iexten -echo -echoe -echok -echoctl -echoke noflsh -ixon -crtscts

This is my PHP code:

<?php
$fp =fopen("/dev/ttyACM0", "w+");
if( !$fp) {
        echo "Error";die("can't open Serialport!");
}
sleep(2);// wait while restart
fwrite($fp, "1");// turn LED on
$s = null;
while($s != "0"){// wait for answer
        $s = fread($fp, 1);
}
echo $s."<- relsult";
fclose($fp);
?>

This is the Arduino code:

void setup() {
  Serial.begin(9600);
  pinMode(13, OUTPUT);
}
void loop() {
  if ( Serial.available() > 0 ) {
    int inByte = Serial.read(); 
    if (inByte == 0x30) {digitalWrite(13, HIGH);}
    if (inByte == 0x31) {digitalWrite(13, LOW);}
    delay(50);//psydo for doing other things
    Serial.print("0");//say i am ready for the next
  }
} 

Have any one an idea to disable the DTR option.

Author:LFS96,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/36100516/linux-serial-disable-dtr-php
yy