title: Read response from command on serial port
body: <p>I am programming a PHP application that uses a serial device to do stuff with GSM modem. So you can communicate with the serial port via <code>screen</code> and you would get a response when you write a command.</p>
  
  <p>I use PHP to communicate with my serial port and use <code>sleep</code> to wait between the commands, I se <code>fopen</code> with <code>w+</code> flags and <code>fwrite</code> to send the commands. I tried using the <code>fread</code> function to check if the response is there, but it wasn't. How could that be done in PHP?</p>