public void SegmentAck(IPEndPoint endPoint, BacNetAddress source, byte invokeId, byte sequenceNumber, byte propWindowSize) { var apdu = new SegmentAck() { InvokeId = invokeId, SequenceNumber = sequenceNumber, PropWindowSize = propWindowSize }; var npdu = new BacNetIpNpdu(); npdu.Destination = source; //npdu.Destination = new BacNetAddress(); //npdu.Destination.Network = ByteConverter.GetBytes((ushort)65535); BacNetDevice.Instance.Services.Execute(npdu, apdu, endPoint); //WaitForResponce(); }
public BacNetIpNpdu(byte[] npduBytes) { if (npduBytes.Length < 2) { return; } byte npci = npduBytes[1]; bool destSpecified = false, sourceSpecified = false; for (int i = 0; i < 8; i++) { if ((npci >> i & 1) == 1) { switch (i) { case 2: ExpectingReply = true; break; case 3: sourceSpecified = true; break; case 5: destSpecified = true; break; } } } if (destSpecified) { Destination = new BacNetAddress(); Destination.Network[0] = npduBytes[2]; Destination.Network[1] = npduBytes[3]; Destination.Address = new byte[npduBytes[4]]; for (int i = 0; i < Destination.AddressLength; i++) { Destination.Address[i] = npduBytes[5 + i]; } } if (sourceSpecified) { int sourceStart = Destination == null ? 0 : 5 + Destination.AddressLength; Source = new BacNetAddress(); Source.Network[0] = npduBytes[sourceStart + 2]; Source.Network[1] = npduBytes[sourceStart + 3]; Source.Address = new byte[npduBytes[sourceStart + 4]]; for (int i = 0; i < Source.AddressLength; i++) { Source.Address[i] = npduBytes[sourceStart + 5 + i]; } if (destSpecified) { Destination.HopCount = npduBytes[sourceStart + 5 + Source.AddressLength]; } } if (destSpecified && !sourceSpecified) { Destination.HopCount = npduBytes[5 + Destination.AddressLength]; } }