protect against boundary condition
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 15 Oct 2015 07:30:19 +0000 (07:30 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 15 Oct 2015 07:30:19 +0000 (07:30 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2445 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/fsk_horus_stream.m

index 6db02f990e46b8279f8a9a44e8dfc7ccea1df69f..f9aa1a2b8386a4a667402bb3ee6cdfd1154931aa 100755 (executable)
@@ -20,7 +20,7 @@ fsk_horus_as_a_lib = 1;
 fsk_horus;  
 
 gps_log = "~/Desktop/gps_log.txt"
-system_command = "echo -n \"/home/david/Desktop/gps_log.txt\" | nc -u -q1 127.0.0.1 21234"
+system_command = "echo -n \"/home/david/Desktop/gps_log.txt\" | nc -u -q1 127.0.0.1 21234";
 
 more off;
 states = fsk_horus_init();
@@ -75,15 +75,17 @@ while c
       rx_bits_buf =  rx_bits_buf(uw_loc2-1:length(rx_bits_buf));
 
       % extract GPS coords and save to log file for mapping software
+      % TODO: sanitise, make sure they are all numbers, decimal point in right place
 
       str_split = strsplit(str,",");
-      lat = str_split{1,4}; long = str_split{1,5};
-      f = fopen(gps_log,"at");
-      fprintf(f,"%s,%s\n", lat, long);
-      fclose(f);
-
-      % thin out log file to points_max points to lighten plotting load
-      % TBC
+      if length(str_split) > 4
+        lat = str_split{1,4}; long = str_split{1,5};
+        f = fopen(gps_log,"at");
+        fprintf(f,"%s,%s\n", lat, long);
+        fclose(f);
+      end
+
+      % TODO: thin out log file to points_max points to lighten plotting load
 
       % tell foxtrotGPS to plot track