first pass at writing to log file and telling foxtrotgps to plot track
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 15 Oct 2015 05:00:47 +0000 (05:00 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Thu, 15 Oct 2015 05:00:47 +0000 (05:00 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2444 01035d8c-6547-0410-b346-abe4f91aad63

codec2-dev/octave/fsk_horus.m
codec2-dev/octave/fsk_horus_stream.m [changed mode: 0644->0755]

index 3ca303fe612aadb8a09fc45903538766c40bacb1..4a4b309f2c131d266f9f1fb9a15193d878e76f95 100644 (file)
@@ -306,7 +306,8 @@ function [str crc_ok] = extract_ascii(states, rx_bits_buf, uw_loc1, uw_loc2)
   nfield = states.nfield;
   npad = states.npad;
 
-  str = []; str_dec = []; nstr = 0;
+  str = []; str_dec = []; nstr = 0; ptx_crc = 1; rx_crc = "";
+
   st = uw_loc1 + length(states.uw);  % first bit of first char
   for i=st:nfield+npad:uw_loc2
     field = rx_bits_buf(i:i+nfield-1);
@@ -330,8 +331,12 @@ function [str crc_ok] = extract_ascii(states, rx_bits_buf, uw_loc1, uw_loc2)
       str_dec = [str_dec ch_dec];
     end
   end
-  tx_crc = str(ptx_crc:ptx_crc+3);
-  crc_ok = strcmp(tx_crc, rx_crc);
+  if (ptx_crc+3) <= length(str)
+    tx_crc = str(ptx_crc:ptx_crc+3);
+    crc_ok = strcmp(tx_crc, rx_crc);
+  else
+    crc_ok = 0;
+  end
   str = str(1:ptx_crc-2);
   if crc_ok
     str = sprintf("%s CRC OK", str);
old mode 100644 (file)
new mode 100755 (executable)
index 5355d32..6db02f9
@@ -19,6 +19,9 @@
 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"
+
 more off;
 states = fsk_horus_init();
 N = states.N;
@@ -64,12 +67,27 @@ while c
     uw_loc2 = find_uw(states, uw_loc1+length(uw), rx_bits_buf);
 
     if uw_loc2 != -1
-      str = extract_ascii(states, rx_bits_buf, uw_loc1, uw_loc2);
+      [str crc_ok] = extract_ascii(states, rx_bits_buf, uw_loc1, uw_loc2);
       printf("%s         \n", str);
 
       % throw out used bits in buffer
 
       rx_bits_buf =  rx_bits_buf(uw_loc2-1:length(rx_bits_buf));
+
+      % extract GPS coords and save to log file for mapping software
+
+      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
+
+      % tell foxtrotGPS to plot track
+
+      system(system_command);
     end
   end
   [s,c] = fread(stdin, N, "short");