void SegmentUIFrames(Int32 frameSize, Byte[] buffer, Frame.ProtocolVersion version) { Int32 tmpMaxSegments = MaxUISegments; fSize = frameSize; if (version.Equals(Frame.ProtocolVersion.V20)) { tmpMaxSegments = 1; // No segmenter if using the old protocol } if (buf.Length <= fSize) { _segmentTotal = 1; } else { fSize--; // Reduce frame size by one byte if we will be using segmented frames _segmentTotal = (buffer.Length + (fSize - 1)) / fSize; } if (_segmentTotal > tmpMaxSegments) { throw new Exception("Data buffer too large. " + fSize * tmpMaxSegments + " byte maximum"); } }
public Segmenter(Int32 frameSize, Byte[] buffer, Frame.FrameTypes frameType, Frame.ProtocolVersion version) { fType = frameType; buf = buffer; fSize = frameSize; if (frameType.Equals(Frame.FrameTypes.IType)) { // // Call the IFRame segmenter. This segmenter does not use fragmented packets // SegmentIFrames(frameSize, buffer); } else { // // Call the UIFRame segmenter. This segmenter does use fragmented packets if we're running V22 protocol // SegmentUIFrames(frameSize, buffer, version); } }
public void SendDatagram(String destinationStation, String relayStation1, String relayStation2, Byte[] buf, Frame.ProtocolVersion version) { // // Split the datagram into segment as needed and send them off // Note the buffer returned from GetNextSegment has the appropriate PID byte(s) // prepended to the data. // Int32 tmpFSize = defMaxUFrameSize; Station stationLink = new Station(); stationLink.sourceStation = _localStationAddress; stationLink.destinationStation.SetCallSign(destinationStation); if (relayStation1.Length > 0) { stationLink.relayStation1.SetCallSign(relayStation1); if (relayStation2.Length > 0) { stationLink.relayStation2.SetCallSign(relayStation2); } } // // Use user selected value for new protocol version // if (version.Equals(Frame.ProtocolVersion.V22)) { tmpFSize = _maxUFrameSize; } Segmenter segment = new Segmenter(tmpFSize, buf, Frame.FrameTypes.UIType, version); do { Frame.Packet packet = new Frame.Packet( Frame.TransmitFrameBuild(stationLink, Station.CommandResponse.DoCommand, 0, Frame.FrameTypes.UIType, segment.GetNextSegment())); dataLinkProviderQ.Enqueue(packet); } while (segment.segmentsRemaining > 0); }
public void SendDatagram(String destinationStation, String relayStation1, Byte[] buf, Frame.ProtocolVersion version) { SendDatagram(destinationStation, relayStation1, "", buf, version); }