private KeyValuePair <byte[], int> read_binary(Int16 maxLe, Int16 offset = 0x00)
        {
            KeyValuePair <byte[], int> pair;

            byte[] buffOut = new byte[256];
            int    outSize = 300;

            byte[] byBuffIn   = new byte[] { 0x00, 0xB0, (byte)(offset >> 8), (byte)offset, (byte)maxLe };
            int    returnCode = CSC.CSC_ISOCommand(byBuffIn, byBuffIn.Length, buffOut, ref outSize);

            if (returnCode == CSC.RCSC_Ok && outSize > 2 && buffOut[outSize - 2] == 0x90 &&
                buffOut[outSize - 1] == 0x00)
            {
                Console.WriteLine("read binary");
                var res = new byte[outSize - 3];
                for (var i = 1; i < outSize - 2; i++)
                {
                    res[i - 1] = buffOut[i];
                }

                return(new KeyValuePair <byte[], int>(res, outSize - 3));
            }
            Console.WriteLine("offset : " + offset + " maxLe : " + maxLe);
            throw new Exception("read binary failed " + CSC.ToStringN(buffOut));
        }
        private void select_file(byte[] file)
        {
            byte[] buffOut = new byte[256];
            int    outSize = 300;

            byte[] byBuffIn   = new byte[] { 0x00, 0xA4, 0x00, 0x0C, 0x02, file[0], file[1] };
            int    returnCode = CSC.CSC_ISOCommand(byBuffIn, byBuffIn.Length, buffOut, ref outSize);

            if (returnCode == CSC.RCSC_Ok && outSize > 2 && buffOut[outSize - 2] == 0x90 &&
                buffOut[outSize - 1] == 0x00)
            {
                Console.WriteLine("selected file");
                return;
            }

            throw new Exception("select failed " + returnCode);
        }
        private void select_appli()
        {
            byte[] byBuffIn   = new byte[] { 0x00, 0xA4, 0x04, 0x00, 0x07, 0xD2, 0x76, 0x00, 0x00, 0X85, 0x01, 0x01, 0x00 };
            byte[] buffOut    = new byte[200];
            int    outSize    = 300;
            int    returnCode = CSC.CSC_ISOCommand(byBuffIn, byBuffIn.Length, buffOut, ref outSize);

            Console.WriteLine("return code : " + returnCode);
            Console.WriteLine("buffout : " + CSC.ToStringN(buffOut));

            if (returnCode == CSC.RCSC_Ok && outSize > 2 && buffOut[outSize - 2] == 0x90 &&
                buffOut[outSize - 1] == 0x00)
            {
                Console.WriteLine("selected appli : " + CSC.ToStringN(buffOut));
                return;
            }

            throw new Exception("select failed " + returnCode);
        }
        private void testWriteContent()
        {
            //create global buff in
            //byte[] byBuffIn = new byte[35] { 0x00, 0xD6, 0x00, 0x00, 0x00, 0x34, 0x91, 0x01, 0x11, 0x55, 0x01, 0x70, 0x61, 0x72, 0x61, 0x67, 0x6F, 0x6E, 0x2D, 0x72, 0x66, 0x69, 0x64, 0x2E, 0x63, 0x6F, 0x6D, 0x51, 0x01, 0x04, 0x54, 0x00, 0x50, 0x49, 0x44};
            //byte[] byBuffIn = new byte[10] { 0x00, 0xD6, 0x00, 0x00, 0x05, 0x00, 0x03, 0xD0, 0x00, 0x00 };

            byte[] byBuffIn = new byte[] { 0x00, 0xD6, 0x00, 0x00, 0x2D, 0x00, 0x2B, 0x91, 0x01, 0x0B, 0x55, 0x01, 0x67, 0x6F, 0x6F, 0x67, 0x6C, 0x65, 0x2E, 0x63, 0x6F, 0x6D, 0x11, 0x01, 0x11, 0x54, 0x02, 0x66, 0x72, 0x43, 0x6F, 0x75, 0x63, 0x6F, 0x75, 0x20, 0x54, 0x69, 0x62, 0x6F, 0x77, 0x20, 0x21, 0x51, 0x00, 0x04, 0x31, 0x32, 0x33, 0x34, 0x65, 0xA9 };
            byte[] buffOut  = new byte[200];
            int    outSize  = 300;

            Console.WriteLine("buffIn : " + CSC.ToStringN(byBuffIn));
            int returnCode = CSC.CSC_ISOCommand(byBuffIn, byBuffIn.Length, buffOut, ref outSize);

            Console.WriteLine("buffout : " + CSC.ToStringN(buffOut));


            if (returnCode == CSC.RCSC_Ok && outSize > 2 && buffOut[outSize - 2] == 0x90 &&
                buffOut[outSize - 1] == 0x00)
            {
                Console.WriteLine("have been written");
                return;
            }
            throw new Exception("write failed " + returnCode);
        }
        private void writeContent(int maxLc, string uri, string texte, string data, string protocol)
        {
            byte protocolId = 0x00;

            switch (protocol)
            {
            case "http://www.":
                protocolId = 0x01;
                break;

            case "https://www.":
                protocolId = 0x02;
                break;

            case "http://":
                protocolId = 0x03;
                break;

            case "https://":
                protocolId = 0x04;
                break;
            }

            Console.WriteLine("protocolId : " + protocolId);

            byte[] uriBytes  = Encoding.UTF8.GetBytes(uri);
            byte[] textBytes = Encoding.UTF8.GetBytes(texte);
            byte[] dataBytes = Encoding.UTF8.GetBytes(data);

            //creating total uri bytes bloc
            //TO DO add uri identifier in parameters of function.
            byte[] totalUriBytes = new byte[5 + uriBytes.Length];
            //dansle cas particulier de apple.com
            byte[] uriCommand = new byte[] { 0x91, 0x01, (byte)(uriBytes.Length + 1) /*length*/, 0x55, protocolId };
            uriCommand.CopyTo(totalUriBytes, 0);
            uriBytes.CopyTo(totalUriBytes, uriCommand.Length);
            Console.WriteLine("totalUriBytes : " + CSC.ToStringN(totalUriBytes) + " nbr:" + totalUriBytes.Length);

            //creating total data bytes bloc
            byte[] totalDataBytes = new byte[7 + dataBytes.Length];
            byte[] dataCommand    = new byte[] { 0x11, 0x01, (byte)(dataBytes.Length + 3) /*length*/, 0x54 /*T*/, 0x02 /*UTF8*/, 0x66, 0x72 };
            dataCommand.CopyTo(totalDataBytes, 0);
            dataBytes.CopyTo(totalDataBytes, dataCommand.Length);
            Console.WriteLine("totalDatabytes : " + CSC.ToStringN(totalDataBytes) + " nbr:" + totalDataBytes.Length);


            //creating raw data
            byte[] totalTextBytes = new byte[textBytes.Length + 3];
            byte[] textCommand    = new byte[] { 0x51, 0x00, (byte)(textBytes.Length) };
            textCommand.CopyTo(totalTextBytes, 0);
            textBytes.CopyTo(totalTextBytes, textCommand.Length);
            Console.WriteLine("totalTextbytes : " + CSC.ToStringN(totalTextBytes) + " nbr:" + totalTextBytes.Length);


            //data
            byte[] dataToWrite = new byte[totalUriBytes.Length + totalDataBytes.Length + totalTextBytes.Length];
            totalUriBytes.CopyTo(dataToWrite, 0);
            totalDataBytes.CopyTo(dataToWrite, totalUriBytes.Length);
            totalTextBytes.CopyTo(dataToWrite, totalUriBytes.Length + totalDataBytes.Length);

            //command
            byte[] command = new byte[] { 0x00, 0xD6 };
            //offset
            byte[] offset = new byte[] { 0x00, 0x00 };
            //total length
            byte[] totalLength = new byte[] { (byte)(dataToWrite.Length + 2), 0x00, (byte)(dataToWrite.Length) };

            //create global buff in
            byte[] byBuffIn = new byte[command.Length + offset.Length + totalLength.Length /*+ header.Length*/ + dataToWrite.Length];
            command.CopyTo(byBuffIn, 0);
            offset.CopyTo(byBuffIn, command.Length);
            totalLength.CopyTo(byBuffIn, command.Length + offset.Length);
            dataToWrite.CopyTo(byBuffIn, command.Length + offset.Length + totalLength.Length /*+ header.Length*/);

            byte[] buffOut = new byte[200];
            int    outSize = 300;

            Console.WriteLine("buffIn : " + CSC.ToStringN(byBuffIn));
            int returnCode = CSC.CSC_ISOCommand(byBuffIn, byBuffIn.Length, buffOut, ref outSize);

            Console.WriteLine("buffout : " + CSC.ToStringN(buffOut));


            if (returnCode == CSC.RCSC_Ok && outSize > 2 && buffOut[outSize - 2] == 0x90 &&
                buffOut[outSize - 1] == 0x00)
            {
                Console.WriteLine("have been written");
                return;
            }
            throw new Exception("write failed " + returnCode);
        }