|
|
|
|
@ -105,14 +105,19 @@ int smaller;
|
|
|
|
|
int flip_ctr = 0;
|
|
|
|
|
int phase = 1;
|
|
|
|
|
int ctr = 0;
|
|
|
|
|
long int ptr = 0;
|
|
|
|
|
|
|
|
|
|
void copy_samples();
|
|
|
|
|
void write_to_buffer(int i, int symbol, int val);
|
|
|
|
|
void write_wave();
|
|
|
|
|
#define SAMPLES (S_RATE / BIT_RATE)
|
|
|
|
|
#define FRAME_CNT 11 //33 // Add 3 frames to the count
|
|
|
|
|
#define FRAME_CNT 33 // Add 3 frames to the count
|
|
|
|
|
|
|
|
|
|
//#define BUF_LEN (FRAME_CNT * (SYNC_BITS + 10 * (8 + 6 * DATA_LEN + 96)) * SAMPLES)
|
|
|
|
|
#define BUF_LEN (FRAME_CNT * (SYNC_BITS + 10 * (HEADER_LEN + RS_FRAMES * (RS_FRAME_LEN + PARITY_LEN))) * SAMPLES)
|
|
|
|
|
short int buffer[BUF_LEN];
|
|
|
|
|
short int phase0[SAMPLES], phase1[SAMPLES];
|
|
|
|
|
int size_of_phase;
|
|
|
|
|
short int data10[8 + RS_FRAMES * (RS_FRAME_LEN + PARITY_LEN)];
|
|
|
|
|
short int data8[8 + RS_FRAMES * (RS_FRAME_LEN + PARITY_LEN)];
|
|
|
|
|
int reset_count;
|
|
|
|
|
@ -688,16 +693,29 @@ int get_tlm_fox() {
|
|
|
|
|
int data;
|
|
|
|
|
int val;
|
|
|
|
|
int offset = 0;
|
|
|
|
|
|
|
|
|
|
for (i = 1; i <= SYNC_BITS * SAMPLES; i++)
|
|
|
|
|
ptr = 0;
|
|
|
|
|
size_of_phase = sizeof(phase0);
|
|
|
|
|
|
|
|
|
|
phase = 1;
|
|
|
|
|
for (i = 0; i < SAMPLES; i++)
|
|
|
|
|
{
|
|
|
|
|
write_wave(i, phase1);
|
|
|
|
|
}
|
|
|
|
|
phase = 0
|
|
|
|
|
for (i = 0; i < SAMPLES; i++)
|
|
|
|
|
{
|
|
|
|
|
write_wave(i, phase0);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 1; i <= SYNC_BITS; i++)
|
|
|
|
|
{
|
|
|
|
|
write_wave(ctr);
|
|
|
|
|
copy_samples();
|
|
|
|
|
if ( (i % SAMPLES) == 0) {
|
|
|
|
|
int bit = SYNC_BITS - i/SAMPLES + 1;
|
|
|
|
|
int bit = SYNC_BITS - i + 1;
|
|
|
|
|
val = sync;
|
|
|
|
|
data = val & 1 << (bit - 1);
|
|
|
|
|
// printf ("%d i: %d new frame %d sync bit %d = %d \n",
|
|
|
|
|
// ctr/SAMPLES, i, frames, bit, (data > 0) );
|
|
|
|
|
// ctr, i, frames, bit, (data > 0) );
|
|
|
|
|
if (DUV)
|
|
|
|
|
{
|
|
|
|
|
phase = ((data != 0) * 2) - 1;
|
|
|
|
|
@ -707,24 +725,24 @@ int get_tlm_fox() {
|
|
|
|
|
{
|
|
|
|
|
if (data == 0) {
|
|
|
|
|
phase *= -1;
|
|
|
|
|
if ( (ctr - smaller) > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 1; j <= smaller; j++)
|
|
|
|
|
buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
|
}
|
|
|
|
|
flip_ctr = ctr;
|
|
|
|
|
// if ( (ctr - smaller) > 0)
|
|
|
|
|
// {
|
|
|
|
|
// for (int j = 1; j <= smaller; j++)
|
|
|
|
|
// buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
|
// }
|
|
|
|
|
// flip_ctr = ctr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 1;
|
|
|
|
|
i <= (10 * (HEADER_LEN + DATA_LEN * PAYLOADS + RS_FRAMES * PARITY_LEN) * SAMPLES); i++) // 572
|
|
|
|
|
i <= (10 * (HEADER_LEN + DATA_LEN * PAYLOADS + RS_FRAMES * PARITY_LEN) * 1); i++) // 572
|
|
|
|
|
{
|
|
|
|
|
write_wave(ctr);
|
|
|
|
|
if ( (i % SAMPLES) == 0) {
|
|
|
|
|
int symbol = (int)((i - 1)/ (SAMPLES * 10));
|
|
|
|
|
int bit = 10 - (i - symbol * SAMPLES * 10) / SAMPLES + 1;
|
|
|
|
|
copy_samples();
|
|
|
|
|
// if ( (i % SAMPLES) == 0) {
|
|
|
|
|
int symbol = (int)((i - 1)/ 10);
|
|
|
|
|
int bit = 10 - (i - symbol * 10);
|
|
|
|
|
val = data10[symbol];
|
|
|
|
|
data = val & 1 << (bit - 1);
|
|
|
|
|
// printf ("%d i: %d new frame %d data10[%d] = %x bit %d = %d \n",
|
|
|
|
|
@ -738,15 +756,15 @@ int get_tlm_fox() {
|
|
|
|
|
{
|
|
|
|
|
if (data == 0) {
|
|
|
|
|
phase *= -1;
|
|
|
|
|
if ( (ctr - smaller) > 0)
|
|
|
|
|
{
|
|
|
|
|
for (int j = 1; j <= smaller; j ++)
|
|
|
|
|
buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
|
}
|
|
|
|
|
flip_ctr = ctr;
|
|
|
|
|
// if ( (ctr - smaller) > 0)
|
|
|
|
|
// {
|
|
|
|
|
// for (int j = 1; j <= smaller; j ++)
|
|
|
|
|
// buffer[ctr - j] = buffer[ctr - j] * 0.4;
|
|
|
|
|
// }
|
|
|
|
|
// flip_ctr = ctr;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// }
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
write_wav("transmit.wav", BUF_LEN, buffer, S_RATE);
|
|
|
|
|
@ -1028,26 +1046,34 @@ void write_wav(char * filename, unsigned long num_samples, short int * data, int
|
|
|
|
|
// return 0;
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
void write_wave(int i)
|
|
|
|
|
void write_wave(int i, short int *buf)
|
|
|
|
|
{
|
|
|
|
|
if (DUV)
|
|
|
|
|
{
|
|
|
|
|
// if ((ctr - flip_ctr) < smaller)
|
|
|
|
|
// buffer[ctr++] = 0.1 * phase * (ctr - flip_ctr) / smaller;
|
|
|
|
|
// else
|
|
|
|
|
buffer[ctr++] = 0.25 * amplitude * phase;
|
|
|
|
|
buf[i] = 0.25 * amplitude * phase;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if ((ctr - flip_ctr) < smaller)
|
|
|
|
|
buffer[ctr++] = (int)(amplitude * 0.4 * phase *
|
|
|
|
|
sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
|
|
|
|
|
else
|
|
|
|
|
buffer[ctr++] = (int)(amplitude * phase *
|
|
|
|
|
sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
|
|
|
|
|
// if ((ctr - flip_ctr) < smaller)
|
|
|
|
|
// buffer[ctr++] = (int)(amplitude * 0.4 * phase *
|
|
|
|
|
// sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
|
|
|
|
|
// else
|
|
|
|
|
buf[i] = (int)(amplitude * phase * sin((float)(2*M_PI*i*freq_Hz/S_RATE)));
|
|
|
|
|
}
|
|
|
|
|
// printf("%d %d \n", i, buffer[ctr - 1]);
|
|
|
|
|
printf("%d %d \n", i, buf[i]);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void copy_samples()
|
|
|
|
|
{
|
|
|
|
|
if (phase == 0)
|
|
|
|
|
memcpy(buffer[ptr], phase0, size_of_phase);
|
|
|
|
|
else
|
|
|
|
|
memcpy(buffer[ptr], phase1, size_of_phase);
|
|
|
|
|
|
|
|
|
|
ptr += size_of_phase;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|