[moserial] Fixed over-active file writing in record mode, pre-rel version bump



commit 578c2580e7e968faeb800042cf737cf1e7c677b3
Author: Michael J. Chudobiak <mjc avtechpulse com>
Date:   Wed Jan 18 14:35:04 2012 -0500

    Fixed over-active file writing in record mode, pre-rel version bump

 NEWS                          |    5 +++++
 configure.ac                  |    2 +-
 src/MainWindow.vala           |    2 +-
 src/SerialConnection.vala     |   15 +++++++++++----
 src/SerialStreamRecorder.vala |   17 ++++++++++++++---
 5 files changed, 32 insertions(+), 9 deletions(-)
---
diff --git a/NEWS b/NEWS
index d6ce83d..22b3288 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,8 @@
+Version 3.0.3
+-------------
+	* fixed over-active file writing in record mode
+
+
 Version 3.0.2
 -------------
 	* support BSD device names
diff --git a/configure.ac b/configure.ac
index 8999cc2..db3e5ad 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1,4 +1,4 @@
-AC_INIT([moserial],[3.0.2],[http://bugzilla.gnome.org/enter_bug.cgi?product=moserial])
+AC_INIT([moserial],[3.0.3],[http://bugzilla.gnome.org/enter_bug.cgi?product=moserial])
 AC_CONFIG_SRCDIR([Makefile.am])
 AC_CONFIG_HEADERS(config.h)
 AM_INIT_AUTOMAKE([dist-bzip2])
diff --git a/src/MainWindow.vala b/src/MainWindow.vala
index df0d401..856f491 100644
--- a/src/MainWindow.vala
+++ b/src/MainWindow.vala
@@ -727,11 +727,11 @@ public class moserial.MainWindow : Gtk.Window //Have to extend Gtk.Winow to get
 						recordTimeoutID = GLib.Timeout.add_seconds(currentPreferences.timeout, recordTimeout);
 				}
 
-                                streamRecorder.writeIncoming(data[x]);
 				recordDataReceived=true;
                                 bytecountbar.pop(bytecountbarContext);
                                 bytecountbar.push(bytecountbarContext, sc.getBytecountbarString());
                         }
+                        streamRecorder.writeIncoming(data);
                 }
         }
 
diff --git a/src/SerialConnection.vala b/src/SerialConnection.vala
index 8bf5059..516292c 100644
--- a/src/SerialConnection.vala
+++ b/src/SerialConnection.vala
@@ -47,6 +47,7 @@ public class moserial.SerialConnection : GLib.Object
 						 GLib.N_("ESC end"), 
 						 GLib.N_("No end") };
 	public const string[] LineEndValues = {"\r\n", "\r", "\n", "\t", "\x1b", ""}; 
+	public const int max_buf_size = 128;
 
 
 	uint? sourceId;
@@ -127,8 +128,8 @@ public class moserial.SerialConnection : GLib.Object
         }
 
         private bool readBytes(GLib.IOChannel source, GLib.IOCondition condition) {
-                uchar[] m_buf = new uchar[128];
-                int bytesRead=(int)Posix.read(m_fd, m_buf, 128);
+                uchar[] m_buf = new uchar[max_buf_size];
+                int bytesRead=(int)Posix.read(m_fd, m_buf, max_buf_size);
 		rx += (ulong) bytesRead;
 
                 while(Gtk.events_pending() || Gdk.events_pending())
@@ -136,9 +137,15 @@ public class moserial.SerialConnection : GLib.Object
 
                 if (bytesRead<0)
                         return false;
-                newData(m_buf, bytesRead);
+
+                uchar[] sized_buf = new uchar[bytesRead];
+		for (int x=0; x<bytesRead; x++) {
+			sized_buf[x] = m_buf[x];
+                }
+
+                newData(sized_buf, bytesRead);
                 if(localEcho)
-                	sendBytes((char[])m_buf, bytesRead);
+                	sendBytes((char[])sized_buf, bytesRead);
                 return connected;
         }
 	
diff --git a/src/SerialStreamRecorder.vala b/src/SerialStreamRecorder.vala
index e1b2233..524d9ea 100644
--- a/src/SerialStreamRecorder.vala
+++ b/src/SerialStreamRecorder.vala
@@ -55,18 +55,29 @@ public class moserial.SerialStreamRecorder {
 			}
 			catch(GLib.Error e) {
 				stdout.printf(_("error: %s\n"), e.message);
-				// What should be done here?
 			}
 		}
 	
 	}
+	private void write_array(uchar[] data) {
+		if(isOpen) {
+			try {
+	                        fos.write(data, null);
+			}
+			catch(GLib.Error e) {
+				stdout.printf(_("error: %s\n"), e.message);
+			}
+		}
+	
+	}
+
 	public void writeOutgoing(uchar data) {
 		if(isOpen && (direction==Direction.OUTGOING || direction==Direction.BOTH))
 			write(data);
 	}
-	public void writeIncoming(uchar data) {
+	public void writeIncoming(uchar[] data) {
 		if(isOpen && (direction==Direction.INCOMING || direction==Direction.BOTH))
-			write(data);
+			write_array(data);
 	}
 	public void close (bool launch){
 		if(isOpen) {



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