Strange Behaviour with String

Hello,

I have declared a String array like this :

String Tab_String[ ]	{ "Z" , "0"    , "001" ,
				  "X" , "0"    , "002" ,
                                  "?" , "0"    , "003" ,
                                  "H" , "0"    , "003" ,
                                  "I"   , "0"    , "004" ,
                                  "Id?" , "0"    , "004" ,
                                  "Cal" , "0"    , "005" ,
                                  "P BNO055 ?" , "0"    , "006" ,
                                  "Err. XBEE!!!" , "0"    , "007" ,
                                  "U"			, "0"		, "008" ,
                                  "D"		        , "0"		, "009" ,																							 
                                  "R"	                , "0"		, "010" ,
                                  "L"	                , "0"		, "011" ,
                                  "NICOLAS"    , "0"		, "012" ,
                                  ""};

And when I want to print this string array I can see some problems in the stdio output

 	Indice_String = 0;

		while( Tab_String[ Indice_String ] != "" )
		{

			Serial.print( "Cde : " );
			Serial.print( Indice_String  );
			Serial.print( " : \n\t" );
			Serial.print( Tab_String[ Indice_String ] );
			Indice_String  ++;
			Serial.print( "\n\n" );

		}

Some bad and stanger caracters appears…

Some body have informations?

Bests Regards…

Cannot reproduce on an Arduino Uno.

Program

#include <Arduino.h>

String Tab_String[] { "Z", "0", "001", "X", "0", "002", "?", "0", "003", "H",
		"0", "003", "I", "0", "004", "Id?", "0", "004", "Cal", "0", "005",
		"P BNO055 ?", "0", "006", "Err. XBEE!!!", "0", "007", "U", "0", "008",
		"D", "0", "009", "R", "0", "010", "L", "0", "011", "NICOLAS", "0",
		"012", "" };

void setup() {
	Serial.begin(115200);
	int Indice_String = 0;

	while (Tab_String[Indice_String] != "") {
		Serial.print("Cde : ");
		Serial.print(Indice_String);
		Serial.print(" : \n\t");
		Serial.print(Tab_String[Indice_String]);
		Indice_String++;
		Serial.print("\n\n");
	}
}

void loop() { }

Output

Cde : 0 :
        Z

Cde : 1 :
        0

Cde : 2 :
        001

Cde : 3 :
        X

Cde : 4 :
        0

Cde : 5 :
        002

Cde : 6 :
        ?

Cde : 7 :
        0

Cde : 8 :
        003

Cde : 9 :
        H

Cde : 10 :
        0

Cde : 11 :
        003

Cde : 12 :
        I

Cde : 13 :
        0

Cde : 14 :
        004

Cde : 15 :
        Id?

Cde : 16 :
        0

Cde : 17 :
        004

Cde : 18 :
        Cal

Cde : 19 :
        0

Cde : 20 :
        005

Cde : 21 :
        P BNO055 ?

Cde : 22 :
        0

Cde : 23 :
        006

Cde : 24 :
        Err. XBEE!!!

Cde : 25 :
        0

Cde : 26 :
        007

Cde : 27 :
        U

Cde : 28 :
        0

Cde : 29 :
        008

Cde : 30 :
        D

Cde : 31 :
        0

Cde : 32 :
        009

Cde : 33 :
        R

Cde : 34 :
        0

Cde : 35 :
        010

Cde : 36 :
        L

Cde : 37 :
        0

Cde : 38 :
        011

Cde : 39 :
        NICOLAS

Cde : 40 :
        0

Cde : 41 :
        012

What weird output are you seeing exactly?

First Thank you for your Help…

In Fact, I have and I need 2 String Array… I am using an ARDUINO YUN and it works well in the ARDUINO EDI 1.85…

String Tab_String1[] { "Z", "0", "001", "X", "0", "002", "?", "0", "003", "H",
		"0", "003", "I", "0", "004", "Id?", "0", "004", "Cal", "0", "005",
		"P BNO055 ?", "0", "006", "Err. XBEE!!!", "0", "007", "U", "0", "008",
		"D", "0", "009", "R", "0", "010", "L", "0", "011", "NICOLAS", "0",
		"012", "" };

String Tab_String2[ ]	{ "+++" ,"O" ,"ATRE\r" ,"O" ,"ATID2468\r" ,"O" ,"ATCE1\r" ,"O" ,
                                          "ATSH\r" ,"N" ,"ATSL\r" ,"N" ,"ATDH0013A200\r" ,"N" ,"ATDL4177E10A\r" ,		 																				 
                                          "N" ,"ATAP0\r" ,"O" ,"ATWR\r" ,"O" ,"ATCN\r" ,"O" , "" };

void setup() {
	Serial.begin(115200);
	int Indice_String = 0;

	while (Tab_String1[Indice_String] != "") {
		Serial.print("Cde : ");
		Serial.print(Indice_String);
		Serial.print(" : \n\t");
		Serial.print(Tab_String1[Indice_String]);
		Indice_String++;
		Serial.print("\n\n");
	}

    Indice_String = 0;

	while (Tab_String2[Indice_String] != "") {
		Serial.print("Cde : ");
		Serial.print(Indice_String);
		Serial.print(" : \n\t");
		Serial.print(Tab_String2[Indice_String]);
		Indice_String++;
		Serial.print("\n\n");
	}
}

void loop() { }

Part of OutPut :slight_smile:
Cde : 32 :
009

Cde : 33 :
R

Cde : 34 :
0

Cde : 35 :
010

Cde : 36 :
L

Cde : 37 :
0

Cde : 38 :
011

Cde : 39 :
�ICOLAS

Cde : 40 :
0

Cde : 41 :
012

We can see in this example that there a Problem cde 39 NICOLAS…

Some times, we can see a complete strange line…

 Did you see some thing.... Thanks...

I don’t see any abnormal output when viewing serial data with miniterm…

C:\Users\Maxi>miniterm.py --exit-char=50 COM7 115200
--- Miniterm on COM7  115200,8,N,1 ---
--- Quit: u'2' | Menu: Ctrl+T | Help: Ctrl+T followed by Ctrl+H ---
Cde : 0 :
        Z

Cde : 1 :
        0

Cde : 2 :
        001

Cde : 3 :
        X

Cde : 4 :
        0

Cde : 5 :
        002

Cde : 6 :
        ?

Cde : 7 :
        0

Cde : 8 :
        003

Cde : 9 :
        H

Cde : 10 :
        0

Cde : 11 :
        003

Cde : 12 :
        I

Cde : 13 :
        0

Cde : 14 :
        004

Cde : 15 :
        Id?

Cde : 16 :
        0

Cde : 17 :
        004

Cde : 18 :
        Cal

Cde : 19 :
        0

Cde : 20 :
        005

Cde : 21 :
        P BNO055 ?

Cde : 22 :
        0

Cde : 23 :
        006

Cde : 24 :
        Err. XBEE!!!

Cde : 25 :
        0

Cde : 26 :
        007

Cde : 27 :
        U

Cde : 28 :
        0

Cde : 29 :
        008

Cde : 30 :
        D

Cde : 31 :
        0

Cde : 32 :
        009

Cde : 33 :
        R

Cde : 34 :
        0

Cde : 35 :
        010

Cde : 36 :
        L

Cde : 37 :
        0

Cde : 38 :
        011

Cde : 39 :
        NICOLAS

Cde : 40 :
        0

Cde : 41 :
        012

Cde : 0 :
        +++

Cde : 1 :
        O

Cde : 2 :
        ATRE

Cde : 3 :
        O

Cde : 4 :
        ATID2468

Cde : 5 :
        O

Cde : 6 :
        ATCE1

Cde : 7 :
        O

Cde : 8 :
        ATSH

Cde : 9 :
        N

Cde : 10 :
        ATSL

Cde : 11 :
        N

Cde : 12 :
        ATDH0013A200

Cde : 13 :
        N

Cde : 14 :
        ATDL4177E10A

Cde : 15 :
        N

Cde : 16 :
        ATAP0

Cde : 17 :
        O

Cde : 18 :
        ATWR

Cde : 19 :
        O

Cde : 20 :
        ATCN

Cde : 21 :
        O

Note though that you string contains a \r (carriage return). It places the cursor back at the beginning of the line and when no \n (newline) is given, the next character will try to overwrite the beginning of the line.

Hello,

 I have rewritten and reorganize my software to be sure that I'm not asking you
 to solve my buggs....

 After rewritting a great part of my software, the strange behavior became again visible....

 I have some new informations to provide : 

 First of all, my whole project is constitued of 6 files...

 Next, I hope to be able to show you with screenshots the strange behavior of my application.

 On this first picture, we can see that all is working well !!!
 The case 902 and default are not invoqued…

In this second picture and step, I have uncomment the line 1402 and we can see in the stdio output there is some strange caracters….
The case 902 and default are not invoqued…

In this third picture and step, I have comment the line 1402, uncomment the line 1414 and we can see in the stdio output there is some strange caracters….
The case 902 and default are not invoqued…

In this fourth picture and step, I have comment the line 1402, comment the line 1414, uncomment the line 1401 and we can see that all is working well !!!
The case 902 and default are not invoqued…

I can post only one picture, I can send the 4 pictures in 4 reply or by email if you want…

My interpretation of that is when we want to use a lot of time Serial.print function, there is a problem in the memory manage…

Tell me if you some more informations…. I want to participate a maximum to solve this problem….

Thank fo advanced for your help !!!

  Bests regards.