Exemplo n.º 1
0
        static void Main(string[] args)
        {
            int    N, i, R;
            string RESP;

            RESP = "S";
            while (RESP.ToUpper() == "S")
            {
                Console.Clear();
                Console.WriteLine("PROGRAMA - TABUADA 2.0");
                Console.WriteLine();
                Console.Write("Informe um valor: ");
                N = int.Parse(Console.ReadLine());
                Console.ReadLine();

                for (i = 1; i <= 10; i++)
                {
                    // Cálculo da tabuada propriamente dito
                    R = N * i;
                    // Apresentação da tabuada no formato N X i = R
                    Console.WriteLine("{0,2} X {1,2} = {2,3}", N, i, R);
                }

                Console.WriteLine();
                Console.WriteLine("Deseja continuar?");
                Console.Write("[S] para SIM ou [N] para NÂo: ");
                RESP = Console.ReadLine();
                Console.WriteLine();
            }
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            int    N, I, R;
            string RESP;

            RESP = "S";
            while (RESP.ToUpper() == "S")
            {
                Console.Clear();
                Console.WriteLine("PROGRAMA - TABUADA");
                Console.WriteLine();
                Console.Write("Informe um valor: ");
                N = int.Parse(Console.ReadLine());
                Console.WriteLine();

                for (I = 1; I <= 10; I++)
                {
                    R = N * I;
                    Console.WriteLine("{0,2} X {1,2} = {2,3}", N, I, R);
                }

                Console.WriteLine();
                Console.WriteLine("Deseja continuar?");
                Console.Write("[S] para SIM ou [N] para NAO: ");
                RESP = Console.ReadLine();
                Console.WriteLine();
            }
        }
Exemplo n.º 3
0
        private bool PeekCommand(ref CardBuffer inBuffer)
        {
            CardBuffer RESP;
            CardBuffer CTRL = new CardBuffer("84");

            RESP = ReaderChannel.Control(CTRL);
            if ((RESP == null) || (RESP.Length <= 1) || (RESP.GetByte(0) != 0x00))
            {
                Trace.WriteLine("Control(" + CTRL.AsString() + ") failed");

                if (RESP == null)
                {
                    Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString);
                }
                else
                {
                    Trace.WriteLine("\tResp= " + RESP.AsString());
                }

                return(false);
            }

            byte[] buffer = new byte[RESP.Length - 1];

            for (int i = 0; i < RESP.Length - 1; i++)
            {
                buffer[i] = RESP.GetByte(i + 1);
            }

            inBuffer = new CardBuffer(buffer);
            return(true);
        }
Exemplo n.º 4
0
        private bool PokeResponse(CardBuffer outBuffer)
        {
            CardBuffer RESP;
            CardBuffer CTRL;

            byte[] buffer = new byte[outBuffer.Length + 1];
            buffer[0] = 0x84;
            for (int i = 0; i < outBuffer.Length; i++)
            {
                buffer[i + 1] = outBuffer.GetByte(i);
            }

            CTRL = new CardBuffer(buffer);

            RESP = ReaderChannel.Control(CTRL);
            if ((RESP == null) || (RESP.Length < 1) || (RESP.GetByte(0) != 0x00))
            {
                Trace.WriteLine("Control(" + CTRL.AsString() + ") failed");

                if (RESP == null)
                {
                    Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString);
                }
                else
                {
                    Trace.WriteLine("\tResp= " + RESP.AsString());
                }

                return(false);
            }

            return(true);
        }
Exemplo n.º 5
0
        public bool WaitEvent(ref byte evtcode, ref byte evtflags, ushort timeout_ms)
        {
            CardBuffer RESP;

            byte[] _ctrl = new byte[4];

            _ctrl[0] = 0x83;
            _ctrl[1] = 0x00;
            _ctrl[2] = (byte)(timeout_ms / 0x0100);
            _ctrl[3] = (byte)(timeout_ms % 0x0100);

            CardBuffer CTRL = new CardBuffer(_ctrl);

            RESP = ReaderChannel.Control(CTRL);
            if ((RESP == null) || (RESP.Length < 3) || (RESP.GetByte(0) != 0x00))
            {
                Trace.WriteLine("Control(" + CTRL.AsString() + ") failed");

                if (RESP == null)
                {
                    Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString);
                }
                else
                {
                    Trace.WriteLine("\tResp= " + RESP.AsString());
                }

                return(false);
            }

            evtcode  = RESP.GetByte(1);
            evtflags = RESP.GetByte(2);

            return(true);
        }
Exemplo n.º 6
0
        public bool GetEvent(ref byte evtcode, ref byte evtflags)
        {
            if (ReaderChannel == null)
            {
                return(false);
            }

            CardBuffer RESP;
            CardBuffer CTRL = new CardBuffer("8300");

            RESP = ReaderChannel.Control(CTRL);
            if ((RESP == null) || (RESP.Length < 3) || (RESP.GetByte(0) != 0x00))
            {
                Trace.WriteLine("Control(" + CTRL.AsString() + ") failed");

                if (RESP == null)
                {
                    Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString);
                }
                else
                {
                    Trace.WriteLine("\tResp= " + RESP.AsString());
                }

                return(false);
            }

            evtcode  = RESP.GetByte(1);
            evtflags = RESP.GetByte(2);

            return(true);
        }
Exemplo n.º 7
0
        private bool DriveBuzzer(bool active)
        {
            if (ReaderChannel == null)
            {
                return(false);
            }

            CardBuffer RESP;
            CardBuffer CTRL;

            if (active)
            {
                CTRL = new CardBuffer("581C0040");
            }
            else
            {
                CTRL = new CardBuffer("581C0200");
            }

            RESP = ReaderChannel.Control(CTRL);

            if ((RESP == null) || (RESP.Length < 1) || (RESP.GetByte(0) != 0x00))
            {
                return(false);
            }

            return(true);
        }
Exemplo n.º 8
0
        private bool EmulStop()
        {
            if (ReaderChannel == null)
            {
                return(false);
            }

            if (trace)
            {
                Trace.WriteLine("Stopping NFC card emulation");
            }

            CardBuffer RESP;
            CardBuffer CTRL_LED = new CardBuffer("581E");
            CardBuffer CTRL_BUZ = new CardBuffer("581C");
            CardBuffer CTRL_NFC = new CardBuffer("83100000");

            RESP = ReaderChannel.Control(CTRL_NFC);
            if ((RESP == null) || (RESP.Length < 1) || ((RESP.GetByte(0) != 0x00) && (RESP.GetByte(0) != 0x1D)))
            {
                if (trace)
                {
                    Trace.WriteLine("Control(" + CTRL_NFC.AsString() + ") failed");
                    if (RESP == null)
                    {
                        Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString);
                    }
                    else
                    {
                        Trace.WriteLine("\tResp= " + RESP.AsString());
                    }
                }

                return(false);
            }

            ReaderChannel.Control(CTRL_LED);
            ReaderChannel.Control(CTRL_BUZ);

            return(true);
        }
Exemplo n.º 9
0
        private bool EmulStart()
        {
            if (ReaderChannel == null)
            {
                return(false);
            }

            if (trace)
            {
                Trace.WriteLine("Starting NFC card emulation");
            }

            CardBuffer RESP;
            CardBuffer CTRL = new CardBuffer("83100100");

            RESP = ReaderChannel.Control(CTRL);
            if ((RESP == null) || (RESP.Length < 1) || (RESP.GetByte(0) != 0x00))
            {
                if (trace)
                {
                    Trace.WriteLine("Control(" + CTRL.AsString() + ") failed");
                    if (RESP == null)
                    {
                        Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString);
                    }
                    else
                    {
                        Trace.WriteLine("\tResp= " + RESP.AsString());
                    }
                }

                return(false);
            }

            if (debug)
            {
                Trace.WriteLine("=");
            }
            return(true);
        }