I am trying to send some data over a serial connection (2 arduino's with xbee's) on the receiver side it should be placed in an array/string (still not quite sure what the difference is).
On the internet I found the command "Serial.readStringUntil" and I think is is exactly what I need.
But it looks like I can't find any example codes that could give me some sort of direction on how to use the command?
Does someone have some code I can use as example, or know where I can find a code.
It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.
Robin2:
It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.
Hi Robin2,
Could you elaborate, or point us to a minimal example that reproduces such a memory-corruption issue caused by the String class?
deey:
Could you elaborate, or point us to a minimal example that reproduces such a memory-corruption issue caused by the String class?
That would be really interesting.
Sorry, no.
It may be interesting but I can't see that it would be useful.
If you don't believe in my concern then go ahead and use the String class and provide me with a future opportunity to say "I told you so". Who knows, you might get away with it.
If you got a delay on readStringUntil, you can consider using Serial.setTimeout(t)
t is the time in milliseconds, not sure if it helps you but it works for me
To anyone trying to make sense of this, the gist is 'use Serial.read because it isn't that much harder and you don't have to deal with String'.
Incidentally, this thread makes me wonder why you'd bother replying to a post just to tell someone you won't help them and assume they're trying to insult you
seagullpat:
Incidentally, this thread makes me wonder why you'd bother replying to a post just to tell someone you won't help them and assume they're trying to insult you