Show Posts
Pages: [1]
1  Using Arduino / Interfacing w/ Software on the Computer / Re: PHP fread arduino serial com doesn't work. PLEASE Help!!! on: December 20, 2012, 01:30:42 pm
@billroy

To bypass to bootloader timeout, I disabled the AutoReset by using this method:

http://playground.arduino.cc/Main/DisablingAutoResetOnSerialConnection

Noted that to upload to the board, you must first disconnect this resistor.
2  Using Arduino / Interfacing w/ Software on the Computer / Re: PHP fread arduino serial com doesn't work. PLEASE Help!!! on: December 20, 2012, 01:20:36 pm
Writing to the port works flawlessly. The Arduino picks it up right away. It's the reading afterward that is the problem. If I use the Arduino's compiler to upload code or use it's Serial Monitor once before running my PHP, everything works great.

It is the cold start of the board without activating the Arduino Compiler or Serial Monitor that my PHP can't read the board. Writing to it still work on cold start.
3  Using Arduino / Interfacing w/ Software on the Computer / Re: PHP fread arduino serial com doesn't work. PLEASE Help!!! on: December 20, 2012, 01:08:25 pm
While I'll eventually move to Linux once I get my Rpi, I would like to resolve this problem for future potential Arduino users.

Obviously, the developers of Arduino managed to resolve the issue with Windows serial communication to allow their boards to be programmed. I am hoping someone from the team can share some insight/codes on how they managed to initialize the board for reading and writing.

Or, perhaps is there a way I can execute the "Serial Monitor" once and then close it so I can access the board with PHP. Perhaps a standalone version of "Serial Monitor" from the Arduino team can be develop to run and then close.

Quote
There are, of course, plenty of alternative scripting languages that use Windows-exposed APIs to deal with the serial port that can work bi-directionally on Windows.

Or, create an executable application, instead.

Perhaps you can share with us what those programs are or how to create and executable application as I am new to the development world.

Thanks.
4  Using Arduino / Interfacing w/ Software on the Computer / Re: Reading serial port through PHP on linux on: December 20, 2012, 12:57:34 pm
Were you able to resolve the problem?

It seem I have the same problem on windows XP. I can write to it fine, I can not read from it unless I use the Arduino compiler/Serial Monitor at least one.

Here's a link to my thread.
http://arduino.cc/forum/index.php/topic,138335.0.html
5  Using Arduino / Interfacing w/ Software on the Computer / Re: 2 way serial arduino to vb6 on: December 20, 2012, 03:07:24 am
I haven't test your version of ASCII digits for 0-9, but here is what I used and it works:

Code:
if ((ch>47)&&(ch<58))
{
             int actual_digit = ch-48;
             // do something iwth actual digit
}
6  Using Arduino / Interfacing w/ Software on the Computer / PHP fread arduino serial com doesn't work. PLEASE Help!!! on: December 20, 2012, 02:55:09 am
I've been searching for the last two weeks to solve a simple problem but have no luck. I'm registering so I can ask the experts here at Arduino.

Here's the operating system specs

OS: Windows XP
Programs: Apache PHP
Hardware: Arduino nano v3, USB communication via COM3 port

Arduino Code (pseudo code):
Code:
I send the Arduino a command (read something), it read a port and send back a number via Serial.print().

Results: this works great when I use the Arduino's compiler (v1.0.1) or serial monitor to send and receive command

The problems:
Sending the commands via PHP or sending anything to Arduino works great, it picks up everything.
BUTTTT, reading from the serial COM port is a bigggg problem

PHP code:
Code:
<?php

exec 
(`mode COM3: BAUD=9600 PARITY=N data=8 stop=1 xon=off`);

if (@
$fp=fopen("COM3""rb+")) {

        
fwrite($fp"r");   //tell Arduino to read
sleep(5);             //wait 5 seconds before getting result
$raw="";

$raw=stream_get_contents($fp);         //this doesn't work
//$raw=fread($fp,4096);                       //this doesn't work
        //$raw=fget($fp,4096);                         //this doesn't work
        /******The below doesn't work
while(!feof($fp)){
         $raw.=stream_get_contents($fp, 2);
   }
        ******/


fclose($fp);
}

echo 
$raw;


?>



Here is what I observed:

When arduino board first turn on (plug into my usb, without using Arduino's Serial Monitor ),
Using PHP:
    1. I CAN use fwrite
    2. I CAN NOT use fread even with delays
    3. I CAN NOT use stream_get_contents

Here is what weird....
When arduino board first turn on (plug into my usb),
Using Arduino's 1.0.1 compiler serial monitor:
    1. I open the serial monitor
    2. I send it a command and received a response
    3. I then closed the serial monitor
After using the Arduino's serial monitor or compiler without switching the board off
    1. I CAN use fwrite
    2. I CAN use fread
    3. I CAN use stream_get_contents

I'm sure the solution lies somewhere in how the Arduino first initiate the board and the COM port to allow fread to access it freely. Without first initializing the Arduino through the Arduino's compiler, I CAN NOT access the board using fread, I can send command to it just fine.

I'm sure someone with more experience in how Arduino initiate the COM port can solve this. I've searched the web for two weeks and have not found the answer. The "Google God" did not provide an answer this time. Please help.

TLDR:  fread doesn't work unless you first run Arduino's "Serial Monitor" or compiler to talk to it first

Begging for solutions. Sincerely, CooCooWorld
Pages: [1]