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-03-18 04:41:54 +0300
committerAlexey 'Cluster' Avdyukhin <clusterrr@clusterrr.com>2017-03-18 04:41:54 +0300
commitd1227b9af15cbf3fc8d09c1af0945b06457ef727 (patch)
tree3691c3e74603532ec41129fbbe65739bb0fda755 /Clovershell
parent24d29a664710d19107b23a3430995daf648c54ff (diff)
NES/Famicom autodetection
Diffstat (limited to 'Clovershell')
-rw-r--r--Clovershell/ClovershellConnection.cs15
-rw-r--r--Clovershell/ExecConnection.cs1
2 files changed, 15 insertions, 1 deletions
diff --git a/Clovershell/ClovershellConnection.cs b/Clovershell/ClovershellConnection.cs
index 39f18ac5..a99127f9 100644
--- a/Clovershell/ClovershellConnection.cs
+++ b/Clovershell/ClovershellConnection.cs
@@ -31,6 +31,8 @@ namespace com.clusterrr.clovershell
bool autoreconnect = false;
byte[] lastPingResponse = null;
DateTime lastAliveTime;
+ public delegate void OnClovershellConnected();
+ public event OnClovershellConnected OnConnected = delegate{};
internal enum ClovershellCommand
{
@@ -242,8 +244,9 @@ namespace com.clusterrr.clovershell
epReader.ReadBufferSize = 65536;
epReader.DataReceived += epReader_DataReceived;
epReader.DataReceivedEnabled = true;
- online = true;
lastAliveTime = DateTime.Now;
+ online = true;
+ OnConnected();
while (device.mUsbRegistry.IsAlive)
{
Thread.Sleep(100);
@@ -573,6 +576,16 @@ namespace com.clusterrr.clovershell
return (int)(DateTime.Now - start).TotalMilliseconds;
}
+ public string ExecuteSimple(string command, int timeout = 1500, bool throwOnNonZero = false)
+ {
+ var stdOut = new MemoryStream();
+ Execute(command, null, stdOut, null, timeout, throwOnNonZero);
+ var buff = new byte[stdOut.Length];
+ stdOut.Seek(0, SeekOrigin.Begin);
+ stdOut.Read(buff, 0, buff.Length);
+ return Encoding.UTF8.GetString(buff).Trim();
+ }
+
public int Execute(string command, Stream stdin = null, Stream stdout = null, Stream stderr = null, int timeout = 0, bool throwOnNonZero = false)
{
if (throwOnNonZero && stderr == null)
diff --git a/Clovershell/ExecConnection.cs b/Clovershell/ExecConnection.cs
index 7389fd40..913d07b3 100644
--- a/Clovershell/ExecConnection.cs
+++ b/Clovershell/ExecConnection.cs
@@ -59,6 +59,7 @@ namespace com.clusterrr.clovershell
connection.writeUsb(ClovershellConnection.ClovershellCommand.CMD_EXEC_STDIN, (byte)id, buffer, l);
else
break;
+ LastDataTime = DateTime.Now;
if (stdinQueue > 32 * 1024 && connection.IsOnline)
{
Debug.WriteLine(string.Format("queue: {0} / {1}, {2}MB / {3}MB ({4}%)",