示例#1
0
        public static TransmitFrame TransmitFrameBuild(Station stl, Station.CommandResponse cmdResp, Int32 pfBit, FrameTypes frameType, Byte[] buf)
        {
            //
            // Build AX25 frames
            //
            Int32 doBufLen = 0;

            if (buf != null)
            {
                doBufLen = buf.Length;
            }

            TransmitFrame transmitFrame = new TransmitFrame();

            Byte[] stlB = stl.GetStationAddresBuffer(cmdResp);

            transmitFrame.ibuf        = new Byte[stlB.Length + 1 + doBufLen];
            transmitFrame.frameType   = frameType;
            transmitFrame.pfBit       = pfBit;
            transmitFrame.seqNumMode  = SequenceNumberMode.Mod8;
            transmitFrame.cmdOctetPtr = stlB.Length;

            if (cmdResp.Equals(Station.CommandResponse.DoCommand) && pfBit == 1) // (JNW Jan15)
            {
                transmitFrame.AckModeID = 0xff;                                  // Use ackmode if enabled  (JNW Jan15)
            }
            stlB.CopyTo(transmitFrame.ibuf, 0);                                  // Load station address fields
            transmitFrame.ibuf[stlB.Length] = (Byte)(((Int32)frameType) | (pfBit << 4));

            if (doBufLen > 0)
            {
                buf.CopyTo(transmitFrame.ibuf, stlB.Length + 1);
            }

            return(transmitFrame);
        }
示例#2
0
        const Byte TEST = 0xe3;  // Test

        //
        // General purpose frame encoder
        //
        public static TransmitFrame TransmitFrameBuild(Station stl, Station.CommandResponse cmdResp, Int32 pfBit, FrameTypes frameType)
        {
            return(TransmitFrameBuild(stl, cmdResp, pfBit, frameType, null));
        }
示例#3
0
            public static TransmitFrame Encode(Station stl, Connection.ConnectionParameterBuf cBuf, Station.CommandResponse cmdResp, Int32 pfBit)
            {
                //
                // Build the XID frame to send
                //

                TransmitFrame commandFrame = new TransmitFrame();

                Byte[] stlB = stl.GetStationAddresBuffer(cmdResp);
                Int32  ptr  = stlB.Length;
                Int32  t;
                Int32  c;
                Int32  paramPtr = 0;

                Byte[] tmpP = new Byte[30];

                commandFrame.ibuf        = new Byte[tmpP.Length + stlB.Length]; // overallocate buffer space to handle worst case.  We'll trim later
                commandFrame.frameType   = FrameTypes.XIDType;
                commandFrame.seqNumMode  = SequenceNumberMode.Mod8;
                commandFrame.cmdOctetPtr = stlB.Length;

                stlB.CopyTo(commandFrame.ibuf, 0);     // Load station address fields

                commandFrame.ibuf[ptr++] = (Byte)(((Int32)FrameTypes.XIDType) | (pfBit << 4));
                commandFrame.ibuf[ptr++] = (Byte)(FormatIdentifier.GeneralPurposeXIDInfo);
                commandFrame.ibuf[ptr++] = (Byte)(GroupIdentifier.ParameterNegotiation);
                //
                // Load parameters to negotiate
                //

                t = (Int32)ClassOfProcedures.BalancedABMHalfDup;
                tmpP[paramPtr++] = (Byte)(ParameterIndicator.ClassOfProcedures);
                tmpP[paramPtr++] = (Byte)2;
                tmpP[paramPtr++] = (Byte)((t >> 8) & 0xff);
                tmpP[paramPtr++] = (Byte)(t & 0x7f);

                tmpP[paramPtr++] = (Byte)(ParameterIndicator.HDLCOptionalParams);
                tmpP[paramPtr++] = (Byte)3;
                tmpP[paramPtr++] = (Byte)(cBuf.optionalFuncByte0);
                tmpP[paramPtr++] = (Byte)(cBuf.optionalFuncByte1);
                tmpP[paramPtr++] = (Byte)(cBuf.optionalFuncByte2);

                //
                // The IFrame size specified here is in bits.  Check to see how many bytes we'll need to specify
                //
                tmpP[paramPtr++] = (Byte)(ParameterIndicator.RXIFieldLen);
                c = cBuf.maxIFrame * 8;
                if (c >= 65536)
                {
                    //
                    // Need 4 bytes to specify the window size
                    //
                    tmpP[paramPtr++] = (Byte)4;
                    tmpP[paramPtr++] = (Byte)((c >> 24) & 0xff);
                    tmpP[paramPtr++] = (Byte)((c >> 16) & 0xff);
                }
                else
                {
                    //
                    // Need only 2 bytes
                    //
                    tmpP[paramPtr++] = (Byte)2;
                }
                tmpP[paramPtr++] = (Byte)((c >> 8) & 0xff);
                tmpP[paramPtr++] = (Byte)(c & 0xff);

                tmpP[paramPtr++] = (Byte)(ParameterIndicator.RXWindowSize);
                tmpP[paramPtr++] = (Byte)1;
                tmpP[paramPtr++] = (Byte)(cBuf.maxWindowSize & 0xff);

                //
                // The Ack timer is specified in mSec.  Check to see how many bytes we'll need
                //
                tmpP[paramPtr++] = (Byte)(ParameterIndicator.AckTimer);
                if (cBuf.ackTimer >= 65536)
                {
                    //
                    // Need 4 bytes to specify ack timer
                    //
                    tmpP[paramPtr++] = (Byte)4;
                    tmpP[paramPtr++] = (Byte)((cBuf.ackTimer >> 24) & 0xff);
                    tmpP[paramPtr++] = (Byte)((cBuf.ackTimer >> 16) & 0xff);
                }
                else
                {
                    //
                    // Need only 2 bytes
                    //
                    tmpP[paramPtr++] = (Byte)2;
                }
                tmpP[paramPtr++] = (Byte)((cBuf.ackTimer >> 8) & 0xff);
                tmpP[paramPtr++] = (Byte)(cBuf.ackTimer & 0xff);

                tmpP[paramPtr++] = (Byte)(ParameterIndicator.NumRetries);
                tmpP[paramPtr++] = (Byte)1;
                tmpP[paramPtr++] = (Byte)(cBuf.maxRetry & 0xff);

                tmpP = Support.PackByte(tmpP, 0, paramPtr);     // Pack it down

                //
                // Add parameter length field to buffer
                //

                commandFrame.ibuf[ptr++] = (Byte)((tmpP.Length >> 8) & 0xff);
                commandFrame.ibuf[ptr++] = (Byte)(tmpP.Length & 0xff);

                //
                // Add the parameters to the buffer
                //
                tmpP.CopyTo(commandFrame.ibuf, ptr);
                ptr += tmpP.Length;

                commandFrame.ibuf = Support.PackByte(commandFrame.ibuf, 0, ptr);  //Pack it down

                return(commandFrame);
            }