mirror of
https://github.com/n5ac/smartsdr-dsp.git
synced 2026-01-18 06:19:58 +01:00
Add slow data encode of message and header data
This commit is contained in:
parent
3a9f59def9
commit
8a210b587b
|
|
@ -50,7 +50,7 @@
|
|||
#include "bit_pattern_matcher.h"
|
||||
#include "dstar.h"
|
||||
#include "DStarDefines.h"
|
||||
|
||||
#include "slow_data.h"
|
||||
|
||||
//static Queue sched_fft_queue;
|
||||
static pthread_rwlock_t _list_lock;
|
||||
|
|
@ -603,8 +603,6 @@ static void * _sched_waveform_thread( void * param ) {
|
|||
decode_out = thumbDV_encode( _dv_serial_fd, speech_in, mod_out, DV_PACKET_SAMPLES );
|
||||
}
|
||||
|
||||
uint32 j = 0;
|
||||
|
||||
if ( initial_tx ) {
|
||||
|
||||
initial_tx = FALSE;
|
||||
|
|
@ -617,13 +615,13 @@ static void * _sched_waveform_thread( void * param ) {
|
|||
|
||||
dstar_txStateMachine(_dstar, _gmsk_mod, TX4_cb, NULL);
|
||||
|
||||
slow_data_createEncodeBytes(_dstar);
|
||||
|
||||
initial_tx_flush = TRUE;
|
||||
|
||||
dstar_tx_frame_count = 0;
|
||||
} else {
|
||||
/* Data and Voice */
|
||||
float data_buf[DATA_FRAME_LENGTH_BITS * DSTAR_RADIO_BIT_LENGTH] = {0};
|
||||
|
||||
if ( decode_out != 0 ) {
|
||||
_dstar->tx_state = VOICE_FRAME;
|
||||
|
|
@ -632,69 +630,12 @@ static void * _sched_waveform_thread( void * param ) {
|
|||
if ( dstar_tx_frame_count % 21 == 0 ) {
|
||||
_dstar->tx_state = DATA_SYNC_FRAME;
|
||||
dstar_txStateMachine(_dstar, _gmsk_mod, TX4_cb, NULL);
|
||||
if ( _dstar->slow_encoder->encode_state == HEADER_TX )
|
||||
_dstar->slow_encoder->header_index = 0;
|
||||
} else {
|
||||
|
||||
|
||||
dstar_pfcs pfcs;
|
||||
pfcs.crc16 = 0xFFFF;
|
||||
|
||||
unsigned char header_bytes[RADIO_HEADER_LENGTH_BITS] = {0};
|
||||
dstar_headerToBytes( &( _dstar->outgoing_header ), header_bytes );
|
||||
dstar_pfcsUpdateBuffer( &pfcs, header_bytes, 312 / 8 );
|
||||
dstar_pfcsResult( &pfcs, header_bytes + 312 / 8 );
|
||||
|
||||
//output("PFCS Bytes: 0x%08X 0x%08X\n", *(header_bytes + 312/8), *(header_bytes + 320/8));
|
||||
|
||||
unsigned char icom_bytes[41 + 4 + 9] = { 0 } ;
|
||||
|
||||
/* Interleave SLOW_DATA_HEADER */
|
||||
uint32 icom_idx = 0;
|
||||
uint32 header_idx = 0;
|
||||
|
||||
for ( i = 0 ; i < 8 ; i++ ) {
|
||||
icom_bytes[icom_idx++] = 0x55;
|
||||
|
||||
for ( j = 0 ; j < 5 ; j++ ) {
|
||||
icom_bytes[icom_idx++] = header_bytes[header_idx++];
|
||||
}
|
||||
}
|
||||
|
||||
icom_bytes[icom_idx++] = 0x51;
|
||||
icom_bytes[icom_idx++] = header_bytes[header_idx++];
|
||||
|
||||
for ( i = 0 ; i < 4 ; i++ )
|
||||
icom_bytes[icom_idx++] = 'f';
|
||||
|
||||
|
||||
unsigned char * dummy_bytes = NULL;
|
||||
static uint32 dbytes_idx = 0;
|
||||
dummy_bytes = icom_bytes + dbytes_idx;
|
||||
dbytes_idx += DATA_FRAME_LENGTH_BYTES;
|
||||
|
||||
if ( dbytes_idx >= 41 + 4 + 9 ) {
|
||||
dbytes_idx = 0;
|
||||
}
|
||||
|
||||
// thumbDV_dump("Data: ", dummy_bytes, DATA_FRAME_LENGTH_BYTES);
|
||||
BOOL dummy_bits[DATA_FRAME_LENGTH_BITS] = {0};
|
||||
BOOL dummy_bits_out[DATA_FRAME_LENGTH_BITS] = {0};
|
||||
uint32 dummy_count = 0;
|
||||
//gmsk_bytesToBits(dummy_bytes, dummy_bits, DATA_FRAME_LENGTH_BITS);
|
||||
uint32 n = 0;
|
||||
|
||||
for ( i = 0 , n = 0 ; i < DATA_FRAME_LENGTH_BYTES ; i++ , n += 8 ) {
|
||||
icom_byteToBits( dummy_bytes[i], dummy_bits + n );
|
||||
}
|
||||
|
||||
dstar_scramble( dummy_bits, dummy_bits_out, DATA_FRAME_LENGTH_BITS, &dummy_count );
|
||||
|
||||
gmsk_bitsToBytes( dummy_bits_out, dummy_bytes, DATA_FRAME_LENGTH_BITS );
|
||||
|
||||
gmsk_encodeBuffer( _gmsk_mod, dummy_bytes, DATA_FRAME_LENGTH_BITS, data_buf, DATA_FRAME_LENGTH_BITS * DSTAR_RADIO_BIT_LENGTH );
|
||||
|
||||
for ( i = 0 ; i < DATA_FRAME_LENGTH_BITS * DSTAR_RADIO_BIT_LENGTH ; i++ ) {
|
||||
cbWriteFloat( TX4_cb, data_buf[i] );
|
||||
}
|
||||
_dstar->tx_state = DATA_FRAME;
|
||||
dstar_txStateMachine(_dstar, _gmsk_mod, TX4_cb, NULL);
|
||||
}
|
||||
|
||||
dstar_tx_frame_count++;
|
||||
|
|
|
|||
|
|
@ -97,7 +97,7 @@ static const BOOL NULL_SLOW_DATA_BITS[] = {FALSE, FALSE, FALSE, TRUE, FALSE, TR
|
|||
#define LONG_CALLSIGN_LENGTH 8U
|
||||
#define SHORT_CALLSIGN_LENGTH 4U
|
||||
|
||||
#define SLOW_DATA_MESSAGE_LENGTH_BITS 20U
|
||||
#define SLOW_DATA_MESSAGE_LENGTH_BYTES 20U
|
||||
#define SLOW_DATA_PACKET_LEN_BYTES 3
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -516,6 +516,10 @@ DSTAR_MACHINE dstar_createMachine( void ) {
|
|||
dstar_createTestHeader( &( machine->outgoing_header ) );
|
||||
|
||||
machine->slow_decoder = safe_malloc(sizeof(slow_data_decoder));
|
||||
machine->slow_encoder = safe_malloc(sizeof(slow_data_encoder));
|
||||
|
||||
/* Temporary */
|
||||
strcpy(machine->slow_encoder->message, "12345678901234567890");
|
||||
|
||||
machine->slice = 0;
|
||||
|
||||
|
|
@ -528,6 +532,7 @@ void dstar_destroyMachine( DSTAR_MACHINE machine ) {
|
|||
bitPM_destroy( machine->end_pm );
|
||||
|
||||
safe_free(machine->slow_decoder);
|
||||
safe_free(machine->slow_encoder);
|
||||
|
||||
safe_free( machine );
|
||||
}
|
||||
|
|
@ -572,7 +577,7 @@ void dstar_processHeader( unsigned char * bytes, DSTAR_HEADER header ) {
|
|||
memcpy( header->own_call1, &bytes[3 + 8 + 8 + 8], 8 );
|
||||
memcpy( header->own_call2, &bytes[3 + 8 + 8 + 8 + 8], 4 );
|
||||
|
||||
//dstar_dumpHeader( header );
|
||||
dstar_dumpHeader( header );
|
||||
}
|
||||
|
||||
static unsigned char icom_bitsToByte( const BOOL * bits ) {
|
||||
|
|
@ -657,7 +662,7 @@ void dstar_txStateMachine( DSTAR_MACHINE machine, GMSK_MOD gmsk_mod, Circular_Fl
|
|||
switch ( machine->tx_state ) {
|
||||
case BIT_FRAME_SYNC:
|
||||
/* Create Sync */
|
||||
for ( i = 0 ; i < 64 + 20; i += 2 ) {
|
||||
for ( i = 0 ; i < 64 * 7; i += 2 ) {
|
||||
gmsk_encode( gmsk_mod, TRUE, buf, DSTAR_RADIO_BIT_LENGTH );
|
||||
|
||||
for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
|
|
@ -734,7 +739,32 @@ void dstar_txStateMachine( DSTAR_MACHINE machine, GMSK_MOD gmsk_mod, Circular_Fl
|
|||
break;
|
||||
}
|
||||
case DATA_FRAME:
|
||||
{
|
||||
unsigned char encode_bytes[SLOW_DATA_PACKET_LEN_BYTES] = {0};
|
||||
BOOL encode_bits[DATA_FRAME_LENGTH_BITS] = {0};
|
||||
BOOL encode_bits_scrambled[DATA_FRAME_LENGTH_BITS] = {0};
|
||||
unsigned char encode_bytes_scrambled[SLOW_DATA_PACKET_LEN_BYTES] = {0};
|
||||
uint32 count = 0;
|
||||
float data_buf[DATA_FRAME_LENGTH_BITS * DSTAR_RADIO_BIT_LENGTH ] = {0};
|
||||
|
||||
slow_data_getEncodeBytes(machine, encode_bytes, SLOW_DATA_PACKET_LEN_BYTES);
|
||||
|
||||
for ( i = 0, j = 0 ; i < SLOW_DATA_PACKET_LEN_BYTES ; i++, j += 8 ) {
|
||||
icom_byteToBits( encode_bytes[i], encode_bits + j);
|
||||
}
|
||||
|
||||
dstar_scramble(encode_bits, encode_bits_scrambled, DATA_FRAME_LENGTH_BITS, &count);
|
||||
|
||||
gmsk_bitsToBytes(encode_bits_scrambled, encode_bytes_scrambled, DATA_FRAME_LENGTH_BITS);
|
||||
|
||||
gmsk_encodeBuffer(gmsk_mod, encode_bytes_scrambled, DATA_FRAME_LENGTH_BITS, data_buf, DATA_FRAME_LENGTH_BITS * DSTAR_RADIO_BIT_LENGTH);
|
||||
|
||||
for ( i = 0 ; i < DATA_FRAME_LENGTH_BITS * DSTAR_RADIO_BIT_LENGTH ; i++ ) {
|
||||
cbWriteFloat(tx_cb, data_buf[i]);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case DATA_SYNC_FRAME:
|
||||
{
|
||||
/* Sync Bits */
|
||||
|
|
@ -759,7 +789,7 @@ void dstar_txStateMachine( DSTAR_MACHINE machine, GMSK_MOD gmsk_mod, Circular_Fl
|
|||
cbWriteFloat( tx_cb, end_buf[i] );
|
||||
}
|
||||
|
||||
for ( i = 0 ; i < 20 ; i += 2 ) {
|
||||
for ( i = 0 ; i < 100 ; i += 2 ) {
|
||||
gmsk_encode( gmsk_mod, TRUE, buf, DSTAR_RADIO_BIT_LENGTH );
|
||||
|
||||
for ( j = 0 ; j < DSTAR_RADIO_BIT_LENGTH ; j++ ) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,11 @@ enum _slow_data_decode_state {
|
|||
MESSAGE_SECOND_FRAME
|
||||
};
|
||||
|
||||
enum _slow_data_encode_state {
|
||||
MESSAGE_TX = 0,
|
||||
HEADER_TX
|
||||
};
|
||||
|
||||
typedef struct _slow_data_decoder {
|
||||
enum _slow_data_decode_state decode_state;
|
||||
unsigned char header_bytes[RADIO_HEADER_LENGTH_BYTES];
|
||||
|
|
@ -51,10 +56,15 @@ typedef struct _slow_data_decoder {
|
|||
char message_string[21];
|
||||
} slow_data_decoder, * SLOW_DATA_DECODER;
|
||||
|
||||
typedef struct _slow_data_machine {
|
||||
|
||||
} slow_data_machine, *SLOW_DATA_MACHINE;
|
||||
|
||||
typedef struct _slow_data_encoder {
|
||||
enum _slow_data_encode_state encode_state;
|
||||
unsigned char message_bytes[SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC];
|
||||
uint32 message_index;
|
||||
unsigned char header_bytes[SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC];
|
||||
uint32 header_index;
|
||||
char message[SLOW_DATA_MESSAGE_LENGTH_BYTES + 1];
|
||||
} slow_data_encoder, * SLOW_DATA_ENCODER;
|
||||
|
||||
enum DSTAR_RX_STATE {
|
||||
BIT_FRAME_SYNC = 0x1,
|
||||
|
|
@ -103,6 +113,7 @@ typedef struct _dstar_machine {
|
|||
BOOL data_bits[DATA_FRAME_LENGTH_BITS];
|
||||
|
||||
SLOW_DATA_DECODER slow_decoder;
|
||||
SLOW_DATA_ENCODER slow_encoder;
|
||||
|
||||
uint32 slice;
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue