What steps will reproduce the problem?
1. On Arduino, load the attached file as an Arduino sketch
2. Run it.
3.
What is the expected output? What do you see instead? Expected: "Running test suite... Tests run: 1 Successful: 1 Failed: 0"
Actual, connecting via serial monitor at 57600 bps: "····························································································································································································································"
What version of the product are you using? On what operating system? ArduinoUnit 1.4.2 Arduino 1.0 Mac OS X 10.7.2
Please provide any additional information below.
Hi Matthew -
Just used a variant of the code given in the previous non-9600-baud bug,
but it doesn't work for me.
I'm using Arduino 1.0 on Mac OS X 10.7
Here's the code I used. Works fine with BAUD set to 9600, but any other value makes the serial connection just spew bad chars.
-Evan Jones 05 Feb 2012
Comment #1
Posted on Apr 10, 2012 by Happy DogEvan,
I've reproduced this on my Windows 7 system. It seems to work OK for baud rates up to and including 9600 but fails above that rate. Is that the behavior you are experiencing too?
Thanks,
Matthew
Comment #2
Posted on Apr 10, 2012 by Happy CatHi Matthew - To be honest, I didn't test at bauds lower than 9600, but definitely did have problems with baud higher than 9600.
Comment #3
Posted on Apr 19, 2012 by Happy DogHi Evan,
Could you try the following simple sketch for me and let me know the outcome?
void setup() {
Serial.begin(14400);
}
void loop() {
Serial.println("Hello World");
}
Thanks,
Matthew
Comment #4
Posted on Apr 19, 2012 by Happy CatHi Matthew - At 14400, without any ArduinoUnit extras added in, everything works as intended: just repeated 'Hello World' lines.
I did go back and load the original test file and run it at several different baud rates. This time, everything <= 28800 worked just fine. 57600 didn't work, but I was surprised to find different behavior than I'd seen before. Don't you hate it when bugs disappear or mutate even when you think you're doing the same thing? I've attached the scratch file; it's not significantly different from the original. I put a println in loop() to see if that affected things, but it didn't seem to. Hmm.
Comment #5
Posted on Apr 20, 2012 by Happy DogHmmm... On my Arduino Duemilanova on Windows 7 the simple Serial sketch (with no ArduinoUnit code) prints random characters with anything over 9600 baud... Which suggests a problem with the underlying core HardwareSerial implementation.
I've tried the same simple sketch on Arduino 1.0, 1.0.1-rc2 and 0023, all with the same (bad) result.
Could you do me a favor and rerun the simple sketch at various baud rates and let me know if you see any differences in behavior?
Comment #6
Posted on Apr 20, 2012 by Happy CatHi Matthew - Just ran the following code with all baud rates, without problems. I've been bitten by a couple things in the past. Have you been updating the baud of the serial monitor every time you load new code to the board? And have you tried closing and reopening the serial monitor when you get gibberish out? Sometimes there's some cruft (left over from the bootloader?) when I first open the monitor, but if I close and reopen the monitor, everything looks good. My intuition is that some problem like this is probably the culprit rather than a core library.
Cheers, Evan
include
define BAUD 9600
void setup() { Serial.begin( BAUD); }
int times_printed = 0; void loop() {
if ( times_printed < 10){
Serial.print(times_printed);
Serial.println(" Hello World");
times_printed++;
}
}
On Apr 20, 2012, at 2:49 PM, arduinounit@googlecode.com wrote:
Comment #7
Posted on Apr 21, 2012 by Happy DogHi Evan,
OK. I've rerun the simple (Serial.begin()/println() only) sketch on my setup and it works for all baud rates except 14400 and 28800 which print out gibberish.
To investigate further I modified your sketch so that it loops through all supported baud rates. That way I'm able to upload it and watch what happens when I change the baud rate in the Serial Monitor window. Naturally I'd expect to see a lot of gibberish printed out when the baud rates don't match but for each selected baud rate should also see output such as:
Baud rate: 1200 (Index: 2) 0 Hello World 1 Hello World 2 Hello World 3 Hello World 4 Hello World 5 Hello World 6 Hello World 7 Hello World 8 Hello World 9 Hello World
(where the 'Baud rate:' and 'Index:' depend on the baud rate selected in the Serial Monitor window).
The output is as expected for most of the baud rates, but interestingly at 14400 and 28800 I get this output:
Baud rate: 9600 (Index: 4) 0 Hello World 1 Hello World 2 Hello World 3 Hello World 4 Hello World 5 Hello World 6 Hello World 7 Hello World 8 Hello World 9 Hello World
i.e. it looks as though the Serial Monitor is treating 14400 and 28800 as though they were 9600...
I also tried the following to see if they made any difference (they didn't): * closing and reopening the Serial Monitor window * closing and reopening the IDE * resetting the Arduino * changing the baud rates in the Serial Monitor window in different orders
This is all pretty weird and I wonder if I'm even seeing the same problem that you are. I've ordered an Uno (which I believe has a different bootloader to my Duemilanova) to see if that gives different results...
If you'd like to try the modified sketch below and let me know what you see, it would be greatly appreciated!
Modified Sketch:
//////////////////////////
define BAUD_RATE_COUNT 11
long baud_rates[] = { 300, 1200, 2400, 4800, 9600, 14400, 19200, 28800, 38400, 57600, 115200 };
void setup() { }
int baud_rate_index = 0; void loop() { if (baud_rate_index < BAUD_RATE_COUNT) { long baud_rate = baud_rates[baud_rate_index]; Serial.begin(baud_rate); delay(1000); // Without this delay the start of the output isn't printed correctly Serial.println(); Serial.print("Baud rate: "); Serial.print(baud_rate); Serial.print(" (Index: "); Serial.print(baud_rate_index); Serial.println(")"); for (int times_printed = 0; times_printed < 10; times_printed++) { Serial.print(times_printed); Serial.println(" Hello World"); } Serial.println(); Serial.end();
baud_rate_index++;
}
}
//////////////////////////
Thanks,
Matthew
Comment #8
Posted on Apr 22, 2012 by Happy DogI've tried the modified sketch (from comment 7) using PuTTY (see http://blue-networks.net/wp/?p=69 for required settings) instead of the Arduino IDE Serial Monitor.
All selected baud rates work as expected. This suggests that the problem is with the Serial Monitor rather than the code uploaded to the Arduino.
Comment #9
Posted on Apr 25, 2012 by Happy DogHi Evan,
I think I have fix for this issue. Please can you try commenting out line 41 in SerialReporter.cpp (in the ArduinoUnit utility directory) and let me know whether this fixes your problem.
The line to comment out reads: Serial.begin(baudRate);
Note you will still need the Serial.begin() call which you had in the setup() function. If you don't have this you won't see any output at all.
Thanks,
Matthew
Comment #10
Posted on Dec 28, 2012 by Happy HippoCommenting out Serial.begin(baudRate) fixes the issue. The user must call Serial.begin(....) in setup() (obviously). The baud rate argument should be removed from SerialReporter interface, IMHO. The examples should also be updated.
I think the baud rate, i.e. Serial.begin() call should be left to the user.
my 2 cents.
BTW, excellent library.
Comment #11
Posted on Dec 29, 2012 by Grumpy PandaMarcello,
Thanks for the feedback. I think your conclusion is correct (it's been a while, though, so I'll have to refresh my memory). I'll take another look and make the relevant changes.
Much appreciated!
Matthew
Comment #12
Posted on Jan 3, 2013 by Happy Dog(No comment was entered for this change.)
Comment #13
Posted on Aug 6, 2013 by Happy Rhinoplease try with another serial (Serial1,Serial2 etc.)
Status: Fixed
Labels:
Type-Defect
Priority-High