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-01-10 05:35:05 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-01-10 05:35:05 +0300
commita840b0fcf413b039ce48c1f1e7f676d27f302c9d (patch)
tree9754349dde30453385d7b353aacd62653a6e7032 /FelLib
parent3c251a0c90be32e18545cd028955ea40a064749a (diff)
Finally 'pipe read' problem solved! Also added idiot protection.
Diffstat (limited to 'FelLib')
-rw-r--r--FelLib/AWUSBRequest.cs2
-rw-r--r--FelLib/Fel.cs31
2 files changed, 30 insertions, 3 deletions
diff --git a/FelLib/AWUSBRequest.cs b/FelLib/AWUSBRequest.cs
index 6984c457..d026ba6b 100644
--- a/FelLib/AWUSBRequest.cs
+++ b/FelLib/AWUSBRequest.cs
@@ -49,10 +49,12 @@ namespace com.clusterrr.FelLib
data[15] = CmdLen; // cmd_len
data[16] = (byte)Cmd;
data[17] = 0; // reserved3
+
data[18] = (byte)(Len & 0xFF); // len
data[19] = (byte)((Len >> 8) & 0xFF); // len
data[20] = (byte)((Len >> 16) & 0xFF); // len
data[21] = (byte)((Len >> 24) & 0xFF); // len
+
return data;
}
}
diff --git a/FelLib/Fel.cs b/FelLib/Fel.cs
index 4a99bbb8..d6f51059 100644
--- a/FelLib/Fel.cs
+++ b/FelLib/Fel.cs
@@ -19,6 +19,7 @@ namespace com.clusterrr.FelLib
byte inEndp = 0;
byte outEndp = 0;
const int ReadTimeout = 1000;
+ const int WriteTimeout = 1000;
public const int MaxBulkSize = 0x10000;
UInt16 vid, pid;
bool DramInitDone = false;
@@ -69,14 +70,27 @@ namespace com.clusterrr.FelLib
else
outEndp = pipe.Address;
}
- device.Pipes[outEndp].Policy.PipeTransferTimeout = ReadTimeout;
- ClearInputBuffer();
+ device.Pipes[inEndp].Policy.PipeTransferTimeout = ReadTimeout;
+ device.Pipes[outEndp].Policy.PipeTransferTimeout = WriteTimeout;
+ //ClearInputBuffer();
if (VerifyDevice().Board != 0x00166700) throw new FelException("Invalid board ID");
}
public void Close()
{
if (device != null)
{
+ try
+ {
+ device.Pipes[inEndp].Abort();
+ }
+ catch { }
+ try
+ {
+ device.Pipes[outEndp].Abort();
+ }
+ catch
+ {
+ }
device.Dispose();
device = null;
}
@@ -157,7 +171,15 @@ namespace com.clusterrr.FelLib
public AWFELVerifyDeviceResponse VerifyDevice()
{
FelRequest(AWFELStandardRequest.RequestType.FEL_VERIFY_DEVICE);
- var resp = FelRead(32);
+ byte[] resp;
+ try
+ {
+ resp = FelRead(32);
+ }
+ catch
+ {
+ resp = new byte[32];
+ }
var status = new AWFELStatusResponse(FelRead(8));
return new AWFELVerifyDeviceResponse(resp);
}
@@ -317,7 +339,10 @@ namespace com.clusterrr.FelLib
{
errorCount++;
if (errorCount >= 10)
+ {
+ Close();
throw ex;
+ }
Thread.Sleep(2000);
}
}