Esempio n. 1
0
        public static void AbortInput(IntPtr sctp)
        {
            byte[] Command = new byte[3];

            Command[0] = 0x01; //keyboard commands
            Command[1] = 0x03; //stop input

            ScpCommands.DoIO(sctp, 0xF8, Command, 0xF0);
        }
Esempio n. 2
0
        public static byte[] EndInput(IntPtr sctp)
        {
            byte[] Command = new byte[3];

            Command[0] = 0x01; //keyboard commands
            Command[1] = 0x04; //read buffer
            Command[2] = 0x00; //buffer no

            return(ScpCommands.DoIO(sctp, 0xF8, Command, 0xF0));
        }
Esempio n. 3
0
        public static bool GetInputHasEnded(IntPtr sctp)
        {
            byte[] Command = new byte[3];

            Command[0] = 0x01; //keyboard commands
            Command[1] = 0x02; //check keyboard status

            byte[] Response = ScpCommands.DoIO(sctp, 0xF8, Command, new[] { 0xF0, 0xFF });

            return(Response == null);
        }
Esempio n. 4
0
 public override byte[] PowerOn(IntPtr sctp, bool reset)
 {
     if (reset)
     {
         return(ScpCommands.DoIO(sctp, 0x01, new byte[] { 0x04 }, 0x82));
     }
     else
     {
         return(ScpCommands.DoIO(sctp, 0x01, 0x82));
     }
 }
Esempio n. 5
0
        public static void WriteOnDisplay(IntPtr sctp, string message)
        {
            byte[] Message = Encoding.ASCII.GetBytes(message);
            byte[] Command = new byte[Message.Length + 3];

            Command[0] = 0x00; //Display commands
            Command[1] = 0x03; //Display text at cursor
            Array.Copy(Message, 0, Command, 2, Message.Length);

            ScpCommands.DoIO(sctp, 0xF8, Command, 0xF0);
        }
Esempio n. 6
0
        public static Point GetCursor(IntPtr sctp)
        {
            byte[] Command = new byte[2];

            Command[0] = 0x00; //Display commands
            Command[1] = 0x04; //get cursor position

            byte[] Response = ScpCommands.DoIO(sctp, 0xF8, Command, 0xF0);

            return(new Point(Response[1], Response[0]));
        }
Esempio n. 7
0
        public static void SetCursor(IntPtr sctp, Point position)
        {
            byte[] Command = new byte[4];

            Command[0] = 0x00; //Display commands
            Command[1] = 0x02; //set cursor position
            Command[2] = (byte)position.Y;
            Command[3] = (byte)position.X;

            ScpCommands.DoIO(sctp, 0xF8, Command, 0xF0);
        }
Esempio n. 8
0
        private static void Display(IntPtr sctp, byte row, string message)
        {
            byte[] Message = Encoding.ASCII.GetBytes(message);
            byte[] Command = new byte[Message.Length + 4];

            Command[0] = 0x00; //Display commands
            Command[1] = 0x01; //Display text
            Command[2] = row;
            Array.Copy(Message, 0, Command, 3, Message.Length);

            ScpCommands.DoIO(sctp, 0xF8, Command, 0xF0);
        }
Esempio n. 9
0
        public static string GetVersionString(IntPtr sctp)
        {
            byte[] Response                = ScpCommands.DoIO(sctp, 0xF6, 0xF0);
            string VersionString           = new string(Encoding.ASCII.GetChars(Response));
            Regex  VersionStringExpression = new Regex(@"^(?<Version>[VX]\d\.\d\d) (?<Id>.*?) \((?<Text>.*?)\) (?<Copyright>.*?)$");

            if (VersionStringExpression.IsMatch(VersionString))
            {
                return(VersionStringExpression.Match(VersionString).Groups["Text"].Value);
            }
            else
            {
                return("unknown SCP device");
            }
        }
Esempio n. 10
0
        public static void StartInput(IntPtr sctp, byte minLength, byte length)
        {
            ScpCommands.InitKeyboard(sctp);
            byte[] Command = new byte[9];

            Command[0] = 0x01; //keyboard commands
            Command[1] = 0x01; //init buffer
            Command[2] = 0x00; //buffer no
            Command[3] = 0x00; //no security lock
            Command[4] = minLength;
            Command[5] = length;
            Command[6] = 0x23; //# character as 'confirm'
            Command[7] = 0x2a; //* character as 'backspace'
            Command[8] = 0x2a; //* character as echo char

            ScpCommands.DoIO(sctp, 0xF8, Command, 0xF0);
        }
Esempio n. 11
0
 public static CardStatus GetStatus(IntPtr sctp)
 {
     byte[] Response = ScpCommands.DoIO(sctp, 0xF8, new byte[] { 0x04, 0x00 }, 0xF0);
     if (Response[0] == 0x00)
     {
         return(CardStatus.NoCard);
     }
     else if (Response[0] == 0x01)
     {
         return(CardStatus.CardInsertedPowerOff);
     }
     else if (Response[0] == 0x02)
     {
         return(CardStatus.CardInsertedPowerOn);
     }
     else
     {
         return(CardStatus.Unknown);
     }
 }
Esempio n. 12
0
        public static void SelectApplicationProtocol(IntPtr sctp, Scap scap)
        {
            ScpCommands.DoIO(sctp, 0xF1, (byte)scap, new[] { 0x80, 0x81, 0x82 });

            ScapCommands Scap;

            switch (scap)
            {
            case SCP.Scap.T0:
                Scap = new Scap3Commands();
                break;

            /*case SCAP.T1:
             *                  Scap = new SCAPxCommands();
             *                  break;*/
            default:
                throw new ScpException(LowLevelError.CardNotSupported);
            }

            ScpCommands.scapsByHandle[sctp] = Scap;
        }
Esempio n. 13
0
        public override byte[] SendApdu(IntPtr sctp, byte[] data)
        {
            byte[] Command = new byte[data.Length + 2];
            Array.Copy(data, 0, Command, 0, 5); //Copy header
            if (data.Length > 5)
            {
                //Data to send
                Command[5] = data[4];                             //Set length of command data
                Array.Copy(data, 5, Command, 7, data.Length - 5); //Copy data
            }
            else
            {
                Command[6] = data[4]; //Set length of excpected data
            }

            byte[] Response = ScpCommands.DoIO(sctp, 0x04, Command, 0x82);

            byte[] ReturnData = new byte[Response.Length - 1];
            Array.Copy(Response, 3, ReturnData, 0, Response.Length - 3);   //Copy response data
            Array.Copy(Response, 0, ReturnData, ReturnData.Length - 2, 2); //Copy status word

            return(ReturnData);
        }
Esempio n. 14
0
 public static byte[] DoIO(IntPtr sctp, int command, byte[] data, int excpectedReturnCode)
 {
     return(ScpCommands.DoIO(sctp, command, data, new[] { excpectedReturnCode }));
 }
Esempio n. 15
0
 public static byte[] DoIO(IntPtr sctp, int command, byte data, int[] excpectedReturnCodes)
 {
     return(ScpCommands.DoIO(sctp, command, new[] { data }, excpectedReturnCodes));
 }
Esempio n. 16
0
 public static Size InitDisplay(IntPtr sctp)
 {
     byte[] Response = ScpCommands.DoIO(sctp, 0xF8, new byte[] { 0x00, 0x00 }, 0xF0);
     return(new Size(Response[1], Response[0]));
 }
Esempio n. 17
0
 public static void PowerOff(IntPtr sctp)
 {
     ScpCommands.DoIO(sctp, 0xF8, new byte[] { 0x04, 0x02 }, 0xF0);
 }
Esempio n. 18
0
 public static string GetVersionString(IntPtr sctp, Scap scap)
 {
     byte[] Response = ScpCommands.DoIO(sctp, 0xF6, new[] { (byte)scap }, 0xF0);
     return(new string(Encoding.ASCII.GetChars(Response)));
 }
Esempio n. 19
0
 public static int InitKeyboard(IntPtr sctp)
 {
     byte[] Response = ScpCommands.DoIO(sctp, 0xF8, new byte[] { 0x01, 0x00 }, 0xF0);
     return(Response[0]);
 }