Ejemplo n.º 1
0
 /// <summary>
 /// Creates a view model using an existing <see cref="MyObjectBuilder_SessionSettings"/> object.
 /// </summary>
 public SessionSettingsViewModel(MyObjectBuilder_SessionSettings settings)
 {
     _settings = settings;
     foreach (var limit in settings.BlockTypeLimits.Dictionary)
     {
         BlockLimits.Add(new BlockLimitViewModel(this, limit.Key, limit.Value));
     }
 }
Ejemplo n.º 2
0
Archivo: SSC.cs Proyecto: paulyc/Aaru
        public Ssc ReportScsiSsc()
        {
            var report = new Ssc();

            AaruConsole.WriteLine("Querying SCSI READ BLOCK LIMITS...");
            bool sense = _dev.ReadBlockLimits(out byte[] buffer, out byte[] _, _dev.Timeout, out _);

            if (!sense)
            {
                BlockLimits.BlockLimitsData?decBl = BlockLimits.Decode(buffer);

                if (decBl?.granularity > 0)
                {
                    report.BlockSizeGranularity = decBl.Value.granularity;
                }

                if (decBl?.maxBlockLen > 0)
                {
                    report.MaxBlockLength = decBl.Value.maxBlockLen;
                }

                if (decBl?.minBlockLen > 0)
                {
                    report.MinBlockLength = decBl.Value.minBlockLen;
                }
            }

            AaruConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT...");
            sense = _dev.ReportDensitySupport(out buffer, out byte[] _, false, false, _dev.Timeout, out _);

            if (!sense)
            {
                DensitySupport.DensitySupportHeader?dsh = DensitySupport.DecodeDensity(buffer);

                if (dsh.HasValue)
                {
                    SupportedDensity[] array = new SupportedDensity[dsh.Value.descriptors.Length];

                    for (int i = 0; i < dsh.Value.descriptors.Length; i++)
                    {
                        array[i] = new SupportedDensity
                        {
                            BitsPerMm      = dsh.Value.descriptors[i].bpmm,
                            Capacity       = dsh.Value.descriptors[i].capacity,
                            DefaultDensity = dsh.Value.descriptors[i].defaultDensity,
                            Description    = dsh.Value.descriptors[i].description,
                            Duplicate      = dsh.Value.descriptors[i].duplicate,
                            Name           = dsh.Value.descriptors[i].name,
                            Organization   = dsh.Value.descriptors[i].organization,
                            PrimaryCode    = dsh.Value.descriptors[i].primaryCode,
                            SecondaryCode  = dsh.Value.descriptors[i].secondaryCode,
                            Tracks         = dsh.Value.descriptors[i].tracks,
                            Width          = dsh.Value.descriptors[i].width,
                            Writable       = dsh.Value.descriptors[i].writable
                        }
                    }
                    ;

                    report.SupportedDensities = array.ToList();
                }
            }

            AaruConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types...");
            sense = _dev.ReportDensitySupport(out buffer, out byte[] _, true, false, _dev.Timeout, out _);

            if (sense)
            {
                return(report);
            }

            DensitySupport.MediaTypeSupportHeader?mtsh = DensitySupport.DecodeMediumType(buffer);

            if (!mtsh.HasValue)
            {
                return(report);
            }

            SscSupportedMedia[] array2 = new SscSupportedMedia[mtsh.Value.descriptors.Length];

            for (int i = 0; i < mtsh.Value.descriptors.Length; i++)
            {
                array2[i] = new SscSupportedMedia
                {
                    Description  = mtsh.Value.descriptors[i].description,
                    Length       = mtsh.Value.descriptors[i].length,
                    MediumType   = mtsh.Value.descriptors[i].mediumType,
                    Name         = mtsh.Value.descriptors[i].name,
                    Organization = mtsh.Value.descriptors[i].organization,
                    Width        = mtsh.Value.descriptors[i].width
                };

                if (mtsh.Value.descriptors[i].densityCodes == null)
                {
                    continue;
                }

                DensityCode[] array3 = new DensityCode[mtsh.Value.descriptors[i].densityCodes.Length];

                for (int j = 0; j < mtsh.Value.descriptors[i].densityCodes.Length; j++)
                {
                    array3[j] = new DensityCode
                    {
                        Code = mtsh.Value.descriptors[i].densityCodes[j]
                    }
                }
                ;

                array2[i].DensityCodes = array3.Distinct().ToList();
            }

            report.SupportedMediaTypes = array2.ToList();

            return(report);
        }
Ejemplo n.º 3
0
        public pnlDeviceInfo(DeviceInfo devInfo)
        {
            XamlReader.Load(this);

            this.devInfo = devInfo;

            txtType.Text         = devInfo.Type.ToString();
            txtManufacturer.Text = devInfo.Manufacturer;
            txtModel.Text        = devInfo.Model;
            txtRevision.Text     = devInfo.Revision;
            txtSerial.Text       = devInfo.Serial;
            txtScsiType.Text     = devInfo.ScsiType.ToString();
            chkRemovable.Checked = devInfo.IsRemovable;
            chkUsb.Checked       = devInfo.IsUsb;

            if (devInfo.IsUsb)
            {
                tabUsb.Visible = true;
                btnSaveUsbDescriptors.Enabled = devInfo.UsbDescriptors != null;
                txtUsbVendorId.Text           = $"{devInfo.UsbVendorId:X4}";
                txtUsbProductId.Text          = $"{devInfo.UsbProductId:X4}";
                txtUsbManufacturer.Text       = devInfo.UsbManufacturerString;
                txtUsbProduct.Text            = devInfo.UsbProductString;
                txtUsbSerial.Text             = devInfo.UsbSerialString;
            }

            if (devInfo.IsFireWire)
            {
                tabFirewire.Visible          = true;
                txtFirewireVendorId.Text     = $"{devInfo.FireWireVendor:X4}";
                txtFirewireModelId.Text      = $"{devInfo.FireWireModel:X4}";
                txtFirewireManufacturer.Text = devInfo.FireWireVendorName;
                txtFirewireModel.Text        = devInfo.FireWireModelName;
                txtFirewireGuid.Text         = $"{devInfo.FireWireGuid:X16}";
            }

            if (devInfo.IsPcmcia)
            {
                tabPcmciaInfo tabPcmciaInfo = new tabPcmciaInfo();
                tabPcmciaInfo.LoadData(devInfo.Cis);
                tabInfos.Pages.Add(tabPcmciaInfo);
            }

            if (devInfo.AtaIdentify != null || devInfo.AtapiIdentify != null)
            {
                tabAtaInfo tabAtaInfo = new tabAtaInfo();
                tabAtaInfo.LoadData(devInfo.AtaIdentify, devInfo.AtapiIdentify, devInfo.AtaMcptError);

                tabInfos.Pages.Add(tabAtaInfo);
            }

            if (devInfo.ScsiInquiryData != null)
            {
                tabScsiInfo tabScsiInfo = new tabScsiInfo();
                tabScsiInfo.LoadData(devInfo.ScsiInquiryData, devInfo.ScsiInquiry, devInfo.ScsiEvpdPages,
                                     devInfo.ScsiMode, devInfo.ScsiType, devInfo.ScsiModeSense6,
                                     devInfo.ScsiModeSense10, devInfo.MmcConfiguration);

                tabInfos.Pages.Add(tabScsiInfo);

                if (devInfo.PlextorFeatures != null)
                {
                    tabPlextor.Visible = true;
                    if (devInfo.PlextorFeatures.Eeprom != null)
                    {
                        stkPlextorEeprom.Visible   = true;
                        txtPlextorDiscs.Text       = $"{devInfo.PlextorFeatures.Discs}";
                        txtPlextorCdReadTime.Text  = TimeSpan.FromSeconds(devInfo.PlextorFeatures.CdReadTime).ToString();
                        txtPlextorCdWriteTime.Text =
                            TimeSpan.FromSeconds(devInfo.PlextorFeatures.CdWriteTime).ToString();
                        if (devInfo.PlextorFeatures.IsDvd)
                        {
                            stkPlextorDvdTimes.Visible = true;
                            txtPlextorDvdReadTime.Text =
                                TimeSpan.FromSeconds(devInfo.PlextorFeatures.DvdReadTime).ToString();
                            txtPlextorDvdWriteTime.Text =
                                TimeSpan.FromSeconds(devInfo.PlextorFeatures.DvdWriteTime).ToString();
                        }
                    }

                    chkPlextorPoweRec.Checked = devInfo.PlextorFeatures.PoweRec;

                    if (devInfo.PlextorFeatures.PoweRec)
                    {
                        chkPlextorPoweRecEnabled.Visible = true;
                        chkPlextorPoweRecEnabled.Checked = devInfo.PlextorFeatures.PoweRecEnabled;

                        if (devInfo.PlextorFeatures.PoweRecEnabled)
                        {
                            stkPlextorPoweRecEnabled.Visible = true;

                            if (devInfo.PlextorFeatures.PoweRecRecommendedSpeed > 0)
                            {
                                stkPlextorPoweRecRecommended.Visible = true;
                                txtPlextorPoweRecRecommended.Text    =
                                    $"{devInfo.PlextorFeatures.PoweRecRecommendedSpeed} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecSelected > 0)
                            {
                                stkPlextorPoweRecSelected.Visible = true;
                                txtPlextorPoweRecSelected.Text    =
                                    $"{devInfo.PlextorFeatures.PoweRecSelected} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecMax > 0)
                            {
                                stkPlextorPoweRecMax.Visible = true;
                                txtPlextorPoweRecMax.Text    = $"{devInfo.PlextorFeatures.PoweRecMax} Kb/sec.";
                            }

                            if (devInfo.PlextorFeatures.PoweRecLast > 0)
                            {
                                stkPlextorPoweRecLast.Visible = true;
                                txtPlextorPoweRecLast.Text    = $"{devInfo.PlextorFeatures.PoweRecLast} Kb/sec.";
                            }
                        }
                    }

                    chkPlextorSilentMode.Checked = devInfo.PlextorFeatures.SilentMode;

                    if (devInfo.PlextorFeatures.SilentMode)
                    {
                        chkPlextorSilentModeEnabled.Visible = true;
                        chkPlextorSilentModeEnabled.Checked = devInfo.PlextorFeatures.SilentModeEnabled;

                        if (devInfo.PlextorFeatures.SilentModeEnabled)
                        {
                            lblPlextorSilentModeAccessTime.Text = devInfo.PlextorFeatures.AccessTimeLimit == 2
                                                                      ? "\tAccess time is slow"
                                                                      : "\tAccess time is fast";

                            txtPlextorSilentModeCdReadSpeedLimit.Text =
                                devInfo.PlextorFeatures.CdReadSpeedLimit > 0
                                    ? $"{devInfo.PlextorFeatures.CdReadSpeedLimit}x"
                                    : "unlimited";

                            txtPlextorSilentModeCdWriteSpeedLimit.Text =
                                devInfo.PlextorFeatures.CdWriteSpeedLimit > 0
                                    ? $"{devInfo.PlextorFeatures.CdReadSpeedLimit}x"
                                    : "unlimited";

                            if (devInfo.PlextorFeatures.IsDvd)
                            {
                                stkPlextorSilentModeDvdReadSpeedLimit.Visible = true;
                                txtPlextorSilentModeDvdReadSpeedLimit.Text    =
                                    devInfo.PlextorFeatures.DvdReadSpeedLimit > 0
                                        ? $"{devInfo.PlextorFeatures.DvdReadSpeedLimit}x"
                                        : "unlimited";
                            }
                        }
                    }

                    chkPlextorGigaRec.Checked   = devInfo.PlextorFeatures.GigaRec;
                    chkPlextorSecuRec.Checked   = devInfo.PlextorFeatures.SecuRec;
                    chkPlextorSpeedRead.Checked = devInfo.PlextorFeatures.SpeedRead;

                    if (devInfo.PlextorFeatures.SpeedRead)
                    {
                        chkPlextorSpeedEnabled.Visible = true;
                        chkPlextorSpeedEnabled.Checked = devInfo.PlextorFeatures.SpeedReadEnabled;
                    }

                    chkPlextorHiding.Checked = devInfo.PlextorFeatures.Hiding;
                    if (devInfo.PlextorFeatures.Hiding)
                    {
                        stkPlextorHiding.Visible           = true;
                        chkPlextorHidesRecordables.Checked = devInfo.PlextorFeatures.HidesRecordables;
                        chkPlextorHidesSessions.Checked    = devInfo.PlextorFeatures.HidesSessions;
                    }

                    chkPlextorVariRec.Checked = devInfo.PlextorFeatures.VariRec;

                    if (devInfo.PlextorFeatures.IsDvd)
                    {
                        stkPlextorDvd.Visible              = true;
                        chkPlextorVariRecDvd.Checked       = devInfo.PlextorFeatures.VariRecDvd;
                        chkPlextorBitSetting.Checked       = devInfo.PlextorFeatures.BitSetting;
                        chkPlextorBitSettingDl.Checked     = devInfo.PlextorFeatures.BitSettingDl;
                        chkPlextorDvdPlusWriteTest.Checked = devInfo.PlextorFeatures.DvdPlusWriteTest;
                    }
                }

                if (devInfo.ScsiInquiry?.KreonPresent == true)
                {
                    tabKreon.Visible = true;
                    chkKreonChallengeResponse.Checked    = devInfo.KreonFeatures.HasFlag(KreonFeatures.ChallengeResponse);
                    chkKreonDecryptSs.Checked            = devInfo.KreonFeatures.HasFlag(KreonFeatures.DecryptSs);
                    chkKreonXtremeUnlock.Checked         = devInfo.KreonFeatures.HasFlag(KreonFeatures.XtremeUnlock);
                    chkKreonWxripperUnlock.Checked       = devInfo.KreonFeatures.HasFlag(KreonFeatures.WxripperUnlock);
                    chkKreonChallengeResponse360.Checked =
                        devInfo.KreonFeatures.HasFlag(KreonFeatures.ChallengeResponse360);
                    chkKreonDecryptSs360.Checked      = devInfo.KreonFeatures.HasFlag(KreonFeatures.DecryptSs360);
                    chkKreonXtremeUnlock360.Checked   = devInfo.KreonFeatures.HasFlag(KreonFeatures.XtremeUnlock360);
                    chkKreonWxripperUnlock360.Checked = devInfo.KreonFeatures.HasFlag(KreonFeatures.WxripperUnlock360);
                    chkKreonLock.Checked          = devInfo.KreonFeatures.HasFlag(KreonFeatures.Lock);
                    chkKreonErrorSkipping.Checked = devInfo.KreonFeatures.HasFlag(KreonFeatures.ErrorSkipping);
                }

                if (devInfo.BlockLimits != null)
                {
                    BlockLimits.BlockLimitsData?blockLimits = BlockLimits.Decode(devInfo.BlockLimits);

                    if (blockLimits.HasValue)
                    {
                        tabSsc.Visible = true;
                        if (blockLimits.Value.minBlockLen == blockLimits.Value.maxBlockLen)
                        {
                            lblMinBlockSize.Visible = true;
                            lblMinBlockSize.Text    =
                                $"Device's block size is fixed at {blockLimits.Value.minBlockLen} bytes";
                        }
                        else
                        {
                            lblMinBlockSize.Visible = true;
                            lblMaxBlockSize.Visible = true;

                            lblMaxBlockSize.Text = blockLimits.Value.maxBlockLen > 0
                                                       ? $"Device's maximum block size is {blockLimits.Value.maxBlockLen} bytes"
                                                       : "Device does not specify a maximum block size";
                            lblMinBlockSize.Text =
                                $"Device's minimum block size is {blockLimits.Value.minBlockLen} bytes";

                            if (blockLimits.Value.granularity > 0)
                            {
                                lblBlockSizeGranularity.Visible = true;
                                lblBlockSizeGranularity.Text    =
                                    $"Device's needs a block size granularity of 2^{blockLimits.Value.granularity} ({Math.Pow(2, blockLimits.Value.granularity)}) bytes";
                            }
                        }
                    }
                }

                if (devInfo.DensitySupport != null)
                {
                    if (devInfo.DensitySupportHeader.HasValue)
                    {
                        stkDensities.Visible = true;
                        txtDensities.Text    = DensitySupport.PrettifyDensity(devInfo.DensitySupportHeader);
                    }
                }

                if (devInfo.MediumDensitySupport != null)
                {
                    if (devInfo.MediaTypeSupportHeader.HasValue)
                    {
                        stkMediaTypes.Visible = true;
                        txtMediumTypes.Text   = DensitySupport.PrettifyMediumType(devInfo.MediaTypeSupportHeader);
                    }

                    txtMediumDensity.Visible = true;
                    txtMediumDensity.Text    = DensitySupport.PrettifyMediumType(devInfo.MediumDensitySupport);
                }
            }

            tabSdMmcInfo tabSdMmcInfo = new tabSdMmcInfo();

            tabSdMmcInfo.LoadData(devInfo.Type, devInfo.CID, devInfo.CSD, devInfo.OCR, devInfo.ExtendedCSD,
                                  devInfo.SCR);

            tabInfos.Pages.Add(tabSdMmcInfo);
        }
Ejemplo n.º 4
0
        /// <summary>
        ///     Fills a SCSI device report with parameters and media tests specific to a Streaming device
        /// </summary>
        /// <param name="dev">Device</param>
        /// <param name="report">Device report</param>
        /// <param name="debug">If debug is enabled</param>
        internal static void Report(Device dev, ref DeviceReport report, bool debug)
        {
            if (report == null)
            {
                return;
            }

            bool           sense;
            const uint     TIMEOUT = 5;
            ConsoleKeyInfo pressedKey;

            report.SCSI.SequentialDevice = new sscType();
            DicConsole.WriteLine("Querying SCSI READ BLOCK LIMITS...");
            sense = dev.ReadBlockLimits(out byte[] buffer, out byte[] senseBuffer, TIMEOUT, out _);
            if (!sense)
            {
                BlockLimits.BlockLimitsData?decBl = BlockLimits.Decode(buffer);
                if (decBl.HasValue)
                {
                    if (decBl.Value.granularity > 0)
                    {
                        report.SCSI.SequentialDevice.BlockSizeGranularitySpecified = true;
                        report.SCSI.SequentialDevice.BlockSizeGranularity          = decBl.Value.granularity;
                    }

                    if (decBl.Value.maxBlockLen > 0)
                    {
                        report.SCSI.SequentialDevice.MaxBlockLengthSpecified = true;
                        report.SCSI.SequentialDevice.MaxBlockLength          = decBl.Value.maxBlockLen;
                    }

                    if (decBl.Value.minBlockLen > 0)
                    {
                        report.SCSI.SequentialDevice.MinBlockLengthSpecified = true;
                        report.SCSI.SequentialDevice.MinBlockLength          = decBl.Value.minBlockLen;
                    }
                }
            }

            DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT...");
            sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, false, TIMEOUT, out _);
            if (!sense)
            {
                DensitySupport.DensitySupportHeader?dsh = DensitySupport.DecodeDensity(buffer);
                if (dsh.HasValue)
                {
                    report.SCSI.SequentialDevice.SupportedDensities =
                        new SupportedDensity[dsh.Value.descriptors.Length];
                    for (int i = 0; i < dsh.Value.descriptors.Length; i++)
                    {
                        report.SCSI.SequentialDevice.SupportedDensities[i].BitsPerMm = dsh.Value.descriptors[i].bpmm;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Capacity  =
                            dsh.Value.descriptors[i].capacity;
                        report.SCSI.SequentialDevice.SupportedDensities[i].DefaultDensity =
                            dsh.Value.descriptors[i].defaultDensity;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Description =
                            dsh.Value.descriptors[i].description;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Duplicate =
                            dsh.Value.descriptors[i].duplicate;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Name         = dsh.Value.descriptors[i].name;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Organization =
                            dsh.Value.descriptors[i].organization;
                        report.SCSI.SequentialDevice.SupportedDensities[i].PrimaryCode =
                            dsh.Value.descriptors[i].primaryCode;
                        report.SCSI.SequentialDevice.SupportedDensities[i].SecondaryCode =
                            dsh.Value.descriptors[i].secondaryCode;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Tracks   = dsh.Value.descriptors[i].tracks;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Width    = dsh.Value.descriptors[i].width;
                        report.SCSI.SequentialDevice.SupportedDensities[i].Writable = dsh.Value.descriptors[i].writable;
                    }
                }
            }

            DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types...");
            sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, false, TIMEOUT, out _);
            if (!sense)
            {
                DensitySupport.MediaTypeSupportHeader?mtsh = DensitySupport.DecodeMediumType(buffer);
                if (mtsh.HasValue)
                {
                    report.SCSI.SequentialDevice.SupportedMediaTypes =
                        new SupportedMedia[mtsh.Value.descriptors.Length];
                    for (int i = 0; i < mtsh.Value.descriptors.Length; i++)
                    {
                        report.SCSI.SequentialDevice.SupportedMediaTypes[i].Description =
                            mtsh.Value.descriptors[i].description;
                        report.SCSI.SequentialDevice.SupportedMediaTypes[i].Length     = mtsh.Value.descriptors[i].length;
                        report.SCSI.SequentialDevice.SupportedMediaTypes[i].MediumType =
                            mtsh.Value.descriptors[i].mediumType;
                        report.SCSI.SequentialDevice.SupportedMediaTypes[i].Name         = mtsh.Value.descriptors[i].name;
                        report.SCSI.SequentialDevice.SupportedMediaTypes[i].Organization =
                            mtsh.Value.descriptors[i].organization;
                        report.SCSI.SequentialDevice.SupportedMediaTypes[i].Width = mtsh.Value.descriptors[i].width;
                        if (mtsh.Value.descriptors[i].densityCodes == null)
                        {
                            continue;
                        }

                        report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes =
                            new int[mtsh.Value.descriptors[i].densityCodes.Length];
                        for (int j = 0; j < mtsh.Value.descriptors.Length; j++)
                        {
                            report.SCSI.SequentialDevice.SupportedMediaTypes[i].DensityCodes[j] =
                                mtsh.Value.descriptors[i].densityCodes[j];
                        }
                    }
                }
            }

            List <SequentialMedia> seqTests = new List <SequentialMedia>();

            pressedKey = new ConsoleKeyInfo();
            while (pressedKey.Key != ConsoleKey.N)
            {
                pressedKey = new ConsoleKeyInfo();
                while (pressedKey.Key != ConsoleKey.Y && pressedKey.Key != ConsoleKey.N)
                {
                    DicConsole.Write("Do you have media that you can insert in the drive? (Y/N): ");
                    pressedKey = System.Console.ReadKey();
                    DicConsole.WriteLine();
                }

                if (pressedKey.Key != ConsoleKey.Y)
                {
                    continue;
                }

                DicConsole.WriteLine("Please insert it in the drive and press any key when it is ready.");
                System.Console.ReadKey(true);

                SequentialMedia seqTest = new SequentialMedia();
                DicConsole.Write("Please write a description of the media type and press enter: ");
                seqTest.MediumTypeName = System.Console.ReadLine();
                DicConsole.Write("Please write the media manufacturer and press enter: ");
                seqTest.Manufacturer = System.Console.ReadLine();
                DicConsole.Write("Please write the media model and press enter: ");
                seqTest.Model = System.Console.ReadLine();

                seqTest.MediaIsRecognized = true;

                dev.Load(out senseBuffer, TIMEOUT, out _);
                sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
                if (sense)
                {
                    FixedSense?decSense = Sense.DecodeFixed(senseBuffer);
                    if (decSense.HasValue)
                    {
                        if (decSense.Value.ASC == 0x3A)
                        {
                            int leftRetries = 20;
                            while (leftRetries > 0)
                            {
                                DicConsole.Write("\rWaiting for drive to become ready");
                                Thread.Sleep(2000);
                                sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
                                if (!sense)
                                {
                                    break;
                                }

                                leftRetries--;
                            }

                            seqTest.MediaIsRecognized &= !sense;
                        }
                        else if (decSense.Value.ASC == 0x04 && decSense.Value.ASCQ == 0x01)
                        {
                            int leftRetries = 20;
                            while (leftRetries > 0)
                            {
                                DicConsole.Write("\rWaiting for drive to become ready");
                                Thread.Sleep(2000);
                                sense = dev.ScsiTestUnitReady(out senseBuffer, TIMEOUT, out _);
                                if (!sense)
                                {
                                    break;
                                }

                                leftRetries--;
                            }

                            seqTest.MediaIsRecognized &= !sense;
                        }
                        else
                        {
                            seqTest.MediaIsRecognized = false;
                        }
                    }
                    else
                    {
                        seqTest.MediaIsRecognized = false;
                    }
                }

                if (seqTest.MediaIsRecognized)
                {
                    Modes.DecodedMode?decMode = null;

                    DicConsole.WriteLine("Querying SCSI MODE SENSE (10)...");
                    sense = dev.ModeSense10(out buffer, out senseBuffer, false, true, ScsiModeSensePageControl.Current,
                                            0x3F, 0x00, TIMEOUT, out _);
                    if (!sense && !dev.Error)
                    {
                        report.SCSI.SupportsModeSense10 = true;
                        decMode = Modes.DecodeMode10(buffer, dev.ScsiType);
                        if (debug)
                        {
                            seqTest.ModeSense10Data = buffer;
                        }
                    }

                    DicConsole.WriteLine("Querying SCSI MODE SENSE...");
                    sense = dev.ModeSense(out buffer, out senseBuffer, TIMEOUT, out _);
                    if (!sense && !dev.Error)
                    {
                        report.SCSI.SupportsModeSense6 = true;
                        if (!decMode.HasValue)
                        {
                            decMode = Modes.DecodeMode6(buffer, dev.ScsiType);
                        }
                        if (debug)
                        {
                            seqTest.ModeSense6Data = buffer;
                        }
                    }

                    if (decMode.HasValue)
                    {
                        seqTest.MediumType          = (byte)decMode.Value.Header.MediumType;
                        seqTest.MediumTypeSpecified = true;
                        if (decMode.Value.Header.BlockDescriptors != null &&
                            decMode.Value.Header.BlockDescriptors.Length > 0)
                        {
                            seqTest.Density          = (byte)decMode.Value.Header.BlockDescriptors[0].Density;
                            seqTest.DensitySpecified = true;
                        }
                    }
                }

                DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for current media...");
                sense = dev.ReportDensitySupport(out buffer, out senseBuffer, false, true, TIMEOUT, out _);
                if (!sense)
                {
                    DensitySupport.DensitySupportHeader?dsh = DensitySupport.DecodeDensity(buffer);
                    if (dsh.HasValue)
                    {
                        seqTest.SupportedDensities = new SupportedDensity[dsh.Value.descriptors.Length];
                        for (int i = 0; i < dsh.Value.descriptors.Length; i++)
                        {
                            seqTest.SupportedDensities[i].BitsPerMm      = dsh.Value.descriptors[i].bpmm;
                            seqTest.SupportedDensities[i].Capacity       = dsh.Value.descriptors[i].capacity;
                            seqTest.SupportedDensities[i].DefaultDensity = dsh.Value.descriptors[i].defaultDensity;
                            seqTest.SupportedDensities[i].Description    = dsh.Value.descriptors[i].description;
                            seqTest.SupportedDensities[i].Duplicate      = dsh.Value.descriptors[i].duplicate;
                            seqTest.SupportedDensities[i].Name           = dsh.Value.descriptors[i].name;
                            seqTest.SupportedDensities[i].Organization   = dsh.Value.descriptors[i].organization;
                            seqTest.SupportedDensities[i].PrimaryCode    = dsh.Value.descriptors[i].primaryCode;
                            seqTest.SupportedDensities[i].SecondaryCode  = dsh.Value.descriptors[i].secondaryCode;
                            seqTest.SupportedDensities[i].Tracks         = dsh.Value.descriptors[i].tracks;
                            seqTest.SupportedDensities[i].Width          = dsh.Value.descriptors[i].width;
                            seqTest.SupportedDensities[i].Writable       = dsh.Value.descriptors[i].writable;
                        }
                    }
                }

                DicConsole.WriteLine("Querying SCSI REPORT DENSITY SUPPORT for medium types for current media...");
                sense = dev.ReportDensitySupport(out buffer, out senseBuffer, true, true, TIMEOUT, out _);
                if (!sense)
                {
                    DensitySupport.MediaTypeSupportHeader?mtsh = DensitySupport.DecodeMediumType(buffer);
                    if (mtsh.HasValue)
                    {
                        seqTest.SupportedMediaTypes = new SupportedMedia[mtsh.Value.descriptors.Length];
                        for (int i = 0; i < mtsh.Value.descriptors.Length; i++)
                        {
                            seqTest.SupportedMediaTypes[i].Description  = mtsh.Value.descriptors[i].description;
                            seqTest.SupportedMediaTypes[i].Length       = mtsh.Value.descriptors[i].length;
                            seqTest.SupportedMediaTypes[i].MediumType   = mtsh.Value.descriptors[i].mediumType;
                            seqTest.SupportedMediaTypes[i].Name         = mtsh.Value.descriptors[i].name;
                            seqTest.SupportedMediaTypes[i].Organization = mtsh.Value.descriptors[i].organization;
                            seqTest.SupportedMediaTypes[i].Width        = mtsh.Value.descriptors[i].width;
                            if (mtsh.Value.descriptors[i].densityCodes == null)
                            {
                                continue;
                            }

                            seqTest.SupportedMediaTypes[i].DensityCodes =
                                new int[mtsh.Value.descriptors[i].densityCodes.Length];
                            for (int j = 0; j < mtsh.Value.descriptors.Length; j++)
                            {
                                seqTest.SupportedMediaTypes[i].DensityCodes[j] =
                                    mtsh.Value.descriptors[i].densityCodes[j];
                            }
                        }
                    }
                }

                seqTest.CanReadMediaSerialSpecified = true;
                DicConsole.WriteLine("Trying SCSI READ MEDIA SERIAL NUMBER...");
                seqTest.CanReadMediaSerial = !dev.ReadMediaSerialNumber(out buffer, out senseBuffer, TIMEOUT, out _);
                seqTests.Add(seqTest);
            }

            report.SCSI.SequentialDevice.TestedMedia = seqTests.ToArray();
        }