Searching for ASCII control characters with Serial.find()

Hello,

I am trying to use Serial.find() to help parse incoming data for a project. The problem is that one part of the data that I need is immediately preceded by a control code (Start of Text, aka ASCII 2) instead of a printable character. With a printable character, I would just use .find('A'), but that does not work as easily with a character that is not on my keyboard. I have tried .find(2) and .find(char(2)) but have gotten invalid int to char* and char to char* conversion errors, respectively. Is there a way that I can search for this ASCII value with .find()?

Thanks!

two ways: Isolate the character and use iscntrl()

use the '\02' escape (or '\x02')

Or many

\u0002

I would just use .find('A')

That doesn't compile. Did you mean:

Serial.find ("A");

You need to make a string, not a character, eg.

char * number2 = "\2";
Serial.find (number2);

Personally I wouldn't be using Serial.find. Try reading this:

http://www.gammon.com.au/serial

In the IDE examples there is textfinder which might be of interest.