Proper string handling syntax
K6MLE
Posts: 106
in Propeller 1
I am trying to wait for a serial string that starts with "$ULTW" to arrive before I pay attention to any data that follows that header.
I've tried:
repeat until (inbuf[0]) := $24
This returns a "Expected end of line" error, which isn't leading me to much of a clue for a solution. The buffer is 60 bytes and the data comes in at roughly 5 minute intervals.
I appreciate any help!
I've tried:
repeat until (inbuf[0]) := $24
This returns a "Expected end of line" error, which isn't leading me to much of a clue for a solution. The buffer is 60 bytes and the data comes in at roughly 5 minute intervals.
I appreciate any help!
Comments
repeat until (inbuf[0]) := $24
is an assignment, rather than a test for equals. Normally that would not flag an error. But in your case you're trying to make the assignment to an expression, rather than to a variable, due to the parentheses.
The parentheses are not necessary, and the := should be changed to == to perform the test.
-Phil
Before setting state back to zero in the else, you should check if the character that kicked you out is the first one in the header, otherwise you could miss a frame.
...$UL$ULTW...
would be missed.
At each step the two longs are compared for alignment with the long aligned DATa.
It's straightforward to branch on a set of possibilities within a fixed length command set.