mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Redo Reformat and cleanup.
Rider EAP was having a bug interpreting .editorconfig that didn't generate the code style as we wanted. This is now done with Rider-stable.
This commit is contained in:
@@ -63,12 +63,14 @@ public partial class Device
|
||||
|
||||
if((statusRegisters.Status & 0x23) == 0)
|
||||
{
|
||||
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) + (statusRegisters.LbaMidCurrent << 8) +
|
||||
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) +
|
||||
(statusRegisters.LbaMidCurrent << 8) +
|
||||
statusRegisters.LbaLowCurrent);
|
||||
|
||||
lba <<= 24;
|
||||
|
||||
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) + (statusRegisters.LbaMidPrevious << 8) +
|
||||
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) +
|
||||
(statusRegisters.LbaMidPrevious << 8) +
|
||||
statusRegisters.LbaLowPrevious);
|
||||
}
|
||||
|
||||
@@ -246,12 +248,14 @@ public partial class Device
|
||||
|
||||
if((statusRegisters.Status & 0x23) == 0)
|
||||
{
|
||||
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) + (statusRegisters.LbaMidCurrent << 8) +
|
||||
lba = (ulong)((statusRegisters.LbaHighCurrent << 16) +
|
||||
(statusRegisters.LbaMidCurrent << 8) +
|
||||
statusRegisters.LbaLowCurrent);
|
||||
|
||||
lba <<= 24;
|
||||
|
||||
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) + (statusRegisters.LbaMidPrevious << 8) +
|
||||
lba += (ulong)((statusRegisters.LbaHighPrevious << 16) +
|
||||
(statusRegisters.LbaMidPrevious << 8) +
|
||||
statusRegisters.LbaLowPrevious);
|
||||
}
|
||||
|
||||
|
||||
@@ -225,8 +225,7 @@ public partial class Device
|
||||
|
||||
Features.SeparatedFeatures features = Features.Separate(featureBuffer);
|
||||
|
||||
if(features.Descriptors?.Length != 1 ||
|
||||
features.Descriptors[0].Code != 0x0108)
|
||||
if(features.Descriptors?.Length != 1 || features.Descriptors[0].Code != 0x0108)
|
||||
return dev;
|
||||
|
||||
Feature_0108? serialFeature = Features.Decode_0108(features.Descriptors[0].Data);
|
||||
|
||||
@@ -116,8 +116,7 @@ public partial class Device
|
||||
{
|
||||
var aaruUri = new Uri(aaruRemote);
|
||||
|
||||
if(aaruUri.Scheme != "aaru" &&
|
||||
aaruUri.Scheme != "dic")
|
||||
if(aaruUri.Scheme != "aaru" && aaruUri.Scheme != "dic")
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Invalid_remote_URI);
|
||||
|
||||
|
||||
@@ -144,10 +144,7 @@ public partial class Device
|
||||
if(sense)
|
||||
return true;
|
||||
|
||||
if(buffer[0] != 0xA5 ||
|
||||
buffer[1] != 0x5A ||
|
||||
buffer[2] != 0x5A ||
|
||||
buffer[3] != 0xA5)
|
||||
if(buffer[0] != 0xA5 || buffer[1] != 0x5A || buffer[2] != 0x5A || buffer[3] != 0xA5)
|
||||
return true;
|
||||
|
||||
for(var i = 4; i < 26; i += 2)
|
||||
|
||||
@@ -683,11 +683,10 @@ public partial class Device
|
||||
Error = LastError != 0;
|
||||
|
||||
AaruConsole.DebugWriteLine(SCSI_MODULE_NAME,
|
||||
Localization.READ_READ_SUB_CHANNEL_MCN_Sense_1_Last_Error_2_took_0_ms,
|
||||
duration, sense, LastError);
|
||||
Localization.READ_READ_SUB_CHANNEL_MCN_Sense_1_Last_Error_2_took_0_ms, duration,
|
||||
sense, LastError);
|
||||
|
||||
if(!sense &&
|
||||
(buffer[8] & 0x80) == 0x80)
|
||||
if(!sense && (buffer[8] & 0x80) == 0x80)
|
||||
mcn = Encoding.ASCII.GetString(buffer, 9, 13);
|
||||
|
||||
return sense;
|
||||
@@ -729,8 +728,7 @@ public partial class Device
|
||||
READ_READ_SUB_CHANNEL_ISRC_Track_Number_1_Sense_2_Last_Error_3_took_0_ms,
|
||||
duration, trackNumber, sense, LastError);
|
||||
|
||||
if(!sense &&
|
||||
(buffer[8] & 0x80) == 0x80)
|
||||
if(!sense && (buffer[8] & 0x80) == 0x80)
|
||||
isrc = Encoding.ASCII.GetString(buffer, 9, 12);
|
||||
|
||||
return sense;
|
||||
|
||||
@@ -90,8 +90,7 @@ public partial class Device
|
||||
cdb[4] = (byte)((lba & 0xFF00) >> 8);
|
||||
cdb[5] = (byte)(lba & 0xFF);
|
||||
|
||||
if(requested > 0 ||
|
||||
scanLength > 1)
|
||||
if(requested > 0 || scanLength > 1)
|
||||
{
|
||||
buffer = new byte[8];
|
||||
buffer[0] = (byte)((requested & 0xFF000000) >> 24);
|
||||
|
||||
@@ -74,7 +74,10 @@ public partial class Device
|
||||
buffer = new byte[36];
|
||||
senseBuffer = new byte[64];
|
||||
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0 };
|
||||
byte[] cdb =
|
||||
{
|
||||
(byte)ScsiCommands.Inquiry, 0, 0, 0, 36, 0
|
||||
};
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -86,7 +89,10 @@ public partial class Device
|
||||
|
||||
var pagesLength = (byte)(buffer[4] + 5);
|
||||
|
||||
cdb = new byte[] { (byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0 };
|
||||
cdb = new byte[]
|
||||
{
|
||||
(byte)ScsiCommands.Inquiry, 0, 0, 0, pagesLength, 0
|
||||
};
|
||||
|
||||
buffer = new byte[pagesLength];
|
||||
senseBuffer = new byte[64];
|
||||
@@ -145,7 +151,10 @@ public partial class Device
|
||||
buffer = new byte[36];
|
||||
senseBuffer = new byte[64];
|
||||
|
||||
byte[] cdb = { (byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0 };
|
||||
byte[] cdb =
|
||||
{
|
||||
(byte)ScsiCommands.Inquiry, 1, page, 0, 36, 0
|
||||
};
|
||||
|
||||
LastError = SendScsiCommand(cdb, ref buffer, out senseBuffer, timeout, ScsiDirection.In, out duration,
|
||||
out bool sense);
|
||||
@@ -161,7 +170,10 @@ public partial class Device
|
||||
|
||||
var pagesLength = (byte)(buffer[3] + 4);
|
||||
|
||||
cdb = new byte[] { (byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0 };
|
||||
cdb = new byte[]
|
||||
{
|
||||
(byte)ScsiCommands.Inquiry, 1, page, 0, pagesLength, 0
|
||||
};
|
||||
|
||||
buffer = new byte[pagesLength];
|
||||
senseBuffer = new byte[64];
|
||||
@@ -185,7 +197,10 @@ public partial class Device
|
||||
{
|
||||
senseBuffer = new byte[64];
|
||||
|
||||
byte[] cdb = { (byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0 };
|
||||
byte[] cdb =
|
||||
{
|
||||
(byte)ScsiCommands.TestUnitReady, 0, 0, 0, 0, 0
|
||||
};
|
||||
|
||||
byte[] buffer = Array.Empty<byte>();
|
||||
|
||||
|
||||
@@ -376,7 +376,8 @@ public partial class Device
|
||||
/// <param name="duration">Duration.</param>
|
||||
public bool Read16(out byte[] buffer, out byte[] senseBuffer, ulong objectId, uint blocks, uint blockSize,
|
||||
uint timeout, out double duration) => Read16(out buffer, out senseBuffer, false, true, 0,
|
||||
objectId, blocks, blockSize, timeout, out duration);
|
||||
objectId, blocks, blockSize, timeout,
|
||||
out duration);
|
||||
|
||||
/// <summary>Reads a number of fixed-length blocks starting at specified block from the specified partition</summary>
|
||||
/// <param name="buffer">Buffer.</param>
|
||||
|
||||
@@ -91,8 +91,7 @@ public partial class Device
|
||||
if(readLong)
|
||||
cdb[5] += 0x40;
|
||||
|
||||
if(!inhibitDma &&
|
||||
!readLong)
|
||||
if(!inhibitDma && !readLong)
|
||||
buffer = transferLength == 0 ? new byte[256 * blockSize] : new byte[transferLength * blockSize];
|
||||
else if(readLong)
|
||||
{
|
||||
@@ -172,8 +171,7 @@ public partial class Device
|
||||
if(readLong)
|
||||
cdb[9] += 0x40;
|
||||
|
||||
if(!inhibitDma &&
|
||||
!readLong)
|
||||
if(!inhibitDma && !readLong)
|
||||
buffer = new byte[transferLength * blockSize];
|
||||
else if(readLong)
|
||||
{
|
||||
|
||||
@@ -153,8 +153,7 @@ partial class Device
|
||||
cdb[0] = (byte)ScsiCommands.AtaPassThrough16;
|
||||
cdb[1] = (byte)((byte)protocol << 1 & 0x1E);
|
||||
|
||||
if(transferRegister != AtaTransferRegister.NoTransfer &&
|
||||
protocol != AtaProtocol.NonData)
|
||||
if(transferRegister != AtaTransferRegister.NoTransfer && protocol != AtaProtocol.NonData)
|
||||
{
|
||||
switch(protocol)
|
||||
{
|
||||
@@ -188,8 +187,7 @@ partial class Device
|
||||
int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout,
|
||||
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
||||
|
||||
if(senseBuffer.Length < 22 ||
|
||||
senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
|
||||
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
|
||||
return error;
|
||||
|
||||
errorRegisters.Error = senseBuffer[11];
|
||||
@@ -226,8 +224,7 @@ partial class Device
|
||||
cdb[0] = (byte)ScsiCommands.AtaPassThrough16;
|
||||
cdb[1] = (byte)((byte)protocol << 1 & 0x1E);
|
||||
|
||||
if(transferRegister != AtaTransferRegister.NoTransfer &&
|
||||
protocol != AtaProtocol.NonData)
|
||||
if(transferRegister != AtaTransferRegister.NoTransfer && protocol != AtaProtocol.NonData)
|
||||
{
|
||||
switch(protocol)
|
||||
{
|
||||
@@ -261,8 +258,7 @@ partial class Device
|
||||
int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout,
|
||||
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
||||
|
||||
if(senseBuffer.Length < 22 ||
|
||||
senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
|
||||
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
|
||||
return error;
|
||||
|
||||
errorRegisters.Error = senseBuffer[11];
|
||||
@@ -300,8 +296,7 @@ partial class Device
|
||||
cdb[1] = (byte)((byte)protocol << 1 & 0x1E);
|
||||
cdb[1] |= 0x01;
|
||||
|
||||
if(transferRegister != AtaTransferRegister.NoTransfer &&
|
||||
protocol != AtaProtocol.NonData)
|
||||
if(transferRegister != AtaTransferRegister.NoTransfer && protocol != AtaProtocol.NonData)
|
||||
{
|
||||
switch(protocol)
|
||||
{
|
||||
@@ -340,8 +335,7 @@ partial class Device
|
||||
int error = SendScsiCommand(cdb, ref buffer, out byte[] senseBuffer, timeout,
|
||||
AtaProtocolToScsiDirection(protocol), out duration, out sense);
|
||||
|
||||
if(senseBuffer.Length < 22 ||
|
||||
senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
|
||||
if(senseBuffer.Length < 22 || senseBuffer[8] != 0x09 && senseBuffer[9] != 0x0C)
|
||||
return error;
|
||||
|
||||
errorRegisters.Error = senseBuffer[11];
|
||||
@@ -612,8 +606,7 @@ partial class Device
|
||||
|
||||
int error = Marshal.GetLastWin32Error();
|
||||
|
||||
if(error != 13 &&
|
||||
error != 30)
|
||||
if(error != 13 && error != 30)
|
||||
{
|
||||
LastError = Marshal.GetLastWin32Error();
|
||||
Error = true;
|
||||
|
||||
@@ -382,8 +382,7 @@ partial class Device : Devices.Device
|
||||
|
||||
string possibleDir = Path.Combine(resolvedLink, "pcmcia_socket", subdirs[0]);
|
||||
|
||||
if(!File.Exists(possibleDir + "/card_type") ||
|
||||
!File.Exists(possibleDir + "/cis"))
|
||||
if(!File.Exists(possibleDir + "/card_type") || !File.Exists(possibleDir + "/cis"))
|
||||
continue;
|
||||
|
||||
var cisFs = new FileStream(possibleDir + "/cis", FileMode.Open, FileAccess.Read);
|
||||
|
||||
@@ -91,8 +91,7 @@ static class ListDevices
|
||||
|
||||
StreamReader sr;
|
||||
|
||||
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) &&
|
||||
string.IsNullOrEmpty(devices[i].Vendor))
|
||||
if(File.Exists(Path.Combine(sysdevs[i], "device/vendor")) && string.IsNullOrEmpty(devices[i].Vendor))
|
||||
{
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/vendor"), Encoding.ASCII);
|
||||
devices[i].Vendor = sr.ReadLine()?.Trim();
|
||||
@@ -109,15 +108,13 @@ static class ListDevices
|
||||
else if(devices[i].Path.StartsWith("/dev/loop", StringComparison.CurrentCulture))
|
||||
devices[i].Model = "Linux";
|
||||
|
||||
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) &&
|
||||
string.IsNullOrEmpty(devices[i].Serial))
|
||||
if(File.Exists(Path.Combine(sysdevs[i], "device/serial")) && string.IsNullOrEmpty(devices[i].Serial))
|
||||
{
|
||||
sr = new StreamReader(Path.Combine(sysdevs[i], "device/serial"), Encoding.ASCII);
|
||||
devices[i].Serial = sr.ReadLine()?.Trim();
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(devices[i].Vendor) ||
|
||||
devices[i].Vendor == "ATA")
|
||||
if(string.IsNullOrEmpty(devices[i].Vendor) || devices[i].Vendor == "ATA")
|
||||
{
|
||||
if(devices[i].Model != null)
|
||||
{
|
||||
|
||||
@@ -180,8 +180,7 @@ public partial class Device
|
||||
ref command.buffer, out command.response, out double cmdDuration,
|
||||
out bool cmdSense, timeout);
|
||||
|
||||
if(error == 0 &&
|
||||
singleError != 0)
|
||||
if(error == 0 && singleError != 0)
|
||||
error = singleError;
|
||||
|
||||
duration += cmdDuration;
|
||||
|
||||
@@ -62,8 +62,7 @@ public class Remote : IDisposable
|
||||
/// <exception cref="IOException">Network error.</exception>
|
||||
public Remote(Uri uri)
|
||||
{
|
||||
if(uri.Scheme != "aaru" &&
|
||||
uri.Scheme != "dic")
|
||||
if(uri.Scheme != "aaru" && uri.Scheme != "dic")
|
||||
throw new ArgumentException(Localization.Invalid_remote_protocol, nameof(uri.Scheme));
|
||||
|
||||
_host = uri.DnsSafeHost;
|
||||
@@ -102,8 +101,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -253,8 +251,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -347,8 +344,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -360,9 +356,8 @@ public class Remote : IDisposable
|
||||
if(hdr.packetType != AaruPacketType.Nop)
|
||||
{
|
||||
AaruConsole.
|
||||
ErrorWriteLine(
|
||||
Localization.Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0,
|
||||
hdr.packetType);
|
||||
ErrorWriteLine(Localization.Remote_ListDevices_Expected_List_Devices_Response_Packet_got_packet_type_0,
|
||||
hdr.packetType);
|
||||
|
||||
return Array.Empty<DeviceInfo>();
|
||||
}
|
||||
@@ -470,8 +465,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
lastError = -1;
|
||||
@@ -590,8 +584,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -700,8 +693,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -809,8 +801,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -919,8 +910,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1035,8 +1025,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1117,8 +1106,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1197,8 +1185,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1327,8 +1314,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1421,8 +1407,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1504,8 +1489,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1635,17 +1619,17 @@ public class Remote : IDisposable
|
||||
int off = tmp.Length;
|
||||
|
||||
foreach(AaruCmdSdhci cmd in commands.Select(command => new AaruCmdSdhci
|
||||
{
|
||||
application = command.isApplication,
|
||||
argument = command.argument,
|
||||
block_size = command.blockSize,
|
||||
blocks = command.blocks,
|
||||
buf_len = (uint)(command.buffer?.Length ?? 0),
|
||||
command = command.command,
|
||||
flags = command.flags,
|
||||
timeout = timeout,
|
||||
write = command.write
|
||||
}))
|
||||
{
|
||||
application = command.isApplication,
|
||||
argument = command.argument,
|
||||
block_size = command.blockSize,
|
||||
blocks = command.blocks,
|
||||
buf_len = (uint)(command.buffer?.Length ?? 0),
|
||||
command = command.command,
|
||||
flags = command.flags,
|
||||
timeout = timeout,
|
||||
write = command.write
|
||||
}))
|
||||
{
|
||||
tmp = Marshal.StructureToByteArrayLittleEndian(cmd);
|
||||
Array.Copy(tmp, 0, buf, off, tmp.Length);
|
||||
@@ -1654,7 +1638,7 @@ public class Remote : IDisposable
|
||||
}
|
||||
|
||||
foreach(Devices.Device.MmcSingleCommand command in
|
||||
commands.Where(command => (command.buffer?.Length ?? 0) != 0))
|
||||
commands.Where(command => (command.buffer?.Length ?? 0) != 0))
|
||||
{
|
||||
Array.Copy(command.buffer, 0, buf, off, command.buffer.Length);
|
||||
|
||||
@@ -1683,8 +1667,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1731,8 +1714,7 @@ public class Remote : IDisposable
|
||||
command.response = cmdRes.response;
|
||||
duration += cmdRes.duration;
|
||||
|
||||
if(cmdRes.error_no != 0 &&
|
||||
error == 0)
|
||||
if(cmdRes.error_no != 0 && error == 0)
|
||||
error = (int)cmdRes.error_no;
|
||||
|
||||
if(cmdRes.sense != 0)
|
||||
@@ -1827,8 +1809,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
@@ -1931,8 +1912,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruPacketHeader hdr = Marshal.ByteArrayToStructureLittleEndian<AaruPacketHeader>(hdrBuf);
|
||||
|
||||
if(hdr.remote_id != Consts.REMOTE_ID ||
|
||||
hdr.packet_id != Consts.PACKET_ID)
|
||||
if(hdr.remote_id != Consts.REMOTE_ID || hdr.packet_id != Consts.PACKET_ID)
|
||||
{
|
||||
AaruConsole.ErrorWriteLine(Localization.Received_data_is_not_an_Aaru_Remote_Packet);
|
||||
|
||||
|
||||
@@ -525,35 +525,28 @@ partial class Device
|
||||
|
||||
commandDescriptor.responseType = 0;
|
||||
|
||||
if(flags.HasFlag(MmcFlags.ResponseR1) ||
|
||||
flags.HasFlag(MmcFlags.ResponseSpiR1))
|
||||
if(flags.HasFlag(MmcFlags.ResponseR1) || flags.HasFlag(MmcFlags.ResponseSpiR1))
|
||||
commandDescriptor.responseType = SdResponseType.R1;
|
||||
|
||||
if(flags.HasFlag(MmcFlags.ResponseR1B) ||
|
||||
flags.HasFlag(MmcFlags.ResponseSpiR1B))
|
||||
if(flags.HasFlag(MmcFlags.ResponseR1B) || flags.HasFlag(MmcFlags.ResponseSpiR1B))
|
||||
commandDescriptor.responseType = SdResponseType.R1b;
|
||||
|
||||
if(flags.HasFlag(MmcFlags.ResponseR2) ||
|
||||
flags.HasFlag(MmcFlags.ResponseSpiR2))
|
||||
if(flags.HasFlag(MmcFlags.ResponseR2) || flags.HasFlag(MmcFlags.ResponseSpiR2))
|
||||
commandDescriptor.responseType = SdResponseType.R2;
|
||||
|
||||
if(flags.HasFlag(MmcFlags.ResponseR3) ||
|
||||
flags.HasFlag(MmcFlags.ResponseSpiR3))
|
||||
if(flags.HasFlag(MmcFlags.ResponseR3) || flags.HasFlag(MmcFlags.ResponseSpiR3))
|
||||
commandDescriptor.responseType = SdResponseType.R3;
|
||||
|
||||
if(flags.HasFlag(MmcFlags.ResponseR4) ||
|
||||
flags.HasFlag(MmcFlags.ResponseSpiR4))
|
||||
if(flags.HasFlag(MmcFlags.ResponseR4) || flags.HasFlag(MmcFlags.ResponseSpiR4))
|
||||
commandDescriptor.responseType = SdResponseType.R4;
|
||||
|
||||
if(flags.HasFlag(MmcFlags.ResponseR5) ||
|
||||
flags.HasFlag(MmcFlags.ResponseSpiR5))
|
||||
if(flags.HasFlag(MmcFlags.ResponseR5) || flags.HasFlag(MmcFlags.ResponseSpiR5))
|
||||
commandDescriptor.responseType = SdResponseType.R5;
|
||||
|
||||
if(flags.HasFlag(MmcFlags.ResponseR6))
|
||||
commandDescriptor.responseType = SdResponseType.R6;
|
||||
|
||||
var commandB =
|
||||
new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize];
|
||||
var commandB = new byte[commandData.size + commandData.protocolArgumentSize + commandData.deviceDataBufferSize];
|
||||
|
||||
Array.Copy(buffer, 0, commandB, commandData.size + commandData.protocolArgumentSize, buffer.Length);
|
||||
IntPtr hBuf = Marshal.AllocHGlobal(commandB.Length);
|
||||
@@ -611,8 +604,7 @@ partial class Device
|
||||
command.argument, command.blockSize, command.blocks, ref command.buffer,
|
||||
out command.response, out double cmdDuration, out bool cmdSense, timeout);
|
||||
|
||||
if(error == 0 &&
|
||||
singleError != 0)
|
||||
if(error == 0 && singleError != 0)
|
||||
error = singleError;
|
||||
|
||||
duration += cmdDuration;
|
||||
|
||||
@@ -112,8 +112,7 @@ partial class Device : Devices.Device
|
||||
|
||||
Marshal.Copy(descriptorPtr, descriptorB, 0, 1000);
|
||||
|
||||
if(!hasError &&
|
||||
error == 0)
|
||||
if(!hasError && error == 0)
|
||||
{
|
||||
var descriptor = new StorageDeviceDescriptor
|
||||
{
|
||||
@@ -235,12 +234,9 @@ partial class Device : Devices.Device
|
||||
sdBuffer = new byte[4];
|
||||
|
||||
dev.LastError =
|
||||
dev.SendMmcCommand(
|
||||
dev._cachedScr != null
|
||||
? (MmcCommands)SecureDigitalCommands.SendOperatingCondition
|
||||
: MmcCommands.SendOpCond,
|
||||
false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0,
|
||||
4, 1, ref sdBuffer, out _, out _, out sense);
|
||||
dev.SendMmcCommand(dev._cachedScr != null ? (MmcCommands)SecureDigitalCommands.SendOperatingCondition : MmcCommands.SendOpCond,
|
||||
false, true, MmcFlags.ResponseSpiR3 | MmcFlags.ResponseR3 | MmcFlags.CommandBcr, 0,
|
||||
4, 1, ref sdBuffer, out _, out _, out sense);
|
||||
|
||||
if(!sense)
|
||||
{
|
||||
@@ -292,10 +288,10 @@ partial class Device : Devices.Device
|
||||
|
||||
// I have to search for USB disks, floppies and CD-ROMs as separate device types
|
||||
foreach(string devGuid in new[]
|
||||
{
|
||||
Usb.GUID_DEVINTERFACE_FLOPPY, Usb.GUID_DEVINTERFACE_CDROM, Usb.GUID_DEVINTERFACE_DISK,
|
||||
Usb.GUID_DEVINTERFACE_TAPE
|
||||
})
|
||||
{
|
||||
Usb.GUID_DEVINTERFACE_FLOPPY, Usb.GUID_DEVINTERFACE_CDROM, Usb.GUID_DEVINTERFACE_DISK,
|
||||
Usb.GUID_DEVINTERFACE_TAPE
|
||||
})
|
||||
{
|
||||
usbDevice = Usb.FindDrivePath(devicePath, devGuid);
|
||||
|
||||
|
||||
@@ -104,8 +104,7 @@ static class ListDevices
|
||||
string physId = devId;
|
||||
|
||||
// TODO: This can be done better
|
||||
if(devId.Length == 2 &&
|
||||
devId[1] == ':')
|
||||
if(devId.Length == 2 && devId[1] == ':')
|
||||
physId = "\\\\?\\" + devId;
|
||||
|
||||
SafeFileHandle fd = Extern.CreateFile(physId, 0, FileShare.Read | FileShare.Write, IntPtr.Zero,
|
||||
@@ -182,8 +181,7 @@ static class ListDevices
|
||||
info.Serial = HexStringToString(info.Serial).Trim();
|
||||
}
|
||||
|
||||
if(string.IsNullOrEmpty(info.Vendor) ||
|
||||
info.Vendor == "ATA")
|
||||
if(string.IsNullOrEmpty(info.Vendor) || info.Vendor == "ATA")
|
||||
{
|
||||
string[] pieces = info.Model?.Split(' ');
|
||||
|
||||
|
||||
Reference in New Issue
Block a user