Hello. I am newby here. So far, after using the terminal of Arduino, I have decided to use other terminals. Why? Arduino terminal uses to behave weirdly. Weirdly means that it lacks, delays, blank, garbage, etc. May be I am wrong but have you experience something like this? If so, Is the Arduino team planning to work on make it more reliable? Thank you.
I have never had it display anything but what my Arduino outputs. If it is displaying weird things then you likely need to modify your sketch.
Have you had the terminal display things incorrectly that display properly in hyperterminal or similar.
I have only observed an issue with the serial monitor that is hardware related. The only issue I have observed is bad external crystals and poor fuse settings.
What kind of hardware are working with (Uno, Mega, Breadboard Stand-a-lone, etc.)?
I switched to a different serial port reader (gnu screen) and only then I noticed how stinking slow the arduino's serial monitor is. If you're receiving a lot of data (likie if you run this sketch:
void setup() { Serial.begin(115200); }
void loop() {Serial.println(digitalRead(12)); }
) it could easily freeze your whole system. With screen, it just goes along smoothly.
Usually it's faster than your reading speed ( Which is the reason why 9600 is so popular )
Sure, java is slower than gnu c++, at least when it's rather close to hardware specific stuff.
BTW: I got partial garbage when choosing
Serial.begin( 56700 ); // guess why this does not work well
WilfredoMolina:
Arduino terminal uses to behave weirdly. Weirdly means that it lacks, delays, blank, garbage, etc.
I haven't seen anything like that, but I only tend to print text and only at a slow rate. If you were printing binary data, it's possible that some of it would confuse the Arduino IDE serial port monitor since it expects an ASCII character stream. A similar problem could occur if you had a problem with the levels or frequency on the serial port since this could introduce parity and framing errors on the receiving side. As spcomputing asks: what hardware are you using, and what Serial setup are you doing in your sketch, and what are you writing to Serial? Do you have anything connected to the serial pins (0 and 1)?
I am trying to catch coordinates x and y from a camera of one of my robots through a vision software called Roborealm. I am using Serial.print() at 115200 bps to "see" what I am getting. Because of the freezing's and issues with the terminal, I decided to write a pseudo code to make sure I am not messing up something. Serial.print read the following chain everytime: .XXX,YYY; where .,; are flags and XXX and YYY are my coordinates. Here the pseudo code:
Deactivate flags one and two.
SET UP (infinite loop)
- Deactivate flag set.
- Read the serial input into b.
- If b is equal to 46, then
- set i equal to 0.
- activate flags one and set.
- deactivate flag two.
- Else, if b is equal to 44, then
- set j equal to 0.
- activate flags two and set.
- deactivate flag one.
- Else if b is equal to 59, then
- deactivate flags one and two.
- If flag set is deactivated, then
- STORAGE.
STORAGE
- If flag one is activated, then
- Store b into arr[0]
-
- i++*
2. If flag two is activated, then
- i++*
-
- Store b into arr[1][j]*
-
- j++*
It should work. I am working on the code. Here so far my c++ code:
int arr[2][3], b, i = 0, j = 0;
Boolean one, two, three, set;
void setup()
{
- j++*
-
Serial.begin(115200);*
}
void loop()
{ -
if (Serial.available() > 0)*
-
{*
-
// SET UP*
-
set = false;*
-
b = Serial.read();*
-
if (b == 46)*
-
{*
-
i = 0;*
-
one = true;*
-
set = true;*
-
two = false;*
-
}*
-
else if (b == 44)*
-
{*
-
j = 0;*
-
two = true;*
-
set = true;*
-
one = false;*
-
}*
-
else if (b == 59)*
-
{*
-
one = false;*
-
two = false;*
-
i = 0;*
-
j = 0;*
-
}*
-
//STORAGE*
-
if (set == false)*
-
{*
-
if (one == true)*
-
{*
_ arr[0] = b;_
* i++;*
* }*
* if (two == true)*
* {*
* arr[1][j] = b;*
* j++;*
* }*
* }*
// PRINTING
// I NEED TO PUT HERE SOME CODE AFTER READING THE FIRST PAIR OF COORDINATES (i==3 && j==3).
// AND SEE WHAT I GOT. PLEASE, HELP!
* }*
}
The structure is not very intuitive but I think I see what you're aiming at. You aren't helping by using magic numbers for the ascii codes instead of simply using '.', ',' and ';' character literals, and using variable names that only relate obliquely to their purpose.
I think you're reading a stream of characters and picking out the flags .'; to work out where you are in the message.
You have an missing in the handling where one == true but I assume that's because you didn't put your code in [ code ] [ /code ] tags. You can use the # button when you compose a post to insert code tags, or just write them in by hand. Anyway, you need to add the code tags one way or the other to stop the forum code interpreting formatting instructions such as [ i ] (meaning 'start italics') in your post.
If the incoming message is corrupted or malformed for any reason you may get more than three character between flags, and you don't deal with that. I suggest you simply compare the array index with the array size before appending to it.
You could simplify your code considerably using a switch statement:
* *const int WordCount = 0; const int DigitCount = 3; arr[WordCount][DigitCount+1]; // allow space for the null terminator ... switch(b) { case '.': word = 0; digit = 0; break; case ',': word = 1 digit = 0; break; case ';': // deal with the complete message // for testing, just echo it back to the Serial port Serial.print("."); Serial.print(arr[0]); Serial.print(","); Serial.print(arr[1]); Serial.println(";"); break; default: if((b >= '0') && (b <= '9')) { if(digit < DigitCount) { arr[word][digit++] = b; } } else { // we ignore any other characters such as cr/nl characters that may appear in the character stream } } arr[word][digit] = 0; // add a null terminator after any update to the character array* *
I'm not sure how this relates to your original post, but I guess that what you were writing to the Serial port did not consist of ASCII characters.
michael_x:
Usually it's faster than your reading speed ( Which is the reason why 9600 is so popular )
Does it make sense to slow down my 16MHz processor because my 2GHz one can't keep up?
You mean you can read 960 characters a second?
AWOL:
You mean you can read 960 characters a second?
If it's a graph, certainly.
However, the bigger problem is checking to see if it's time to print --- if I'm debugging a library, I may have several prints inside different library calls and some in the main sketch, and if each one had its own mechanism to see if it's print time, it would be unlikely they'd always print in the same order.
Also, adding the time checks is more work which is unnecessary if you use the right software.