@startuml
start
if(eventCode != -1)then(yes)
if(headCodeFound || index >= 9?)then(no)
if(eventCode != 12 && index < 9?)then(yes)
:按Index寫入Buffer
Index++;
elseif(eventCode = 12 && index < 9?)then(yes)
:buffer內容整體後移
計算buffer缺省長度
頭部碼發現標誌位置1
index置零;
else(其他情況)
:index = 0;
endif
else(yes)
if(eventCode != 12 && index < 缺省長度?)then(yes)
:按Index寫入Buffer
Index++;
elseif(eventCode = 12 && index < 缺省長度?)then(yes)
end
elseif(index >= 缺省長度)then(yes)
:和校驗標誌位置1
index = 0
缺省長度 = 9;
endif
if(和校驗標誌位 == 1?)then(yes)
:和校驗;
else(no)
endif
endif
else(no)
endif
end
@enduml
運行效果