mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
[Aaru.Devices] Reformat and cleanup.
This commit is contained in:
@@ -41,7 +41,7 @@ namespace Aaru.Devices.Remote;
|
||||
public partial class Device
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public override int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
public override int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
ScsiDirection direction, out double duration, out bool sense)
|
||||
{
|
||||
// We need a timeout
|
||||
@@ -91,9 +91,9 @@ public partial class Device
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags,
|
||||
uint argument, uint blockSize, uint blocks, ref byte[] buffer,
|
||||
out uint[] response, out double duration, out bool sense, uint timeout = 15)
|
||||
public override int SendMmcCommand(MmcCommands command, bool write, bool isApplication, MmcFlags flags,
|
||||
uint argument, uint blockSize, uint blocks, ref byte[] buffer,
|
||||
out uint[] response, out double duration, out bool sense, uint timeout = 15)
|
||||
{
|
||||
// We need a timeout
|
||||
if(timeout == 0)
|
||||
@@ -160,7 +160,7 @@ public partial class Device
|
||||
|
||||
/// <inheritdoc />
|
||||
public override int SendMultipleMmcCommands(MmcSingleCommand[] commands, out double duration, out bool sense,
|
||||
uint timeout = 15)
|
||||
uint timeout = 15)
|
||||
{
|
||||
// We need a timeout
|
||||
if(timeout == 0)
|
||||
@@ -169,7 +169,7 @@ public partial class Device
|
||||
if(_remote.ServerProtocolVersion >= 2)
|
||||
return _remote.SendMultipleMmcCommands(commands, out duration, out sense, timeout);
|
||||
|
||||
int error = 0;
|
||||
var error = 0;
|
||||
duration = 0;
|
||||
sense = false;
|
||||
|
||||
|
||||
@@ -42,8 +42,11 @@ namespace Aaru.Devices.Remote;
|
||||
/// <inheritdoc />
|
||||
public sealed partial class Device : Devices.Device
|
||||
{
|
||||
bool? _isRemoteAdmin;
|
||||
Remote _remote;
|
||||
|
||||
Device() {}
|
||||
|
||||
/// <summary>Returns if remote is running under administrative (aka root) privileges</summary>
|
||||
public bool IsAdmin
|
||||
{
|
||||
@@ -57,21 +60,24 @@ public sealed partial class Device : Devices.Device
|
||||
|
||||
/// <summary>Current device is remote</summary>
|
||||
public bool IsRemote => _remote != null;
|
||||
|
||||
/// <summary>Remote application</summary>
|
||||
public string RemoteApplication => _remote?.ServerApplication;
|
||||
|
||||
/// <summary>Remote application server</summary>
|
||||
public string RemoteVersion => _remote?.ServerVersion;
|
||||
|
||||
/// <summary>Remote operating system name</summary>
|
||||
public string RemoteOperatingSystem => _remote?.ServerOperatingSystem;
|
||||
|
||||
/// <summary>Remote operating system version</summary>
|
||||
public string RemoteOperatingSystemVersion => _remote?.ServerOperatingSystemVersion;
|
||||
|
||||
/// <summary>Remote architecture</summary>
|
||||
public string RemoteArchitecture => _remote?.ServerArchitecture;
|
||||
|
||||
/// <summary>Remote protocol version</summary>
|
||||
public int RemoteProtocolVersion => _remote?.ServerProtocolVersion ?? 0;
|
||||
bool? _isRemoteAdmin;
|
||||
|
||||
Device() {}
|
||||
|
||||
/// <summary>Opens the device for sending direct commands</summary>
|
||||
/// <param name="aaruUri">AaruRemote URI</param>
|
||||
@@ -156,7 +162,8 @@ public sealed partial class Device : Devices.Device
|
||||
break;
|
||||
}
|
||||
|
||||
#region SecureDigital / MultiMediaCard
|
||||
#region SecureDigital / MultiMediaCard
|
||||
|
||||
if(dev._cachedCid != null)
|
||||
{
|
||||
dev.ScsiType = PeripheralDeviceTypes.DirectAccess;
|
||||
@@ -189,9 +196,11 @@ public sealed partial class Device : Devices.Device
|
||||
|
||||
return dev;
|
||||
}
|
||||
#endregion SecureDigital / MultiMediaCard
|
||||
|
||||
#region USB
|
||||
#endregion SecureDigital / MultiMediaCard
|
||||
|
||||
#region USB
|
||||
|
||||
if(dev._remote.GetUsbData(out byte[] remoteUsbDescriptors, out ushort remoteUsbVendor,
|
||||
out ushort remoteUsbProduct, out string remoteUsbManufacturer,
|
||||
out string remoteUsbProductString, out string remoteUsbSerial))
|
||||
@@ -204,9 +213,11 @@ public sealed partial class Device : Devices.Device
|
||||
dev.UsbProductString = remoteUsbProductString;
|
||||
dev.UsbSerialString = remoteUsbSerial;
|
||||
}
|
||||
#endregion USB
|
||||
|
||||
#region FireWire
|
||||
#endregion USB
|
||||
|
||||
#region FireWire
|
||||
|
||||
if(dev._remote.GetFireWireData(out dev._firewireVendor, out dev._firewireModel, out dev._firewireGuid,
|
||||
out string remoteFireWireVendorName, out string remoteFireWireModelName))
|
||||
{
|
||||
@@ -214,14 +225,18 @@ public sealed partial class Device : Devices.Device
|
||||
dev.FireWireVendorName = remoteFireWireVendorName;
|
||||
dev.FireWireModelName = remoteFireWireModelName;
|
||||
}
|
||||
#endregion FireWire
|
||||
#region PCMCIA
|
||||
|
||||
#endregion FireWire
|
||||
|
||||
#region PCMCIA
|
||||
|
||||
if(!dev._remote.GetPcmciaData(out byte[] cisBuf))
|
||||
return dev;
|
||||
|
||||
dev.IsPcmcia = true;
|
||||
dev.Cis = cisBuf;
|
||||
#endregion PCMCIA
|
||||
|
||||
#endregion PCMCIA
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
@@ -35,19 +35,41 @@ namespace Aaru.Devices.Remote;
|
||||
/// <summary>Packet type enumeration</summary>
|
||||
public enum AaruPacketType : sbyte
|
||||
{
|
||||
#pragma warning disable 1591
|
||||
Nop = -1, Hello = 1, CommandListDevices = 2,
|
||||
ResponseListDevices = 3, CommandOpen = 4, CommandScsi = 5,
|
||||
ResponseScsi = 6, CommandAtaChs = 7, ResponseAtaChs = 8,
|
||||
CommandAtaLba28 = 9, ResponseAtaLba28 = 10, CommandAtaLba48 = 11,
|
||||
ResponseAtaLba48 = 12, CommandSdhci = 13, ResponseSdhci = 14,
|
||||
CommandGetType = 15, ResponseGetType = 16, CommandGetSdhciRegisters = 17,
|
||||
ResponseGetSdhciRegisters = 18, CommandGetUsbData = 19, ResponseGetUsbData = 20,
|
||||
CommandGetFireWireData = 21, ResponseGetFireWireData = 22, CommandGetPcmciaData = 23,
|
||||
ResponseGetPcmciaData = 24, CommandCloseDevice = 25, CommandAmIRoot = 26,
|
||||
ResponseAmIRoot = 27, MultiCommandSdhci = 28, ResponseMultiSdhci = 29,
|
||||
CommandReOpenDevice = 30, CommandOsRead = 31, ResponseOsRead = 32
|
||||
#pragma warning restore 1591
|
||||
#pragma warning disable 1591
|
||||
Nop = -1,
|
||||
Hello = 1,
|
||||
CommandListDevices = 2,
|
||||
ResponseListDevices = 3,
|
||||
CommandOpen = 4,
|
||||
CommandScsi = 5,
|
||||
ResponseScsi = 6,
|
||||
CommandAtaChs = 7,
|
||||
ResponseAtaChs = 8,
|
||||
CommandAtaLba28 = 9,
|
||||
ResponseAtaLba28 = 10,
|
||||
CommandAtaLba48 = 11,
|
||||
ResponseAtaLba48 = 12,
|
||||
CommandSdhci = 13,
|
||||
ResponseSdhci = 14,
|
||||
CommandGetType = 15,
|
||||
ResponseGetType = 16,
|
||||
CommandGetSdhciRegisters = 17,
|
||||
ResponseGetSdhciRegisters = 18,
|
||||
CommandGetUsbData = 19,
|
||||
ResponseGetUsbData = 20,
|
||||
CommandGetFireWireData = 21,
|
||||
ResponseGetFireWireData = 22,
|
||||
CommandGetPcmciaData = 23,
|
||||
ResponseGetPcmciaData = 24,
|
||||
CommandCloseDevice = 25,
|
||||
CommandAmIRoot = 26,
|
||||
ResponseAmIRoot = 27,
|
||||
MultiCommandSdhci = 28,
|
||||
ResponseMultiSdhci = 29,
|
||||
CommandReOpenDevice = 30,
|
||||
CommandOsRead = 31,
|
||||
ResponseOsRead = 32
|
||||
#pragma warning restore 1591
|
||||
}
|
||||
|
||||
/// <summary>Reasons for non-data request or response</summary>
|
||||
|
||||
@@ -89,7 +89,7 @@ public class Remote : IDisposable
|
||||
|
||||
AaruConsole.WriteLine(Localization.Connected_to_0, uri.Host);
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
int len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -196,14 +196,19 @@ public class Remote : IDisposable
|
||||
|
||||
/// <summary>Remote server application</summary>
|
||||
public string ServerApplication { get; }
|
||||
|
||||
/// <summary>Remote server application version</summary>
|
||||
public string ServerVersion { get; }
|
||||
|
||||
/// <summary>Remote server operating system</summary>
|
||||
public string ServerOperatingSystem { get; }
|
||||
|
||||
/// <summary>Remote server operating system version</summary>
|
||||
public string ServerOperatingSystemVersion { get; }
|
||||
|
||||
/// <summary>Remote server architecture</summary>
|
||||
public string ServerArchitecture { get; }
|
||||
|
||||
/// <summary>Remote server protocol version</summary>
|
||||
public int ServerProtocolVersion { get; }
|
||||
|
||||
@@ -235,7 +240,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -281,9 +286,13 @@ public class Remote : IDisposable
|
||||
}
|
||||
}
|
||||
|
||||
#region IDisposable Members
|
||||
|
||||
/// <inheritdoc />
|
||||
public void Dispose() => Disconnect();
|
||||
|
||||
#endregion
|
||||
|
||||
/// <summary>Disconnects from remote</summary>
|
||||
public void Disconnect()
|
||||
{
|
||||
@@ -325,7 +334,7 @@ public class Remote : IDisposable
|
||||
return Array.Empty<DeviceInfo>();
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -351,8 +360,9 @@ 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>();
|
||||
}
|
||||
@@ -446,7 +456,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -495,8 +505,10 @@ public class Remote : IDisposable
|
||||
|
||||
switch(nop.reasonCode)
|
||||
{
|
||||
case AaruNopReason.OpenOk: return true;
|
||||
case AaruNopReason.NotImplemented: throw new NotImplementedException($"{nop.reason}");
|
||||
case AaruNopReason.OpenOk:
|
||||
return true;
|
||||
case AaruNopReason.NotImplemented:
|
||||
throw new NotImplementedException($"{nop.reason}");
|
||||
}
|
||||
|
||||
AaruConsole.ErrorWriteLine($"{nop.reason}");
|
||||
@@ -517,8 +529,8 @@ public class Remote : IDisposable
|
||||
/// <c>True</c> if SCSI command returned non-OK status and <paramref name="senseBuffer" /> contains
|
||||
/// SCSI sense
|
||||
/// </param>
|
||||
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
ScsiDirection direction, out double duration, out bool sense)
|
||||
public int SendScsiCommand(byte[] cdb, ref byte[] buffer, out byte[] senseBuffer, uint timeout,
|
||||
ScsiDirection direction, out double duration, out bool sense)
|
||||
{
|
||||
senseBuffer = null;
|
||||
duration = 0;
|
||||
@@ -546,7 +558,7 @@ public class Remote : IDisposable
|
||||
cmdPkt.hdr.len = (uint)(Marshal.SizeOf<AaruPacketCmdScsi>() + cmdPkt.cdb_len + cmdPkt.buf_len);
|
||||
|
||||
byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||
byte[] buf = new byte[cmdPkt.hdr.len];
|
||||
var buf = new byte[cmdPkt.hdr.len];
|
||||
|
||||
Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf<AaruPacketCmdScsi>());
|
||||
|
||||
@@ -565,7 +577,7 @@ public class Remote : IDisposable
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -659,7 +671,7 @@ public class Remote : IDisposable
|
||||
cmdPkt.hdr.len = (uint)(Marshal.SizeOf<AaruPacketCmdAtaChs>() + cmdPkt.buf_len);
|
||||
|
||||
byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||
byte[] buf = new byte[cmdPkt.hdr.len];
|
||||
var buf = new byte[cmdPkt.hdr.len];
|
||||
|
||||
Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf<AaruPacketCmdAtaChs>());
|
||||
|
||||
@@ -675,7 +687,7 @@ public class Remote : IDisposable
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -739,8 +751,8 @@ public class Remote : IDisposable
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
|
||||
public int SendAtaCommand(AtaRegistersLba28 registers, out AtaErrorRegistersLba28 errorRegisters,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = true;
|
||||
@@ -768,7 +780,7 @@ public class Remote : IDisposable
|
||||
cmdPkt.hdr.len = (uint)(Marshal.SizeOf<AaruPacketCmdAtaLba28>() + cmdPkt.buf_len);
|
||||
|
||||
byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||
byte[] buf = new byte[cmdPkt.hdr.len];
|
||||
var buf = new byte[cmdPkt.hdr.len];
|
||||
|
||||
Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf<AaruPacketCmdAtaLba28>());
|
||||
|
||||
@@ -784,7 +796,7 @@ public class Remote : IDisposable
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -849,8 +861,8 @@ public class Remote : IDisposable
|
||||
/// <param name="duration">Time it took to execute the command in milliseconds</param>
|
||||
/// <param name="sense"><c>True</c> if ATA/ATAPI command returned non-OK status</param>
|
||||
public int SendAtaCommand(AtaRegistersLba48 registers, out AtaErrorRegistersLba48 errorRegisters,
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
AtaProtocol protocol, AtaTransferRegister transferRegister, ref byte[] buffer,
|
||||
uint timeout, bool transferBlocks, out double duration, out bool sense)
|
||||
{
|
||||
duration = 0;
|
||||
sense = true;
|
||||
@@ -878,7 +890,7 @@ public class Remote : IDisposable
|
||||
cmdPkt.hdr.len = (uint)(Marshal.SizeOf<AaruPacketCmdAtaLba48>() + cmdPkt.buf_len);
|
||||
|
||||
byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||
byte[] buf = new byte[cmdPkt.hdr.len];
|
||||
var buf = new byte[cmdPkt.hdr.len];
|
||||
|
||||
Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf<AaruPacketCmdAtaLba48>());
|
||||
|
||||
@@ -894,7 +906,7 @@ public class Remote : IDisposable
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -994,7 +1006,7 @@ public class Remote : IDisposable
|
||||
cmdPkt.hdr.len = (uint)(Marshal.SizeOf<AaruPacketCmdSdhci>() + cmdPkt.command.buf_len);
|
||||
|
||||
byte[] pktBuf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||
byte[] buf = new byte[cmdPkt.hdr.len];
|
||||
var buf = new byte[cmdPkt.hdr.len];
|
||||
|
||||
Array.Copy(pktBuf, 0, buf, 0, Marshal.SizeOf<AaruPacketCmdSdhci>());
|
||||
|
||||
@@ -1010,7 +1022,7 @@ public class Remote : IDisposable
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1092,7 +1104,7 @@ public class Remote : IDisposable
|
||||
return DeviceType.Unknown;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1172,7 +1184,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1246,7 +1258,8 @@ public class Remote : IDisposable
|
||||
|
||||
switch(res.scr_len)
|
||||
{
|
||||
case <= 0: return res.isSdhci;
|
||||
case <= 0:
|
||||
return res.isSdhci;
|
||||
case > 16:
|
||||
res.scr_len = 16;
|
||||
|
||||
@@ -1269,7 +1282,7 @@ public class Remote : IDisposable
|
||||
/// <param name="serial">USB serial number string</param>
|
||||
/// <returns><c>true</c> if the device is attached via USB, <c>false</c> otherwise</returns>
|
||||
public bool GetUsbData(out byte[] descriptors, out ushort idVendor, out ushort idProduct, out string manufacturer,
|
||||
out string product, out string serial)
|
||||
out string product, out string serial)
|
||||
{
|
||||
descriptors = null;
|
||||
idVendor = 0;
|
||||
@@ -1301,7 +1314,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1363,7 +1376,7 @@ public class Remote : IDisposable
|
||||
/// <param name="model">FireWire model string</param>
|
||||
/// <param name="guid">FireWire GUID</param>
|
||||
/// <returns><c>true</c> if the device is attached via FireWire, <c>false</c> otherwise</returns>
|
||||
public bool GetFireWireData(out uint idVendor, out uint idProduct, out ulong guid, out string vendor,
|
||||
public bool GetFireWireData(out uint idVendor, out uint idProduct, out ulong guid, out string vendor,
|
||||
out string model)
|
||||
{
|
||||
idVendor = 0;
|
||||
@@ -1395,7 +1408,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1478,7 +1491,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1535,7 +1548,7 @@ public class Remote : IDisposable
|
||||
/// <returns>Retrieved number of bytes</returns>
|
||||
static int Receive(Socket socket, byte[] buffer, int size, SocketFlags socketFlags)
|
||||
{
|
||||
int offset = 0;
|
||||
var offset = 0;
|
||||
|
||||
while(size > 0)
|
||||
{
|
||||
@@ -1588,7 +1601,7 @@ public class Remote : IDisposable
|
||||
/// <param name="timeout">Maximum allowed time to execute a single command</param>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
public int SendMultipleMmcCommands(Devices.Device.MmcSingleCommand[] commands, out double duration, out bool sense,
|
||||
uint timeout = 0)
|
||||
uint timeout = 0)
|
||||
{
|
||||
if(ServerProtocolVersion < 2)
|
||||
return SendMultipleMmcCommandsV1(commands, out duration, out sense, timeout);
|
||||
@@ -1597,7 +1610,7 @@ public class Remote : IDisposable
|
||||
duration = 0;
|
||||
|
||||
long packetSize = Marshal.SizeOf<AaruPacketMultiCmdSdhci>() +
|
||||
(Marshal.SizeOf<AaruCmdSdhci>() * commands.LongLength);
|
||||
Marshal.SizeOf<AaruCmdSdhci>() * commands.LongLength;
|
||||
|
||||
packetSize = commands.Aggregate(packetSize, (current, command) => current + (command.buffer?.Length ?? 0));
|
||||
|
||||
@@ -1614,7 +1627,7 @@ public class Remote : IDisposable
|
||||
}
|
||||
};
|
||||
|
||||
byte[] buf = new byte[packetSize];
|
||||
var buf = new byte[packetSize];
|
||||
byte[] tmp = Marshal.StructureToByteArrayLittleEndian(packet);
|
||||
|
||||
Array.Copy(tmp, 0, buf, 0, tmp.Length);
|
||||
@@ -1657,7 +1670,7 @@ public class Remote : IDisposable
|
||||
return -1;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1708,7 +1721,7 @@ public class Remote : IDisposable
|
||||
|
||||
off = Marshal.SizeOf<AaruPacketMultiCmdSdhci>();
|
||||
|
||||
int error = 0;
|
||||
var error = 0;
|
||||
|
||||
foreach(Devices.Device.MmcSingleCommand command in commands)
|
||||
{
|
||||
@@ -1750,16 +1763,16 @@ public class Remote : IDisposable
|
||||
/// <param name="timeout">Maximum allowed time to execute a single command</param>
|
||||
/// <returns>0 if no error occurred, otherwise, errno</returns>
|
||||
int SendMultipleMmcCommandsV1(Devices.Device.MmcSingleCommand[] commands, out double duration, out bool sense,
|
||||
uint timeout)
|
||||
uint timeout)
|
||||
{
|
||||
sense = false;
|
||||
duration = 0;
|
||||
int error = 0;
|
||||
var error = 0;
|
||||
|
||||
foreach(Devices.Device.MmcSingleCommand command in commands)
|
||||
{
|
||||
error = SendMmcCommand(command.command, command.write, command.isApplication, command.flags,
|
||||
command.argument, command.blockSize, command.blocks, ref command.buffer,
|
||||
error = SendMmcCommand(command.command, command.write, command.isApplication, command.flags,
|
||||
command.argument, command.blockSize, command.blocks, ref command.buffer,
|
||||
out command.response, out double cmdDuration, out bool cmdSense, timeout);
|
||||
|
||||
if(cmdSense)
|
||||
@@ -1801,7 +1814,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
@@ -1850,7 +1863,8 @@ public class Remote : IDisposable
|
||||
|
||||
switch(nop.reasonCode)
|
||||
{
|
||||
case AaruNopReason.ReOpenOk: return true;
|
||||
case AaruNopReason.ReOpenOk:
|
||||
return true;
|
||||
case AaruNopReason.CloseError:
|
||||
case AaruNopReason.OpenError:
|
||||
AaruConsole.ErrorWriteLine(Localization.ReOpen_error_closing_device);
|
||||
@@ -1904,7 +1918,7 @@ public class Remote : IDisposable
|
||||
return false;
|
||||
}
|
||||
|
||||
byte[] hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
var hdrBuf = new byte[Marshal.SizeOf<AaruPacketHeader>()];
|
||||
|
||||
len = Receive(_socket, hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user