diff options
author | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-10-20 14:33:55 +0300 |
---|---|---|
committer | Alexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com> | 2017-10-20 14:33:55 +0300 |
commit | 52fee8252f3bd1b8f88f3d28a99bc4c315b6ec9a (patch) | |
tree | b12bb17dcce2c99a93d4a9e7ec17bf2f94220971 /Clovershell | |
parent | 7d014b7da4b6d2af1e62ef7f665342cee0e1b467 (diff) |
clovershell fix
Diffstat (limited to 'Clovershell')
-rw-r--r-- | Clovershell/ClovershellConnection.cs | 25 |
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)
|