Click here to Skip to main content
15,893,564 members
Articles / Programming Languages / C#

SCSI Library in C# - Burn CDs and DVDs, Access Hard Disks, etc.

Rate me:
Please Sign up or sign in to vote.
4.77/5 (48 votes)
19 Jun 2017Ms-PL6 min read 146K   8.1K   146  
Ever wonder how programs like Nero work? They make their own SCSI libraries... like this!
using System;
using System.ComponentModel;
using System.Diagnostics;
using System.Runtime.InteropServices;
using Helper;

namespace Scsi.Multimedia
{
	/// <summary>This feature identifies a drive that has the ability to perform media certification and RECOVERED ERROR reporting for drive assisted software defect management. In case of Persistent-DM mode, the <see cref="Read12Command"/> command with Streaming bit = 1 may be performed without medium certification. When this feature is current, the <see cref="DefectManagementFeature"/> is not current. This feature may be current when Restricted Overwrite formatted media or Rigid Restricted Overwrite formatted media is present.</summary>
	[Description("This feature identifies a drive that has the ability to perform media certification and RECOVERED ERROR reporting for drive assisted software defect management.\r\nIn case of Persistent-DM mode, the Read12Command command with Streaming bit = 1 may be performed without medium certification.\r\nWhen this feature is current, the DefectManagementFeature is not current.\r\nThis feature may be current when Restricted Overwrite formatted media or Rigid Restricted Overwrite formatted media is present.")]
	[StructLayout(LayoutKind.Sequential, Pack = 1)]
	public class EnhancedDefectReportingFeature : MultimediaFeature
	{
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private static readonly ScsiCommandCode[] __SupportedOperations = Sort(new ScsiCommandCode[] { ScsiCommandCode.GetPerformance, ScsiCommandCode.Read10, ScsiCommandCode.Read12, ScsiCommandCode.ReadDiscInformation, ScsiCommandCode.Write10, ScsiCommandCode.Write12, ScsiCommandCode.Verify10, ScsiCommandCode.WriteAndVerify10, ScsiCommandCode.SynchronizeCache10, ScsiCommandCode.SetStreaming });

		public override FeatureSupportKind GetSupport(ScsiCommand command)
		{
			return Array.BinarySearch<ScsiCommandCode>(__SupportedOperations, command.OpCode) >= 0
				&& (command.OpCode != ScsiCommandCode.GetPerformance || (((GetPerformanceCommand)command).PerformanceType == PerformanceType.DefectiveBlockInformation))
				&& (command.OpCode != ScsiCommandCode.Read12 || (this.DRTDM == ((Read12Command)command).Streaming))
				&& (command.OpCode != ScsiCommandCode.Write12 || (this.DRTDM == ((Write12Command)command).Streaming))
				? FeatureSupportKind.Mandatory : FeatureSupportKind.None;
		}

		public EnhancedDefectReportingFeature() : base(FeatureCode.EnhancedDefectReporting) { }

		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private byte byte4;
		[DisplayName("DRT-DM")]
		public bool DRTDM { get { return Bits.GetBit(this.byte4, 0); } set { this.byte4 = Bits.SetBit(this.byte4, 0, value); } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private byte _NumberOfDefectiveBlockInformationCacheZones;
		[DisplayName("Defective Block Information Cache Zones")]
		public byte NumberOfDefectiveBlockInformationCacheZones { get { return this._NumberOfDefectiveBlockInformationCacheZones; } set { this._NumberOfDefectiveBlockInformationCacheZones = value; } }
		[DebuggerBrowsable(DebuggerBrowsableState.Never)]
		private ushort _NumberOfEntries;
		[DisplayName("Entry Count")]
		public ushort NumberOfEntries { get { return Bits.BigEndian(this._NumberOfEntries); } set { this._NumberOfEntries = Bits.BigEndian(value); } }
	}
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Microsoft Public License (Ms-PL)


Written By
United States United States
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions