Go Down

Topic: Arduino Uno with string split (Read 611 times) previous topic - next topic

yoonpoh

Hi,
I am using string txtKey= "test|Hello, dear value cusomer, Please gimme your contact number to perform test. Please reply me if you are keen in this, testing 123456."
I am using below code to split | char into 2 string wHen the string length is around 100,it is fine. I can get the firstString & secondString variable value. i increase the length to 145 and above, firstString variable value is fine, no value is showing at secondString variable.
Please advise. I have no idea why it seem not stable.
I have attached the following information
Arduino UNO R3 ,
Binary sketch size 92% used
Minimum memory usage : 68% used.



  int commaPosition;
        commaPosition = txtKey.indexOf('|');
        if(commaPosition != -1)
        {
            firstString = txtKey.substring(0,commaPosition);
            secondString = txtKey.substring(commaPosition+1, txtKey.length());
           
        }
        else
        {  // here after the last comma is found
           if(txtKey.length() > 0)
           {
             clientMsg= txtKey;
             commaPosition = -1;
           }                           
        }

AWOL

"Pete, it's a fool looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.

Nick Gammon

Code: [Select]
        commaPosition = txtKey.indexOf('|');

That's a comma?
Please post technical questions on the forum, not by personal message. Thanks!

More info:
http://www.gammon.com.au/electronics

holmes4

Sounds like you have gone over the 2k bytes of ram.

Try posting all your code. Auto format your code before posting.

Mark

yoonpoh


Code: [Select]
        commaPosition = txtKey.indexOf('|');

That's a comma?


My appology for that, I forget to changed the commanPosition keyword as variable colonposition.

yoonpoh


Sounds like you have gone over the 2k bytes of ram.

Try posting all your code. Auto format your code before posting.

Mark


Thanks for remind me on memory issue, mark. I have resolved the issue after remove those comment and unnecessary code to reduce the memory usage. It is work after reduce the binary size sketch. :)
I wonder if there any code can debug print for memory has been spent during that line of code. So we can aware of out of memory issue.

PaulS

Quote
I wonder if there any code can debug print for memory has been spent during that line of code. So we can aware of out of memory issue.

http://playground.arduino.cc/Code/AvailableMemory

yoonpoh


Quote
I wonder if there any code can debug print for memory has been spent during that line of code. So we can aware of out of memory issue.

http://playground.arduino.cc/Code/AvailableMemory


THank you so much. This would be very helpful :)

Go Up