private void button11_Click(object sender, EventArgs e) { byte[] Buf = new byte[1500]; byte[] Tata = new byte[2]; Tata = Tools.Int16ToByte(int.Parse(textBox2.Text)); int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_Read1024Byte, Tata, (byte)Tata.Length); ZigBeeBus.ZigBee_CheckCrc(Buf); Usart1.WriteBuffer(Buf, Length); }
private void button5_Click(object sender, EventArgs e) { byte[] Buf = new byte[1500]; byte[] Data = new byte[1]; Data[0] = byte.Parse(textBox1.Text); int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_Read64Byte, Data, (byte)Data.Length); ZigBeeBus.ZigBee_CheckCrc(Buf); Usart1.WriteBuffer(Buf, Length); }
private void button3_Click(object sender, EventArgs e) { byte[] Data = new byte[1]; byte[] Buf = new byte[1500]; int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_GoToBootLoader, Data, 0); ZigBeeBus.ZigBee_CheckCrc(Buf); Usart1.WriteBuffer(Buf, Length); Thread.Sleep(50); }
private void Write64Bytes(byte[] Data, byte Index) { byte[] Buf = new byte[1500]; byte[] Tata = new byte[65]; Tata[0] = Index; for (int i = 0; i < 64; i++) { Tata[i + 1] = Data[i]; } int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_Write64Byte, Tata, (byte)Tata.Length); ZigBeeBus.ZigBee_CheckCrc(Buf); Usart1.WriteBuffer(Buf, Length); }
public static byte[] ZigBee_Write64Bytes(uint OnlyAddr, byte[] DataI, byte PageIndex) { byte[] Buf = new byte[1500]; byte[] Data = new byte[65]; Data[0] = PageIndex; for (int i = 0; i < 64; i++) { Data[1 + i] = DataI[i]; } int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, OnlyAddr, (byte)ACFF.SCFF_Write64Byte, Data, (byte)Data.Length); ZigBeeBus.ZigBee_CheckCrc(Buf); return(Buf); }
private void button12_Click(object sender, EventArgs e) { byte[] Buf = new byte[1500]; byte[] Tata = new byte[8]; FileInfo fi = new FileInfo(Ini.Read("附件路径")); uint len = (uint)fi.Length; Tools.ByteFromU32(len, ref Tata, 0, 0); Tata[4] = 0x19; Tata[5] = 0x89; Tata[6] = 0x11; Tata[7] = 0x06; int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_EraseFlase, Tata, (byte)Tata.Length); ZigBeeBus.ZigBee_CheckCrc(Buf); Usart1.WriteBuffer(Buf, Length); }
private void WritePage(byte[] Data, int Addr) { byte[] Buf = new byte[100]; int CrcValue = Tools.GetCrc16(Data, 0, 1024); Write1024Bytes(Data); Data = new byte[4]; Data[0] = (byte)(CrcValue >> 8); Data[1] = (byte)(CrcValue & 0xff); Data[2] = (byte)(Addr >> 8); Data[3] = (byte)(Addr & 0xff); int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_Write1024Byte, Data, 4); ZigBeeBus.ZigBee_CheckCrc(Buf); Usart1.WriteBuffer(Buf, Length); Thread.Sleep(50); }
private void button7_Click(object sender, EventArgs e) { byte[] Data = new byte[1024]; byte[] Ref = new byte[1024]; for (int i = 0; i < 1024; i++) { Data[i] = 3; } byte[] Buf = new byte[1500]; Data[0] = 0x91; Data[1] = 0x0e; Data[2] = 0x00; Data[3] = 0x00; int Length = ZigBeeBus.ZigBee_SendMsg(ref Buf, DevAddr, (byte)ACFF.SCFF_Write1024Byte, Data, 4); ZigBeeBus.ZigBee_CheckCrc(Buf); Usart1.WriteBuffer(Buf, Length); }
public int SendData(byte[] TxBuffer, int TxLength, ref byte[] RxBuffer, int RxLength) { int Length = 0; for (int n = 0; n < RxLength; n++) { RxBuffer[n] = 0; } if (!SP.IsOpen) { return(0); } for (int i = 0; i < 10; i++) { Length = SendDataOne(TxBuffer, TxLength, ref RxBuffer, RxLength); if (ZigBeeBus.ZigBee_CheckCrc(RxBuffer)) { return(Length); } } MessageBox.Show("重试次数过多"); return(Length); }