I am doing this the "brute force way", so I am looking for a better way.
I am intteracting with another program that is getting an ASCII text file via the serial port. I can't change how I get the data, it will be given to me one character at a time, I make a call to its function and it returns one character, then I do something with it then I make another call to it, etc., etc.
I need to know when a specific string comes in the serial port, but since I am getting the characters one character at a time, I "think" I have to "assemble" them first (at least that is what I am doing now).
What I am doing now is keeping track of certain flags, so when the first known character comes in I set a flag, then if I see the next known character I set another flag.
When all of my flags are set then I know I have the string I want then I can run the rest of my code.
My issue is that I am starting to do this all the time and I have to keep re-writing my code depending on what specific string I am looking for.
1. I need a better, more efficient way of writting my code so that I can just plug in the known string as a variable instead of hard coding each letter of it.
2. Is there a better way then setting all these flags?
Anyone have a good idea?
I am intteracting with another program that is getting an ASCII text file via the serial port. I can't change how I get the data, it will be given to me one character at a time, I make a call to its function and it returns one character, then I do something with it then I make another call to it, etc., etc.
I need to know when a specific string comes in the serial port, but since I am getting the characters one character at a time, I "think" I have to "assemble" them first (at least that is what I am doing now).
What I am doing now is keeping track of certain flags, so when the first known character comes in I set a flag, then if I see the next known character I set another flag.
When all of my flags are set then I know I have the string I want then I can run the rest of my code.
My issue is that I am starting to do this all the time and I have to keep re-writing my code depending on what specific string I am looking for.
1. I need a better, more efficient way of writting my code so that I can just plug in the known string as a variable instead of hard coding each letter of it.
2. Is there a better way then setting all these flags?
Anyone have a good idea?