Read() public static method

public static Read ( ushort com ) : byte
com ushort
return byte
Beispiel #1
0
        public static void Process()
        {
            if (!enabled)
            {
                return;
            }

            if (!Serial.IsDataReady(com))
            {
                return;
            }

            byte b = Serial.Read(com);

            bool bad = false;

            if (index == 0 && b != (byte)'M')
            {
                bad = true;
            }
            else if (index == 1 && b != (byte)'O')
            {
                bad = true;
            }
            else if (index == 2 && b != (byte)'S')
            {
                bad = true;
            }
            else if (index == 3 && b != (byte)'A')
            {
                bad = true;
            }

            if (bad)
            {
                BadDataAbort();
                return;
            }

            Native.Set8(buffer + index, b);
            index++;

            if (index >= 16 && length == -1)
            {
                length = GetInt32(12);
            }

            if (length > 4096 || index > 4096)
            {
                BadDataAbort();
                return;
            }

            if (length + 20 == index)
            {
                ProcessCommand();

                ResetBuffer();
            }
        }
Beispiel #2
0
        private static bool ProcessSerial()
        {
            if (!Serial.IsDataReady(com))
            {
                return(false);
            }

            byte b = Serial.Read(com);

            if (index == 0 && b != (byte)'!')
            {
                return(true);
            }

            if (index + 1 > MaxBuffer)
            {
                index = 0;
                return(true);
            }

            Intrinsic.Store8(new IntPtr(Address.DebuggerBuffer), index++, b);

            if (index >= HeaderSize)
            {
                uint length = GetLength();

                if (length > MaxBuffer)
                {
                    index = 0;
                    return(true);
                }

                if (index == length + HeaderSize)
                {
                    ProcessCommand();
                    index = 0;
                }
            }

            return(true);
        }
Beispiel #3
0
        private static bool ProcessSerial()
        {
            if (!Serial.IsDataReady(com))
            {
                return(false);
            }

            byte b = Serial.Read(com);

            bool bad = false;

            if (index == 0 && b != (byte)'M')
            {
                bad = true;
            }
            else if (index == 1 && b != (byte)'O')
            {
                bad = true;
            }
            else if (index == 2 && b != (byte)'S')
            {
                bad = true;
            }
            else if (index == 3 && b != (byte)'A')
            {
                bad = true;
            }

            if (bad)
            {
                BadDataAbort();
                return(true);
            }

            Native.Set8(Address.DebuggerBuffer + index, b);
            index++;

            uint length = 0;

            if (index >= 16)
            {
                length = GetLength();

                if (length > MaxBuffer || index > MaxBuffer)
                {
                    BadDataAbort();
                    return(true);
                }

                if (length + 20 == index)
                {
                    ProcessCommand();
                    ResetBuffer();
                }
            }

            Screen.Goto(24, 0);
            Screen.Write("INDEX: ");
            Screen.Write(index, 10, 5);
            Screen.Write(" LENGTH: ");
            Screen.Write((uint)length, 10, 5);

            unsafe
            {
                Screen.Write(" EIP: ");
                Screen.Write((uint)idt_stack->EIP, 16, 8);
            }

            return(true);
        }