Now if you only wanted to grab say byte 2 (beginning counting from zero).
Code:
counter var byte
counter = 0
'oh looky here.. a serial byte arrived
if serialbyte = “S” then
counter = 0
else
counter = counter + 1
endif
if counter = 2 then
byteyoucareabout = serialbyte
endif
A lot of this will fall apart if another byte of the command can be the same value as the “S” or the termination character,
which is why it’s better to go something close to the first way, and check both start and end chars if they are always the same.
Bookmarks