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
diff options
context:
space:
mode:
authorAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-20 14:33:55 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-10-20 14:33:55 +0300
commit52fee8252f3bd1b8f88f3d28a99bc4c315b6ec9a (patch)
treeb12bb17dcce2c99a93d4a9e7ec17bf2f94220971 /Clovershell
parent7d014b7da4b6d2af1e62ef7f665342cee0e1b467 (diff)
clovershell fix
Diffstat (limited to 'Clovershell')
-rw-r--r--Clovershell/ClovershellConnection.cs25
1 files changed, 20 insertions, 5 deletions
diff --git a/Clovershell/ClovershellConnection.cs b/Clovershell/ClovershellConnection.cs
index 1ca67883..a4662df0 100644
--- a/Clovershell/ClovershellConnection.cs
+++ b/Clovershell/ClovershellConnection.cs
@@ -33,6 +33,8 @@ namespace com.clusterrr.clovershell
DateTime lastAliveTime;
public delegate void OnClovershellConnected();
public event OnClovershellConnected OnConnected = delegate { };
+ public delegate void OnClovershellDisconnected();
+ public event OnClovershellDisconnected OnDisconnected = delegate { };
internal enum ClovershellCommand
{
@@ -148,8 +150,16 @@ namespace com.clusterrr.clovershell
void dropAll()
{
- writeUsb(ClovershellCommand.CMD_SHELL_KILL_ALL, 0);
- writeUsb(ClovershellCommand.CMD_EXEC_KILL_ALL, 0);
+ try
+ {
+ writeUsb(ClovershellCommand.CMD_SHELL_KILL_ALL, 0);
+ }
+ catch { }
+ try
+ {
+ writeUsb(ClovershellCommand.CMD_EXEC_KILL_ALL, 0);
+ }
+ catch { }
for (var i = 0; i < shellConnections.Length; i++)
if (shellConnections[i] != null)
{
@@ -266,7 +276,12 @@ namespace com.clusterrr.clovershell
break;
}
}
- if (online) Debug.WriteLine("clovershell disconnected");
+ if (online)
+ {
+ dropAll();
+ OnDisconnected();
+ Debug.WriteLine("clovershell disconnected");
+ }
online = false;
if (device != null)
device.Close();
@@ -386,9 +401,9 @@ namespace com.clusterrr.clovershell
buff[1] = 0;
buff[2] = 0;
buff[3] = 0;
- r= epWriter.Write(buff, 0, buff.Length, 1000, out tLen);
+ r = epWriter.Write(buff, 0, buff.Length, 1000, out tLen);
if (tLen != buff.Length)
- throw new ClovershellException("kill all exec: write error - "+r.ToString());
+ throw new ClovershellException("kill all exec: write error - " + r.ToString());
}
internal void writeUsb(ClovershellCommand cmd, byte arg, byte[] data = null, int pos = 0, int l = -1)