mirror of
https://github.com/aaru-dps/Aaru.git
synced 2025-12-16 19:24:25 +00:00
Add packet to close device.
This commit is contained in:
@@ -50,18 +50,25 @@ namespace DiscImageChef.Devices
|
|||||||
|
|
||||||
public void Close()
|
public void Close()
|
||||||
{
|
{
|
||||||
if(FileHandle == null) return;
|
if (_remote != null)
|
||||||
|
{
|
||||||
|
_remote.Close();
|
||||||
|
_remote.Disconnect();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch(PlatformId)
|
if (FileHandle == null) return;
|
||||||
|
|
||||||
|
switch (PlatformId)
|
||||||
{
|
{
|
||||||
case PlatformID.Win32NT:
|
case PlatformID.Win32NT:
|
||||||
(FileHandle as SafeFileHandle)?.Close();
|
(FileHandle as SafeFileHandle)?.Close();
|
||||||
break;
|
break;
|
||||||
case PlatformID.Linux:
|
case PlatformID.Linux:
|
||||||
Extern.close((int)FileHandle);
|
Extern.close((int) FileHandle);
|
||||||
break;
|
break;
|
||||||
case PlatformID.FreeBSD:
|
case PlatformID.FreeBSD:
|
||||||
FreeBSD.Extern.cam_close_device((IntPtr)FileHandle);
|
FreeBSD.Extern.cam_close_device((IntPtr) FileHandle);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ namespace DiscImageChef.Devices.Remote
|
|||||||
CommandGetFireWireData = 21,
|
CommandGetFireWireData = 21,
|
||||||
ResponseGetFireWireData = 22,
|
ResponseGetFireWireData = 22,
|
||||||
CommandGetPcmciaData = 23,
|
CommandGetPcmciaData = 23,
|
||||||
ResponseGetPcmciaData = 24
|
ResponseGetPcmciaData = 24,
|
||||||
|
CommandCloseDevice = 25
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum DicNopReason : byte
|
public enum DicNopReason : byte
|
||||||
|
|||||||
@@ -1202,5 +1202,23 @@ namespace DiscImageChef.Devices.Remote
|
|||||||
|
|
||||||
return offset;
|
return offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Close()
|
||||||
|
{
|
||||||
|
var cmdPkt = new DicPacketCmdClose
|
||||||
|
{
|
||||||
|
hdr = new DicPacketHeader
|
||||||
|
{
|
||||||
|
remote_id = Consts.RemoteId, packet_id = Consts.PacketId,
|
||||||
|
len = (uint) Marshal.SizeOf<DicPacketCmdClose>(),
|
||||||
|
version = Consts.PacketVersion,
|
||||||
|
packetType = DicPacketType.CommandCloseDevice
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
var buf = Marshal.StructureToByteArrayLittleEndian(cmdPkt);
|
||||||
|
|
||||||
|
_socket.Send(buf, SocketFlags.None);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -306,4 +306,10 @@ namespace DiscImageChef.Devices.Remote
|
|||||||
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65536)]
|
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65536)]
|
||||||
public byte[] cis;
|
public byte[] cis;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
|
||||||
|
public struct DicPacketCmdClose
|
||||||
|
{
|
||||||
|
public DicPacketHeader hdr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user