void MainFormShown(object sender, EventArgs e) { waitForm = new WaitForm(); SplashForm f = new SplashForm(); f.ShowDialog(); if (AppConfig.ReadBoolean("reader_reconnect")) { ReaderList = new SCardReaderList(); if (ReaderList != null) { string reader_name = AppConfig.ReadString("reader_name"); if (ReaderList.Contains(reader_name)) { Reader = new SCardReader(reader_name); DisplayReaderPresent(); Reader.StartMonitor(new SCardReader.StatusChangeCallback(ReaderStatusChanged)); return; } ReaderList = null; } } SelectReader(); }
private static byte[] sendRequest(SCardReader rfidReader, SCardError sc, SCardPCI receivePci, IntPtr sendPci, CommandApdu apdu, ResponseApdu responseApdu, IsoCase isoCase) { sc = rfidReader.BeginTransaction(); if (sc != SCardError.Success) { return(null); } receivePci = new SCardPCI(); sendPci = SCardPCI.GetPci(rfidReader.ActiveProtocol); var receiveBuffer = new byte[256]; var command = apdu.ToArray(); sc = rfidReader.Transmit( sendPci, command, receivePci, ref receiveBuffer); if (sc != SCardError.Success) { return(null); } responseApdu = new ResponseApdu(receiveBuffer, isoCase, rfidReader.ActiveProtocol); if (!responseApdu.HasData) { return(null); } return((byte[])responseApdu.GetData()); }
//} while (flag ); public static void connection() { context = new SCardContext(); context.Establish(SCardScope.System); string[] readerList = context.GetReaders(); Boolean noReaders = readerList.Length <= 0; if (noReaders) { throw new PCSCException(SCardError.NoReadersAvailable, "Czytnik nie zostal odnaleziony"); // Console.WriteLine("Czytnik nie zostal odnaleziony"); } int counter = 1; Console.WriteLine("Wybierz czytnik: "); foreach (string element in readerList) { Console.WriteLine("F" + counter + " -> " + element); counter++; } var input = Console.ReadKey(); string tmp = readerList[0]; switch (input.Key) { case ConsoleKey.F1: tmp = readerList[0]; break; case ConsoleKey.F2: tmp = readerList[1]; break; } Console.WriteLine("Wcisnij dowolny klawisz by kontynowac..."); Console.ReadKey(); reader = new SCardReader(context); error = reader.Connect(tmp, SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); checkError(error); if (reader.ActiveProtocol == SCardProtocol.T0) { intptr = SCardPCI.T0; } else if (reader.ActiveProtocol == SCardProtocol.T1) { intptr = SCardPCI.T1; } else { Console.WriteLine("Protokol nie jest obslugiwany"); Console.WriteLine("Wcisnij dowolny klawisz by kontynowac..."); Console.ReadKey(); } }
//Called every time the card is inserted public static void initiateTransaction() { //Read the tag SCardReader scardReader = reader.getReader(reader.getReaderContext(SCardScope.System)); if (scardReader != null) { //Success :: Connect to the reader scardReader = reader.connect(); string phoneNo = ReadTag(scardReader); //Make sure phone no is not empty or null; if (!String.IsNullOrEmpty(phoneNo)) { //Call the checkout process Transaction t = new Transaction(300, phoneNo, "DATA Shoes"); string respone = t.pay(); Console.WriteLine("MPESA Response ::::::::" + respone); } else { Console.WriteLine("No Tag detected, tap your phone again please"); } } else { Console.WriteLine("ACR1252U Reader is not connected, connec and try again later"); } }
void OnNetworkReaderListInstantiated(SCardReaderList_CcidOverNetwork NetworkReaders) { if (InvokeRequired) { IAsyncResult ar = this.BeginInvoke(new OnNetworkReaderListInstantiatedInvoker(OnNetworkReaderListInstantiated), NetworkReaders); this.EndInvoke(ar); return; } if (NetworkReaders == null) { MessageBox.Show(this, "Failed to connect to the network reader. Please check your hardware and your configuration, and click the 'Reader' link to try to re-open the reader, or to select another reader.", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } SCardReader_CcidOver NetworkReader = NetworkReaders.GetReader(0); if (NetworkReader == null) { MessageBox.Show(this, "The network reader has not been correctly activated. Please click the 'Reader' link to try to re-open the reader, or to select another reader.", Title, MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return; } ReaderList = NetworkReaders; Reader = NetworkReader; DisplayReaderPresent(); NetworkReader.StartMonitor(new SCardReader_CcidOver.StatusChangeCallback(ReaderStatusChanged)); }
private void _dcmd(byte[] _name) { try { // initialize the reader. SCardReader _reader = new SCardReader(_context); _context.Establish(SCardScope.System); // connect to the reader, protocol not limited. SCardError _error = _reader.Connect(_port, SCardShareMode.Direct, SCardProtocol.Unset); if (CheckError(_error)) { throw new PCSCException(_error); } byte[] _pbRecvBuffer = new byte[256]; // use the hexadecimal code to control the LED. _error = _reader.Control(IOCTL_SCL2000_CTL, _name, ref _pbRecvBuffer); if (CheckError(_error)) { throw new PCSCException(_error); } string _result = ToHexString(_pbRecvBuffer); // disconnect the reader. _reader.Disconnect(SCardReaderDisposition.Leave); } catch (PCSCException ex) { Console.WriteLine(ex.Message + " (" + ex.SCardError.ToString() + ") "); } catch (InvalidOperationException ex) { Console.WriteLine(ex.Message); } }
// Inicjuje sesję, powinno być wywoływane jako pierwsze public bool Initialize() { try { // Rozpocznij nową sesję context = new SCardContext(); context.Establish(SCardScope.System); // Pobierz listę wszystkich czytników // - zakładamy że czytnik w systemie jest tylko jeden string[] lReaders = context.GetReaders(); if (lReaders.Length <= 0) { throw new PCSCException(SCardError.NoReadersAvailable, "Nie można znaleźć żadnego czytnika."); } readerName = lReaders[0]; // Stwórz nowy obiekt czytnika dla tej sesji reader = new SCardReader(context); state = State.INITIALIZED; return(true); } catch (PCSCException ex) { return(false); } }
/// <summary> /// NFC 리더기로 Message를 보내는 함수입니다. 보낼 명령어를 string 형태로 입력하면 Byte 배열로 자동 변환됩니다. /// </summary> /// <param name="message">보낼 메세지를 string 형태로 입력합니다.</param> /// <returns>APDU 통신 결과를 리턴합니다.</returns> public string SendMessageToReader(string message) { SCardReader reader = new SCardReader(SContext); // 카드에 연결합니다. SCardError err = reader.Connect(readers[0], SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); long SendPCILength = 0; switch (reader.ActiveProtocol) { case SCardProtocol.T0: SendPCILength = (long)SCardPCI.T0; break; case SCardProtocol.T1: SendPCILength = (long)SCardPCI.T1; break; default: throw new Exception("Protocol not support,"); } byte[] receiveBuffer = new byte[256]; err = reader.Transmit(StringToByte(message), ref receiveBuffer); CheckError(err); return(ByteToString(receiveBuffer)); }
public void ReadUid(SCardError err, SCardReader reader, IntPtr pioSendPci, string block) { byte[] pbRecvBuffer = new byte[256]; byte[] cmd4 = new byte[] { (byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x00 }; err = reader.Transmit(pioSendPci, cmd4, ref pbRecvBuffer); CheckErr(err); string carduid = BitConverter.ToString(pbRecvBuffer.Take(4).ToArray()).Replace("-", string.Empty).ToUpper(); pbRecvBuffer = new byte[256]; //to read stored value from block byte[] cmd5 = new byte[] { (byte)0xFF, (byte)0xB1, (byte)0x00, (byte)int.Parse(block), (byte)0x04 }; err = reader.Transmit(pioSendPci, cmd5, ref pbRecvBuffer); CheckErr(err); string hex_uid = ""; if (pbRecvBuffer.Length > 2) { for (int i = 0; i < pbRecvBuffer.Length - 2; i++) { hex_uid = hex_uid + string.Format("{0:X2}", pbRecvBuffer[i]); } int in_uid = Convert.ToInt32(hex_uid); sdb.RegisterAttendence(in_uid, carduid); } else { MessageBox.Show("User Data Not Found"); } }
/// <summary>Initializes a new instance of the <see cref="IsoReader" /> class that will create its own instance of a <see cref="SCardReader" />.</summary> /// <param name="context">A context to the PC/SC Resource Manager.</param> /// <param name="releaseContextOnDispose">if set to <c>true</c> the <paramref name="context" /> will be released on <see cref="Dispose()" />.</param> /// <exception cref="System.ArgumentNullException">If <paramref name="context" /> is <see langword="null" /></exception> public IsoReader(ISCardContext context, bool releaseContextOnDispose = false) { _context = context ?? throw new ArgumentNullException(nameof(context)); Reader = new SCardReader(context); _releaseContextOnDispose = releaseContextOnDispose; _disconnectReaderOnDispose = true; }
//fin zona biometrica private void cbReaders_SelectedIndexChanged(object sender, EventArgs e) { if (cbReaders.SelectedIndex == -1) { return; } if (reader != null) { reader.StopMonitor(); } try { string readerName = this.cbReaders.GetItemText(cbReaders.SelectedItem); reader = new SCardReader(readerName); reader.StartMonitor(readerStatusChanged); } catch (Exception Ex) { MessageBox.Show("Hay un error mientras se esta creado el objeto de lectoras : " + Ex.Message); return; } }
void cardMonitor_CardInserted(object sender, CardStatusEventArgs e) { var cardReader = new SCardReader(cardContext); cardReader.Connect(e.ReaderName, SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); int rxBuffLen = 32; byte[] recieveBuff = new byte[rxBuffLen]; cardReader.Transmit(new byte[] { 0xFF, 0xCA, 0x00, 0x00, 0x04 }, recieveBuff, ref rxBuffLen); string tag = BitConverter.ToString(recieveBuff, 0, rxBuffLen); if (IsMonitoring == true) { base.RaiseTagRead(tag); foreach (var listener in TagListeners) { listener.TagRead(new RFIDTag { RFIDTagType = RFIDTag.TagType.Short, Tag = tag }); } } cardReader.Disconnect(SCardReaderDisposition.Leave); }
private SCardReader GetReader() { TS.TraceI("Start GetReader."); //// Establish SCard context SCardContext hContext = OpenSystemWideCardContext(); //// Create a reader object using the existing context SCardReader reader = new SCardReader(hContext); //// Connect to the card SCardError err = reader.Connect(this.ReaderName, SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); if (err != SCardError.Success) { TS.TraceV("CardReaderException: \"{0}\".", SCardHelper.StringifyError(err)); throw new CardReaderException(err, "Unfortunately, this smart card can not be read"); } if (reader.ActiveProtocol != SCardProtocol.T0 && reader.ActiveProtocol != SCardProtocol.T1) { throw new CardReaderException(SCardError.ProtocolMismatch, "Protocol not supported: " + reader.ActiveProtocol.ToString()); } TS.TraceV("AciveProtocol: \"{0}\".", reader.ActiveProtocol); TS.TraceI("End GetReader."); return(reader); }
public void InitializeNFC() { ShowOnStatusBar("Initializing card reader..."); context = new SCardContext(); context.Establish(SCardScope.System); var readerNames = context.GetReaders(); if (readerNames == null || readerNames.Length < 1) { MessageBoxResult result = MessageBox.Show("No NFC readers detected, please reconnect the reader and run the program again", "NFC reader not found", MessageBoxButton.OK, MessageBoxImage.Stop); Environment.Exit(-1); } readerName = readerNames[0]; rfidReader = new SCardReader(context); apdu = new CommandApdu(IsoCase.Case2Short, rfidReader.ActiveProtocol) { CLA = 0xFF, Instruction = InstructionCode.GetData, P1 = 0x00, P2 = 0x00, Le = 0 }; monitor = new SCardMonitor(_contextFactory, SCardScope.System); monitor.Start(readerName); // This event is triggered whenever card insertion happens monitor.CardInserted += (sender, args) => OnCardInsertion(); }
public override EnumDeviceStatus[] GetDeviceStatus() { try { var contextFactory = ContextFactory.Instance; var context = contextFactory.Establish(SCardScope.System); var reader = new SCardReader(context); var readerNames = context.GetReaders(); if (readerNames.Contains(_readerName)) { // connected return(new EnumDeviceStatus[] { EnumDeviceStatus.Connected }); } else { // disconnected return(new EnumDeviceStatus[] { EnumDeviceStatus.Disconnected }); } } catch (Exception ex) { Debug.WriteLine("SmartCardReaderUtils.GetDeviceStatus exception: " + ex.Message); return(new EnumDeviceStatus[] { EnumDeviceStatus.None }); } }
public static bool LimitToP2PProtocols(SCardReader reader, bool yes) { if (yes) { /* Set protocols to Felica + ISO A */ return(SetPollingProtocols(reader, 0x1001)); } else { /* Restore reader's protocol list */ if (!SetPollingProtocols(reader, 0xF7FF)) { return(false); } byte[] control_command = new byte[3]; control_command[0] = 0x58; /* SpringProx control header */ control_command[1] = 0x8D; /* Push register */ control_command[2] = 0xB0; /* Register = 0xB0 for active protoclls */ /* Empty value restores default value */ return(ControlReader(reader, control_command)); } }
public void Connect(int position) { if (hContext.CheckValidity() != PCSC.SCardError.Success) { init(); } // Create a reader object using the existing context reader = new SCardReader(hContext); // Connect to the card SCardError err = reader.Connect(szReaders[position], SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); CheckErr(err); switch (reader.ActiveProtocol) { case SCardProtocol.T0: pioSendPci = SCardPCI.T0; break; case SCardProtocol.T1: pioSendPci = SCardPCI.T1; break; default: throw new PCSCException(SCardError.ProtocolMismatch, "Protocol not supported: " + reader.ActiveProtocol.ToString()); } }
void ChangeReader() { if (reader != null) { reader.StopMonitor(); reader = null; } eReaderStatus.Text = ""; eCardAtr.Text = ""; ReaderSelectForm readerSelect = new ReaderSelectForm(imgHeader.BackColor); readerSelect.SelectedReader = eReaderName.Text; readerSelect.ShowDialog(); if (readerSelect.SelectedReader != null) { eReaderName.Text = readerSelect.SelectedReader; } reader = new SCardReader(eReaderName.Text); SetNfcMode(0, false); reader.StartMonitor(new SCardReader.StatusChangeCallback(ReaderStatusChanged)); }
public bool LoadAuth(SCardError err, SCardReader reader, IntPtr pioSendPci) { byte[] pbRecvBuffer = new byte[256]; // load auth key reader (page 12) //FF=class, 82=ins, 00=key structure(p1), 00=key no p2 (location), 06=byte, (FF, FF, FF, FF, FF, FF)=key value loaded in reader byte[] cmd2 = new byte[] { (byte)0xff, (byte)0x82, 00, 01, 06, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF, (byte)0xFF }; err = reader.Transmit(pioSendPci, cmd2, ref pbRecvBuffer); CheckErr(err); Console.Write("load authkey to reader: "); string retstr = ""; for (int i = 0; i < pbRecvBuffer.Length; i++) { retstr = retstr + " " + string.Format("{0:X2}", pbRecvBuffer[i]); Console.Write("{0:X2} ", pbRecvBuffer[i]); } Console.WriteLine(); if ((retstr).Trim() == "90 00") { return(true); } else { return(false); } }
static void Main(string[] args) { var context = new SCardContext(); context.Establish(SCardScope.System); // Get readers Console.WriteLine("Currently connected readers: "); var readerNames = context.GetReaders(); foreach (var readerName in readerNames) { Console.WriteLine("\t" + readerName); } if (readerNames.Length == 0) { Console.WriteLine("No readers"); } else { var reader = new SCardReader(context); reader.Connect(readerNames[0], SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); IntPtr protocol; switch (reader.ActiveProtocol) { case SCardProtocol.T0: protocol = SCardPCI.T0; break; case SCardProtocol.T1: protocol = SCardPCI.T1; break; default: throw new PCSCException(SCardError.ProtocolMismatch, "No protocol: " + reader.ActiveProtocol.ToString()); } // SELECT TELECOM SendCommand(reader, protocol, new byte[] { 0xA0, 0xA4, 0x00, 0x00, 0x02, 0x7F, 0x10, }, "SELECT TELECOM", ReadType.Bytes); // GET RESPONSE SendCommand(reader, protocol, new byte[] { 0xA0, 0xC0, 0x00, 0x00, 0x16 }, "GET RESPONSE", ReadType.Bytes); // SELECT ADN SendCommand(reader, protocol, new byte[] { 0xA0, 0xA4, 0x00, 0x00, 0x02, 0x6F, 0x3A }, "SELECT ADN", ReadType.Bytes); // GET RESPONSE SendCommand(reader, protocol, new byte[] { 0xA0, 0xC0, 0x00, 0x00, 0x0F }, "GET RESPONSE", ReadType.Bytes); // READ RECORD for (byte i = 0; i < 45; ++i) { SendCommand(reader, protocol, new byte[] { 0xA0, 0xB2, i, 0x04, 0x2E }, "READ RECORD", ReadType.ASCII); } context.Release(); } Console.Read(); }
private void MainForm_FormClosing(object sender, FormClosingEventArgs e) { if (activeReader != null) { activeReader.StopWaitCard(); activeReader = null; } }
static void Main(string[] args) { SCardContext ctx = new SCardContext(); ctx.Establish(SCardScope.System); string[] readernames = ctx.GetReaders(); if (readernames == null || readernames.Length < 1) { throw new Exception("You need at least one reader in order to run this example."); } // Receive the ATR of each reader by using the GetAttrib function foreach (string name in readernames) { SCardReader reader = new SCardReader(ctx); Console.Write("Trying to connect to reader.. " + name); // Connect to the reader, error if no card present. SCardError rc = reader.Connect( name, SCardShareMode.Shared, SCardProtocol.Any); if (rc == SCardError.Success) { // Reader is now connected. Console.WriteLine(" done."); // receive ATR string attribute byte[] atr; rc = reader.GetAttrib(SCardAttr.ATRString, out atr); if (rc != SCardError.Success) { // ATR not supported? Console.WriteLine("Error by trying to receive the ATR. " + SCardHelper.StringifyError(rc) + "\n"); } else { Console.WriteLine("ATR: " + StringAtr(atr) + "\n"); } // Disconnect reader.Disconnect(SCardReaderDisposition.Leave); } else { // Probably no SmartCard present. Console.WriteLine(" failed. " + SCardHelper.StringifyError(rc) + "\n"); } } ctx.Release(); return; }
// public byte[] ReadBlockRange(byte msb, byte blockFrom, byte blockTo) // { // byte i; // int nBlock = 0; // int count = 0; // // for (i = blockFrom; i <= blockTo;) // { // if ((i + 1) % 4 == 0) continue; // nBlock++; // } // // var dataOut = new byte[nBlock * 16]; // for (i = blockFrom; i <= blockTo; i++) // { // if ((i + 1) % 4 == 0) continue; // Array.Copy(ReadBlock(msb, i), 0, dataOut, count * 16, 16); // count++; // } // // return dataOut; // } public void connect() { var ctx = new SCardContext(); ctx.Establish(SCardScope.System); var reader = new SCardReader(ctx); reader.Connect(nfcReader, SCardShareMode.Shared, SCardProtocol.Any); }
private void TransmitBytes() { // Create a new PC/SC context. var ctx = new SCardContext(); ctx.Establish(SCardScope.System); // Connect to the reader var rfidReader = new SCardReader(ctx); SCardError rc = rfidReader.Connect( READER_NAME, SCardShareMode.Shared, SCardProtocol.T1); if (rc != SCardError.Success) { return; } // prepare APDU byte[] ucByteSend = new byte[] { 0xFF, // the instruction class 0xCA, // the instruction code 0x00, // parameter to the instruction 0x00, // parameter to the instruction 0x00 // size of I/O transfer }; rc = rfidReader.BeginTransaction(); if (rc != SCardError.Success) { MessageBox.Show("Klaida: nutruko ryšys su skaitytuvu..."); } SCardPCI ioreq = new SCardPCI(); // IO returned protocol control information. byte[] ucByteReceive = new byte[10]; rc = rfidReader.Transmit( SCardPCI.T1, // Protocol control information, T0, T1 and Raw // are global defined protocol header structures. ucByteSend, // the actual data to be written to the card ioreq, // The returned protocol control information ref ucByteReceive); if (rc == SCardError.Success) { var byteList = new List <byte>(ucByteReceive); byteList.RemoveRange(byteList.Count - 2, 2); ucByteReceive = byteList.ToArray(); backgroundNFCListener.ReportProgress(0, String.Format(BitConverter.ToString(ucByteReceive).Replace("-", ""))); } else { backgroundNFCListener.ReportProgress(0, String.Format("Klaida: " + SCardHelper.StringifyError(rc))); } rfidReader.EndTransaction(SCardReaderDisposition.Leave); rfidReader.Disconnect(SCardReaderDisposition.Reset); ctx.Release(); }
public static byte[] sendCommand(SCardReader reader, IntPtr pioSendPci, byte[] apdu) { SCardError err; byte[] pbRecvBuffer = new byte[256]; err = reader.Transmit(pioSendPci, apdu, ref pbRecvBuffer); CheckErr(err); return(pbRecvBuffer); }
public static bool Resume(SCardReader reader) { byte[] control_command = new byte[2]; control_command[0] = 0x58; control_command[1] = 0x23; return(ControlReader(reader, control_command)); }
void ReleaseReader() { if (reader != null) { reader.StopMonitor(); LimitToP2PProtocols(false); reader = null; } }
public static void connection() { context = new SCardContext(); //nawiązanie połączenia z czytnikiem string[] readerList = context.GetReaders(); // wczytanie dostępnych czytników do listy Boolean noReaders = readerList.Length <= 0; if (noReaders) { throw new PCSCException(SCardError.NoReadersAvailable, "Czytnik nie zostal odnaleziony"); } int counter = 1; Console.WriteLine("Wybierz czytnik: "); foreach (string element in readerList) { Console.WriteLine("F" + counter + " -> " + element); counter++; } var input = Console.ReadKey(); string tmp = readerList[0]; switch (input.Key) { case ConsoleKey.F1: tmp = readerList[0]; break; case ConsoleKey.F2: tmp = readerList[1]; break; } Console.WriteLine("Wcisnij dowolny klawisz by kontynowac..."); Console.ReadKey(); //w zależności od wybranego czytniku wybrany zostanie odpowiedni protokół T0 lub T1. W przypadku pozostałych zostanie wyrzucony wyjątek reader = new SCardReader(context); error = reader.Connect(tmp, SCardShareMode.Shared, SCardProtocol.T0 | SCardProtocol.T1); checkError(error); if (reader.ActiveProtocol == SCardProtocol.T0) { intptr = SCardPCI.T0; } else if (reader.ActiveProtocol == SCardProtocol.T1) { intptr = SCardPCI.T1; } else { Console.WriteLine("Protokol nie jest obslugiwany"); Console.WriteLine("Wcisnij dowolny klawisz by kontynowac..."); Console.ReadKey(); } }
private void _CloseRfid() { if (_reader != null) { _reader.Disconnect(SCardReaderDisposition.Reset); } _reader = null; _context.Dispose(); _context = null; }
/// <summary>Initializes a new instance of the <see cref="IsoReader" /> class that will create its own instance of a <see cref="SCardReader" />.</summary> /// <param name="context">A context to the PC/SC Resource Manager.</param> /// <param name="releaseContextOnDispose">if set to <c>true</c> the <paramref name="context" /> will be released on <see cref="Dispose()" />.</param> /// <exception cref="System.ArgumentNullException">If <paramref name="context" /> is <see langword="null" /></exception> public IsoReader(ISCardContext context, bool releaseContextOnDispose = false) { if (context == null) { throw new ArgumentNullException(nameof(context)); } _context = context; Reader = new SCardReader(context); _releaseContextOnDispose = releaseContextOnDispose; _disconnectReaderOnDispose = true; }
public string GetCardId(SCardError err, SCardReader reader, IntPtr pioSendPci) { byte[] pbRecvBuffer = new byte[256]; //store value hex id into block byte[] cmd4 = new byte[] { (byte)0xFF, (byte)0xCA, (byte)0x00, (byte)0x00, (byte)0x00 }; err = reader.Transmit(pioSendPci, cmd4, ref pbRecvBuffer); // CheckErr(err); return(BitConverter.ToString(pbRecvBuffer.Take(4).ToArray()).Replace("-", string.Empty)); }