So now, i want to converti receiveString into an int. But int(receiveString) doesnt work "invalid cast from String to int"
I already found this topic, but he didnt give the answear to his problem, its just "solved" :0
So you didn't really read it then. The atoi() function takes a null-terminated char array (or C type string) as a parameter, not a String object.
You need to extract the character array from the String object, using the toCharArray() method, and then use atoi() (ascii to integer) function to convert the array of characters to an int.
You need to extract the character array from the String object, using the toCharArray() method, and then use atoi() (ascii to integer) function to convert the array of characters to an int.
Ah, Paul. The interrupt service routine, and the main thread. Those two things.
But, only one of them is running at a time. Only one can be attempting to modify the String instance at a time.
Now, there may well be issues with atomic access to the internal data that should be addressed if the String class is to be used inside an interrupt handler.
Since those issues potentially (and, in reality do) exist, using String in an ISR is probably not a good idea. Not there ever using it is all that great an idea.
PaulS:
But, only one of them is running at a time. Only one can be attempting to modify the String instance at a time.
Indeed. As would occur on any single-processor system.
However we would need to be confident that attempting to do a malloc inside an ISR would not corrupt a malloc that is being attempted outside an ISR ...
PaulS:
Since those issues potentially (and, in reality do) exist, using String in an ISR is probably not a good idea. Not there ever using it is all that great an idea.