diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-01-16 18:43:38 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-01-16 18:43:38 +0300 |
commit | 2623e972f7f2b2568e66a2b596272668aafd1c9d (patch) | |
tree | 567f2b836b0518b988cc8081d216d7869a181e08 /FelLib | |
parent | 2e07a79d4ddd78bc0ac06bf87c9e86979cce414b (diff) |
Many debug info for problem users
Diffstat (limited to 'FelLib')
-rw-r--r-- | FelLib/Fel.cs | 51 | ||||
-rw-r--r-- | FelLib/WinUSBNet/API/DeviceManagement.cs | 10 |
2 files changed, 13 insertions, 48 deletions
diff --git a/FelLib/Fel.cs b/FelLib/Fel.cs index ba618d6d..012cb4d3 100644 --- a/FelLib/Fel.cs +++ b/FelLib/Fel.cs @@ -1,7 +1,7 @@ using MadWizard.WinUSBNet;
using System;
using System.Collections.Generic;
-using System.IO;
+using System.Diagnostics;
using System.Linq;
using System.Text;
using System.Threading;
@@ -65,16 +65,12 @@ namespace com.clusterrr.FelLib try
{
fel.Open(vid, pid);
-#if DEBUG
- DebugLog("Device detection successful");
-#endif
+ Debug.WriteLine("Device detection successful");
return true;
}
catch (Exception ex)
{
-#if DEBUG
- DebugLog("Device detection error: " + ex.Message + ex.StackTrace);
-#endif
+ Debug.WriteLine("Device detection error: " + ex.Message + ex.StackTrace);
return false;
}
finally
@@ -88,36 +84,26 @@ namespace com.clusterrr.FelLib this.vid = vid;
this.pid = pid;
Close();
-#if DEBUG
- DebugLog("Trying to open device...");
-#endif
+ Debug.WriteLine("Trying to open device...");
device = USBDevice.GetSingleDevice(vid, pid);
if (device == null) throw new FelException("Device with such VID and PID not found");
-#if DEBUG
- DebugLog("Checking USB endpoints...");
-#endif
+ Debug.WriteLine("Checking USB endpoints...");
foreach (var pipe in device.Pipes)
{
if (pipe.IsIn)
{
inEndp = pipe.Address;
-#if DEBUG
- DebugLog("IN endpoint found: " + inEndp);
-#endif
+ Debug.WriteLine("IN endpoint found: " + inEndp);
}
else
{
outEndp = pipe.Address;
-#if DEBUG
- DebugLog("Out endpoint found: " + outEndp);
-#endif
+ Debug.WriteLine("Out endpoint found: " + outEndp);
}
}
device.Pipes[inEndp].Policy.PipeTransferTimeout = ReadTimeout;
device.Pipes[outEndp].Policy.PipeTransferTimeout = WriteTimeout;
-#if DEBUG
- DebugLog("Trying to verify device");
-#endif
+ Debug.WriteLine("Trying to verify device");
if (VerifyDevice().Board != 0x00166700) throw new FelException("Invalid board ID: " + VerifyDevice().Board);
}
public void Close()
@@ -143,19 +129,14 @@ namespace com.clusterrr.FelLib private void WriteToUSB(byte[] buffer)
{
-#if DEBUG
- DebugLog("-> " + BitConverter.ToString(buffer));
-#endif
-
+ Debug.WriteLine("-> " + BitConverter.ToString(buffer));
device.Pipes[outEndp].Write(buffer);
}
private int ReadFromUSB(byte[] buffer, int offset, int length)
{
var data = device.Pipes[inEndp].Read(buffer, offset, length);
-#if DEBUG
- DebugLog("<- " + BitConverter.ToString(buffer));
-#endif
+ Debug.WriteLine("<- " + BitConverter.ToString(buffer));
return data;
}
private byte[] ReadFromUSB(UInt32 length)
@@ -389,17 +370,5 @@ namespace com.clusterrr.FelLib }
}
}
-
-#if DEBUG
- public static void DebugLog(string text)
- {
- Console.WriteLine(text);
- try
- {
- File.AppendAllText("debug.txt", DateTime.Now + ": " + text + "\r\n");
- }
- catch { }
- }
-#endif
}
}
diff --git a/FelLib/WinUSBNet/API/DeviceManagement.cs b/FelLib/WinUSBNet/API/DeviceManagement.cs index d094025e..c283a26f 100644 --- a/FelLib/WinUSBNet/API/DeviceManagement.cs +++ b/FelLib/WinUSBNet/API/DeviceManagement.cs @@ -14,7 +14,7 @@ using System.Runtime.InteropServices; using System.Collections.Generic;
using System.Windows.Forms;
using System.Text.RegularExpressions;
-using com.clusterrr.FelLib;
+using System.Diagnostics;
namespace MadWizard.WinUSBNet.API
{
@@ -239,18 +239,14 @@ namespace MadWizard.WinUSBNet.API // Get the String containing the devicePathName.
try
{
-#if DEBUG
- Fel.DebugLog("Trying to parse device: " + pathName);
-#endif
+ Debug.WriteLine("Trying to parse device: " + pathName);
DeviceDetails details = GetDeviceDetails(pathName, deviceInfoSet, da);
if (details.VID == vid && details.PID == pid)
deviceList.Add(details);
}
catch (APIException ex)
{
-#if DEBUG
- Fel.DebugLog("Can't parse this device: " + ex.Message + ex.StackTrace);
-#endif
+ Debug.WriteLine("Can't parse this device: " + ex.Message + ex.StackTrace);
continue;
}
}
|