So I'm sitting here scratching my head a bit because I can't figure out what I've done wrong when using strcmp.
I've read a few threads regarding the same problem, but none of the solutions have been applicable here.
rxBufString is sent from the ECU in my car via CAN bus.
I'm getting the length of the String to be able to determine if the String is exactly P_Manifold, and not something that contains P_Manifold.
I'm removing the first 8 characters of rxBufString because they can't be used here.
The toCharArray seems to be working fine since I can see that symbolCompare = "P_Manifold" when printed to the serial monitor.
debug is never set to 1 and P_Manifold is never set to rxBufString.substring(0, 5).
Like I said, I print symbolCompare to the serial monitor and can see that it is in fact exactly "P_Manifold", so why isn't it working?
The second argument to the toCharArray() is NOT the length of the String. It is the size of the buffer to be written to. Do you have a large enough array?
When I see it in the serial monitor I don't see a line break, but when I paste it here there is a line break after ">P_Manifold" before "<". Could that be a clue as to why I can't get strcmp to work? I'll check the rest of the code to see if I can find anything.
The second argument to the toCharArray() is NOT the length of the String. It is the size of the buffer to be written to. Do you have a large enough array?
Thanks, I know. symbolLength will always be 8 characters longer than symbolCompare because I'm removing the first 8 characters from rxBufString when converting it to a char array.
Edit: Solved it!
For some reason when reading from the ECU via my Sparkfun CAN bus shield an extra line break is set when the ECU sends "D" and then "A", which marks the end of a parameter that has been sent. I don't know if this a universal thing because the serial monitor seems to understand "DA" and makes a line break automatically.
To solve this I changed