ESP32 indexOf() function not recognizing 'PASSWORD' in received RS485 message

Hi everyone, I have a problem with the string function indexOf() that I don't understand. My board with the ESP32 module is connected via RS485 (on UART1) to another board. This second board can send me its data if I ask them sending a magic word. If this word is sent and received correctly, the board asks me the password sending me the word PASSWORD. The only other msg that I can receive from the second board is PASSWORD ERRATA. So, as you can see in the picture below, I receive the msg, and I check if the msg contains the words PASSWORD and ERRATA. In the case shown in the picture, I received the msg PASSWORD, but the instruction "posizione1 = msg.indexOf("PASSWORD");" don't recognize it (as you can see in the serial monitor, posizione1 has the value -1). What am I doing wrong? I know that indexOf can check strings, the sintax seems to be correct, but it doesn't work. Any suggestion ? Thanks, Stefano. [edit] in a new sketch I defined "String msg = "PASSWORD"; ", then asking for "posizione = msg.indexOf("PASSWORD");" I have the correct result. I continue to not understand. Both in the new sketch and in the original program, the variables are global.
attachment 0
0 Replies
No replies yetBe the first to reply to this messageJoin
Want results from more Discord servers?
Add your server