Merge branch 'develop' of https://github.com/n5ac/smartsdr-dsp into develop

This commit is contained in:
Abed Haque 2015-09-04 17:32:59 -05:00
commit 0b5cf02cd4
3 changed files with 132 additions and 75 deletions

View file

@ -159,6 +159,8 @@ static struct my_callback_state _my_cb_state;
#define MAX_RX_STRING_LENGTH 40
static char _rx_string[MAX_RX_STRING_LENGTH + 5];
static BOOL _end_of_transmission = FALSE;
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Circular Buffer Declarations
@ -249,6 +251,10 @@ void freedv_set_string(uint32 slice, char* string)
output(ANSI_MAGENTA "new TX string is '%s'\n",string);
}
void sched_waveform_setEndOfTX(BOOL end_of_transmission)
{
_end_of_transmission = TRUE;
}
@ -284,7 +290,8 @@ static void* _sched_waveform_thread(void* param)
float tx_float_in_24k[PACKET_SAMPLES * DECIMATION_FACTOR + FILTER_TAPS];
float tx_float_out_24k[PACKET_SAMPLES * DECIMATION_FACTOR ];
BOOL inhibit_tx = FALSE;
BOOL flush_tx = FALSE;
// ======================= Initialization Section =========================
@ -394,7 +401,9 @@ static void* _sched_waveform_thread(void* param)
// Set the transmit 'initial' flag
initial_tx = TRUE;
inhibit_tx = FALSE;
flush_tx = FALSE;
_end_of_transmission = FALSE;
// Check for new receiver input packet & move to RX1_cb.
// TODO - If transmit packet, discard here?
@ -528,6 +537,7 @@ static void* _sched_waveform_thread(void* param)
initial_rx = FALSE;
}
emit_waveform_output(buf_desc);
} else if ( (buf_desc->stream_id & 1) == 1) { //TX BUFFER
// If 'initial_rx' flag, clear buffers TX1, TX2, TX3, TX4
@ -558,7 +568,7 @@ static void* _sched_waveform_thread(void* param)
// Check for new receiver input packet & move to TX1_cb.
// TODO - If transmit packet, discard here?
if ( !inhibit_tx ) {
for( i = 0 ; i < PACKET_SAMPLES ; i++ )
{
//output("Outputting ")
@ -567,7 +577,7 @@ static void* _sched_waveform_thread(void* param)
}
//
//
// Check for >= 384 samples in TX1_cb and spin downsampler
// Convert to shorts and move to TX2_cb.
if(cfbContains(TX1_cb) >= 384)
@ -586,8 +596,8 @@ static void* _sched_waveform_thread(void* param)
}
}
//
// // Check for >= 320 samples in TX2_cb and spin vocoder
//
// // Check for >= 320 samples in TX2_cb and spin vocoder
// Move output to TX3_cb.
@ -624,7 +634,7 @@ static void* _sched_waveform_thread(void* param)
}
//Sig2Noise = (_freedvS->fdmdv_stats.snr_est);
}
}
// Check for >= 128 samples in RX4_cb. Form packet and
// export.
@ -633,6 +643,10 @@ static void* _sched_waveform_thread(void* param)
if(initial_tx)
tx_check_samples = PACKET_SAMPLES * 3;
if ( _end_of_transmission )
flush_tx = TRUE;
if ( !inhibit_tx ) {
if(cfbContains(TX4_cb) >= tx_check_samples )
{
for( i = 0 ; i < PACKET_SAMPLES ; i++)
@ -653,11 +667,48 @@ static void* _sched_waveform_thread(void* param)
initial_tx = FALSE;
}
emit_waveform_output(buf_desc);
if ( flush_tx ) {
inhibit_tx = TRUE;
while ( cfbContains(TX4_cb) > 0 ) {
if ( cfbContains(TX4_cb) > PACKET_SAMPLES ) {
for( i = 0 ; i < PACKET_SAMPLES ; i++)
{
// Set up the outbound packet
fsample = cbReadFloat(TX4_cb);
// put the fsample into the outbound packet
((Complex*)buf_desc->buf_ptr)[i].real = fsample;
((Complex*)buf_desc->buf_ptr)[i].imag = fsample;
}
} else {
int end_index = 0;
for ( i = 0 ; i <= cfbContains(TX4_cb); i++ ) {
fsample = cbReadFloat(TX4_cb);
((Complex*)buf_desc->buf_ptr)[i].real = fsample;
((Complex*)buf_desc->buf_ptr)[i].imag = fsample;
end_index = i+1;
}
for ( i = end_index ; i < PACKET_SAMPLES ; i++ ) {
((Complex*)buf_desc->buf_ptr)[i].real = 0.0f;
((Complex*)buf_desc->buf_ptr)[i].imag = 0.0f;
}
}
emit_waveform_output(buf_desc);
}
}
}
}
emit_waveform_output(buf_desc);
hal_BufferRelease(&buf_desc);
}

View file

@ -41,5 +41,5 @@ void sched_waveform_Init(void);
void sched_waveform_signal(void);
void sched_waveformTreadExit(void);
void sched_waveform_setEndOfTX(BOOL end_of_transmission);
#endif /* SCHED_WAVEFORM_H_ */

View file

@ -37,6 +37,7 @@
#include "common.h"
#include "traffic_cop.h"
#include "sched_waveform.h"
static void _handle_status(char* string)
{
@ -144,6 +145,11 @@ static void _handle_status(char* string)
{
output(ANSI_MAGENTA "we are receiving\n");
}
else if ( strncmp(state, "UNKEY_REQUESTED", strlen("UNKEY_REQUESTED")) == 0 )
{
output(ANSI_MAGENTA "unkey requested \n");
sched_waveform_setEndOfTX(TRUE);
}
}
}