Пример #1
0
            public static Int32 Decode(ReceivedFrame frame, Byte[] buf, Int32 ptr, out String s)
            {
                String r = "";

                s = "";
                ptr++;

                if (frame.frameType.Equals(FrameTypes.UIType))
                {
                    frame.pidInfo = new PidInfo();
                    ptr           = frame.pidInfo.Decode(buf, ptr, out r);

                    if (frame.pidInfo.cmdDecode.Equals(PidInfo.CommandDecode.Standard))
                    {
                        //
                        // On standard PID fields, pre-load the segmentation chuck data where the PID used to be in the buffer.
                        // Extended info will already have the correct segmentation chunk info there.
                        //
                        buf[ptr] = Segmenter.StartOfSegment;
                    }

                    frame.iBuf = Support.PackByte(buf, ptr, (buf.Length - ptr));

                    s = r + "|||len:" + frame.iBuf.Length.ToString() + "|txt:(" + Support.GetString(frame.iBuf) + ")";
                }
                if (frame.frameType == FrameTypes.TESTType)
                {
                    frame.iBuf = Support.PackByte(buf, ptr, (buf.Length - ptr));
                }
                if (frame.frameType == FrameTypes.XIDType)
                {
                    XIDInfo xidInfo = new XIDInfo();
                    ptr            = xidInfo.Decode(buf, ptr, out r);
                    s              = r;
                    frame.xidFrame = xidInfo;
                }

                return(ptr);
            }
Пример #2
0
        private static void Main(string[] args)
        {
            Task.Factory.StartNew(async() =>
            {
                while (true)
                {
                    // Receive
                    var result             = await server.ReceiveAsync();
                    ReceivedFrame received = new ReceivedFrame()
                    {
                        Message = Encoding.ASCII.GetString(result.Buffer, 0, result.Buffer.Length),
                        Sender  = result.RemoteEndPoint
                    };
                    Logger.Instance.Info("Sender: " + received.Sender);

                    // Send
                    var datagram = Encoding.ASCII.GetBytes(received.Message);
                    server.Send(datagram, datagram.Length, received.Sender);
                }
            });

            Console.ReadLine();
        }
Пример #3
0
            public static Int32 Decode(ReceivedFrame frame, Byte[] buf, Int32 ptr, out String s)
            {
                String r;

                //if (seqNumMode.Equals(SequenceNumberMode.Mod8))
                //{
                frame.numS = (buf[ptr] >> 1) & 0x07;
                frame.numR = (buf[ptr++] >> 5) & 0x07;

                //    NumR = (buf[ptr++] >> 5) & 0x07;
                //}
                //else
                //{
                //    NumS = (buf[ptr++] >> 1) & 0x7f;
                //    PFBit = buf[ptr] & 0x01;
                //    NumR = (buf[ptr++] >> 1) & 0x7f;
                //}
                s = "|ns=" + frame.numS.ToString() + "|nr=" + frame.numR.ToString();

                frame.pidInfo = new PidInfo();
                ptr           = frame.pidInfo.Decode(buf, ptr, out r);

                if (frame.pidInfo.cmdDecode.Equals(PidInfo.CommandDecode.Standard))
                {
                    //
                    // On standard PID fields, pre-load the segmentation chuck data where the PID used to be in the buffer.
                    // Extended info will already have the correct segmentation chunk info there.
                    //
                    buf[ptr] = Segmenter.StartOfSegment;
                }

                frame.iBuf = Support.PackByte(buf, ptr, (buf.Length - ptr));

                s = s + r + "|len:" + frame.iBuf.Length.ToString() + "|txt:(" + Support.GetString(frame.iBuf) + ")";

                return(ptr);
            }
Пример #4
0
 public static Int32 Decode(ReceivedFrame frame, Byte[] buf, Int32 ptr, out String s)
 {
     frame.numR = (buf[ptr++] >> 5) & 0x07;
     s          = "||nr=" + frame.numR.ToString();
     return(ptr);
 }