agv 정보 전송 수정

This commit is contained in:
backuppc
2025-11-14 15:03:41 +09:00
parent 6c8ed6d2f2
commit 4f360f33a7
5 changed files with 52 additions and 23 deletions

View File

@@ -178,14 +178,16 @@ namespace ENIG
OnDataReceived?.Invoke(this, new DataEventArgs { ReceivedPacket = packet });
return true;
}
catch
catch(Exception ex)
{
RaiseMessage(ex.Message, true);
return false;
}
}
// 데이터 수신 처리 메서드 (시리얼 포트에서 데이터를 받았을 때 호출)
private List<byte> buffer = new List<byte>();
private int ProtocolParseError = 0;
public void ProcessReceivedData(byte[] data)
{
buffer.AddRange(data);
@@ -216,7 +218,12 @@ namespace ENIG
byte[] packetData = buffer.Take(expectedLength).ToArray();
buffer.RemoveRange(0, expectedLength);
ParsePacket(packetData);
var parseOK = ParsePacket(packetData);
if(parseOK==false) //분석이 실패되었다면 해당 데이터는 삭제한다.
{
ProtocolParseError += 1;
if (ProtocolParseError > 3) buffer.Clear();
} else ProtocolParseError = 0;
}
}
}