Better handling of boundary conditions
Trying with serialport.readpartial
This commit is contained in:
@@ -5,7 +5,7 @@ class ConfirmingSyncPatternState < StatePattern::State
|
||||
sync_length = Synchronizer::SYNC_PATTERN.length
|
||||
|
||||
# confirm rest of sync pattern
|
||||
while ((idx < sync_length) && bytes[idx] == Synchronizer::SYNC_PATTERN[idx]) do idx = idx+1 end
|
||||
while (idx < bytes.length && idx < sync_length && bytes[idx] == Synchronizer::SYNC_PATTERN[idx]) do idx = idx+1 end
|
||||
|
||||
if (idx == sync_length)
|
||||
#p "Sync pattern confirmed"
|
||||
|
||||
Reference in New Issue
Block a user