// カード読込メソッド private async Task <string> Getmid() { // Reader検索 var selector = SmartCardReader.GetDeviceSelector(SmartCardReaderKind.Any); var devices = await DeviceInformation.FindAllAsync(selector); var device = devices.FirstOrDefault(); if (device == null) { return(""); } var reader = await SmartCardReader.FromIdAsync(device.Id); if (reader == null) { return(""); } // カード検索 var cards = await reader.FindAllCardsAsync(); var card = cards.FirstOrDefault(); if (card == null) { return(""); } // 接続してポーリングコマンド送信 using (var con = await card.ConnectAsync()) { var handler = new AccessHandler(con); try { var result = await handler.TransparentExchangeAsync(new byte[] { 6, 0, 0xff, 0xff, 0, 3 }); byte[] idm = new byte[8]; Array.Copy(result, 2, idm, 0, idm.Length); string s = ""; foreach (byte b in idm) { // 0x00がでたらループを抜けるならここにif文とかいれる s += b.ToString("X2"); } return(s); } catch { return(""); } } }
public async Task <String> GetIdm() { var result = await _handler.TransparentExchangeAsync(new byte[] { 6, 0, 0xff, 0xff, 0, 3 }); Debug.WriteLine(result.ToString()); /* * byte systemCodeHigher = (byte)(systemCode >> 8); * byte systemCodeLower = (byte)(systemCode & 0x00ff); * * byte[] commandData = new byte[] { * 0x00, 0x00, systemCodeHigher, systemCodeLower, 0x01, 0x0f, * }; * commandData[0] = (byte)commandData.Length; * * byte[] result = await felicaAccess.TransparentExchangeAsync(commandData); * * byte[] idm = new byte[8]; * Array.Copy(result, 2, idm, 0, idm.Length); * * return idm; */ return(null); }