Pages: [1]   Go Down
Author Topic: Transfer data via Serial USB with Serial Monitor closed  (Read 1598 times)
0 Members and 1 Guest are viewing this topic.
Madrid, Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I'm a newby, so pls, forgive me in case I'm asking somethink a bit stupid   smiley-roll-sweat

I had been looking long time a solution to send data trough USB Serial port with the serial monitor closed from the PC to the Arduino but always is needed to have the Serial Monitor Open. Is possible to send data with serial monitor closed?

During the development phase could not be a real problem, but once the project is finished, my project will need to receive data from PC using the USB. If I need to have the Arduino IDE open will be a bit weird.

Thanks for your help!
« Last Edit: February 11, 2011, 05:28:16 pm by crazystress » Logged

Left Coast, CA (USA)
Offline Offline
Brattain Member
*****
Karma: 331
Posts: 16540
Measurement changes behavior
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi all,

I'm a newby, so pls, forgive me in case I'm asking somethink a bit stupid   smiley-roll-sweat

I had been looking long time a solution to send data trough USB Serial port from the PC to the Arduino but always is needed to have the Serial Monitor Open. Is possible to send data with serial monitor closed?

During the development phase could not a real problem, but once the project is finished, my project will need to receive data from PC using the USB. If I need to have the Arduino SDK open will be a bit weird.

Thanks for your help!

The Arduino communicates with the PC as a simple serial comm port. Any PC software that can connect to a PC's comm port can then send or receive from an Arduino. The Arduino serial statements are not limited to just sending or receiving from the Arduino IDE serial monitor.

 You are free to use the the Arduino IDE serial monitor to test and debug your sketch, but once done the serial link is available and usable for any PC application program that can work with a comm port.

That make sense?

Lefty
Logged

Madrid, Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks for answer. I agree with you, but maybe I'm doing something wrong because when I'm sending data from PC to the Arduino with the serial monitor CLOSED, I can't receive nothing from the PC. In case the Serial Monitor is open, everything works smoothly...

This is the code I'm using:
Code:
  while( Serial.available() > 0 ) {
    sCadena += String( byte( Serial.read() ) );

    if( sCadena.endsWith("#$#$!#") ) {
      bReset = true;
      break;
    }
  }
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46215
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What application, on the PC, is sending the serial data? What operating system are you using?
Logged

Madrid, Spain
Offline Offline
Newbie
*
Karma: 0
Posts: 3
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm sending the data from the following PHP script:

Code:
$lenstr = strlen( $sString );
$fp = fopen("/dev/cu.usbmodem1a21", "w");
fwrite( $fp, $streamType . $sString . "#$#$!#");
fclose($fp);

I tried the script from Mac OS X and Windows 7 with Arduino 0022, always with the same result: Everything works, but Only if the Serial Monitor window is open.
Logged

0
Offline Offline
God Member
*****
Karma: 39
Posts: 986
Get Bitlash: http://bitlash.net
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

The Arduino resets when you open the serial port, and hangs out in the bootloader.  Perhaps your fwrite() is being sent before your program is running and listening for it.

Try a short delay (1000-2000 ms) after the fopen().

-br
http://bitlash.net
http://entropymouse.com
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 551
Posts: 46215
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
Try a short delay (1000-2000 ms) after the fopen().
Or, try handshaking. That is, wait for the Arduino to say "ready" (or anything) before sending it data.
Logged

Pages: [1]   Go Up
Jump to: