From 69f386d457997531570cd3b897e2268be5f248f2 Mon Sep 17 00:00:00 2001 From: xxe Date: Thu, 29 Sep 2022 08:40:03 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=B7=E5=8D=A1=E6=9C=BA=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HKControl/Main.cs | 1 + UHFHelper/UHF_RS485_Helper.cs | 14 ++++++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/HKControl/Main.cs b/HKControl/Main.cs index 1b291f8..48dd77c 100644 --- a/HKControl/Main.cs +++ b/HKControl/Main.cs @@ -146,6 +146,7 @@ namespace HKControl private void Control(int num, string add) { + Debug.WriteLine($"{num} 号出餐口控制"); SiemensDicitonary[num].Write(add, true); Thread.Sleep(1000); SiemensDicitonary[num].Write(add, false); diff --git a/UHFHelper/UHF_RS485_Helper.cs b/UHFHelper/UHF_RS485_Helper.cs index 5b7b667..c74021d 100644 --- a/UHFHelper/UHF_RS485_Helper.cs +++ b/UHFHelper/UHF_RS485_Helper.cs @@ -258,8 +258,18 @@ namespace UHFHelper /// public void OpenBeep(int addr) { - byte[] sendData = new byte[] { 0x07, (byte)addr, 0x33, 0x08, 0x02, 0x03, 0x33, 0xB1 }; - + //byte[] sendData = new byte[] { 0x07, (byte)addr, 0x33, 0x08, 0x02, 0x03, 0x33, 0xB1 }; + byte[] data1 = new byte[6] { 0x07, (byte)addr, 0x33, 0x08, 0x02, 0x03 }; + //生成crc校验码 + byte[] data2 = CRC16.ToCRC16(data1); + byte[] data3 = new byte[data1.Length + data2.Length]; + data1.CopyTo(data3, 0); + data2.CopyTo(data3, data1.Length); + if (_serialPort != null) + { + _serialPort.DiscardInBuffer(); + _serialPort.Write(data3, 0, data3.Length); + } } }