[chronojump] Encoder capture safe no crash if port cannot open



commit 4447fd0347ee594f7af97a3a3cb563a254f0a2b0
Author: Xavier de Blas <xaviblas gmail com>
Date:   Fri Feb 22 00:36:33 2013 +0100

    Encoder capture safe no crash if port cannot open

 rdotnet/Makefile   |   20 ++++++++++----------
 src/gui/encoder.cs |   38 ++++++++++++++++++++++++++++++--------
 2 files changed, 40 insertions(+), 18 deletions(-)
---
diff --git a/rdotnet/Makefile b/rdotnet/Makefile
index 333f8ad..f186655 100644
--- a/rdotnet/Makefile
+++ b/rdotnet/Makefile
@@ -49,8 +49,8 @@ POST_INSTALL = :
 NORMAL_UNINSTALL = :
 PRE_UNINSTALL = :
 POST_UNINSTALL = :
-build_triplet = i686-pc-linux-gnu
-host_triplet = i686-pc-linux-gnu
+build_triplet = x86_64-unknown-linux-gnu
+host_triplet = x86_64-unknown-linux-gnu
 subdir = rdotnet
 DIST_COMMON = $(srcdir)/Makefile.am $(srcdir)/Makefile.in
 ACLOCAL_M4 = $(top_srcdir)/aclocal.m4
@@ -110,7 +110,7 @@ AUTOMAKE = ${SHELL} /home/xavier/informatica/progs_meus/chronojump/chronojump/mi
 AWK = gawk
 CC = gcc
 CCDEPMODE = depmode=gcc3
-CESARPLAYER_CFLAGS = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/i386-linux-gnu/gtk-2.0/include 
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 
-I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/i386-linux-gnu/glib-2.0/include 
-I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gstreamer-0.10 
-I/usr/include/libxml2  
+CESARPLAYER_CFLAGS = -pthread -I/usr/include/gtk-2.0 -I/usr/lib/x86_64-linux-gnu/gtk-2.0/include 
-I/usr/include/atk-1.0 -I/usr/include/cairo -I/usr/include/gdk-pixbuf-2.0 -I/usr/include/pango-1.0 
-I/usr/include/gio-unix-2.0/ -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include 
-I/usr/include/pixman-1 -I/usr/include/freetype2 -I/usr/include/libpng12 -I/usr/include/gstreamer-0.10 
-I/usr/include/libxml2  
 CESARPLAYER_LIBS = -pthread -lgtk-x11-2.0 -latk-1.0 -lpangoft2-1.0 -lfreetype -lfontconfig -lgdk-x11-2.0 
-lpangocairo-1.0 -lgdk_pixbuf-2.0 -lpango-1.0 -lcairo -lgio-2.0 -lgstaudio-0.10 -lgstvideo-0.10 
-lgstpbutils-0.10 -lgstinterfaces-0.10 -lgstapp-0.10 -lgstbase-0.10 -lgsttag-0.10 -lgstreamer-0.10 
-lgobject-2.0 -lgmodule-2.0 -lgthread-2.0 -lrt -lxml2 -lglib-2.0  
 CFLAGS = -g -O2
 CPP = gcc -E
@@ -139,7 +139,7 @@ INSTALL_DATA = ${INSTALL} -m 644
 INSTALL_PROGRAM = ${INSTALL}
 INSTALL_SCRIPT = ${INSTALL}
 INSTALL_STRIP_PROGRAM = $(install_sh) -c -s
-LD = /usr/bin/ld
+LD = /usr/bin/ld -m elf_x86_64
 LDFLAGS = 
 LIBOBJS = 
 LIBS = 
@@ -197,11 +197,11 @@ am__quote =
 am__tar = $${TAR-tar} chof - "$$tardir"
 am__untar = $${TAR-tar} xf -
 bindir = ${exec_prefix}/bin
-build = i686-pc-linux-gnu
+build = x86_64-unknown-linux-gnu
 build_alias = 
-build_cpu = i686
+build_cpu = x86_64
 build_os = linux-gnu
-build_vendor = pc
+build_vendor = unknown
 builddir = .
 datadir = ${datarootdir}
 datarootdir = ${prefix}/share
@@ -211,11 +211,11 @@ exec_prefix = /usr/local
 expanded_bindir = /usr/local/bin
 expanded_datadir = /usr/local/share
 expanded_libdir = /usr/local/lib
-host = i686-pc-linux-gnu
+host = x86_64-unknown-linux-gnu
 host_alias = 
-host_cpu = i686
+host_cpu = x86_64
 host_os = linux-gnu
-host_vendor = pc
+host_vendor = unknown
 htmldir = ${docdir}
 includedir = ${prefix}/include
 infodir = ${datarootdir}/info
diff --git a/src/gui/encoder.cs b/src/gui/encoder.cs
index bf75d8a..9705ace 100644
--- a/src/gui/encoder.cs
+++ b/src/gui/encoder.cs
@@ -892,6 +892,22 @@ public partial class ChronoJumpWindow
                Log.WriteLine("F22222222222222");
        }
        
+       private bool runEncoderCaptureCsharpCheckPort(string port) {
+               Log.WriteLine("00a 1");
+               SerialPort sp = new SerialPort(port);
+               Log.WriteLine("00b 1");
+               sp.BaudRate = 115200;
+               Log.WriteLine("00c 1");
+               try {
+                       sp.Open();
+                       sp.Close();
+               } catch {
+                       return false;
+               }
+               Log.WriteLine("00d 1");
+               return true;
+       }
+
        //private bool runEncoderCaptureCsharp(string title, EncoderStruct es, string port) 
        private bool runEncoderCaptureCsharp(string title, int time, string outputData1, string port) 
        {
@@ -900,13 +916,13 @@ public partial class ChronoJumpWindow
                //int yrange = height;
                double realHeight = 1000 * 2 * spin_encoder_capture_height.Value;
                
-               Log.WriteLine("00a");
+               Log.WriteLine("00a 2");
                SerialPort sp = new SerialPort(port);
-               Log.WriteLine("00b");
+               Log.WriteLine("00b 2");
                sp.BaudRate = 115200;
-               Log.WriteLine("00c");
+               Log.WriteLine("00c 2");
                sp.Open();
-               Log.WriteLine("00d");
+               Log.WriteLine("00d 2");
                        
                encoderCaptureCountdown = time;
                //int recordingTime = es.Ep.Time * 1000;
@@ -2112,10 +2128,16 @@ Log.WriteLine("RRR4");
                if(mode == encoderModes.CAPTURE) {
                        //encoder_pulsebar_capture.Text = Catalog.GetString("Please, wait.");
                        Log.WriteLine("CCCCCCCCCCCCCCC");
-                       encoderThread = new Thread(new ThreadStart(captureCsharp));
-                       GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCapture));
-                       Log.WriteLine("DDDDDDDDDDDDDDD");
-                       encoderButtonsSensitive(encoderSensEnum.PROCESSINGCAPTURE);
+                       if( runEncoderCaptureCsharpCheckPort(chronopicWin.GetEncoderPort()) ) {
+                               encoderThread = new Thread(new ThreadStart(captureCsharp));
+                               GLib.Idle.Add (new GLib.IdleHandler (pulseGTKEncoderCapture));
+                               Log.WriteLine("DDDDDDDDDDDDDDD");
+                               encoderButtonsSensitive(encoderSensEnum.PROCESSINGCAPTURE);
+                       } else {
+                               new DialogMessage(Constants.MessageTypes.WARNING, 
+                                       Catalog.GetString("Chronopic port is not configured."));
+                               return;
+                       }
                } else if(mode == encoderModes.CALCULECURVES || mode == encoderModes.RECALCULATE_OR_LOAD) {
                        //image is inside (is smaller than) viewport
                        image_encoder_width = UtilGtk.WidgetWidth(viewport_image_encoder_capture)-5; 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]