Jump to content

Giuliano

New Members
  • Posts

    3
  • Joined

  • Last visited

Everything posted by Giuliano

  1. Hello btherl! Do you think the script bellow is correct? I'm trying to execute it, and still PHP is hanging forever. error_reporting(E_ALL); $descriptorspec = array( 0 => array("pipe", "r"), // stdin is a pipe that the child will read from 1 => array("pipe", "w"), // stdout is a pipe that the child will write to 2 => array("file", "error-output.txt", "a") // stderr is a file to write to ); $cwd = NULL; $env = array('some_option' => 'aeiou'); $process = proc_open('c:/fontes/web/sisbalance/lib/plink -serial COM6', $descriptorspec, $pipes, $cwd, $env); if (is_resource($process)) { fclose($pipes[0]); echo stream_get_contents($pipes[1]); fclose($pipes[1]); $return_value = proc_close($process); echo "command returned $return_value\n"; }
  2. btherl, thank you for replying. Using your idea, I executed the following script: error_reporting(E_ALL); $command = exec('c:\fontes\web\sisbalance\lib\plink -serial COM6 -sercfg 4800,7,n,1,n'); With that, PHP hangs forever, just like the other script, because he waits for serial response. So I tried to send the output to a txt file, like this: error_reporting(E_ALL); $command = exec('c:\fontes\web\sisbalance\lib\plink -serial COM6 -sercfg 4800,7,n,1,n >> c:\fontes\web\sisbalance\lib\log.txt 2>&1 &'); PHP still hangs forever. However, the serial port data is sent correctly to log.txt. My question is: Is there a way to execute the script using plink.exe without hanging forever? Thanks in advance!
  3. Hello everybody. I have a script that connects with a weight scale serial port, reads the data and prints the result. Here it is: error_reporting(E_ALL); exec('mode COM6: baud=4800 data=7 stop=1 parity=n xon=on'); $fd = dio_open('COM6:', O_RDWR); if(!$fd) { echo "Error!"; } else { sleep(5); $buffer = dio_read($fd); if ($buffer) { echo $buffer; } } The script should print the buffer when the weight scale print some result. However PHP keeps waiting forever. No error. BUT, if I start a connection with COM6 using Hyperterminal or PUTTY before I run the script, it works perfectly. Any ideas? I'm using Windows, Apache 2.2 and PHP 5.3 Thank you and sorry for my english.
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.