Inheritance: IDisposable
Exemplo n.º 1
0
 /// <summary>
 /// IC カードに接続できるかどうかを確認します。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <returns>IC カードに接続できる場合は <see langword="true"/>。</returns>
 public static bool TryConnectionToCard(int systemCode)
 {
     using (var felica = new Felica(systemCode))
     {
         return(felica.TryConnectionToCard());
     }
 }
Exemplo n.º 2
0
 /// <summary>
 /// 非暗号化領域の連続した複数のブロックのデータを読み込みます。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <param name="serviceCode">サービス コード。</param>
 /// <param name="addressStart">読み込むブロックの最初のアドレス。</param>
 /// <param name="addressCount">読み込むブロックの数。</param>
 /// <returns>非暗号化領域のブロックのデータのシーケンス。</returns>
 public static IEnumerable <byte[]> ReadBlocksWithoutEncryption(int systemCode, int serviceCode, int addressStart, int addressCount)
 {
     using (var felica = new Felica(systemCode))
     {
         return(felica.ReadBlocksWithoutEncryption(serviceCode, addressStart, addressCount));
     }
 }
Exemplo n.º 3
0
 /// <summary>
 /// 製造パラメータ (PMm) を取得します。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <returns>製造パラメータ (PMm)。配列の長さは 8 です。</returns>
 public static byte[] GetPMm(int systemCode)
 {
     using (var felica = new Felica(systemCode))
     {
         return(felica.GetPMm());
     }
 }
Exemplo n.º 4
0
 public void Felica_GetIDm()
 {
     using (var felica = new Felica(FelicaSystemCode.Any))
     {
         Debug.WriteLine(felica.GetIDm().ToHexString());
     }
 }
Exemplo n.º 5
0
 /// <summary>
 /// IC カードに接続できるかどうかを確認します。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <returns>IC カードに接続できる場合は <see langword="true"/>。</returns>
 public static bool TryConnectionToCard(int systemCode)
 {
     using (var felica = new Felica(systemCode))
     {
         return felica.TryConnectionToCard();
     }
 }
Exemplo n.º 6
0
 public void Felica_TryConnectionToPort()
 {
     using (var felica = new Felica(FelicaSystemCode.Any))
     {
         Assert.AreEqual(false, felica.TryConnectionToPort());
     }
 }
Exemplo n.º 7
0
 /// <summary>
 /// 非暗号化領域の 1 つのブロックのデータを読み込みます。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <param name="serviceCode">サービス コード。</param>
 /// <param name="address">アドレス。</param>
 /// <returns>非暗号化領域のブロックのデータ。配列の長さは 16 です。</returns>
 public static byte[] ReadWithoutEncryption(int systemCode, int serviceCode, int address)
 {
     using (var felica = new Felica(systemCode))
     {
         return felica.ReadWithoutEncryption(serviceCode, address);
     }
 }
Exemplo n.º 8
0
 /// <summary>
 /// 非暗号化領域の連続した複数のブロックのデータを読み込みます。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <param name="serviceCode">サービス コード。</param>
 /// <param name="addressStart">読み込むブロックの最初のアドレス。</param>
 /// <param name="addressCount">読み込むブロックの数。</param>
 /// <returns>非暗号化領域のブロックのデータのシーケンス。</returns>
 public static IEnumerable<byte[]> ReadBlocksWithoutEncryption(int systemCode, int serviceCode, int addressStart, int addressCount)
 {
     using (var felica = new Felica(systemCode))
     {
         return felica.ReadBlocksWithoutEncryption(serviceCode, addressStart, addressCount);
     }
 }
Exemplo n.º 9
0
 /// <summary>
 /// 製造パラメータ (PMm) を取得します。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <returns>製造パラメータ (PMm)。配列の長さは 8 です。</returns>
 public static byte[] GetPMm(int systemCode)
 {
     using (var felica = new Felica(systemCode))
     {
         return felica.GetPMm();
     }
 }
Exemplo n.º 10
0
 /// <summary>
 /// FeliCa ポートに接続できるかどうかを確認します。
 /// </summary>
 /// <returns>FeliCa ポートに接続できる場合は <see langword="true"/>。</returns>
 public static bool TryConnectionToPort()
 {
     using (var felica = new Felica(FelicaSystemCode.Any))
     {
         return(felica.TryConnectionToPort());
     }
 }
Exemplo n.º 11
0
 /// <summary>
 /// 非暗号化領域の 1 つのブロックのデータを読み込みます。
 /// </summary>
 /// <param name="systemCode">システム コード。</param>
 /// <param name="serviceCode">サービス コード。</param>
 /// <param name="address">アドレス。</param>
 /// <returns>非暗号化領域のブロックのデータ。配列の長さは 16 です。</returns>
 public static byte[] ReadWithoutEncryption(int systemCode, int serviceCode, int address)
 {
     using (var felica = new Felica(systemCode))
     {
         return(felica.ReadWithoutEncryption(serviceCode, address));
     }
 }
Exemplo n.º 12
0
        static void Main(string[] args)
        {
            #region FelicaLib
            try
            {
                Console.WriteLine("FelicaLib");
                using (FelicaLib.Felica f = new FelicaLib.Felica())
                {
                    PrintSuicaNo(f);
                }
                Console.WriteLine("\n\n");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            #endregion

            #region NfcStarterKitWrap
            try
            {
                Console.WriteLine("NfcStarterKitWrap");
                nfc        mFNS        = new nfc();
                FelicaLite mLite       = null;
                byte[]     mWriteValue = new byte[nfc.BLOCK_SIZE];
                if (!mFNS.init())
                {
                    Console.WriteLine("SDK for NFC Starter Kit fail");
                    Environment.Exit(0);
                    return;
                }

                mLite = new FelicaLite(mFNS);

                bool ret;
                ret = mFNS.pollingF();
                if (!ret)
                {
                    Console.WriteLine("Polling fail");
                    return;
                }
                Console.WriteLine("IDm=" + BitConverter.ToString(mFNS.NfcId));

                // 読み込み
                ReadSuica(mFNS);

                mFNS.unpoll();
                Console.WriteLine("\n\n");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            #endregion

            Console.Read();
        }
Exemplo n.º 13
0
        private static void readNanaco(Felica f)
        {
            f.Polling((int)SystemCode.Common);
            byte[] data = f.ReadWithoutEncryption(0x558b, 0);
            if (data == null)
            {
                throw new Exception("nanaco ID が読み取れません");
            }
            Console.Write("Nanaco ID = ");
            for (int i = 0; i < 8; i++)
            {
                Console.Write(data[i].ToString("X2"));
            }
            Console.Write("\n");

            for (int i = 0; ; i++)
            {
                data = f.ReadWithoutEncryption(0x564f, i);
                if (data == null)
                {
                    break;
                }

                switch (data[0])
                {
                case 0x47:
                default:
                    Console.Write("支払     ");
                    break;

                case 0x6f:
                    Console.Write("チャージ ");
                    break;
                }

                int value = (data[9] << 24) + (data[10] << 16) + (data[11] << 8) + data[12];
                int year  = (value >> 21) + 2000;
                int month = (value >> 17) & 0xf;
                int date  = (value >> 12) & 0x1f;
                int hour  = (value >> 6) & 0x3f;
                int min   = value & 0x3f;

                Console.Write("{0}/{1:D2}/{2:D2} {3:D2}:{4:D2}", year, month, date, hour, min);

                value = (data[1] << 24) + (data[2] << 16) + (data[3] << 8) + data[4];
                Console.Write("  金額 {0,6}円", value);

                value = (data[5] << 24) + (data[6] << 16) + (data[7] << 8) + data[8];
                Console.Write("  残高 {0,6}円", value);

                value = (data[13] << 8) + data[14];
                Console.WriteLine("  連番 {0}", value);
            }
        }
Exemplo n.º 14
0
        static void ReadEdyBalanceEtc()
        {
            using (var felica = new Felica(FelicaSystemCode.Edy))
            {
                Console.WriteLine(felica.GetIDm().ToHexString());
                Console.WriteLine(felica.GetPMm().ToHexString());

                var data = felica.ReadWithoutEncryption(FelicaServiceCode.EdyBalance, 0);
                Console.WriteLine(new EdyBalanceItem(data).Balance);
            }
        }
Exemplo n.º 15
0
 public static void Main()
 {
     try
     {
         using (Felica f = new Felica())
         {
             readNanaco(f);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 16
0
 public static void Main()
 {
     try
     {
         using (Felica f = new Felica())
         {
             readNanaco(f);
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
 }
Exemplo n.º 17
0
        private static void readNanaco(Felica f)
        {
            f.Polling((int)SystemCode.Common);
            byte[] data = f.ReadWithoutEncryption(0x558b, 0);
            if (data == null)
            {
                throw new Exception("nanaco ID ���ǂݎ��܂���");
            }
            Console.Write("Nanaco ID = ");
            for (int i = 0; i < 8; i++) {
                Console.Write(data[i].ToString("X2"));
            }
            Console.Write("\n");

            for (int i = 0; ; i++)
            {
                data = f.ReadWithoutEncryption(0x564f, i);
                if (data == null) break;

                switch (data[0])
                {
                    case 0x47:
                    default:
                        Console.Write("�x��     ");
                        break;
                    case 0x6f:
                        Console.Write("�`���[�W ");
                        break;
                }

                int value = (data[9] << 24) + (data[10] << 16) + (data[11] << 8) + data[12];
                int year = (value >> 21) + 2000;
                int month = (value >> 17) & 0xf;
                int date = (value >> 12) & 0x1f;
                int hour = (value >> 6) & 0x3f;
                int min = value & 0x3f;

                Console.Write("{0}/{1:D2}/{2:D2} {3:D2}:{4:D2}", year, month, date, hour, min);

                value = (data[1] << 24) + (data[2] << 16) + (data[3] << 8) + data[4];
                Console.Write("  ��z {0,6}�~", value);

                value = (data[5] << 24) + (data[6] << 16) + (data[7] << 8) + data[8];
                Console.Write("  �c�� {0,6}�~", value);

                value = (data[13] << 8) + data[14];
                Console.WriteLine("  �A�� {0}", value);
            }
        }
Exemplo n.º 18
0
 static void Test2()
 {
     using (var felica = new Felica(FelicaSystemCode.Edy))
     {
         for (int i = 0; i < 1000; i++)
         {
             try
             {
                 var data = felica.ReadWithoutEncryption(FelicaServiceCode.EdyBalance, 0);
                 Console.WriteLine(new EdyBalanceItem(data).Balance);
             }
             catch (Exception ex)
             {
                 Console.WriteLine(ex.Message);
             }
         }
     }
 }
Exemplo n.º 19
0
        static void Test1()
        {
            for (int i = 0; i < 1000; i++)
            {
                Console.WriteLine("Start");

                using (var felica = new Felica(FelicaSystemCode.Edy))
                {
                    Console.WriteLine("FeliCa ポート: {0}", felica.TryConnectionToPort());
                    Console.WriteLine("IC カード: {0}", felica.TryConnectionToCard());

                    try
                    {
                        Console.WriteLine(felica.GetIDm().ToHexString());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        Console.WriteLine(felica.GetPMm().ToHexString());
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                    try
                    {
                        var data = felica.ReadWithoutEncryption(FelicaServiceCode.EdyBalance, 0);
                        Console.WriteLine(new EdyBalanceItem(data).Balance);
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                    }
                }
            }
        }
Exemplo n.º 20
0
        public void ReadWithoutEncryption_ManyTimes1()
        {
            Task.Run(() =>
            {
                using (var felica = new Felica(FelicaSystemCode.Edy))
                {
                    for (int i = 0; i < 100; i++)
                    {
                        try
                        {
                            var data = felica.ReadWithoutEncryption(FelicaServiceCode.EdyBalance, 0);
                            Console.WriteLine(new EdyBalanceItem(data).Balance);
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine(ex.Message);
                        }
                    }
                }
            });

            Thread.Sleep(10000);
        }
Exemplo n.º 21
0
        /// <summary>
        /// IDm取得メソッド
        /// </summary>
        /// <returns></returns>
        public string getID()
        {
            try
            {
                using (Felica felica = new Felica())
                {
                    felica.Polling(0xFFFF);
                    byte[] data = felica.IDm();
                    id = "";
                    for (int i = 0; i < data.Length; i++)
                    {
                        id += data[i].ToString("X2");
                    }

                }
            }
            catch(Exception)
            {
                //MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return null;
            }
            return id;
        }
Exemplo n.º 22
0
 public void Felica_ReadBlocksWithoutEncryption_Suica()
 {
     using (var felica = new Felica(FelicaSystemCode.Suica))
     {
         foreach (var data in felica.ReadBlocksWithoutEncryption(FelicaServiceCode.SuicaHistory, 0, 20))
         {
             Debug.WriteLine(data.ToHexString());
         }
     }
 }
Exemplo n.º 23
0
 public void Felica_ReadWithoutEncryption_Edy()
 {
     using (var felica = new Felica(FelicaSystemCode.Edy))
     {
         Debug.WriteLine(felica.ReadWithoutEncryption(FelicaServiceCode.EdyBalance, 0).ToHexString());
     }
 }
Exemplo n.º 24
0
 /// <summary>
 /// Initializes a new instance of the MainViewModel class.
 /// </summary>
 public MainViewModel()
 {
     felica = new Felica(FelicaSystemCode.Edy);
     settings = XMLFileManager.ReadXml<Settings>("Settings.xml");
     PollingAsync();
 }
Exemplo n.º 25
0
 /// <summary>
 /// FeliCa ポートに接続できるかどうかを確認します。
 /// </summary>
 /// <returns>FeliCa ポートに接続できる場合は <see langword="true"/>。</returns>
 public static bool TryConnectionToPort()
 {
     using (var felica = new Felica(FelicaSystemCode.Any))
     {
         return felica.TryConnectionToPort();
     }
 }
Exemplo n.º 26
0
        //[FelicaLib]Suica読み込み
        private static void PrintSuicaNo(FelicaLib.Felica f)
        {
            // システムコード: 0003 (Suicaなどの領域)
            f.Polling((int)SystemCode.Suica);
            //f.Polling((int)SystemCode.Any);

            Console.WriteLine("IDm=" + BitConverter.ToString(f.IDm()));
            Console.WriteLine("PMm=" + BitConverter.ToString(f.PMm()));

            // Suica 各サービスコード
            for (int i = 0; ; i++)
            {
                // サービスコード 乗降履歴情報
                byte[] data = f.ReadWithoutEncryption(0x090f, i);
                if (data == null)
                {
                    break;
                }
                Console.WriteLine("Suica 乗降履歴情報 [" + i + "]  " + BitConverter.ToString(data));
            }
            for (int i = 0; ; i++)
            {
                Console.WriteLine("Suica カード種別およびカード残額情報 " + i);
                // サービスコード カード種別およびカード残額情報
                byte[] data = f.ReadWithoutEncryption(0x008B, i);
                if (data == null)
                {
                    break;
                }
            }
            for (int i = 0; ; i++)
            {
                Console.WriteLine("Suica 改札入出場履歴情報 " + i);
                // サービスコード 改札入出場履歴情報
                byte[] data = f.ReadWithoutEncryption(0x108F, i);
                if (data == null)
                {
                    break;
                }
            }
            for (int i = 0; ; i++)
            {
                Console.WriteLine("Suica SF入場情報 " + i);
                // サービスコード SF入場情報
                byte[] data = f.ReadWithoutEncryption(0x10CB, i);
                if (data == null)
                {
                    break;
                }
            }
            for (int i = 0; ; i++)
            {
                Console.WriteLine("Suica 料金券情報 " + i);
                // サービスコード 料金券情報
                byte[] data = f.ReadWithoutEncryption(0x184B, i);
                if (data == null)
                {
                    break;
                }
            }

            for (int i = 0; ; i++)
            {
                byte[] data = f.ReadWithoutEncryption(0x008B, i);
                if (data == null)
                {
                    break;
                }
            }
        }
Exemplo n.º 27
0
 public void Felica_GetPMm_Suica()
 {
     using (var felica = new Felica(FelicaSystemCode.Suica))
     {
         Debug.WriteLine(felica.GetPMm().ToHexString());
     }
 }
Exemplo n.º 28
0
 static FelicaManager()
 {
     felica = new Felica(FelicaSystemCode.Edy);
     client = new AtterecoClient();
 }
Exemplo n.º 29
0
 public void Felica_ReadBlocksWithoutEncryption_Edy_OutOfRange()
 {
     using (var felica = new Felica(FelicaSystemCode.Edy))
     {
         foreach (var data in felica.ReadBlocksWithoutEncryption(FelicaServiceCode.EdyHistory, 5, 2))
         {
             Debug.WriteLine(data.ToHexString());
         }
     }
 }
Exemplo n.º 30
0
 public void Felica_ReadWithoutEncryption_Suica()
 {
     using (var felica = new Felica(FelicaSystemCode.Suica))
     {
         Debug.WriteLine(felica.ReadWithoutEncryption(FelicaServiceCode.SuicaAttributes, 0).ToHexString());
     }
 }
Exemplo n.º 31
0
 public void Felica_TryConnectionToCard()
 {
     using (var felica = new Felica(FelicaSystemCode.Any))
     {
         Assert.AreEqual(true, felica.TryConnectionToCard());
     }
     using (var felica = new Felica(FelicaSystemCode.Edy))
     {
         Assert.AreEqual(false, felica.TryConnectionToCard());
     }
     using (var felica = new Felica(FelicaSystemCode.Suica))
     {
         Assert.AreEqual(true, felica.TryConnectionToCard());
     }
 }
Exemplo n.º 32
0
 //--------------------------------------------------------------------
 /// <summary>
 /// カード読み込み
 /// </summary>
 public override sealed void ReadTransactions()
 {
     using (IFelica f = new Felica()) {
         mTransactions = ReadTransactions(f);
     }
 }