Pages: [1]   Go Down
Author Topic: Arduino Uno with string split  (Read 485 times)
0 Members and 1 Guest are viewing this topic.
Offline Offline
Newbie
*
Karma: 0
Posts: 23
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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;
           }                           
        }
Logged

Global Moderator
UK
Offline Offline
Brattain Member
*****
Karma: 302
Posts: 26273
I don't think you connected the grounds, Dave.
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Please read this
Logged

"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.

Global Moderator
Offline Offline
Brattain Member
*****
Karma: 484
Posts: 18764
Lua rocks!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

That's a comma?
Logged


Poole, Dorset, UK
Offline Offline
Edison Member
*
Karma: 52
Posts: 2296
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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

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

Mark
Logged

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

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

That's a comma?

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

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

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. smiley
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.
Logged

Seattle, WA USA
Online Online
Brattain Member
*****
Karma: 613
Posts: 49251
Seattle, WA USA
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

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

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 smiley
Logged

Pages: [1]   Go Up
Jump to: