Code:
serialbuffer byte [4]
serialbyte var byte
index var byte
…
‘ ooh looky here… a serial byte arrived
for index = 1 to 3
serialbuffer[index] = serialbuffer[index-1]
next index
serialbuffer[0] = serialbyte
Now instead of checking for the first byte in the serial string,
check for what you call the termination byte.
I don’t know what that is, so now it’s $FE.
Code:
if serialbuffer[0] = $FE then
‘ we know the bytes serialbuffer [0,1,2,3] are the desired 4 byte string in reverse
‘ unless only a partial command was received
if serialbuffer[3] = “S” then
‘ we know now that the entire four byte command was received if there was no serial error
endif
endif
Bookmarks