Arduino, RPi & PHP help! (2-way serial comm)

Update:

seems to be working in some reliable fashion now..

I trimmed the PHP (serial_listener.php) script down to just this

$responseValue = "";
do{
      $incomingChar = fread($fp, 1);
      $responseValue .= $incomingChar;
}while(strlen($responseValue) < 1);
echo $responseValue;

I can now work with single character responses with the above... (and I really only need to send a 1 upon completion instead of 'complete'... and I can send whatever I want back to the AJAX callback to be parsed..

If I want to check for the whole string 'complete' coming from the Arduino (which is not needed)..

I just changed the value to 8 for the conditional before sending..etc..

$responseValue = "";
do{
      $incomingChar = fread($fp, 1);
      $responseValue .= $incomingChar;
}while(strlen($responseValue) < 8);
echo $responseValue;

Update 2:

Lost communication again.

I cant make heads or tails of all this now!

There is something going on with the port opening I think? or a combination of the capacitor I have on the Arduino to NOT reset each time the port is opened perhaps?.. SOMETHING!

I could refresh and/or re-send consistently for a little bit (as I was watching debug output in Firebug, and it matched console.log() data to actions)

I need to do some more tests and log each result to see if any patterns arise I guess. :frowning:

I am NOT seeing any NOT OPEN message displayed anywhere.. so I believe the port IS being opened correctly. Grrrrr.. LOL