Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/ClusterM/hakchi2.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/FelLib
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-10 16:44:59 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-10 16:47:23 +0300
commit6af516520f949979686adc4399926d3fe3dc0441 (patch)
tree70487d51693c4f45b1d9839ee9294b10520384d8 /FelLib
parent115c6a445c519103eb7aaeb09930f104d94228fc (diff)
Reduced size of original games, fixes, cleanup
Diffstat (limited to 'FelLib')
-rw-r--r--FelLib/Fel.cs43
1 files changed, 29 insertions, 14 deletions
diff --git a/FelLib/Fel.cs b/FelLib/Fel.cs
index ca44c35a..7e3a8bdd 100644
--- a/FelLib/Fel.cs
+++ b/FelLib/Fel.cs
@@ -64,14 +64,14 @@ namespace com.clusterrr.FelLib
var fel = new Fel();
try
{
- fel.Open(vid, pid);
- Debug.WriteLine("Device detection successful");
- return true;
- }
- catch (Exception ex)
- {
- Debug.WriteLine("Device detection error: " + ex.Message + ex.StackTrace);
- return false;
+ if (fel.Open(vid, pid))
+ {
+ Debug.WriteLine("Device detection successful");
+ return true;
+ } else
+ {
+ return false;
+ }
}
finally
{
@@ -79,12 +79,12 @@ namespace com.clusterrr.FelLib
}
}
- public void Open(UInt16 vid, UInt16 pid)
+ public bool Open(UInt16 vid, UInt16 pid)
{
this.vid = vid;
this.pid = pid;
Close();
- Debug.WriteLine("Trying to open device...");
+ //Debug.WriteLine("Trying to open device...");
var devices = UsbDevice.AllDevices;
device = null;
foreach (UsbRegistry regDevice in devices)
@@ -95,7 +95,13 @@ namespace com.clusterrr.FelLib
break;
}
}
- if (device == null) throw new FelException("Device with such VID and PID not found");
+ if (device == null)
+ {
+#if VERY_DEBUG
+ Debug.WriteLine("Device with such VID and PID not found");
+#endif
+ return false;
+ }
IUsbDevice wholeUsbDevice = device as IUsbDevice;
if (!ReferenceEquals(wholeUsbDevice, null))
@@ -135,12 +141,21 @@ namespace com.clusterrr.FelLib
}
}
if (inEndp != 0x82 || outEndp != 0x01)
- throw new Exception("Uncorrect FEL device");
+ {
+ Debug.WriteLine("Uncorrect FEL device/mode");
+ return false;
+ }
epReader = device.OpenEndpointReader((ReadEndpointID)inEndp, 65536);
epWriter = device.OpenEndpointWriter((WriteEndpointID)outEndp);
Debug.WriteLine("Trying to verify device");
- if (VerifyDevice().Board != 0x00166700) throw new FelException("Invalid board ID: " + VerifyDevice().Board);
+ if (VerifyDevice().Board != 0x00166700)
+ {
+ Debug.WriteLine("Invalid board ID: " + VerifyDevice().Board);
+ return false;
+ }
+
+ return true;
}
public void Close()
{
@@ -394,7 +409,7 @@ namespace com.clusterrr.FelLib
{
Thread.Sleep(500);
callback?.Invoke(CurrentAction.RunningCommand, command);
- }
+ }
int errorCount = 0;
while (true)
{