Pages: [1]   Go Down
Author Topic: serial buffer overflow in Serial monitor?  (Read 775 times)
0 Members and 1 Guest are viewing this topic.
France
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Mr. Watson. Come Here. I need you.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I'm using Arduino 0010 on Windows XP  and I've noticed a problem with the serial monitor grinding to a halt (buttons unresponsive, application hangs) when I use Serial.print(myIntValue) in the main loop function if I don't use a delay();

I'm guessing it's caused by overflowing a buffer somewhere (don't know which end of the connection). Unplugging the arduino then caused all sorts of java error messages to appear.
        
I know common sense  :smiley says not to flood the serial output like this, (I was just trying to debug a problem) but I didn't expect the software on the PC side to lock up.  Is this expected behaviour?

As an aside, I've read on the forums the arduino gets reset when the serial monitor is activated/deactivated.

Should I be using a higher baud rate?  What's the maximum I can attain via USB to the serial monitor in windows?


Code:
void setup()                    
{
  Serial.begin(9600);           // set up Serial library at 9600 bps
  Serial.println("Hello world!");  // prints hello with ending line break
}
        
void loop(){
  val = digitalRead(inputPin);  // read input value
  Serial.print(val);
  if (val == HIGH) {            // check if the input is HIGH
    digitalWrite(ledPin, LOW);  // turn LED OFF
  } else {
    digitalWrite(ledPin, HIGH); // turn LED ON
  }
}
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yea, the serial monitor doesn't handle floods of data very well.  Processing had / has similar issues and there's not even any serial communication involved.  The Java control used to print the messages can only handle so much data and having serial communication happening at the same time just makes it worse.  This is one of those things that we should fix eventually, but I'm not sure how.

You can use up to 115200 baud.  
Logged

France
Offline Offline
Newbie
*
Karma: 0
Posts: 21
Mr. Watson. Come Here. I need you.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thanks,  I'll be more careful in my debugging from now on!

As an aside, I've read on the forums the arduino gets reset when the serial monitor is activated/deactivated.  Is this true?
Logged

Forum Administrator
Cambridge, MA
Offline Offline
Faraday Member
*****
Karma: 12
Posts: 3538
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, the Arduino gets reset when the serial monitor is opened, at least on the Mac and Linux.  I believe that it doesn't under Windows.
Logged

0
Offline Offline
Newbie
*
Karma: 0
Posts: 16
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Yes, the Arduino does not reset when the serial monitor is opened under windows.
Logged

"The early bird may get the worm, but it's the second mouse that gets the cheese!"

Pages: [1]   Go Up
Jump to: