Need help Something with [] buffer


Is’t from an Anduino+python script

I got a problem when I try to catch the input from “messageFromPC” buffer.

char messageFromPC[buffSize] = {0};

Here is it been set…

char * strtokIndx; // this is used by strtok() as an index
  strtokIndx = strtok(inputBuffer,",");      // get the first part - the string
  strcpy(messageFromPC, strtokIndx); // copy it to messageFromPC

Here will I try to catch it:

if (String(messageFromPC == "97")) {
    } else if (String(messageFromPC == "98")) {

Here comes the return from Arduino

Sent from PC – LOOP NUM 0 TEST STR <98,0,0>
Reply Received Msg 98 Time 1

The reply seems to be a string Msg 98
and this looks like a string TEST STR <98,0,0>

How can I get the messageFromPC correct!

if (String(messageFromPC == "97"))

Are the brackets in the right place ?

So Robin tries to keep you away from the String (capital S) class :slight_smile: and the first thing you do is re-introduce it :frowning:

Read up on c-strings, the function you're looking for is strcmp()


For you quick reply...