Better handling of boundary conditions

Trying with serialport.readpartial
This commit is contained in:
Aart van Halteren
2013-06-26 16:03:28 -04:00
parent 58eee12fb5
commit 099d90c9d8
5 changed files with 34 additions and 14 deletions

View File

@@ -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"