Add packet to close device.

This commit is contained in:
2019-10-26 15:47:36 +01:00
parent 934a836412
commit 1617e54a06
4 changed files with 37 additions and 5 deletions

View File

@@ -50,6 +50,13 @@ namespace DiscImageChef.Devices
public void Close()
{
if (_remote != null)
{
_remote.Close();
_remote.Disconnect();
return;
}
if (FileHandle == null) return;
switch (PlatformId)

View File

@@ -26,7 +26,8 @@ namespace DiscImageChef.Devices.Remote
CommandGetFireWireData = 21,
ResponseGetFireWireData = 22,
CommandGetPcmciaData = 23,
ResponseGetPcmciaData = 24
ResponseGetPcmciaData = 24,
CommandCloseDevice = 25
}
public enum DicNopReason : byte

View File

@@ -1202,5 +1202,23 @@ namespace DiscImageChef.Devices.Remote
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);
}
}
}

View File

@@ -306,4 +306,10 @@ namespace DiscImageChef.Devices.Remote
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 65536)]
public byte[] cis;
}
[StructLayout(LayoutKind.Sequential, CharSet = CharSet.Ansi, Pack = 1)]
public struct DicPacketCmdClose
{
public DicPacketHeader hdr;
}
}