From 44c97f58a238d8bbccde55659b61f79a12065226 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Thu, 15 Oct 2015 05:00:47 +0000 Subject: [PATCH] first pass at writing to log file and telling foxtrotgps to plot track git-svn-id: https://svn.code.sf.net/p/freetel/code@2444 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/fsk_horus.m | 11 ++++++++--- codec2-dev/octave/fsk_horus_stream.m | 20 +++++++++++++++++++- 2 files changed, 27 insertions(+), 4 deletions(-) mode change 100644 => 100755 codec2-dev/octave/fsk_horus_stream.m diff --git a/codec2-dev/octave/fsk_horus.m b/codec2-dev/octave/fsk_horus.m index 3ca303fe..4a4b309f 100644 --- a/codec2-dev/octave/fsk_horus.m +++ b/codec2-dev/octave/fsk_horus.m @@ -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); diff --git a/codec2-dev/octave/fsk_horus_stream.m b/codec2-dev/octave/fsk_horus_stream.m old mode 100644 new mode 100755 index 5355d32d..6db02f99 --- a/codec2-dev/octave/fsk_horus_stream.m +++ b/codec2-dev/octave/fsk_horus_stream.m @@ -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"); -- 2.25.1