mirror of
https://github.com/n5ac/smartsdr-dsp.git
synced 2026-04-05 14:25:30 +00:00
Transmit of SYNC bits working. Very dirty state
This commit is contained in:
parent
13d4d64014
commit
fe678569b4
5 changed files with 154 additions and 48 deletions
|
|
@ -208,6 +208,9 @@ static GMSK_DEMOD _gmsk_demod = NULL;
|
|||
static GMSK_MOD _gmsk_mod = NULL;
|
||||
static DSTAR_MACHINE _dstar = NULL;
|
||||
|
||||
static BOOL write_dat = TRUE;
|
||||
static uint32 data_i = 0;
|
||||
|
||||
#define FREEDV_NSAMPLES 160
|
||||
|
||||
static void* _sched_waveform_thread(void* param)
|
||||
|
|
@ -244,6 +247,8 @@ static void* _sched_waveform_thread(void* param)
|
|||
float tx_float_in_24k[DV_PACKET_SAMPLES * DECIMATION_FACTOR + FILTER_TAPS];
|
||||
float tx_float_out_24k[DV_PACKET_SAMPLES * DECIMATION_FACTOR ];
|
||||
|
||||
|
||||
|
||||
// ======================= Initialization Section =========================
|
||||
|
||||
thumbDV_init("/dev/ttyUSB0", &_dv_serial_fd);
|
||||
|
|
@ -338,6 +343,7 @@ static void* _sched_waveform_thread(void* param)
|
|||
|
||||
// Set the transmit 'initial' flag
|
||||
initial_tx = TRUE;
|
||||
write_dat = TRUE;
|
||||
|
||||
// Check for new receiver input packet & move to RX1_cb.
|
||||
// TODO - If transmit packet, discard here?
|
||||
|
|
@ -503,49 +509,126 @@ static void* _sched_waveform_thread(void* param)
|
|||
/* DECODE */
|
||||
uint32 decode_out = 0;
|
||||
decode_out = thumbDV_encode(_dv_serial_fd, speech_in, (unsigned char * )mod_out, DV_PACKET_SAMPLES);
|
||||
//decode_out = thumbDV_decode(_dv_serial_fd, NULL, mod_out, 160);
|
||||
|
||||
for( i = 0 ; i < DV_PACKET_SAMPLES ; i++)
|
||||
{
|
||||
//cbWriteShort(TX3_cb, mod_out[i]);
|
||||
cbWriteShort(TX3_cb, speech_in[i]);
|
||||
}
|
||||
}
|
||||
|
||||
// Check for >= 128 samples in TX3_cb, convert to floats
|
||||
// and spin the upsampler. Move output to TX4_cb.
|
||||
FILE * dat = NULL;
|
||||
|
||||
if(csbContains(TX3_cb) >= DV_PACKET_SAMPLES)
|
||||
{
|
||||
for( i=0 ; i< DV_PACKET_SAMPLES ; i++)
|
||||
{
|
||||
tx_float_in_8k[i+MEM_8] = ((float) (cbReadShort(TX3_cb) / SCALE_TX_OUT));
|
||||
}
|
||||
if ( write_dat ) {
|
||||
dat = fopen("gmsk_txNew2.dat", "a");
|
||||
}
|
||||
if ( initial_tx ) {
|
||||
|
||||
fdmdv_8_to_24(tx_float_out_24k, &tx_float_in_8k[MEM_8], DV_PACKET_SAMPLES);
|
||||
initial_tx = FALSE;
|
||||
float buf[5];
|
||||
uint32 j = 0;
|
||||
/* Create Sync */
|
||||
for ( i = 0 ; i < 64 * 2 ; i += 2 ) {
|
||||
gmsk_encode(_gmsk_mod, TRUE, buf, DSTAR_RADIO_BIT_LENGTH);
|
||||
|
||||
for( i=0 ; i< DV_PACKET_SAMPLES * DECIMATION_FACTOR ; i++)
|
||||
{
|
||||
cbWriteFloat(TX4_cb, tx_float_out_24k[i]);
|
||||
}
|
||||
//Sig2Noise = (_freedvS->fdmdv_stats.snr_est);
|
||||
}
|
||||
for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
cbWriteFloat(TX4_cb, buf[j]);
|
||||
}
|
||||
|
||||
// Check for >= 128 samples in RX4_cb. Form packet and
|
||||
// export.
|
||||
gmsk_encode(_gmsk_mod, FALSE, buf, DSTAR_RADIO_BIT_LENGTH);
|
||||
|
||||
for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
cbWriteFloat(TX4_cb, buf[j]);
|
||||
}
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < FRAME_SYNC_LENGTH_BITS ; i++ ) {
|
||||
gmsk_encode(_gmsk_mod, FRAME_SYNC_BITS[i], buf, DSTAR_RADIO_BIT_LENGTH);
|
||||
|
||||
for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
cbWriteFloat(TX4_cb, buf[j]);
|
||||
}
|
||||
}
|
||||
|
||||
// fclose(dat);
|
||||
|
||||
// dstar_header tmp_h;
|
||||
// tmp_h.flag1 = 0;
|
||||
// tmp_h.flag2 = 0;
|
||||
// tmp_h.flag3 = 0;
|
||||
//
|
||||
// strncpy((char*)tmp_h.destination_rptr, "DIRECT", 9);
|
||||
// strncpy((char*)tmp_h.departure_rptr, "DIRECT", 9);
|
||||
// strncpy((char*)tmp_h.companion_call, "CQCQCQ", 9);
|
||||
// strncpy((char*)tmp_h.own_call1, "K5SDR", 9);
|
||||
// strncpy((char*)tmp_h.own_call1, "K5SDR", 9);
|
||||
//
|
||||
// dstar_pfcs pfcs;
|
||||
// pfcs.crc16 = 0xFFFF;
|
||||
// dstar_pfcsUpdateBuffer(&pfcs, (unsigned char * ) &tmp_h, 312);
|
||||
// dstar_pfcsResult(&pfcs, (unsigned char * )&(tmp_h.p_fcs));
|
||||
//
|
||||
// BOOL bits[FEC_SECTION_LENGTH_BITS] = {0};
|
||||
//
|
||||
// gmsk_bytesToBits((unsigned char *) &tmp_h, bits, 328);
|
||||
// BOOL encoded[330*2] = {0};
|
||||
// BOOL interleaved[330*2] = {0};
|
||||
// BOOL scrambled[330*2] = {0};
|
||||
// uint32 outLen = 0;
|
||||
// dstar_FECencode(bits, encoded, 330, &outLen);
|
||||
// //output("Encode outLen = %d\n", outLen);
|
||||
//
|
||||
// outLen = 660;
|
||||
// dstar_interleave(encoded, interleaved, outLen);
|
||||
//
|
||||
// uint32 count = 0;
|
||||
// dstar_scramble(interleaved, scrambled, outLen, &count);
|
||||
//output("Count = %d\n", count);
|
||||
// for ( i = 0 ; i < count ; i++ ) {
|
||||
// gmsk_encode(_gmsk_mod, scrambled[i], buf, DSTAR_RADIO_BIT_LENGTH);
|
||||
// for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
// cbWriteFloat(TX4_cb, buf[j]);
|
||||
// //fprintf(dat, "%d %.12f\n", data_i++, buf[j]);
|
||||
// }
|
||||
// }
|
||||
|
||||
//fclose(dat);
|
||||
|
||||
}
|
||||
|
||||
uint32 tx_check_samples = PACKET_SAMPLES;
|
||||
|
||||
if(initial_tx)
|
||||
tx_check_samples = PACKET_SAMPLES * 3;
|
||||
if ( !initial_tx && cfbContains(TX4_cb) < PACKET_SAMPLES * 5) {
|
||||
for ( i = 0 ; i < 13 ; i++ ) {
|
||||
float buf[5];
|
||||
uint32 j = 0;
|
||||
gmsk_encode(_gmsk_mod, TRUE, buf, DSTAR_RADIO_BIT_LENGTH);
|
||||
|
||||
for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
cbWriteFloat(TX4_cb, buf[j]);
|
||||
// if ( write_dat ) fprintf(dat, "%d %.12f\n", data_i++, buf[j]);
|
||||
}
|
||||
|
||||
gmsk_encode(_gmsk_mod, FALSE, buf, DSTAR_RADIO_BIT_LENGTH);
|
||||
|
||||
for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
cbWriteFloat(TX4_cb, buf[j]);
|
||||
// if ( write_dat ) fprintf(dat, "%d %.12f\n", data_i++, buf[j]);
|
||||
}
|
||||
}
|
||||
|
||||
// if ( write_dat ) {
|
||||
// fclose(dat);
|
||||
//
|
||||
// sync();
|
||||
// write_dat = FALSE;
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
if(cfbContains(TX4_cb) >= tx_check_samples )
|
||||
{
|
||||
for( i = 0 ; i < PACKET_SAMPLES ; i++)
|
||||
{
|
||||
//output("Fetching from end buffer \n");
|
||||
//output("Fetching from end buffer \n");
|
||||
// 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;
|
||||
|
|
@ -555,10 +638,11 @@ static void* _sched_waveform_thread(void* param)
|
|||
|
||||
memset( buf_desc->buf_ptr, 0, PACKET_SAMPLES * sizeof(Complex));
|
||||
|
||||
if(initial_tx)
|
||||
initial_tx = FALSE;
|
||||
|
||||
}
|
||||
|
||||
initial_tx = FALSE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -586,6 +670,7 @@ void sched_waveform_Init(void)
|
|||
|
||||
_gmsk_demod = gmsk_createDemodulator();
|
||||
_gmsk_mod = gmsk_createModulator();
|
||||
_gmsk_mod->m_invert = TRUE;
|
||||
|
||||
pthread_rwlock_init(&_list_lock, NULL);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue