* DiscImageChef.Devices/Enums.cs:

* DiscImageChef/Commands/DeviceInfo.cs:
	* DiscImageChef.Devices/Device/ScsiCommands.cs:
	  Added Plextor vendor commands.

	* DiscImageChef/Plugins.cs:
	* DiscImageChef/Commands/Analyze.cs:
	* DiscImageChef/Commands/Compare.cs:
	* DiscImageChef/Commands/CreateSidecar.cs:
	  Do not call system console directly.
This commit is contained in:
2016-01-11 19:24:17 +00:00
parent 62768b3e6b
commit c98d64e544
9 changed files with 710 additions and 7 deletions

View File

@@ -1,3 +1,14 @@
2016-01-11 Natalia Portillo <claunia@claunia.com>
* Plugins.cs:
* Commands/Analyze.cs:
* Commands/Compare.cs:
* Commands/CreateSidecar.cs:
Do not call system console directly.
* Commands/DeviceInfo.cs:
Added Plextor vendor commands.
2015-12-31 Natalia Portillo <claunia@claunia.com>
* Commands/CreateSidecar.cs:

View File

@@ -102,7 +102,7 @@ namespace DiscImageChef.Commands
}
catch (Exception ex)
{
System.Console.Error.WriteLine("Unable to open image format");
DicConsole.ErrorWriteLine("Unable to open image format");
DicConsole.ErrorWriteLine("Error: {0}", ex.Message);
return;
}

View File

@@ -54,13 +54,13 @@ namespace DiscImageChef.Commands
if (!System.IO.File.Exists(options.InputFile1))
{
System.Console.Error.WriteLine("Input file 1 does not exist.");
DicConsole.ErrorWriteLine("Input file 1 does not exist.");
return;
}
if (!System.IO.File.Exists(options.InputFile2))
{
System.Console.Error.WriteLine("Input file 2 does not exist.");
DicConsole.ErrorWriteLine("Input file 2 does not exist.");
return;
}

View File

@@ -88,7 +88,7 @@ namespace DiscImageChef.Commands
}
catch (Exception ex)
{
System.Console.Error.WriteLine("Unable to open image format");
DicConsole.ErrorWriteLine("Unable to open image format");
DicConsole.ErrorWriteLine("Error: {0}", ex.Message);
return;
}

View File

@@ -888,6 +888,226 @@ namespace DiscImageChef.Commands
*/
}
#region Plextor
if(dev.Manufacturer == "PLEXTOR")
{
bool plxtSense = true;
bool plxtDvd = false;
byte[] plxtBuf = null;
switch(dev.Model)
{
case "DVDR PX-708A":
case "DVDR PX-708A2":
case "DVDR PX-712A":
plxtDvd = true;
plxtSense = dev.PlextorReadEeprom(out plxtBuf, out senseBuf, dev.Timeout, out duration);
break;
case "DVDR PX-714A":
case "DVDR PX-716A":
case "DVDR PX-716AL":
case "DVDR PX-755A":
case "DVDR PX-760A":
{
byte[] plxtBufSmall;
plxtBuf = new byte[256 * 4];
for(byte i = 0; i < 4; i++)
{
plxtSense = dev.PlextorReadEepromBlock(out plxtBufSmall, out senseBuf, i, 256, dev.Timeout, out duration);
if(plxtSense)
break;
Array.Copy(plxtBufSmall, 0, plxtBuf, i * 256, 256);
}
plxtDvd = true;
break;
}
default:
{
if(dev.Model.StartsWith("CD-R "))
{
plxtSense = dev.PlextorReadEepromCDR(out plxtBuf, out senseBuf, dev.Timeout, out duration);
}
break;
}
}
if (!plxtSense)
{
if(!string.IsNullOrEmpty(options.OutputPrefix))
{
if (!File.Exists(options.OutputPrefix + "_plextor_eeprom.bin"))
{
try
{
DicConsole.DebugWriteLine("Device-Info command", "Writing PLEXTOR READ EEPROM to {0}{1}", options.OutputPrefix, "_plextor_eeprom.bin");
outputFs = new FileStream(options.OutputPrefix +"_plextor_eeprom.bin", FileMode.CreateNew);
outputFs.Write(plxtBuf, 0, plxtBuf.Length);
outputFs.Close();
}
catch
{
DicConsole.ErrorWriteLine("Unable to write file {0}{1}", options.OutputPrefix, "_plextor_eeprom.bin");
}
}
else
DicConsole.ErrorWriteLine("Not overwriting file {0}{1}", options.OutputPrefix, "_plextor_eeprom.bin");
}
ushort discs;
uint cdReadTime, cdWriteTime, dvdReadTime = 0, dvdWriteTime = 0;
BigEndianBitConverter.IsLittleEndian = BitConverter.IsLittleEndian;
if(plxtDvd)
{
discs = BigEndianBitConverter.ToUInt16(plxtBuf, 0x0120);
cdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x0122);
cdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x0126);
dvdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x012A);
dvdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x012E);
}
else
{
discs = BigEndianBitConverter.ToUInt16(plxtBuf, 0x0078);
cdReadTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x006C);
cdWriteTime = BigEndianBitConverter.ToUInt32(plxtBuf, 0x007A);
}
DicConsole.WriteLine("Drive has loaded a total of {0} discs", discs);
DicConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds reading CDs",
cdReadTime / 3600, (cdReadTime / 60) % 60, cdReadTime % 60);
DicConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds writing CDs",
cdWriteTime / 3600, (cdWriteTime / 60) % 60, cdWriteTime % 60);
if(plxtDvd)
{
DicConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds reading DVDs",
dvdReadTime / 3600, (dvdReadTime / 60) % 60, dvdReadTime % 60);
DicConsole.WriteLine("Drive has spent {0} hours, {1} minutes and {2} seconds writing DVDs",
dvdWriteTime / 3600, (dvdWriteTime / 60) % 60, dvdWriteTime % 60);
}
}
bool plxtPwrRecEnabled;
ushort plxtPwrRecSpeed;
plxtSense = dev.PlextorGetPoweRec(out senseBuf, out plxtPwrRecEnabled, out plxtPwrRecSpeed, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.Write("Drive supports PoweRec");
if(plxtPwrRecEnabled)
{
DicConsole.Write(", has it enabled");
if(plxtPwrRecSpeed > 0)
DicConsole.WriteLine(" and recommends {0} Kb/sec.", plxtPwrRecSpeed);
else
DicConsole.WriteLine(".");
ushort plxtPwrRecSelected, plxtPwrRecMax, plxtPwrRecLast;
plxtSense = dev.PlextorGetSpeeds(out senseBuf, out plxtPwrRecSelected, out plxtPwrRecMax, out plxtPwrRecLast, dev.Timeout, out duration);
if(!plxtSense)
{
if(plxtPwrRecSelected > 0)
DicConsole.WriteLine("Selected PoweRec speed for currently inserted media is {0} Kb/sec ({1}x)", plxtPwrRecSelected, plxtPwrRecSelected/177);
if(plxtPwrRecMax > 0)
DicConsole.WriteLine("Maximum PoweRec speed for currently inserted media is {0} Kb/sec ({1}x)", plxtPwrRecMax, plxtPwrRecMax/177);
if(plxtPwrRecLast > 0)
DicConsole.WriteLine("Last used PoweRec was {0} Kb/sec ({1}x)", plxtPwrRecLast, plxtPwrRecLast/177);
}
}
else
DicConsole.WriteLine("PoweRec is disabled");
}
// TODO: Check it with a drive
plxtSense = dev.PlextorGetSilentMode(out plxtBuf, out senseBuf, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.WriteLine("Drive supports Plextor SilentMode");
if(plxtBuf[0] == 1)
{
DicConsole.WriteLine("Plextor SilentMode is enabled:");
if(plxtBuf[1] == 2)
DicConsole.WriteLine("\tAccess time is slow");
else
DicConsole.WriteLine("\tAccess time is fast");
if(plxtBuf[2] > 0)
DicConsole.WriteLine("\tCD read speed limited to {0}x", plxtBuf[2]);
if(plxtBuf[3] > 0 && plxtDvd)
DicConsole.WriteLine("\tDVD read speed limited to {0}x", plxtBuf[3]);
if(plxtBuf[4] > 0)
DicConsole.WriteLine("\tCD write speed limited to {0}x", plxtBuf[4]);
if(plxtBuf[6] > 0)
DicConsole.WriteLine("\tTray eject speed limited to {0}", -(plxtBuf[6] + 48));
if(plxtBuf[7] > 0)
DicConsole.WriteLine("\tTray eject speed limited to {0}", plxtBuf[7] - 47);
}
}
plxtSense = dev.PlextorGetGigaRec(out plxtBuf, out senseBuf, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.WriteLine("Drive supports Plextor GigaRec");
// TODO: Pretty print it
}
plxtSense = dev.PlextorGetSecuRec(out plxtBuf, out senseBuf, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.WriteLine("Drive supports Plextor SecuRec");
// TODO: Pretty print it
}
plxtSense = dev.PlextorGetSpeedRead(out plxtBuf, out senseBuf, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.Write("Drive supports Plextor SpeedRead");
if((plxtBuf[2] & 0x01) == 0x01)
DicConsole.WriteLine("and has it enabled");
else
DicConsole.WriteLine();
}
plxtSense = dev.PlextorGetHiding(out plxtBuf, out senseBuf, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.WriteLine("Drive supports hiding CD-Rs and forcing single session");
if((plxtBuf[2] & 0x02) == 0x02)
DicConsole.WriteLine("Drive currently hides CD-Rs");
if((plxtBuf[2] & 0x01) == 0x01)
DicConsole.WriteLine("Drive currently forces single session");
}
plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, false, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.WriteLine("Drive supports Plextor VariRec");
// TODO: Pretty print it
}
if(plxtDvd)
{
plxtSense = dev.PlextorGetVariRec(out plxtBuf, out senseBuf, true, dev.Timeout, out duration);
if(!plxtSense)
{
DicConsole.WriteLine("Drive supports Plextor VariRec for DVDs");
// TODO: Pretty print it
}
plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, false, dev.Timeout, out duration);
if(!plxtSense)
DicConsole.WriteLine("Drive supports bitsetting DVD+R book type");
plxtSense = dev.PlextorGetBitsetting(out plxtBuf, out senseBuf, true, dev.Timeout, out duration);
if(!plxtSense)
DicConsole.WriteLine("Drive supports bitsetting DVD+R DL book type");
plxtSense = dev.PlextorGetTestWriteDvdPlus(out plxtBuf, out senseBuf, dev.Timeout, out duration);
if(!plxtSense)
DicConsole.WriteLine("Drive supports test writing DVD+");
}
}
#endregion Plextor
break;
}
default:

View File

@@ -42,6 +42,7 @@ using System.Reflection;
using DiscImageChef.ImagePlugins;
using DiscImageChef.PartPlugins;
using DiscImageChef.Plugins;
using DiscImageChef.Console;
namespace DiscImageChef
{
@@ -76,7 +77,7 @@ namespace DiscImageChef
}
catch (Exception exception)
{
System.Console.Error.WriteLine(exception);
DicConsole.ErrorWriteLine("Exception {0}", exception);
}
}
@@ -94,7 +95,7 @@ namespace DiscImageChef
}
catch (Exception exception)
{
System.Console.Error.WriteLine(exception);
DicConsole.ErrorWriteLine("Exception {0}", exception);
}
}
@@ -112,7 +113,7 @@ namespace DiscImageChef
}
catch (Exception exception)
{
System.Console.Error.WriteLine(exception);
DicConsole.ErrorWriteLine("Exception {0}", exception);
}
}
}