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); + } } }