[chronojump] SendCurve with try/catch to solve mono <4.4 problems
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] SendCurve with try/catch to solve mono <4.4 problems
- Date: Sat, 29 Apr 2017 13:18:30 +0000 (UTC)
commit 72b74244276f62b4367b9f61ee6124c429598ee8
Author: Xavier de Blas <xaviblas gmail com>
Date: Wed Apr 26 23:48:01 2017 +0200
SendCurve with try/catch to solve mono <4.4 problems
src/encoderCapture.cs | 4 +++-
src/encoderRProc.cs | 35 +++++++++++++++++++++++++++++++----
2 files changed, 34 insertions(+), 5 deletions(-)
---
diff --git a/src/encoderCapture.cs b/src/encoderCapture.cs
index e559eaf..84740e5 100644
--- a/src/encoderCapture.cs
+++ b/src/encoderCapture.cs
@@ -497,10 +497,12 @@ public abstract class EncoderCapture
if(compujump && Ecca.curvesAccepted == 0)
Networks.WakeUpRaspberryIfNeeded();
- encoderRProcCapture.SendCurve(
+ bool success = encoderRProcCapture.SendCurve(
ecc.startFrame,
UtilEncoder.CompressData(curve, 25)
//compressed
);
+ if(! success)
+ cancel = true;
Ecca.curvesAccepted ++;
Ecca.ecc.Add(ecc);
diff --git a/src/encoderRProc.cs b/src/encoderRProc.cs
index 158d0e8..2f15f76 100644
--- a/src/encoderRProc.cs
+++ b/src/encoderRProc.cs
@@ -192,7 +192,7 @@ public class EncoderRProcCapture : EncoderRProc
}
//here curve is sent compressed (string. eg: "0*5 1 0 -1*3 2")
- public void SendCurve(int startFrame, string curveCompressed)
+ public bool SendCurve(int startFrame, string curveCompressed)
{
/*
* curveCompressed print has made crash Chronojump once.
@@ -201,12 +201,39 @@ public class EncoderRProcCapture : EncoderRProc
*/
//LogB.Information("curveSend [displacement array]",curveCompressed);
+
//since 1.7.1 it's needed to send the startFrame in order to know the startFrame of the
accepted repetitions (on R)
//then this data will be used to save the "Best?" repetitions on C# without calling curves on
cont mode
- p.StandardInput.WriteLine(startFrame.ToString());
- p.StandardInput.WriteLine(curveCompressed); //this will send some lines because
compressed data comes with '\n's
- p.StandardInput.WriteLine("E"); //this will mean the 'E'nd of the curve. Then data
can be uncompressed on R
+ //TODO: a try/catch coluld be good here to solve this errors:
+ //System.IO.IOException: Write fault on path
/home/(user)/informatica/progs_meus/chronojump/chronojump/[Unknown]
+ // at System.IO.FileStream.WriteInternal (System.Byte[] src, Int32 offset, Int32 count)
[0x00000] in <filename unknown>:0
+ // at System.IO.FileStream.Write (System.Byte[] array, Int32 offset, Int32 count) [0x00000]
in <filename unknown>:0
+ // at System.IO.StreamWriter.FlushBytes () [0x00000] in <filename unknown>:0
+ // at System.IO.StreamWriter.FlushCore () [0x00000] in <filename unknown>:0
+ // at System.IO.StreamWriter.Write (System.String value) [0x00000] in <filename unknown>:0
+ // at System.IO.TextWriter.WriteLine (System.String value) [0x00000] in <filename unknown>:0
+ // at EncoderRProcCapture.SendCurve (Int32 startFrame, System.String curveCompressed)
[0x00000] in <filename unknown>:0
+ // at EncoderCapture.Capture (System.String outputData1, EncoderRProcCapture
encoderRProcCapture, Boolean compujump) [0x00000] in <filename unknown>:0
+ // at ChronoJumpWindow.encoderDoCaptureCsharp () [0x00000] in <filename unknown>:0
+ //
+ // maybe R capture process is dead
+ // this happened capturing after a 20 minutes delay
+
+ /*
+ * "Write fault on path" error fixed on Mono 4.4:
+ * http://www.mono-project.com/docs/about-mono/releases/4.4.0/
+ * https://bugzilla.xamarin.com/show_bug.cgi?id=32905
+ */
+ try {
+ p.StandardInput.WriteLine(startFrame.ToString());
+ p.StandardInput.WriteLine(curveCompressed); //this will send some lines because
compressed data comes with '\n's
+ p.StandardInput.WriteLine("E"); //this will mean the 'E'nd of the curve. Then
data can be uncompressed on R
+ } catch {
+ return false;
+ }
+
+ return true;
}
protected override void writeOptionsFile()
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]