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);
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);
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;
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");