/// <summary> /// Run the last setup command. In case of reading bytes, they are automatically pushed into the Data property /// </summary> /// <returns>-1 if the process fails otherwise the number of bytes read</returns> public int RunUltralightCommand() { byte[] dataOut = new byte[0]; bool awaitingData = false; if (Command == UltralightCommand.Read16Bytes) { awaitingData = true; dataOut = new byte[16]; } else if (Command == UltralightCommand.ReadSignature) { awaitingData = true; dataOut = new byte[32]; } else if (Command == UltralightCommand.PasswordAuthentication) { awaitingData = true; dataOut = new byte[2]; } else if (Command == UltralightCommand.ReadFast) { awaitingData = true; if ((_endAddress - BlockNumber) < 0) { throw new ArgumentException("For fast read, last block has to be more than first block"); } dataOut = new byte[(_endAddress - BlockNumber + 1) * 4]; } else if (Command == UltralightCommand.GetVersion) { awaitingData = true; dataOut = new byte[8]; } else if ((Command == UltralightCommand.ThreeDsAuthenticationPart1) || (Command == UltralightCommand.ThreeDsAuthenticationPart2)) { awaitingData = true; dataOut = new byte[9]; } else if (Command == UltralightCommand.ReadCounter) { awaitingData = true; dataOut = new byte[3]; } var ret = _rfid.Transceive(Target, Serialize(), dataOut.AsSpan()); _logger.LogDebug($"{nameof(UltralightCommand)}: {Command}, Target: {Target}, Data: {BitConverter.ToString(Serialize())}, Success: {ret}, Dataout: {BitConverter.ToString(dataOut)}"); if ((ret > 0) && awaitingData) { Data = dataOut; } return(ret); }
/// <summary> /// Run the last setup command. In case of reading bytes, they are automatically pushed into the Data property /// </summary> /// <returns>-1 if the process fails otherwise the number of bytes read</returns> public int RunMifiCardCommand() { byte[] dataOut = new byte[0]; if (Command == MifareCardCommand.Read16Bytes) { dataOut = new byte[16]; } var ret = _rfid.Transceive(Target, Serialize(), dataOut.AsSpan()); LogInfo.Log($"{nameof(RunMifiCardCommand)}: {Command}, Target: {Target}, Data: {BitConverter.ToString(Serialize())}, Success: {ret}, Dataout: {BitConverter.ToString(dataOut)}", LogLevel.Debug); if ((ret > 0) && (Command == MifareCardCommand.Read16Bytes)) { Data = dataOut; } return(ret); }