Does rxtime or rxcheck corrupt the incoming string if you use it?
rxtime uses rxcheck, the latter returns either the oldest received character or -1 indicating that there isn't one. So if there is one then it consumes a character (by returning it to you). I assume you use said function in a simple yes/no manner which - if not handled properly - loses characters.
MsgTest:==debug.rxtime(100)
getstr(@command)
if strcomp(@Reset, @command)
do stuff
From what your telling me my string compare won't work too well.
Let's say you receive the string "fred\n" ('\n' being the end of the line/string). Depending on timing MsgTest will either be -1 (timeout) or 'f'. Then getstr will assemble the string "fred" or "red". So in case you didn't get the timeout you want to recover the missing/consumed character.
getstr looks like one of your methods, so why don't you pass in an extra parameter (i.e. MsgTest) which when -1 is ignored otherwise inserted into the buffer before the serial device is read again?
Sounds interesting, but for the life of me I can't picture how to implement it.
I'd help you but I'd need to see more code in order to do so. An example would be ...
VAR
byte command[16]
PUB null
if (MsgTest := debug.rxtime(100)) <> -1 ' got character
command[0] := MsgTest ' recover character
getstr(@command[1]) ' append remainder of string
if strcomp(@Reset, @command)
do stuff
You can also add a new methode to the FullDuplexSerial object, which returns the number of waiting bytes in the buffer. This does not change the buffer.
PUB rxcount : count
'' Check for bytes in receivebuffer (never waits)
'' returns the number of bytes
count := (rx_head - rx_tail) & 15
Comments
What does your code look like?
getstr(@command)
if strcomp(@Reset, @command)
do stuff
From what your telling me my string compare won't work too well.
Let's say you receive the string "fred\n" ('\n' being the end of the line/string). Depending on timing MsgTest will either be -1 (timeout) or 'f'. Then getstr will assemble the string "fred" or "red". So in case you didn't get the timeout you want to recover the missing/consumed character.
Thanks for the help.
Greg
getstr looks like one of your methods, so why don't you pass in an extra parameter (i.e. MsgTest) which when -1 is ignored otherwise inserted into the buffer before the serial device is read again?
I'd help you but I'd need to see more code in order to do so. An example would be ...
Greg
Andy