From 6f89acbf74c6838db518a9f2b6c83f0ab0d97e7f Mon Sep 17 00:00:00 2001 From: 杨张扬 <634643841@qq.com> Date: 星期二, 29 七月 2025 18:13:31 +0800 Subject: [PATCH] 余料回库流程增加绑定和解绑,RFID校验必须校验开头 --- device/TcpServer.cs | 19 +++++++++++-------- 1 files changed, 11 insertions(+), 8 deletions(-) diff --git a/device/TcpServer.cs b/device/TcpServer.cs index 2f79907..d6537f0 100644 --- a/device/TcpServer.cs +++ b/device/TcpServer.cs @@ -100,8 +100,6 @@ clients.Remove(remote_ip); buffers.Remove(remote_ip); isSend.Remove(remote_ip); - isCheck.Remove(remote_ip); - saoMa.Remove(remote_ip); return; } else @@ -144,18 +142,23 @@ { saoMa.Add(remote_ip, 3); } - if (messageBytes.Length <= 20 && messageBytes.Length > 0) + if (messageBytes.Length <= 20 && messageBytes.Length > 0)//闀垮害涓嶅鏃剁洿鎺ュ垽鏂壂鐮佸け璐� { saoMa[remote_ip] = 3;//鏈壂鍒扮爜 } - if (messageBytes.Length >= 21 && isCheck[remote_ip]) + if (messageBytes.Length >= 21 + && isCheck[remote_ip] + && messageBytes[0] == 0xCC + && messageBytes[1] == 0xFF + && messageBytes[2] == 0xFF) { byte[] rfid = new byte[12]; Array.Copy(messageBytes, 9, rfid, 0, 12); - string rfids16 = BitConverter.ToString(rfid); - string rfids = Encoding.ASCII.GetString(rfid); + string rfids16 = BitConverter.ToString(messageBytes); + string rfids = Encoding.ASCII.GetString(rfid);//鎴彇瀛楃涓�+ LogHelper.Info($"璇诲崱鍣ㄦ牎楠屽搴斿鍣ㄥ彿锛歿rfids}锛屽叾16杩涘埗褰㈠紡锛歿rfids16}"); if (ScanCodeHelper.Analysis(remote_ip, rfids))//鏍¢獙RFID { @@ -183,7 +186,7 @@ { //鍗峰笜闂ㄥ紑鍏� var plc = Settings.SafeDoorDevices.FirstOrDefault(a => a.IPAddress == remote_ip); - var log = string.Join(",", messageBytes.Select(x => x.ToString())); + var log = BitConverter.ToString(messageBytes); if (plc != null && messageBytes[0] == 0x3F && messageBytes[1] == 0x00 && @@ -229,7 +232,7 @@ } catch (Exception ex) { - + LogHelper.Error(ex.Message, ex); } } -- Gitblit v1.9.1