% UW found Sometimes there may be several matches, returns the
% position of the best match to UW.
-function uw_start = find_uw(states, start_bit, rx_bits)
+function [uw_start best_corr] = find_uw(states, start_bit, rx_bits)
uw = states.uw;
mapped_rx_bits = 2*rx_bits - 1;
if crc_ok == 0
[str_flipped crc_flipped_ok rx_bits_log] = sd_bit_flipping(states.rtty, rx_bits_log, rx_bits_sd_log, uw_loc, uw_loc+states.rtty.max_packet_len);
- if crc_flipped_ok
- str = sprintf("%s fixed", str_flipped);
- end
end
% update memory of previous packet, we use this to guess where errors may be
if crc_ok || crc_flipped_ok
states.prev_pkt = rx_bits_log(uw_loc+length(states.rtty.uw):uw_loc+states.rtty.max_packet_len);
end
+
if crc_ok
str = sprintf("%s CRC OK", str);
else
- str = sprintf("%s CRC BAD", str);
+ if crc_flipped_ok
+ str = sprintf("%s fixed", str_flipped);
+ else
+ str = sprintf("%s CRC BAD", str);
+ end
end
printf("%s\n", str);
end
endfunction
-% Extract as many ASCII packets as we can from a great big buffer of bits,
+% Extract as many binary packets as we can from a great big buffer of bits,
% and send them to the C decoder for FEC decoding.
% horus_l2 can be compiled a bunch of different ways. You need to
% compile with:
uwstates = fsk_horus_init_binary_uw;
end
- states.verbose = 0x1 + 0x8;
+ states.verbose = 0x1;
N = states.N;
P = states.P;
f2_int_resample_log = [];
EbNodB_log = [];
ppm_log = [];
+ f1_log = [];
+ f2_log = [];
rx_bits_buf = zeros(1,2*nsym);
% First extract raw bits from samples ------------------------------------------------------
f2_int_resample_log = [f2_int_resample_log abs(states.f2_int_resample)];
EbNodB_log = [EbNodB_log states.EbNodB];
ppm_log = [ppm_log states.ppm];
+ f1_log = [f1_log states.f1];
+ f2_log = [f2_log states.f2];
if test_frame_mode == 1
states = ber_counter(states, test_frame, rx_bits_buf);
printf("plotting...\n");
figure(1);
+ plot(f1_log);
+ hold on;
+ plot(f2_log,'g');
+ hold off;
+
+ figure(2);
plot(f1_int_resample_log,'+')
hold on;
plot(f2_int_resample_log,'g+')
hold off;
- figure(2)
+ figure(3)
clf
subplot(211)
plot(norm_rx_timing_log)
plot(states.nerr_log)
title('num bit errors each frame')
- figure(3)
+ figure(4)
clf
plot(EbNodB_log);
title('Eb/No estimate')
- figure(4)
+ figure(5)
clf
+ rx_nowave = rx(1000:length(rx));
subplot(211)
- plot(rx(1:states.Fs));
+ plot(rx_nowave(1:states.Fs));
title('input signal to demod (1 sec)')
xlabel('Time (samples)');
axis([1 states.Fs -35000 35000])
- % normalise spectrum to 0dB full scale witha 32767 sine wave input
+ % normalise spectrum to 0dB full scale with a 32767 sine wave input
subplot(212)
- RxdBFS = 20*log10(abs(fft(rx(1:states.Fs)))) - 20*log10((states.Fs/2)*32767);
+ RxdBFS = 20*log10(abs(fft(rx_nowave(1:states.Fs)))) - 20*log10((states.Fs/2)*32767);
plot(RxdBFS)
axis([1 states.Fs/2 -80 0])
xlabel('Frequency (Hz)');
- figure(5);
+ figure(6);
clf
plot(ppm_log)
title('Sample clock (baud rate) offset in PPM');
%run_sim(5);
%rx_bits = demod_file("horus.raw",4);
%rx_bits = demod_file("fsk_horus_100bd_binary.raw",5);
- rx_bits = demod_file("~/Desktop/phorus_binary_ascii.wav",4);
+ %rx_bits = demod_file("~/Desktop/phorus_binary_ascii.wav",4);
+ %rx_bits = demod_file("~/Desktop/binary/horus_160102_binary_rtty_2.wav",4);
+ rx_bits = demod_file("~/Desktop/horus_160102_vk5ei_capture2.wav",4);
%rx_bits = demod_file("~/Desktop/horus_rtty_binary.wav",4);
%rx_bits = demod_file("t.raw",5);
%rx_bits = demod_file("~/Desktop/fsk_horus_10dB_1000ppm.wav",4);