mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Implement get device type packet.
This commit is contained in:
@@ -162,6 +162,8 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
var scsiSense = true;
|
var scsiSense = true;
|
||||||
|
|
||||||
|
if (remote is null)
|
||||||
|
{
|
||||||
// Windows is answering SCSI INQUIRY for all device types so it needs to be detected first
|
// Windows is answering SCSI INQUIRY for all device types so it needs to be detected first
|
||||||
switch (PlatformId)
|
switch (PlatformId)
|
||||||
{
|
{
|
||||||
@@ -204,7 +206,8 @@ namespace DiscImageChef.Devices
|
|||||||
RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32)
|
RawPropertiesLength = BitConverter.ToUInt32(descriptorB, 32)
|
||||||
};
|
};
|
||||||
descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength];
|
descriptor.RawDeviceProperties = new byte[descriptor.RawPropertiesLength];
|
||||||
Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0, descriptor.RawPropertiesLength);
|
Array.Copy(descriptorB, 36, descriptor.RawDeviceProperties, 0,
|
||||||
|
descriptor.RawPropertiesLength);
|
||||||
|
|
||||||
switch (descriptor.BusType)
|
switch (descriptor.BusType)
|
||||||
{
|
{
|
||||||
@@ -394,6 +397,13 @@ namespace DiscImageChef.Devices
|
|||||||
scsiSense = ScsiInquiry(out inqBuf, out _);
|
scsiSense = ScsiInquiry(out inqBuf, out _);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Type = remote.GetDeviceType();
|
||||||
|
// TODO: Get INQUIRY if SCSI or ATAPI
|
||||||
|
// TODO: Get SD/MMC registers if SD/MMC
|
||||||
|
}
|
||||||
|
|
||||||
#region SecureDigital / MultiMediaCard
|
#region SecureDigital / MultiMediaCard
|
||||||
|
|
||||||
@@ -424,6 +434,7 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
#endregion SecureDigital / MultiMediaCard
|
#endregion SecureDigital / MultiMediaCard
|
||||||
|
|
||||||
|
|
||||||
#region USB
|
#region USB
|
||||||
|
|
||||||
switch (PlatformId)
|
switch (PlatformId)
|
||||||
|
|||||||
@@ -371,7 +371,64 @@ namespace DiscImageChef.Devices.Remote
|
|||||||
|
|
||||||
public DeviceType GetDeviceType()
|
public DeviceType GetDeviceType()
|
||||||
{
|
{
|
||||||
throw new NotImplementedException("Getting remote device type not yet implemented...");
|
var cmdPkt = new DicPacketCmdGetDeviceType
|
||||||
|
{
|
||||||
|
hdr = new DicPacketHeader
|
||||||
|
{
|
||||||
|
id = Consts.PacketId,
|
||||||
|
len = (uint) Marshal.SizeOf<DicPacketCommandOpenDevice>(),
|
||||||
|
version = Consts.PacketVersion,
|
||||||
|
packetType = DicPacketType.CommandGetType
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var buf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||||
|
|
||||||
|
var len = _socket.Send(buf, SocketFlags.None);
|
||||||
|
|
||||||
|
if (len != buf.Length)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Could not write to the network...");
|
||||||
|
return DeviceType.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hdrBuf = new byte[Marshal.SizeOf<DicPacketHeader>()];
|
||||||
|
|
||||||
|
len = _socket.Receive(hdrBuf, hdrBuf.Length, SocketFlags.Peek);
|
||||||
|
|
||||||
|
if (len < hdrBuf.Length)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Could not read from the network...");
|
||||||
|
return DeviceType.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
var hdr = Marshal.ByteArrayToStructureLittleEndian<DicPacketHeader>(hdrBuf);
|
||||||
|
|
||||||
|
if (hdr.id != Consts.PacketId)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Received data is not a DIC Remote Packet...");
|
||||||
|
return DeviceType.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hdr.packetType != DicPacketType.ResponseGetType)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Expected Device Type Response Packet, got packet type {0}...",
|
||||||
|
hdr.packetType);
|
||||||
|
return DeviceType.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
buf = new byte[hdr.len];
|
||||||
|
len = _socket.Receive(buf, buf.Length, SocketFlags.None);
|
||||||
|
|
||||||
|
if (len < buf.Length)
|
||||||
|
{
|
||||||
|
DicConsole.ErrorWriteLine("Could not read from the network...");
|
||||||
|
return DeviceType.Unknown;
|
||||||
|
}
|
||||||
|
|
||||||
|
var res = Marshal.ByteArrayToStructureLittleEndian<DicPacketResGetDeviceType>(buf);
|
||||||
|
|
||||||
|
return res.device_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool GetSdhciRegisters(out byte[] csd, out byte[] cid, out byte[] ocr, out byte[] scr)
|
public bool GetSdhciRegisters(out byte[] csd, out byte[] cid, out byte[] ocr, out byte[] scr)
|
||||||
|
|||||||
Reference in New Issue
Block a user