private void CleaningBuffer() { byte[] clearCrcArr = { 0xA0, 0x30, 0x64, 0x01, 0x81 }; Crc = Crc16.ComputeChecksum(clearCrcArr); crc1 = Convert.ToByte(Crc & 0xFF); crc2 = Convert.ToByte(Crc >> 8); byte[] clearDataArr = { 0xA0, 0x30, 0x64, 0x01, 0x81, Convert.ToByte(crc1), Convert.ToByte(crc2), 0x03, 0xFA }; _serialPort.Write(clearDataArr, 0, clearDataArr.Length); Thread.Sleep(250); }
private string GettingData() { byte[] incomingGetDataArr = new byte[20]; // Answer of the GetData Array byte[] dataCrcArr = { 0xA0, 0x30, 0x63, 0x1, 0x81 }; // Crc Data Control Array Crc = Crc16.ComputeChecksum(dataCrcArr); crc1 = Convert.ToByte(Crc & 0xFF); // Parses returned value into a part of two bytes crc2 = Convert.ToByte(Crc >> 8); // Parses returned value into a part of two bytes // Data Query: Asks the Card Id. byte[] getDataMessage = { 0xA0, 0x30, 0x63, 0x1, 0x81, Convert.ToByte(crc1), Convert.ToByte(crc2), 0x03, 0xFA }; _serialPort.Write(getDataMessage, 0, getDataMessage.Length); Thread.Sleep(250); _serialPort.Read(incomingGetDataArr, 0, 20); Thread.Sleep(250); return(ByteToHexString(incomingGetDataArr)); }