function run_sim(test_frame_mode)
test_frame_mode = 5;
- frames = 10;
+ frames = 100;
EbNodB = 60;
timing_offset = 0.0; % see resample() for clock offset below
fading = 0; % modulates tx power at 2Hz with 20dB fade depth,
if exist("fsk_horus_as_a_lib") == 0
%run_sim(5);
- rx_bits = demod_file("~/Desktop/4FSK_Scram_Interleaved.wav",5);
+ rx_bits = demod_file("~/Desktop/test2.wav",4);
%rx_bits = demod_file("fsk_horus.raw",5);
%rx_bits = demod_file("~/Desktop/4FSK_Binary_NoLock.wav",4);
%rx_bits = demod_file("~/Desktop/phorus_binary_ascii.wav",4);
telem_upload_command = "python telem_upload.py -c vk5dgr_Octave";
more off;
-states = fsk_horus_init(8000, 100);
-%states = fsk_horus_init_rtty_uw(states);
+states = fsk_horus_init(8000, 50, 4);
+uwstates = fsk_horus_init_rtty_uw(states);
N = states.N;
Rs = states.Rs;
nsym = states.nsym;
% demodulate samples to bit stream
while length(rx) > nin
+ states = est_freq(states, rx(1:nin)', states.M);
[rx_bits states] = fsk_horus_demod(states, rx(1:nin)');
rx_bits_buf = [rx_bits_buf rx_bits];
rx_bits_sd_buf = [rx_bits_sd_buf states.rx_bits_sd];
SNR = EbNo + 10*log10(states.Rs/3000);
%printf("nin: %d length(rx): %d length(rx_bits_buf): %d \n", nin, length(rx), length(rx_bits_buf));
endwhile
- f = (states.f1+states.f2)/2; shift = states.f2 - states.f1;
+ f = (states.f(1)+states.f(2))/2; shift = states.f(2) - states.f(1);
printf("max: %d f: %d fshift %d ppm: %d Eb/No: %3.1f SNR: %3.1f bits: %d\r", max(s), f, shift, states.ppm, EbNo, SNR, length(rx_bits_buf));
packet_found = 0;
$ gcc horus_l2.c -o horus_l2 -Wall -DINTERLEAVER -DTEST_INTERLEAVER -DSCRAMBLER
- 5/ Compile for use as decoder called by fsk_horus.m and fsk_horus_stream.m:
+ 5/ Compile for use as decoder called by fsk_horus.m and fsk_horus_stream.m:
$ gcc horus_l2.c -o horus_l2 -Wall -DDEC_RX_BITS -DHORUS_L2_RX
#ifdef INTERLEAVER
-int primes[] = {
+uint16_t primes[] = {
2, 3, 5, 7, 11, 13, 17, 19, 23, 29,
31, 37, 41, 43, 47, 53, 59, 61, 67, 71,
73, 79, 83, 89, 97, 101, 103, 107, 109, 113,
void interleave(unsigned char *inout, int nbytes, int dir)
{
- int nbits = nbytes*8;
- int i, j, n, ibit, ibyte, ishift, jbyte, jshift;
- int b;
+ /* note: to work on small uCs (e.g. AVR) needed to declare specific words sizes */
+ uint16_t nbits = (uint16_t)nbytes*8;
+ uint32_t i, j, n, ibit, ibyte, ishift, jbyte, jshift;
+ uint32_t b;
unsigned char out[nbytes];
memset(out, 0, nbytes);
nearest prime to nbits. It also uses storage, is run on every call,
and has an upper limit. Oh Well, still seems to interleave OK. */
i = 1;
- int imax = sizeof(primes)/sizeof(int);
+ uint16_t imax = sizeof(primes)/sizeof(uint16_t);
while ((primes[i] < nbits) && (i < imax))
i++;
b = primes[i-1];
*/
i = n;
- j = (b*i) % nbits;
+ j = (b*i) % nbits; /* note these all need to be 32-bit ints to make multiply work without overflow */
if (dir) {
- int tmp = j;
+ uint16_t tmp = j;
j = i;
i = tmp;
}
/* write jbit to ibit position */
out[jbyte] |= ibit << jshift; // replace with i-th bit
+ //out[ibyte] |= ibit << ishift; // replace with i-th bit
}
-
+
memcpy(inout, out, nbytes);
#ifdef DEBUG0