Move to file scoped namespaces.

This commit is contained in:
2022-03-06 13:29:30 +00:00
parent df66f70140
commit f0129131e5
53 changed files with 15299 additions and 15352 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -32,214 +32,213 @@
using System.Diagnostics.CodeAnalysis;
namespace Aaru.CommonTypes.Structs.Devices.SCSI
namespace Aaru.CommonTypes.Structs.Devices.SCSI;
/// <summary>List of known SCSI peripheral qualifiers</summary>
public enum PeripheralQualifiers : byte
{
/// <summary>List of known SCSI peripheral qualifiers</summary>
public enum PeripheralQualifiers : byte
{
/// <summary>Peripheral qualifier: Device is connected and supported</summary>
Supported = 0x00,
/// <summary>Peripheral qualifier: Device is supported but not connected</summary>
Unconnected = 0x01,
/// <summary>Peripheral qualifier: Reserved value</summary>
Reserved = 0x02,
/// <summary>Peripheral qualifier: Device is connected but unsupported</summary>
Unsupported = 0x03,
/// <summary>Peripheral qualifier: Vendor values: 0x04, 0x05, 0x06 and 0x07</summary>
VendorMask = 0x04
}
/// <summary>Peripheral qualifier: Device is connected and supported</summary>
Supported = 0x00,
/// <summary>Peripheral qualifier: Device is supported but not connected</summary>
Unconnected = 0x01,
/// <summary>Peripheral qualifier: Reserved value</summary>
Reserved = 0x02,
/// <summary>Peripheral qualifier: Device is connected but unsupported</summary>
Unsupported = 0x03,
/// <summary>Peripheral qualifier: Vendor values: 0x04, 0x05, 0x06 and 0x07</summary>
VendorMask = 0x04
}
/// <summary>List of known peripheral device types</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PeripheralDeviceTypes : byte
{
/// <summary>Direct-access device</summary>
DirectAccess = 0x00,
/// <summary>Sequential-access device</summary>
SequentialAccess = 0x01,
/// <summary>Printer device</summary>
PrinterDevice = 0x02,
/// <summary>Processor device</summary>
ProcessorDevice = 0x03,
/// <summary>Write-once device</summary>
WriteOnceDevice = 0x04,
/// <summary>CD-ROM/DVD/etc device</summary>
MultiMediaDevice = 0x05,
/// <summary>Scanner device</summary>
ScannerDevice = 0x06,
/// <summary>Optical memory device</summary>
OpticalDevice = 0x07,
/// <summary>Medium change device</summary>
MediumChangerDevice = 0x08,
/// <summary>Communications device</summary>
CommsDevice = 0x09,
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
PrePressDevice1 = 0x0A,
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
PrePressDevice2 = 0x0B,
/// <summary>Array controller device</summary>
ArrayControllerDevice = 0x0C,
/// <summary>Enclosure services device</summary>
EnclosureServiceDevice = 0x0D,
/// <summary>Simplified direct-access device</summary>
SimplifiedDevice = 0x0E,
/// <summary>Optical card reader/writer device</summary>
OCRWDevice = 0x0F,
/// <summary>Bridging Expanders</summary>
BridgingExpander = 0x10,
/// <summary>Object-based Storage Device</summary>
ObjectDevice = 0x11,
/// <summary>Automation/Drive Interface</summary>
ADCDevice = 0x12,
/// <summary>Security Manager Device</summary>
SCSISecurityManagerDevice = 0x13,
/// <summary>Host managed zoned block device</summary>
SCSIZonedBlockDevice = 0x14,
/// <summary>Well known logical unit</summary>
WellKnownDevice = 0x1E,
/// <summary>Unknown or no device type</summary>
UnknownDevice = 0x1F
}
/// <summary>List of known peripheral device types</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PeripheralDeviceTypes : byte
{
/// <summary>Direct-access device</summary>
DirectAccess = 0x00,
/// <summary>Sequential-access device</summary>
SequentialAccess = 0x01,
/// <summary>Printer device</summary>
PrinterDevice = 0x02,
/// <summary>Processor device</summary>
ProcessorDevice = 0x03,
/// <summary>Write-once device</summary>
WriteOnceDevice = 0x04,
/// <summary>CD-ROM/DVD/etc device</summary>
MultiMediaDevice = 0x05,
/// <summary>Scanner device</summary>
ScannerDevice = 0x06,
/// <summary>Optical memory device</summary>
OpticalDevice = 0x07,
/// <summary>Medium change device</summary>
MediumChangerDevice = 0x08,
/// <summary>Communications device</summary>
CommsDevice = 0x09,
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
PrePressDevice1 = 0x0A,
/// <summary>Graphics arts pre-press device (defined in ASC IT8)</summary>
PrePressDevice2 = 0x0B,
/// <summary>Array controller device</summary>
ArrayControllerDevice = 0x0C,
/// <summary>Enclosure services device</summary>
EnclosureServiceDevice = 0x0D,
/// <summary>Simplified direct-access device</summary>
SimplifiedDevice = 0x0E,
/// <summary>Optical card reader/writer device</summary>
OCRWDevice = 0x0F,
/// <summary>Bridging Expanders</summary>
BridgingExpander = 0x10,
/// <summary>Object-based Storage Device</summary>
ObjectDevice = 0x11,
/// <summary>Automation/Drive Interface</summary>
ADCDevice = 0x12,
/// <summary>Security Manager Device</summary>
SCSISecurityManagerDevice = 0x13,
/// <summary>Host managed zoned block device</summary>
SCSIZonedBlockDevice = 0x14,
/// <summary>Well known logical unit</summary>
WellKnownDevice = 0x1E,
/// <summary>Unknown or no device type</summary>
UnknownDevice = 0x1F
}
/// <summary>List of known ANSI SCSI standards</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ANSIVersions : byte
{
/// <summary>Device does not claim conformance to any ANSI version</summary>
ANSINoVersion = 0x00,
/// <summary>Device complies with ANSI X3.131:1986</summary>
ANSI1986Version = 0x01,
/// <summary>Device complies with ANSI X3.131:1994</summary>
ANSI1994Version = 0x02,
/// <summary>Device complies with ANSI X3.301:1997</summary>
ANSI1997Version = 0x03,
/// <summary>Device complies with ANSI X3.351:2001</summary>
ANSI2001Version = 0x04,
/// <summary>Device complies with ANSI X3.408:2005.</summary>
ANSI2005Version = 0x05,
/// <summary>Device complies with SPC-4</summary>
ANSI2008Version = 0x06
}
/// <summary>List of known ANSI SCSI standards</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ANSIVersions : byte
{
/// <summary>Device does not claim conformance to any ANSI version</summary>
ANSINoVersion = 0x00,
/// <summary>Device complies with ANSI X3.131:1986</summary>
ANSI1986Version = 0x01,
/// <summary>Device complies with ANSI X3.131:1994</summary>
ANSI1994Version = 0x02,
/// <summary>Device complies with ANSI X3.301:1997</summary>
ANSI1997Version = 0x03,
/// <summary>Device complies with ANSI X3.351:2001</summary>
ANSI2001Version = 0x04,
/// <summary>Device complies with ANSI X3.408:2005.</summary>
ANSI2005Version = 0x05,
/// <summary>Device complies with SPC-4</summary>
ANSI2008Version = 0x06
}
/// <summary>List of known ECMA SCSI standards</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ECMAVersions : byte
{
/// <summary>Device does not claim conformance to any ECMA version</summary>
ECMANoVersion = 0x00,
/// <summary>Device complies with a ECMA-111 standard</summary>
ECMA111 = 0x01
}
/// <summary>List of known ECMA SCSI standards</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ECMAVersions : byte
{
/// <summary>Device does not claim conformance to any ECMA version</summary>
ECMANoVersion = 0x00,
/// <summary>Device complies with a ECMA-111 standard</summary>
ECMA111 = 0x01
}
/// <summary>List of known ISO SCSI standards</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ISOVersions : byte
{
/// <summary>Device does not claim conformance to any ISO/IEC version</summary>
ISONoVersion = 0x00,
/// <summary>Device complies with ISO/IEC 9316:1995</summary>
ISO1995Version = 0x02
}
/// <summary>List of known ISO SCSI standards</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ISOVersions : byte
{
/// <summary>Device does not claim conformance to any ISO/IEC version</summary>
ISONoVersion = 0x00,
/// <summary>Device complies with ISO/IEC 9316:1995</summary>
ISO1995Version = 0x02
}
/// <summary>List of known SCSI Parallel Interface clocking types</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum SPIClocking : byte
{
/// <summary>Supports only ST</summary>
ST = 0x00,
/// <summary>Supports only DT</summary>
DT = 0x01,
/// <summary>Reserved value</summary>
Reserved = 0x02,
/// <summary>Supports ST and DT</summary>
STandDT = 0x03
}
/// <summary>List of known SCSI Parallel Interface clocking types</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum SPIClocking : byte
{
/// <summary>Supports only ST</summary>
ST = 0x00,
/// <summary>Supports only DT</summary>
DT = 0x01,
/// <summary>Reserved value</summary>
Reserved = 0x02,
/// <summary>Supports ST and DT</summary>
STandDT = 0x03
}
/// <summary>List of known TGPS values</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum TGPSValues : byte
{
/// <summary>Asymmetrical access not supported</summary>
NotSupported = 0x00,
/// <summary>Only implicit asymmetrical access is supported</summary>
OnlyImplicit = 0x01,
/// <summary>Only explicit asymmetrical access is supported</summary>
OnlyExplicit = 0x02,
/// <summary>Both implicit and explicit asymmetrical access are supported</summary>
Both = 0x03
}
/// <summary>List of known TGPS values</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum TGPSValues : byte
{
/// <summary>Asymmetrical access not supported</summary>
NotSupported = 0x00,
/// <summary>Only implicit asymmetrical access is supported</summary>
OnlyImplicit = 0x01,
/// <summary>Only explicit asymmetrical access is supported</summary>
OnlyExplicit = 0x02,
/// <summary>Both implicit and explicit asymmetrical access are supported</summary>
Both = 0x03
}
/// <summary>List of known SCSI protocols</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ProtocolIdentifiers : byte
{
/// <summary>Fibre Channel</summary>
FibreChannel = 0,
/// <summary>Parallel SCSI</summary>
SCSI = 1,
/// <summary>SSA</summary>
SSA = 2,
/// <summary>IEEE-1394</summary>
Firewire = 3,
/// <summary>SCSI Remote Direct Memory Access Protocol</summary>
RDMAP = 4,
/// <summary>Internet SCSI</summary>
iSCSI = 5,
/// <summary>Serial SCSI</summary>
SAS = 6,
/// <summary>Automation/Drive Interface Transport Protocol</summary>
ADT = 7,
/// <summary>AT Attachment Interface (ATA/ATAPI)</summary>
ATA = 8,
/// <summary>USB Attached SCSI</summary>
UAS = 9,
/// <summary>SCSI over PCI Express</summary>
SCSIe = 10,
/// <summary>PCI Express</summary>
PCIe = 11,
/// <summary>No specific protocol</summary>
NoProtocol = 15
}
/// <summary>List of known SCSI protocols</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ProtocolIdentifiers : byte
{
/// <summary>Fibre Channel</summary>
FibreChannel = 0,
/// <summary>Parallel SCSI</summary>
SCSI = 1,
/// <summary>SSA</summary>
SSA = 2,
/// <summary>IEEE-1394</summary>
Firewire = 3,
/// <summary>SCSI Remote Direct Memory Access Protocol</summary>
RDMAP = 4,
/// <summary>Internet SCSI</summary>
iSCSI = 5,
/// <summary>Serial SCSI</summary>
SAS = 6,
/// <summary>Automation/Drive Interface Transport Protocol</summary>
ADT = 7,
/// <summary>AT Attachment Interface (ATA/ATAPI)</summary>
ATA = 8,
/// <summary>USB Attached SCSI</summary>
UAS = 9,
/// <summary>SCSI over PCI Express</summary>
SCSIe = 10,
/// <summary>PCI Express</summary>
PCIe = 11,
/// <summary>No specific protocol</summary>
NoProtocol = 15
}
/// <summary>List of known SCSI definitions</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ScsiDefinitions : byte
{
/// <summary>Unknown</summary>
Current = 0,
/// <summary>SCSI-1</summary>
SCSI1 = 1,
/// <summary>Unknown</summary>
CCS = 2,
/// <summary>SCSI-2</summary>
SCSI2 = 3,
/// <summary>SCSI-3</summary>
SCSI3 = 4
}
/// <summary>List of known SCSI definitions</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum ScsiDefinitions : byte
{
/// <summary>Unknown</summary>
Current = 0,
/// <summary>SCSI-1</summary>
SCSI1 = 1,
/// <summary>Unknown</summary>
CCS = 2,
/// <summary>SCSI-2</summary>
SCSI2 = 3,
/// <summary>SCSI-3</summary>
SCSI3 = 4
}
/// <summary>List of known SCSI physical interfaces</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PhysicalInterfaces : uint
{
/// <summary>Unspecified physical interface</summary>
Unspecified = 0,
/// <summary>SCSI</summary>
SCSI = 1,
/// <summary>ATAPI</summary>
ATAPI = 2,
/// <summary>IEEE-1394/1995</summary>
IEEE1394 = 3,
/// <summary>IEEE-1394A</summary>
IEEE1394A = 4,
/// <summary>Fibre Channel</summary>
FC = 5,
/// <summary>IEEE-1394B</summary>
IEEE1394B = 6,
/// <summary>Serial ATAPI</summary>
SerialATAPI = 7,
/// <summary>USB</summary>
USB = 8,
/// <summary>Vendor unique</summary>
Vendor = 0xFFFF
}
/// <summary>List of known SCSI physical interfaces</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public enum PhysicalInterfaces : uint
{
/// <summary>Unspecified physical interface</summary>
Unspecified = 0,
/// <summary>SCSI</summary>
SCSI = 1,
/// <summary>ATAPI</summary>
ATAPI = 2,
/// <summary>IEEE-1394/1995</summary>
IEEE1394 = 3,
/// <summary>IEEE-1394A</summary>
IEEE1394A = 4,
/// <summary>Fibre Channel</summary>
FC = 5,
/// <summary>IEEE-1394B</summary>
IEEE1394B = 6,
/// <summary>Serial ATAPI</summary>
SerialATAPI = 7,
/// <summary>USB</summary>
USB = 8,
/// <summary>Vendor unique</summary>
Vendor = 0xFFFF
}

File diff suppressed because it is too large Load Diff

View File

@@ -35,480 +35,479 @@ using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes
namespace Aaru.CommonTypes.Structs.Devices.SCSI.Modes;
#region Mode Page 0x2A: CD-ROM capabilities page
/// <summary>
/// CD-ROM capabilities page Page code 0x2A 16 bytes in OB-U0077C 20 bytes in SFF-8020i 22 bytes in MMC-1 26 bytes
/// in MMC-2 Variable bytes in MMC-3
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class ModePage_2A
{
#region Mode Page 0x2A: CD-ROM capabilities page
/// <summary>Write speed performance descriptors</summary>
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors;
/// <summary>Parameters can be saved</summary>
public bool PS { get; set; }
/// <summary>Drive supports multi-session and/or Photo-CD</summary>
public bool MultiSession { get; set; }
/// <summary>Drive is capable of reading sectors in Mode 2 Form 2 format</summary>
public bool Mode2Form2 { get; set; }
/// <summary>Drive is capable of reading sectors in Mode 2 Form 1 format</summary>
public bool Mode2Form1 { get; set; }
/// <summary>Drive is capable of playing audio</summary>
public bool AudioPlay { get; set; }
/// <summary>Drive can return the ISRC</summary>
public bool ISRC { get; set; }
/// <summary>Drive can return the media catalogue number</summary>
public bool UPC { get; set; }
/// <summary>Drive can return C2 pointers</summary>
public bool C2Pointer { get; set; }
/// <summary>Drive can read, deinterlave and correct R-W subchannels</summary>
public bool DeinterlaveSubchannel { get; set; }
/// <summary>Drive can read interleaved and uncorrected R-W subchannels</summary>
public bool Subchannel { get; set; }
/// <summary>Drive can continue from a loss of streaming on audio reading</summary>
public bool AccurateCDDA { get; set; }
/// <summary>Audio can be read as digital data</summary>
public bool CDDACommand { get; set; }
/// <summary>Loading Mechanism Type</summary>
public byte LoadingMechanism { get; set; }
/// <summary>Drive can eject discs</summary>
public bool Eject { get; set; }
/// <summary>Drive's optional prevent jumper status</summary>
public bool PreventJumper { get; set; }
/// <summary>Current lock status</summary>
public bool LockState { get; set; }
/// <summary>Drive can lock media</summary>
public bool Lock { get; set; }
/// <summary>Each channel can be muted independently</summary>
public bool SeparateChannelMute { get; set; }
/// <summary>Each channel's volume can be controlled independently</summary>
public bool SeparateChannelVolume { get; set; }
/// <summary>Maximum drive speed in Kbytes/second</summary>
public ushort MaximumSpeed { get; set; }
/// <summary>Supported volume levels</summary>
public ushort SupportedVolumeLevels { get; set; }
/// <summary>Buffer size in Kbytes</summary>
public ushort BufferSize { get; set; }
/// <summary>Current drive speed in Kbytes/second</summary>
public ushort CurrentSpeed { get; set; }
/// <summary>Can read packet media</summary>
public bool Method2 { get; set; }
/// <summary>Can read CD-RW</summary>
public bool ReadCDRW { get; set; }
/// <summary>Can read CD-R</summary>
public bool ReadCDR { get; set; }
/// <summary>Can write CD-RW</summary>
public bool WriteCDRW { get; set; }
/// <summary>Can write CD-R</summary>
public bool WriteCDR { get; set; }
/// <summary>Supports IEC-958 digital output on port 2</summary>
public bool DigitalPort2 { get; set; }
/// <summary>Supports IEC-958 digital output on port 1</summary>
public bool DigitalPort1 { get; set; }
/// <summary>Can deliver a composite audio and video data stream</summary>
public bool Composite { get; set; }
/// <summary>This bit controls the behavior of the LOAD/UNLOAD command when trying to load a Slot with no Disc present</summary>
public bool SSS { get; set; }
/// <summary>Contains a changer that can report the exact contents of the slots</summary>
public bool SDP { get; set; }
/// <summary>Page length</summary>
public byte Length { get; set; }
/// <summary>Set if LSB comes first</summary>
public bool LSBF { get; set; }
/// <summary>Set if HIGH on LRCK indicates left channel. Clear if HIGH on LRCK indicates right channel.</summary>
public bool RCK { get; set; }
/// <summary>
/// CD-ROM capabilities page Page code 0x2A 16 bytes in OB-U0077C 20 bytes in SFF-8020i 22 bytes in MMC-1 26 bytes
/// in MMC-2 Variable bytes in MMC-3
/// Set if data valid on the falling edge of the BCK signal. Clear if data valid on the rising edge of the BCK
/// signal
/// </summary>
[SuppressMessage("ReSharper", "InconsistentNaming"), SuppressMessage("ReSharper", "MemberCanBeInternal"),
SuppressMessage("ReSharper", "MemberCanBePrivate.Global"), SuppressMessage("ReSharper", "NotAccessedField.Global")]
public class ModePage_2A
public bool BCK { get; set; }
/// <summary>Can do a test write</summary>
public bool TestWrite { get; set; }
/// <summary>Maximum write speed</summary>
public ushort MaxWriteSpeed { get; set; }
/// <summary>Current write speed</summary>
public ushort CurrentWriteSpeed { get; set; }
/// <summary>Can read disc's barcode</summary>
public bool ReadBarcode { get; set; }
/// <summary>Can read DVD-RAM</summary>
public bool ReadDVDRAM { get; set; }
/// <summary>Can read DVD-R</summary>
public bool ReadDVDR { get; set; }
/// <summary>Can read DVD-ROM</summary>
public bool ReadDVDROM { get; set; }
/// <summary>Can write DVD-RAM</summary>
public bool WriteDVDRAM { get; set; }
/// <summary>Can write DVD-R</summary>
public bool WriteDVDR { get; set; }
/// <summary>Can read raw R-W subchannel from the Lead-In</summary>
public bool LeadInPW { get; set; }
/// <summary>Can read both sides of a disc</summary>
public bool SCC { get; set; }
/// <summary>Support copyright management</summary>
public ushort CMRSupported { get; set; }
/// <summary>Supports buffer under-run free recording</summary>
public bool BUF { get; set; }
/// <summary>Selected rotational control</summary>
public byte RotationControlSelected { get; set; }
/// <summary>Current write speed selected</summary>
public ushort CurrentWriteSpeedSelected { get; set; }
/// <summary>Database ID</summary>
[JsonIgnore, Key]
public int Id { get; set; }
/// <summary>Decodes the page 2Ah of a MODE SENSE response</summary>
/// <param name="pageResponse">Raw page 2Ah</param>
/// <returns>Decoded page 2Ah</returns>
public static ModePage_2A Decode(byte[] pageResponse)
{
/// <summary>Write speed performance descriptors</summary>
public ModePage_2A_WriteDescriptor[] WriteSpeedPerformanceDescriptors;
/// <summary>Parameters can be saved</summary>
public bool PS { get; set; }
/// <summary>Drive supports multi-session and/or Photo-CD</summary>
public bool MultiSession { get; set; }
/// <summary>Drive is capable of reading sectors in Mode 2 Form 2 format</summary>
public bool Mode2Form2 { get; set; }
/// <summary>Drive is capable of reading sectors in Mode 2 Form 1 format</summary>
public bool Mode2Form1 { get; set; }
/// <summary>Drive is capable of playing audio</summary>
public bool AudioPlay { get; set; }
/// <summary>Drive can return the ISRC</summary>
public bool ISRC { get; set; }
/// <summary>Drive can return the media catalogue number</summary>
public bool UPC { get; set; }
/// <summary>Drive can return C2 pointers</summary>
public bool C2Pointer { get; set; }
/// <summary>Drive can read, deinterlave and correct R-W subchannels</summary>
public bool DeinterlaveSubchannel { get; set; }
/// <summary>Drive can read interleaved and uncorrected R-W subchannels</summary>
public bool Subchannel { get; set; }
/// <summary>Drive can continue from a loss of streaming on audio reading</summary>
public bool AccurateCDDA { get; set; }
/// <summary>Audio can be read as digital data</summary>
public bool CDDACommand { get; set; }
/// <summary>Loading Mechanism Type</summary>
public byte LoadingMechanism { get; set; }
/// <summary>Drive can eject discs</summary>
public bool Eject { get; set; }
/// <summary>Drive's optional prevent jumper status</summary>
public bool PreventJumper { get; set; }
/// <summary>Current lock status</summary>
public bool LockState { get; set; }
/// <summary>Drive can lock media</summary>
public bool Lock { get; set; }
/// <summary>Each channel can be muted independently</summary>
public bool SeparateChannelMute { get; set; }
/// <summary>Each channel's volume can be controlled independently</summary>
public bool SeparateChannelVolume { get; set; }
/// <summary>Maximum drive speed in Kbytes/second</summary>
public ushort MaximumSpeed { get; set; }
/// <summary>Supported volume levels</summary>
public ushort SupportedVolumeLevels { get; set; }
/// <summary>Buffer size in Kbytes</summary>
public ushort BufferSize { get; set; }
/// <summary>Current drive speed in Kbytes/second</summary>
public ushort CurrentSpeed { get; set; }
if((pageResponse?[0] & 0x40) == 0x40)
return null;
/// <summary>Can read packet media</summary>
public bool Method2 { get; set; }
/// <summary>Can read CD-RW</summary>
public bool ReadCDRW { get; set; }
/// <summary>Can read CD-R</summary>
public bool ReadCDR { get; set; }
/// <summary>Can write CD-RW</summary>
public bool WriteCDRW { get; set; }
/// <summary>Can write CD-R</summary>
public bool WriteCDR { get; set; }
/// <summary>Supports IEC-958 digital output on port 2</summary>
public bool DigitalPort2 { get; set; }
/// <summary>Supports IEC-958 digital output on port 1</summary>
public bool DigitalPort1 { get; set; }
/// <summary>Can deliver a composite audio and video data stream</summary>
public bool Composite { get; set; }
/// <summary>This bit controls the behavior of the LOAD/UNLOAD command when trying to load a Slot with no Disc present</summary>
public bool SSS { get; set; }
/// <summary>Contains a changer that can report the exact contents of the slots</summary>
public bool SDP { get; set; }
/// <summary>Page length</summary>
public byte Length { get; set; }
/// <summary>Set if LSB comes first</summary>
public bool LSBF { get; set; }
/// <summary>Set if HIGH on LRCK indicates left channel. Clear if HIGH on LRCK indicates right channel.</summary>
public bool RCK { get; set; }
/// <summary>
/// Set if data valid on the falling edge of the BCK signal. Clear if data valid on the rising edge of the BCK
/// signal
/// </summary>
public bool BCK { get; set; }
if((pageResponse?[0] & 0x3F) != 0x2A)
return null;
/// <summary>Can do a test write</summary>
public bool TestWrite { get; set; }
/// <summary>Maximum write speed</summary>
public ushort MaxWriteSpeed { get; set; }
/// <summary>Current write speed</summary>
public ushort CurrentWriteSpeed { get; set; }
/// <summary>Can read disc's barcode</summary>
public bool ReadBarcode { get; set; }
/// <summary>Can read DVD-RAM</summary>
public bool ReadDVDRAM { get; set; }
/// <summary>Can read DVD-R</summary>
public bool ReadDVDR { get; set; }
/// <summary>Can read DVD-ROM</summary>
public bool ReadDVDROM { get; set; }
/// <summary>Can write DVD-RAM</summary>
public bool WriteDVDRAM { get; set; }
/// <summary>Can write DVD-R</summary>
public bool WriteDVDR { get; set; }
/// <summary>Can read raw R-W subchannel from the Lead-In</summary>
public bool LeadInPW { get; set; }
/// <summary>Can read both sides of a disc</summary>
public bool SCC { get; set; }
/// <summary>Support copyright management</summary>
public ushort CMRSupported { get; set; }
/// <summary>Supports buffer under-run free recording</summary>
public bool BUF { get; set; }
/// <summary>Selected rotational control</summary>
public byte RotationControlSelected { get; set; }
/// <summary>Current write speed selected</summary>
public ushort CurrentWriteSpeedSelected { get; set; }
if(pageResponse[1] + 2 != pageResponse.Length)
return null;
/// <summary>Database ID</summary>
[JsonIgnore, Key]
public int Id { get; set; }
if(pageResponse.Length < 16)
return null;
/// <summary>Decodes the page 2Ah of a MODE SENSE response</summary>
/// <param name="pageResponse">Raw page 2Ah</param>
/// <returns>Decoded page 2Ah</returns>
public static ModePage_2A Decode(byte[] pageResponse)
{
if((pageResponse?[0] & 0x40) == 0x40)
return null;
var decoded = new ModePage_2A();
if((pageResponse?[0] & 0x3F) != 0x2A)
return null;
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
if(pageResponse[1] + 2 != pageResponse.Length)
return null;
decoded.AudioPlay |= (pageResponse[4] & 0x01) == 0x01;
decoded.Mode2Form1 |= (pageResponse[4] & 0x10) == 0x10;
decoded.Mode2Form2 |= (pageResponse[4] & 0x20) == 0x20;
decoded.MultiSession |= (pageResponse[4] & 0x40) == 0x40;
if(pageResponse.Length < 16)
return null;
decoded.CDDACommand |= (pageResponse[5] & 0x01) == 0x01;
decoded.AccurateCDDA |= (pageResponse[5] & 0x02) == 0x02;
decoded.Subchannel |= (pageResponse[5] & 0x04) == 0x04;
decoded.DeinterlaveSubchannel |= (pageResponse[5] & 0x08) == 0x08;
decoded.C2Pointer |= (pageResponse[5] & 0x10) == 0x10;
decoded.UPC |= (pageResponse[5] & 0x20) == 0x20;
decoded.ISRC |= (pageResponse[5] & 0x40) == 0x40;
var decoded = new ModePage_2A();
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
decoded.Lock |= (pageResponse[6] & 0x01) == 0x01;
decoded.LockState |= (pageResponse[6] & 0x02) == 0x02;
decoded.PreventJumper |= (pageResponse[6] & 0x04) == 0x04;
decoded.Eject |= (pageResponse[6] & 0x08) == 0x08;
decoded.PS |= (pageResponse[0] & 0x80) == 0x80;
decoded.SeparateChannelVolume |= (pageResponse[7] & 0x01) == 0x01;
decoded.SeparateChannelMute |= (pageResponse[7] & 0x02) == 0x02;
decoded.AudioPlay |= (pageResponse[4] & 0x01) == 0x01;
decoded.Mode2Form1 |= (pageResponse[4] & 0x10) == 0x10;
decoded.Mode2Form2 |= (pageResponse[4] & 0x20) == 0x20;
decoded.MultiSession |= (pageResponse[4] & 0x40) == 0x40;
decoded.CDDACommand |= (pageResponse[5] & 0x01) == 0x01;
decoded.AccurateCDDA |= (pageResponse[5] & 0x02) == 0x02;
decoded.Subchannel |= (pageResponse[5] & 0x04) == 0x04;
decoded.DeinterlaveSubchannel |= (pageResponse[5] & 0x08) == 0x08;
decoded.C2Pointer |= (pageResponse[5] & 0x10) == 0x10;
decoded.UPC |= (pageResponse[5] & 0x20) == 0x20;
decoded.ISRC |= (pageResponse[5] & 0x40) == 0x40;
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
decoded.Lock |= (pageResponse[6] & 0x01) == 0x01;
decoded.LockState |= (pageResponse[6] & 0x02) == 0x02;
decoded.PreventJumper |= (pageResponse[6] & 0x04) == 0x04;
decoded.Eject |= (pageResponse[6] & 0x08) == 0x08;
decoded.SeparateChannelVolume |= (pageResponse[7] & 0x01) == 0x01;
decoded.SeparateChannelMute |= (pageResponse[7] & 0x02) == 0x02;
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
if(pageResponse.Length < 20)
return decoded;
decoded.Method2 |= (pageResponse[2] & 0x04) == 0x04;
decoded.ReadCDRW |= (pageResponse[2] & 0x02) == 0x02;
decoded.ReadCDR |= (pageResponse[2] & 0x01) == 0x01;
decoded.WriteCDRW |= (pageResponse[3] & 0x02) == 0x02;
decoded.WriteCDR |= (pageResponse[3] & 0x01) == 0x01;
decoded.Composite |= (pageResponse[4] & 0x02) == 0x02;
decoded.DigitalPort1 |= (pageResponse[4] & 0x04) == 0x04;
decoded.DigitalPort2 |= (pageResponse[4] & 0x08) == 0x08;
decoded.SDP |= (pageResponse[7] & 0x04) == 0x04;
decoded.SSS |= (pageResponse[7] & 0x08) == 0x08;
decoded.Length = (byte)((pageResponse[17] & 0x30) >> 4);
decoded.LSBF |= (pageResponse[17] & 0x08) == 0x08;
decoded.RCK |= (pageResponse[17] & 0x04) == 0x04;
decoded.BCK |= (pageResponse[17] & 0x02) == 0x02;
if(pageResponse.Length < 22)
return decoded;
decoded.TestWrite |= (pageResponse[3] & 0x04) == 0x04;
decoded.MaxWriteSpeed = (ushort)((pageResponse[18] << 8) + pageResponse[19]);
decoded.CurrentWriteSpeed = (ushort)((pageResponse[20] << 8) + pageResponse[21]);
decoded.ReadBarcode |= (pageResponse[5] & 0x80) == 0x80;
if(pageResponse.Length < 26)
return decoded;
decoded.ReadDVDRAM |= (pageResponse[2] & 0x20) == 0x20;
decoded.ReadDVDR |= (pageResponse[2] & 0x10) == 0x10;
decoded.ReadDVDROM |= (pageResponse[2] & 0x08) == 0x08;
decoded.WriteDVDRAM |= (pageResponse[3] & 0x20) == 0x20;
decoded.WriteDVDR |= (pageResponse[3] & 0x10) == 0x10;
decoded.LeadInPW |= (pageResponse[3] & 0x20) == 0x20;
decoded.SCC |= (pageResponse[3] & 0x10) == 0x10;
decoded.CMRSupported = (ushort)((pageResponse[22] << 8) + pageResponse[23]);
if(pageResponse.Length < 32)
return decoded;
decoded.BUF |= (pageResponse[4] & 0x80) == 0x80;
decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03);
decoded.CurrentWriteSpeedSelected = (ushort)((pageResponse[28] << 8) + pageResponse[29]);
ushort descriptors = (ushort)((pageResponse.Length - 32) / 4);
decoded.WriteSpeedPerformanceDescriptors = new ModePage_2A_WriteDescriptor[descriptors];
for(int i = 0; i < descriptors; i++)
decoded.WriteSpeedPerformanceDescriptors[i] = new ModePage_2A_WriteDescriptor
{
RotationControl = (byte)(pageResponse[1 + 32 + (i * 4)] & 0x07),
WriteSpeed = (ushort)((pageResponse[2 + 32 + (i * 4)] << 8) + pageResponse[3 + 32 + (i * 4)])
};
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
if(pageResponse.Length < 20)
return decoded;
}
/// <summary>Encodes a page 2Ah of a MODE SENSE response</summary>
/// <param name="decoded">Decoded page 2Ah</param>
/// <returns>Raw page 2Ah</returns>
public static byte[] Encode(ModePage_2A decoded)
{
byte[] pageResponse = new byte[512];
byte length = 16;
decoded.Method2 |= (pageResponse[2] & 0x04) == 0x04;
decoded.ReadCDRW |= (pageResponse[2] & 0x02) == 0x02;
decoded.ReadCDR |= (pageResponse[2] & 0x01) == 0x01;
pageResponse[0] = 0x2A;
decoded.WriteCDRW |= (pageResponse[3] & 0x02) == 0x02;
decoded.WriteCDR |= (pageResponse[3] & 0x01) == 0x01;
if(decoded.PS)
pageResponse[0] += 0x80;
decoded.Composite |= (pageResponse[4] & 0x02) == 0x02;
decoded.DigitalPort1 |= (pageResponse[4] & 0x04) == 0x04;
decoded.DigitalPort2 |= (pageResponse[4] & 0x08) == 0x08;
if(decoded.AudioPlay)
pageResponse[4] += 0x01;
decoded.SDP |= (pageResponse[7] & 0x04) == 0x04;
decoded.SSS |= (pageResponse[7] & 0x08) == 0x08;
if(decoded.Mode2Form1)
pageResponse[4] += 0x10;
decoded.Length = (byte)((pageResponse[17] & 0x30) >> 4);
decoded.LSBF |= (pageResponse[17] & 0x08) == 0x08;
decoded.RCK |= (pageResponse[17] & 0x04) == 0x04;
decoded.BCK |= (pageResponse[17] & 0x02) == 0x02;
if(decoded.Mode2Form2)
pageResponse[4] += 0x20;
if(pageResponse.Length < 22)
return decoded;
if(decoded.MultiSession)
pageResponse[4] += 0x40;
decoded.TestWrite |= (pageResponse[3] & 0x04) == 0x04;
decoded.MaxWriteSpeed = (ushort)((pageResponse[18] << 8) + pageResponse[19]);
decoded.CurrentWriteSpeed = (ushort)((pageResponse[20] << 8) + pageResponse[21]);
if(decoded.CDDACommand)
pageResponse[5] += 0x01;
decoded.ReadBarcode |= (pageResponse[5] & 0x80) == 0x80;
if(decoded.AccurateCDDA)
pageResponse[5] += 0x02;
if(pageResponse.Length < 26)
return decoded;
if(decoded.Subchannel)
pageResponse[5] += 0x04;
decoded.ReadDVDRAM |= (pageResponse[2] & 0x20) == 0x20;
decoded.ReadDVDR |= (pageResponse[2] & 0x10) == 0x10;
decoded.ReadDVDROM |= (pageResponse[2] & 0x08) == 0x08;
if(decoded.DeinterlaveSubchannel)
pageResponse[5] += 0x08;
decoded.WriteDVDRAM |= (pageResponse[3] & 0x20) == 0x20;
decoded.WriteDVDR |= (pageResponse[3] & 0x10) == 0x10;
if(decoded.C2Pointer)
pageResponse[5] += 0x10;
decoded.LeadInPW |= (pageResponse[3] & 0x20) == 0x20;
decoded.SCC |= (pageResponse[3] & 0x10) == 0x10;
if(decoded.UPC)
pageResponse[5] += 0x20;
decoded.CMRSupported = (ushort)((pageResponse[22] << 8) + pageResponse[23]);
if(decoded.ISRC)
pageResponse[5] += 0x40;
if(pageResponse.Length < 32)
return decoded;
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
decoded.BUF |= (pageResponse[4] & 0x80) == 0x80;
decoded.RotationControlSelected = (byte)(pageResponse[27] & 0x03);
decoded.CurrentWriteSpeedSelected = (ushort)((pageResponse[28] << 8) + pageResponse[29]);
if(decoded.Lock)
pageResponse[6] += 0x01;
ushort descriptors = (ushort)((pageResponse.Length - 32) / 4);
decoded.WriteSpeedPerformanceDescriptors = new ModePage_2A_WriteDescriptor[descriptors];
if(decoded.LockState)
pageResponse[6] += 0x02;
if(decoded.PreventJumper)
pageResponse[6] += 0x04;
if(decoded.Eject)
pageResponse[6] += 0x08;
if(decoded.SeparateChannelVolume)
pageResponse[7] += 0x01;
if(decoded.SeparateChannelMute)
pageResponse[7] += 0x02;
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
if(decoded.Method2 ||
decoded.ReadCDRW ||
decoded.ReadCDR ||
decoded.WriteCDRW ||
decoded.WriteCDR ||
decoded.Composite ||
decoded.DigitalPort1 ||
decoded.DigitalPort2 ||
decoded.SDP ||
decoded.SSS ||
decoded.Length > 0 ||
decoded.LSBF ||
decoded.RCK ||
decoded.BCK)
for(int i = 0; i < descriptors; i++)
decoded.WriteSpeedPerformanceDescriptors[i] = new ModePage_2A_WriteDescriptor
{
length = 20;
RotationControl = (byte)(pageResponse[1 + 32 + (i * 4)] & 0x07),
WriteSpeed = (ushort)((pageResponse[2 + 32 + (i * 4)] << 8) + pageResponse[3 + 32 + (i * 4)])
};
if(decoded.Method2)
pageResponse[2] += 0x04;
if(decoded.ReadCDRW)
pageResponse[2] += 0x02;
if(decoded.ReadCDR)
pageResponse[2] += 0x01;
if(decoded.WriteCDRW)
pageResponse[3] += 0x02;
if(decoded.WriteCDR)
pageResponse[3] += 0x01;
if(decoded.Composite)
pageResponse[4] += 0x02;
if(decoded.DigitalPort1)
pageResponse[4] += 0x04;
if(decoded.DigitalPort2)
pageResponse[4] += 0x08;
if(decoded.SDP)
pageResponse[7] += 0x04;
if(decoded.SSS)
pageResponse[7] += 0x08;
pageResponse[17] = (byte)(decoded.Length << 4);
if(decoded.LSBF)
pageResponse[17] += 0x08;
if(decoded.RCK)
pageResponse[17] += 0x04;
if(decoded.BCK)
pageResponse[17] += 0x02;
}
if(decoded.TestWrite ||
decoded.MaxWriteSpeed > 0 ||
decoded.CurrentWriteSpeed > 0 ||
decoded.ReadBarcode)
{
length = 22;
if(decoded.TestWrite)
pageResponse[3] += 0x04;
pageResponse[18] = (byte)((decoded.MaxWriteSpeed & 0xFF00) >> 8);
pageResponse[19] = (byte)(decoded.MaxWriteSpeed & 0xFF);
pageResponse[20] = (byte)((decoded.CurrentWriteSpeed & 0xFF00) >> 8);
pageResponse[21] = (byte)(decoded.CurrentWriteSpeed & 0xFF);
if(decoded.ReadBarcode)
pageResponse[5] += 0x80;
}
if(decoded.ReadDVDRAM ||
decoded.ReadDVDR ||
decoded.ReadDVDROM ||
decoded.WriteDVDRAM ||
decoded.WriteDVDR ||
decoded.LeadInPW ||
decoded.SCC ||
decoded.CMRSupported > 0)
{
length = 26;
if(decoded.ReadDVDRAM)
pageResponse[2] += 0x20;
if(decoded.ReadDVDR)
pageResponse[2] += 0x10;
if(decoded.ReadDVDROM)
pageResponse[2] += 0x08;
if(decoded.WriteDVDRAM)
pageResponse[3] += 0x20;
if(decoded.WriteDVDR)
pageResponse[3] += 0x10;
if(decoded.LeadInPW)
pageResponse[3] += 0x20;
if(decoded.SCC)
pageResponse[3] += 0x10;
pageResponse[22] = (byte)((decoded.CMRSupported & 0xFF00) >> 8);
pageResponse[23] = (byte)(decoded.CMRSupported & 0xFF);
}
if(decoded.BUF ||
decoded.RotationControlSelected > 0 ||
decoded.CurrentWriteSpeedSelected > 0)
{
length = 32;
if(decoded.BUF)
pageResponse[4] += 0x80;
pageResponse[27] += decoded.RotationControlSelected;
pageResponse[28] = (byte)((decoded.CurrentWriteSpeedSelected & 0xFF00) >> 8);
pageResponse[29] = (byte)(decoded.CurrentWriteSpeedSelected & 0xFF);
}
if(decoded.WriteSpeedPerformanceDescriptors != null)
{
length = 32;
for(int i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
{
length += 4;
pageResponse[1 + 32 + (i * 4)] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
pageResponse[2 + 32 + (i * 4)] =
(byte)((decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF00) >> 8);
pageResponse[3 + 32 + (i * 4)] =
(byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
}
}
pageResponse[1] = (byte)(length - 2);
byte[] buf = new byte[length];
Array.Copy(pageResponse, 0, buf, 0, length);
return buf;
}
return decoded;
}
/// <summary>Page 2Ah write descriptor</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public struct ModePage_2A_WriteDescriptor
/// <summary>Encodes a page 2Ah of a MODE SENSE response</summary>
/// <param name="decoded">Decoded page 2Ah</param>
/// <returns>Raw page 2Ah</returns>
public static byte[] Encode(ModePage_2A decoded)
{
/// <summary>Rotational control</summary>
public byte RotationControl;
/// <summary>Write speed</summary>
public ushort WriteSpeed;
byte[] pageResponse = new byte[512];
byte length = 16;
pageResponse[0] = 0x2A;
if(decoded.PS)
pageResponse[0] += 0x80;
if(decoded.AudioPlay)
pageResponse[4] += 0x01;
if(decoded.Mode2Form1)
pageResponse[4] += 0x10;
if(decoded.Mode2Form2)
pageResponse[4] += 0x20;
if(decoded.MultiSession)
pageResponse[4] += 0x40;
if(decoded.CDDACommand)
pageResponse[5] += 0x01;
if(decoded.AccurateCDDA)
pageResponse[5] += 0x02;
if(decoded.Subchannel)
pageResponse[5] += 0x04;
if(decoded.DeinterlaveSubchannel)
pageResponse[5] += 0x08;
if(decoded.C2Pointer)
pageResponse[5] += 0x10;
if(decoded.UPC)
pageResponse[5] += 0x20;
if(decoded.ISRC)
pageResponse[5] += 0x40;
decoded.LoadingMechanism = (byte)((pageResponse[6] & 0xE0) >> 5);
if(decoded.Lock)
pageResponse[6] += 0x01;
if(decoded.LockState)
pageResponse[6] += 0x02;
if(decoded.PreventJumper)
pageResponse[6] += 0x04;
if(decoded.Eject)
pageResponse[6] += 0x08;
if(decoded.SeparateChannelVolume)
pageResponse[7] += 0x01;
if(decoded.SeparateChannelMute)
pageResponse[7] += 0x02;
decoded.MaximumSpeed = (ushort)((pageResponse[8] << 8) + pageResponse[9]);
decoded.SupportedVolumeLevels = (ushort)((pageResponse[10] << 8) + pageResponse[11]);
decoded.BufferSize = (ushort)((pageResponse[12] << 8) + pageResponse[13]);
decoded.CurrentSpeed = (ushort)((pageResponse[14] << 8) + pageResponse[15]);
if(decoded.Method2 ||
decoded.ReadCDRW ||
decoded.ReadCDR ||
decoded.WriteCDRW ||
decoded.WriteCDR ||
decoded.Composite ||
decoded.DigitalPort1 ||
decoded.DigitalPort2 ||
decoded.SDP ||
decoded.SSS ||
decoded.Length > 0 ||
decoded.LSBF ||
decoded.RCK ||
decoded.BCK)
{
length = 20;
if(decoded.Method2)
pageResponse[2] += 0x04;
if(decoded.ReadCDRW)
pageResponse[2] += 0x02;
if(decoded.ReadCDR)
pageResponse[2] += 0x01;
if(decoded.WriteCDRW)
pageResponse[3] += 0x02;
if(decoded.WriteCDR)
pageResponse[3] += 0x01;
if(decoded.Composite)
pageResponse[4] += 0x02;
if(decoded.DigitalPort1)
pageResponse[4] += 0x04;
if(decoded.DigitalPort2)
pageResponse[4] += 0x08;
if(decoded.SDP)
pageResponse[7] += 0x04;
if(decoded.SSS)
pageResponse[7] += 0x08;
pageResponse[17] = (byte)(decoded.Length << 4);
if(decoded.LSBF)
pageResponse[17] += 0x08;
if(decoded.RCK)
pageResponse[17] += 0x04;
if(decoded.BCK)
pageResponse[17] += 0x02;
}
if(decoded.TestWrite ||
decoded.MaxWriteSpeed > 0 ||
decoded.CurrentWriteSpeed > 0 ||
decoded.ReadBarcode)
{
length = 22;
if(decoded.TestWrite)
pageResponse[3] += 0x04;
pageResponse[18] = (byte)((decoded.MaxWriteSpeed & 0xFF00) >> 8);
pageResponse[19] = (byte)(decoded.MaxWriteSpeed & 0xFF);
pageResponse[20] = (byte)((decoded.CurrentWriteSpeed & 0xFF00) >> 8);
pageResponse[21] = (byte)(decoded.CurrentWriteSpeed & 0xFF);
if(decoded.ReadBarcode)
pageResponse[5] += 0x80;
}
if(decoded.ReadDVDRAM ||
decoded.ReadDVDR ||
decoded.ReadDVDROM ||
decoded.WriteDVDRAM ||
decoded.WriteDVDR ||
decoded.LeadInPW ||
decoded.SCC ||
decoded.CMRSupported > 0)
{
length = 26;
if(decoded.ReadDVDRAM)
pageResponse[2] += 0x20;
if(decoded.ReadDVDR)
pageResponse[2] += 0x10;
if(decoded.ReadDVDROM)
pageResponse[2] += 0x08;
if(decoded.WriteDVDRAM)
pageResponse[3] += 0x20;
if(decoded.WriteDVDR)
pageResponse[3] += 0x10;
if(decoded.LeadInPW)
pageResponse[3] += 0x20;
if(decoded.SCC)
pageResponse[3] += 0x10;
pageResponse[22] = (byte)((decoded.CMRSupported & 0xFF00) >> 8);
pageResponse[23] = (byte)(decoded.CMRSupported & 0xFF);
}
if(decoded.BUF ||
decoded.RotationControlSelected > 0 ||
decoded.CurrentWriteSpeedSelected > 0)
{
length = 32;
if(decoded.BUF)
pageResponse[4] += 0x80;
pageResponse[27] += decoded.RotationControlSelected;
pageResponse[28] = (byte)((decoded.CurrentWriteSpeedSelected & 0xFF00) >> 8);
pageResponse[29] = (byte)(decoded.CurrentWriteSpeedSelected & 0xFF);
}
if(decoded.WriteSpeedPerformanceDescriptors != null)
{
length = 32;
for(int i = 0; i < decoded.WriteSpeedPerformanceDescriptors.Length; i++)
{
length += 4;
pageResponse[1 + 32 + (i * 4)] = decoded.WriteSpeedPerformanceDescriptors[i].RotationControl;
pageResponse[2 + 32 + (i * 4)] =
(byte)((decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF00) >> 8);
pageResponse[3 + 32 + (i * 4)] =
(byte)(decoded.WriteSpeedPerformanceDescriptors[i].WriteSpeed & 0xFF);
}
}
pageResponse[1] = (byte)(length - 2);
byte[] buf = new byte[length];
Array.Copy(pageResponse, 0, buf, 0, length);
return buf;
}
#endregion Mode Page 0x2A: CD-ROM capabilities page
}
}
/// <summary>Page 2Ah write descriptor</summary>
[SuppressMessage("ReSharper", "InconsistentNaming")]
public struct ModePage_2A_WriteDescriptor
{
/// <summary>Rotational control</summary>
public byte RotationControl;
/// <summary>Write speed</summary>
public ushort WriteSpeed;
}
#endregion Mode Page 0x2A: CD-ROM capabilities page

View File

@@ -41,241 +41,240 @@ using System;
using System.Runtime.InteropServices;
using Newtonsoft.Json;
namespace Aaru.CommonTypes.Structs
namespace Aaru.CommonTypes.Structs;
/// <summary>File attributes.</summary>
[Flags]
public enum FileAttributes : ulong
{
/// <summary>File attributes.</summary>
[Flags]
public enum FileAttributes : ulong
/// <summary>File has no attributes</summary>
None = 0,
/// <summary>File is an alias (Mac OS)</summary>
Alias = 0x01,
/// <summary>Indicates that the file can only be writable appended</summary>
AppendOnly = 0x02,
/// <summary>File is candidate for archival/backup</summary>
Archive = 0x04,
/// <summary>File is a block device</summary>
BlockDevice = 0x08,
/// <summary>File is stored on filesystem block units instead of device sectors</summary>
BlockUnits = 0x10,
/// <summary>Directory is a bundle or file contains a BNDL resource</summary>
Bundle = 0x20,
/// <summary>File is a char device</summary>
CharDevice = 0x40,
/// <summary>File is compressed</summary>
Compressed = 0x80,
/// <summary>File is compressed and should not be uncompressed on read</summary>
CompressedRaw = 0x100,
/// <summary>File has compression errors</summary>
CompressionError = 0x200,
/// <summary>Compressed file is dirty</summary>
CompressionDirty = 0x400,
/// <summary>File is a device</summary>
Device = 0x800,
/// <summary>File is a directory</summary>
Directory = 0x1000,
/// <summary>File is encrypted</summary>
Encrypted = 0x2000,
/// <summary>File is stored on disk using extents</summary>
Extents = 0x4000,
/// <summary>File is a FIFO</summary>
FIFO = 0x8000,
/// <summary>File is a normal file</summary>
File = 0x10000,
/// <summary>File is a Mac OS file containing desktop databases that has already been added to the desktop database</summary>
HasBeenInited = 0x20000,
/// <summary>File contains an icon resource / EA</summary>
HasCustomIcon = 0x40000,
/// <summary>File is a Mac OS extension or control panel lacking INIT resources</summary>
HasNoINITs = 0x80000,
/// <summary>File is hidden/invisible</summary>
Hidden = 0x100000,
/// <summary>File cannot be written, deleted, modified or linked to</summary>
Immutable = 0x200000,
/// <summary>Directory is indexed using hashed trees</summary>
IndexedDirectory = 0x400000,
/// <summary>File contents are stored alongside its inode (or equivalent)</summary>
Inline = 0x800000,
/// <summary>File contains integrity checks</summary>
IntegrityStream = 0x1000000,
/// <summary>File is on desktop</summary>
IsOnDesk = 0x2000000,
/// <summary>File changes are written to filesystem journal before being written to file itself</summary>
Journaled = 0x4000000,
/// <summary>Access time will not be modified</summary>
NoAccessTime = 0x8000000,
/// <summary>File will not be subject to copy-on-write</summary>
NoCopyOnWrite = 0x10000000,
/// <summary>File will not be backed up</summary>
NoDump = 0x20000000,
/// <summary>File contents should not be scrubbed</summary>
NoScrub = 0x40000000,
/// <summary>File contents should not be indexed</summary>
NotIndexed = 0x80000000,
/// <summary>File is offline</summary>
Offline = 0x100000000,
/// <summary>File is password protected, but contents are not encrypted on disk</summary>
Password = 0x200000000,
/// <summary>File is read-only</summary>
ReadOnly = 0x400000000,
/// <summary>File is a reparse point</summary>
ReparsePoint = 0x800000000,
/// <summary>When file is removed its content will be overwritten with zeroes</summary>
Secured = 0x1000000000,
/// <summary>File contents are sparse</summary>
Sparse = 0x2000000000,
/// <summary>File is a shadow (OS/2)</summary>
Shadow = 0x4000000000,
/// <summary>File is shared</summary>
Shared = 0x8000000000,
/// <summary>File is a stationery</summary>
Stationery = 0x10000000000,
/// <summary>File is a symbolic link</summary>
Symlink = 0x20000000000,
/// <summary>File writes are synchronously written to disk</summary>
Sync = 0x40000000000,
/// <summary>File belongs to the operating system</summary>
System = 0x80000000000,
/// <summary>If file end is a partial block its content will be merged with other files</summary>
TailMerged = 0x100000000000,
/// <summary>File is temporary</summary>
Temporary = 0x200000000000,
/// <summary>Subdirectories inside of this directory are not related and should be allocated elsewhere</summary>
TopDirectory = 0x400000000000,
/// <summary>If file is deleted, contents should be stored, for a possible future undeletion</summary>
Undeletable = 0x800000000000,
/// <summary>File is a pipe</summary>
Pipe = 0x1000000000000,
/// <summary>File is a socket</summary>
Socket = 0x2000000000000
}
/// <summary>Information about a file entry</summary>
public class FileEntryInfo
{
/// <summary>File attributes</summary>
public FileAttributes Attributes { get; set; }
/// <summary>File length in blocks</summary>
public long Blocks { get; set; }
/// <summary>File block size in bytes</summary>
public long BlockSize { get; set; }
/// <summary>If file points to a device, device number. Null if the underlying filesystem does not support them.</summary>
public ulong? DeviceNo { get; set; }
/// <summary>POSIX group ID. Null if the underlying filesystem does not support them.</summary>
public ulong? GID { get; set; }
/// <summary>inode number for this file (or other unique identifier for the volume)</summary>
public ulong Inode { get; set; }
/// <summary>File length in bytes</summary>
public long Length { get; set; }
/// <summary>Number of hard links pointing to this file (. and .. entries count as hard links)</summary>
public ulong Links { get; set; }
/// <summary>POSIX permissions/mode for this file. Null if the underlying filesystem does not support them.</summary>
public uint? Mode { get; set; }
/// <summary>POSIX owner ID. Null if the underlying filesystem does not support them.</summary>
public ulong? UID { get; set; }
/// <summary>File creation date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? CreationTimeUtc { get; set; }
/// <summary>File last access date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? AccessTimeUtc { get; set; }
/// <summary>File attributes change date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? StatusChangeTimeUtc { get; set; }
/// <summary>File last backup date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? BackupTimeUtc { get; set; }
/// <summary>File last modification date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? LastWriteTimeUtc { get; set; }
/// <summary>File creation date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? CreationTime
{
/// <summary>File has no attributes</summary>
None = 0,
/// <summary>File is an alias (Mac OS)</summary>
Alias = 0x01,
/// <summary>Indicates that the file can only be writable appended</summary>
AppendOnly = 0x02,
/// <summary>File is candidate for archival/backup</summary>
Archive = 0x04,
/// <summary>File is a block device</summary>
BlockDevice = 0x08,
/// <summary>File is stored on filesystem block units instead of device sectors</summary>
BlockUnits = 0x10,
/// <summary>Directory is a bundle or file contains a BNDL resource</summary>
Bundle = 0x20,
/// <summary>File is a char device</summary>
CharDevice = 0x40,
/// <summary>File is compressed</summary>
Compressed = 0x80,
/// <summary>File is compressed and should not be uncompressed on read</summary>
CompressedRaw = 0x100,
/// <summary>File has compression errors</summary>
CompressionError = 0x200,
/// <summary>Compressed file is dirty</summary>
CompressionDirty = 0x400,
/// <summary>File is a device</summary>
Device = 0x800,
/// <summary>File is a directory</summary>
Directory = 0x1000,
/// <summary>File is encrypted</summary>
Encrypted = 0x2000,
/// <summary>File is stored on disk using extents</summary>
Extents = 0x4000,
/// <summary>File is a FIFO</summary>
FIFO = 0x8000,
/// <summary>File is a normal file</summary>
File = 0x10000,
/// <summary>File is a Mac OS file containing desktop databases that has already been added to the desktop database</summary>
HasBeenInited = 0x20000,
/// <summary>File contains an icon resource / EA</summary>
HasCustomIcon = 0x40000,
/// <summary>File is a Mac OS extension or control panel lacking INIT resources</summary>
HasNoINITs = 0x80000,
/// <summary>File is hidden/invisible</summary>
Hidden = 0x100000,
/// <summary>File cannot be written, deleted, modified or linked to</summary>
Immutable = 0x200000,
/// <summary>Directory is indexed using hashed trees</summary>
IndexedDirectory = 0x400000,
/// <summary>File contents are stored alongside its inode (or equivalent)</summary>
Inline = 0x800000,
/// <summary>File contains integrity checks</summary>
IntegrityStream = 0x1000000,
/// <summary>File is on desktop</summary>
IsOnDesk = 0x2000000,
/// <summary>File changes are written to filesystem journal before being written to file itself</summary>
Journaled = 0x4000000,
/// <summary>Access time will not be modified</summary>
NoAccessTime = 0x8000000,
/// <summary>File will not be subject to copy-on-write</summary>
NoCopyOnWrite = 0x10000000,
/// <summary>File will not be backed up</summary>
NoDump = 0x20000000,
/// <summary>File contents should not be scrubbed</summary>
NoScrub = 0x40000000,
/// <summary>File contents should not be indexed</summary>
NotIndexed = 0x80000000,
/// <summary>File is offline</summary>
Offline = 0x100000000,
/// <summary>File is password protected, but contents are not encrypted on disk</summary>
Password = 0x200000000,
/// <summary>File is read-only</summary>
ReadOnly = 0x400000000,
/// <summary>File is a reparse point</summary>
ReparsePoint = 0x800000000,
/// <summary>When file is removed its content will be overwritten with zeroes</summary>
Secured = 0x1000000000,
/// <summary>File contents are sparse</summary>
Sparse = 0x2000000000,
/// <summary>File is a shadow (OS/2)</summary>
Shadow = 0x4000000000,
/// <summary>File is shared</summary>
Shared = 0x8000000000,
/// <summary>File is a stationery</summary>
Stationery = 0x10000000000,
/// <summary>File is a symbolic link</summary>
Symlink = 0x20000000000,
/// <summary>File writes are synchronously written to disk</summary>
Sync = 0x40000000000,
/// <summary>File belongs to the operating system</summary>
System = 0x80000000000,
/// <summary>If file end is a partial block its content will be merged with other files</summary>
TailMerged = 0x100000000000,
/// <summary>File is temporary</summary>
Temporary = 0x200000000000,
/// <summary>Subdirectories inside of this directory are not related and should be allocated elsewhere</summary>
TopDirectory = 0x400000000000,
/// <summary>If file is deleted, contents should be stored, for a possible future undeletion</summary>
Undeletable = 0x800000000000,
/// <summary>File is a pipe</summary>
Pipe = 0x1000000000000,
/// <summary>File is a socket</summary>
Socket = 0x2000000000000
get => CreationTimeUtc?.ToLocalTime();
set => CreationTimeUtc = value?.ToUniversalTime();
}
/// <summary>Information about a file entry</summary>
public class FileEntryInfo
/// <summary>File last access date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? AccessTime
{
/// <summary>File attributes</summary>
public FileAttributes Attributes { get; set; }
/// <summary>File length in blocks</summary>
public long Blocks { get; set; }
/// <summary>File block size in bytes</summary>
public long BlockSize { get; set; }
/// <summary>If file points to a device, device number. Null if the underlying filesystem does not support them.</summary>
public ulong? DeviceNo { get; set; }
/// <summary>POSIX group ID. Null if the underlying filesystem does not support them.</summary>
public ulong? GID { get; set; }
/// <summary>inode number for this file (or other unique identifier for the volume)</summary>
public ulong Inode { get; set; }
/// <summary>File length in bytes</summary>
public long Length { get; set; }
/// <summary>Number of hard links pointing to this file (. and .. entries count as hard links)</summary>
public ulong Links { get; set; }
/// <summary>POSIX permissions/mode for this file. Null if the underlying filesystem does not support them.</summary>
public uint? Mode { get; set; }
/// <summary>POSIX owner ID. Null if the underlying filesystem does not support them.</summary>
public ulong? UID { get; set; }
/// <summary>File creation date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? CreationTimeUtc { get; set; }
/// <summary>File last access date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? AccessTimeUtc { get; set; }
/// <summary>File attributes change date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? StatusChangeTimeUtc { get; set; }
/// <summary>File last backup date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? BackupTimeUtc { get; set; }
/// <summary>File last modification date in UTC. Null if the underlying filesystem does not support them.</summary>
public DateTime? LastWriteTimeUtc { get; set; }
/// <summary>File creation date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? CreationTime
{
get => CreationTimeUtc?.ToLocalTime();
set => CreationTimeUtc = value?.ToUniversalTime();
}
/// <summary>File last access date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? AccessTime
{
get => AccessTimeUtc?.ToLocalTime();
set => AccessTimeUtc = value?.ToUniversalTime();
}
/// <summary>File attributes change date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? StatusChangeTime
{
get => StatusChangeTimeUtc?.ToLocalTime();
set => StatusChangeTimeUtc = value?.ToUniversalTime();
}
/// <summary>File last backup date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? BackupTime
{
get => BackupTimeUtc?.ToLocalTime();
set => BackupTimeUtc = value?.ToUniversalTime();
}
/// <summary>File last modification date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? LastWriteTime
{
get => LastWriteTimeUtc?.ToLocalTime();
set => LastWriteTimeUtc = value?.ToUniversalTime();
}
get => AccessTimeUtc?.ToLocalTime();
set => AccessTimeUtc = value?.ToUniversalTime();
}
/// <summary>Information about a volume</summary>
public class FileSystemInfo
/// <summary>File attributes change date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? StatusChangeTime
{
/// <summary>Blocks for this filesystem</summary>
public ulong Blocks;
/// <summary>Maximum length of filenames on this filesystem</summary>
public ushort FilenameLength;
/// <summary>Files on this filesystem</summary>
public ulong Files;
/// <summary>Blocks free on this filesystem</summary>
public ulong FreeBlocks;
/// <summary>Free inodes on this filesystem</summary>
public ulong FreeFiles;
/// <summary>Filesystem ID</summary>
public FileSystemId Id;
/// <summary>ID of plugin for this file</summary>
public Guid PluginId;
/// <summary>Filesystem type</summary>
public string Type;
/// <summary>Initializes an empty instance of this structure</summary>
public FileSystemInfo() => Id = new FileSystemId();
/// <summary>Gets a clone of this structure</summary>
/// <returns>Clone of this structure</returns>
public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone();
get => StatusChangeTimeUtc?.ToLocalTime();
set => StatusChangeTimeUtc = value?.ToUniversalTime();
}
/// <summary>Stores a filesystem volume unique identifier or serial number</summary>
[StructLayout(LayoutKind.Explicit)]
public struct FileSystemId
/// <summary>File last backup date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? BackupTime
{
/// <summary>Set to <c>true</c> if the identifier is a 32-bit integer</summary>
[FieldOffset(0)]
public bool IsInt;
/// <summary>Set to <c>true</c> if the identifier is a 64-bit integer</summary>
[FieldOffset(1)]
public bool IsLong;
/// <summary>Set to <c>true</c> if the identifier is a GUID</summary>
[FieldOffset(2)]
public bool IsGuid;
/// <summary>Identifier as a 32-bit integer</summary>
[FieldOffset(3)]
public uint Serial32;
/// <summary>Identifier as a 64-bit integer</summary>
[FieldOffset(3)]
public ulong Serial64;
/// <summary>Identifier as a GUID</summary>
[FieldOffset(3)]
public Guid uuid;
get => BackupTimeUtc?.ToLocalTime();
set => BackupTimeUtc = value?.ToUniversalTime();
}
/// <summary>File last modification date. Null if the underlying filesystem does not support them.</summary>
[JsonIgnore]
public DateTime? LastWriteTime
{
get => LastWriteTimeUtc?.ToLocalTime();
set => LastWriteTimeUtc = value?.ToUniversalTime();
}
}
/// <summary>Information about a volume</summary>
public class FileSystemInfo
{
/// <summary>Blocks for this filesystem</summary>
public ulong Blocks;
/// <summary>Maximum length of filenames on this filesystem</summary>
public ushort FilenameLength;
/// <summary>Files on this filesystem</summary>
public ulong Files;
/// <summary>Blocks free on this filesystem</summary>
public ulong FreeBlocks;
/// <summary>Free inodes on this filesystem</summary>
public ulong FreeFiles;
/// <summary>Filesystem ID</summary>
public FileSystemId Id;
/// <summary>ID of plugin for this file</summary>
public Guid PluginId;
/// <summary>Filesystem type</summary>
public string Type;
/// <summary>Initializes an empty instance of this structure</summary>
public FileSystemInfo() => Id = new FileSystemId();
/// <summary>Gets a clone of this structure</summary>
/// <returns>Clone of this structure</returns>
public FileSystemInfo ShallowCopy() => (FileSystemInfo)MemberwiseClone();
}
/// <summary>Stores a filesystem volume unique identifier or serial number</summary>
[StructLayout(LayoutKind.Explicit)]
public struct FileSystemId
{
/// <summary>Set to <c>true</c> if the identifier is a 32-bit integer</summary>
[FieldOffset(0)]
public bool IsInt;
/// <summary>Set to <c>true</c> if the identifier is a 64-bit integer</summary>
[FieldOffset(1)]
public bool IsLong;
/// <summary>Set to <c>true</c> if the identifier is a GUID</summary>
[FieldOffset(2)]
public bool IsGuid;
/// <summary>Identifier as a 32-bit integer</summary>
[FieldOffset(3)]
public uint Serial32;
/// <summary>Identifier as a 64-bit integer</summary>
[FieldOffset(3)]
public ulong Serial64;
/// <summary>Identifier as a GUID</summary>
[FieldOffset(3)]
public Guid uuid;
}

View File

@@ -36,18 +36,17 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.CommonTypes.Structs
namespace Aaru.CommonTypes.Structs;
/// <summary>Describes a tape file</summary>
public struct TapeFile
{
/// <summary>Describes a tape file</summary>
public struct TapeFile
{
/// <summary>File number</summary>
public uint File;
/// <summary>Partition number</summary>
public byte Partition;
/// <summary>First block, inclusive, of the file</summary>
public ulong FirstBlock;
/// <summary>Last block, inclusive, of the file</summary>
public ulong LastBlock;
}
/// <summary>File number</summary>
public uint File;
/// <summary>Partition number</summary>
public byte Partition;
/// <summary>First block, inclusive, of the file</summary>
public ulong FirstBlock;
/// <summary>Last block, inclusive, of the file</summary>
public ulong LastBlock;
}

View File

@@ -36,16 +36,15 @@
// Copyright © 2011-2022 Natalia Portillo
// ****************************************************************************/
namespace Aaru.CommonTypes.Structs
namespace Aaru.CommonTypes.Structs;
/// <summary>Describes a tape partition</summary>
public struct TapePartition
{
/// <summary>Describes a tape partition</summary>
public struct TapePartition
{
/// <summary>Partition number</summary>
public byte Number;
/// <summary>First block, inclusive, of the partition</summary>
public ulong FirstBlock;
/// <summary>Last block, inclusive, of the partition</summary>
public ulong LastBlock;
}
/// <summary>Partition number</summary>
public byte Number;
/// <summary>First block, inclusive, of the partition</summary>
public ulong FirstBlock;
/// <summary>Last block, inclusive, of the partition</summary>
public ulong LastBlock;
}