diff --git a/.gitignore b/.gitignore
index 4d40434..f0f4d72 100644
--- a/.gitignore
+++ b/.gitignore
@@ -3,6 +3,7 @@
*.ko
*.obj
*.elf
+obj
# Libraries
*.lib
@@ -21,3 +22,11 @@
*.i*86
*.x86_64
*.hex
+
+# Others
+.metadata
+.vs
+bin
+Debug
+Release
+.settings
diff --git a/DSP_API/.cproject b/DSP_API/.cproject
index 13dbe50..91dc741 100644
--- a/DSP_API/.cproject
+++ b/DSP_API/.cproject
@@ -1,182 +1,6 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
@@ -190,7 +14,7 @@
-
+
@@ -201,21 +25,21 @@
-
+
+
-
+
@@ -245,7 +69,7 @@
-
+
@@ -267,7 +91,7 @@
-
+
@@ -282,13 +106,12 @@
-
+
@@ -300,9 +123,10 @@
+
-
+
-
+
@@ -354,6 +178,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -418,4 +309,5 @@
+
diff --git a/DSP_API/Release/CODEC2_FREEDV/codebook.d b/DSP_API/Release/CODEC2_FREEDV/codebook.d
deleted file mode 100644
index dc5f6f2..0000000
--- a/DSP_API/Release/CODEC2_FREEDV/codebook.d
+++ /dev/null
@@ -1,4 +0,0 @@
-CODEC2_FREEDV/codebook.d: ../CODEC2_FREEDV/codebook.c \
- ../CODEC2_FREEDV/defines.h
-
-../CODEC2_FREEDV/defines.h:
diff --git a/DSP_API/Release/CODEC2_FREEDV/subdir.mk b/DSP_API/Release/CODEC2_FREEDV/subdir.mk
deleted file mode 100644
index 01a752c..0000000
--- a/DSP_API/Release/CODEC2_FREEDV/subdir.mk
+++ /dev/null
@@ -1,96 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
-# Add inputs and outputs from these tool invocations to the build variables
-C_SRCS += \
-../CODEC2_FREEDV/codebook.c \
-../CODEC2_FREEDV/codebookd.c \
-../CODEC2_FREEDV/codebookdt.c \
-../CODEC2_FREEDV/codebookge.c \
-../CODEC2_FREEDV/codebookjnd.c \
-../CODEC2_FREEDV/codebookjvm.c \
-../CODEC2_FREEDV/codebookvq.c \
-../CODEC2_FREEDV/codebookvqanssi.c \
-../CODEC2_FREEDV/codec2.c \
-../CODEC2_FREEDV/dump.c \
-../CODEC2_FREEDV/fdmdv.c \
-../CODEC2_FREEDV/fifo.c \
-../CODEC2_FREEDV/freedv_api.c \
-../CODEC2_FREEDV/golay23.c \
-../CODEC2_FREEDV/interp.c \
-../CODEC2_FREEDV/kiss_fft.c \
-../CODEC2_FREEDV/lpc.c \
-../CODEC2_FREEDV/lsp.c \
-../CODEC2_FREEDV/nlp.c \
-../CODEC2_FREEDV/pack.c \
-../CODEC2_FREEDV/phase.c \
-../CODEC2_FREEDV/postfilter.c \
-../CODEC2_FREEDV/quantise.c \
-../CODEC2_FREEDV/sine.c \
-../CODEC2_FREEDV/varicode.c
-
-OBJS += \
-./CODEC2_FREEDV/codebook.o \
-./CODEC2_FREEDV/codebookd.o \
-./CODEC2_FREEDV/codebookdt.o \
-./CODEC2_FREEDV/codebookge.o \
-./CODEC2_FREEDV/codebookjnd.o \
-./CODEC2_FREEDV/codebookjvm.o \
-./CODEC2_FREEDV/codebookvq.o \
-./CODEC2_FREEDV/codebookvqanssi.o \
-./CODEC2_FREEDV/codec2.o \
-./CODEC2_FREEDV/dump.o \
-./CODEC2_FREEDV/fdmdv.o \
-./CODEC2_FREEDV/fifo.o \
-./CODEC2_FREEDV/freedv_api.o \
-./CODEC2_FREEDV/golay23.o \
-./CODEC2_FREEDV/interp.o \
-./CODEC2_FREEDV/kiss_fft.o \
-./CODEC2_FREEDV/lpc.o \
-./CODEC2_FREEDV/lsp.o \
-./CODEC2_FREEDV/nlp.o \
-./CODEC2_FREEDV/pack.o \
-./CODEC2_FREEDV/phase.o \
-./CODEC2_FREEDV/postfilter.o \
-./CODEC2_FREEDV/quantise.o \
-./CODEC2_FREEDV/sine.o \
-./CODEC2_FREEDV/varicode.o
-
-C_DEPS += \
-./CODEC2_FREEDV/codebook.d \
-./CODEC2_FREEDV/codebookd.d \
-./CODEC2_FREEDV/codebookdt.d \
-./CODEC2_FREEDV/codebookge.d \
-./CODEC2_FREEDV/codebookjnd.d \
-./CODEC2_FREEDV/codebookjvm.d \
-./CODEC2_FREEDV/codebookvq.d \
-./CODEC2_FREEDV/codebookvqanssi.d \
-./CODEC2_FREEDV/codec2.d \
-./CODEC2_FREEDV/dump.d \
-./CODEC2_FREEDV/fdmdv.d \
-./CODEC2_FREEDV/fifo.d \
-./CODEC2_FREEDV/freedv_api.d \
-./CODEC2_FREEDV/golay23.d \
-./CODEC2_FREEDV/interp.d \
-./CODEC2_FREEDV/kiss_fft.d \
-./CODEC2_FREEDV/lpc.d \
-./CODEC2_FREEDV/lsp.d \
-./CODEC2_FREEDV/nlp.d \
-./CODEC2_FREEDV/pack.d \
-./CODEC2_FREEDV/phase.d \
-./CODEC2_FREEDV/postfilter.d \
-./CODEC2_FREEDV/quantise.d \
-./CODEC2_FREEDV/sine.d \
-./CODEC2_FREEDV/varicode.d
-
-
-# Each subdirectory must supply rules for building sources it contributes
-CODEC2_FREEDV/%.o: ../CODEC2_FREEDV/%.c
- @echo 'Building file: $<'
- @echo 'Invoking: GCC C Compiler'
- arm-linux-gnueabihf-gcc -static -I"/home/graham/workspace/smartsdr-dsp/DSP_API" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/SmartSDR_Interface" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/CODEC2_FREEDV" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
- @echo 'Finished building: $<'
- @echo ' '
-
-
diff --git a/DSP_API/Release/SmartSDR_Interface/subdir.mk b/DSP_API/Release/SmartSDR_Interface/subdir.mk
deleted file mode 100644
index 80b1a54..0000000
--- a/DSP_API/Release/SmartSDR_Interface/subdir.mk
+++ /dev/null
@@ -1,60 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
-# Add inputs and outputs from these tool invocations to the build variables
-C_SRCS += \
-../SmartSDR_Interface/cmd_basics.c \
-../SmartSDR_Interface/cmd_engine.c \
-../SmartSDR_Interface/discovery_client.c \
-../SmartSDR_Interface/hal_buffer.c \
-../SmartSDR_Interface/hal_listener.c \
-../SmartSDR_Interface/hal_vita.c \
-../SmartSDR_Interface/io_utils.c \
-../SmartSDR_Interface/sched_waveform.c \
-../SmartSDR_Interface/smartsdr_dsp_api.c \
-../SmartSDR_Interface/status_processor.c \
-../SmartSDR_Interface/traffic_cop.c \
-../SmartSDR_Interface/utils.c \
-../SmartSDR_Interface/vita_output.c
-
-OBJS += \
-./SmartSDR_Interface/cmd_basics.o \
-./SmartSDR_Interface/cmd_engine.o \
-./SmartSDR_Interface/discovery_client.o \
-./SmartSDR_Interface/hal_buffer.o \
-./SmartSDR_Interface/hal_listener.o \
-./SmartSDR_Interface/hal_vita.o \
-./SmartSDR_Interface/io_utils.o \
-./SmartSDR_Interface/sched_waveform.o \
-./SmartSDR_Interface/smartsdr_dsp_api.o \
-./SmartSDR_Interface/status_processor.o \
-./SmartSDR_Interface/traffic_cop.o \
-./SmartSDR_Interface/utils.o \
-./SmartSDR_Interface/vita_output.o
-
-C_DEPS += \
-./SmartSDR_Interface/cmd_basics.d \
-./SmartSDR_Interface/cmd_engine.d \
-./SmartSDR_Interface/discovery_client.d \
-./SmartSDR_Interface/hal_buffer.d \
-./SmartSDR_Interface/hal_listener.d \
-./SmartSDR_Interface/hal_vita.d \
-./SmartSDR_Interface/io_utils.d \
-./SmartSDR_Interface/sched_waveform.d \
-./SmartSDR_Interface/smartsdr_dsp_api.d \
-./SmartSDR_Interface/status_processor.d \
-./SmartSDR_Interface/traffic_cop.d \
-./SmartSDR_Interface/utils.d \
-./SmartSDR_Interface/vita_output.d
-
-
-# Each subdirectory must supply rules for building sources it contributes
-SmartSDR_Interface/%.o: ../SmartSDR_Interface/%.c
- @echo 'Building file: $<'
- @echo 'Invoking: GCC C Compiler'
- arm-linux-gnueabihf-gcc -static -I"/home/graham/workspace/smartsdr-dsp/DSP_API" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/SmartSDR_Interface" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/CODEC2_FREEDV" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
- @echo 'Finished building: $<'
- @echo ' '
-
-
diff --git a/DSP_API/Release/makefile b/DSP_API/Release/makefile
deleted file mode 100644
index 2872af3..0000000
--- a/DSP_API/Release/makefile
+++ /dev/null
@@ -1,51 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
--include ../makefile.init
-
-RM := rm -rf
-
-# All of the sources participating in the build are defined here
--include sources.mk
--include SmartSDR_Interface/subdir.mk
--include CODEC2_FREEDV/subdir.mk
--include subdir.mk
--include objects.mk
-
-ifneq ($(MAKECMDGOALS),clean)
-ifneq ($(strip $(C_DEPS)),)
--include $(C_DEPS)
-endif
-endif
-
--include ../makefile.defs
-
-# Add inputs and outputs from these tool invocations to the build variables
-
-# All Target
-all: freedv
-
-# Tool invocations
-freedv: $(OBJS) $(USER_OBJS)
- @echo 'Building target: $@'
- @echo 'Invoking: GCC C Linker'
- arm-linux-gnueabihf-gcc -static -o "freedv" $(OBJS) $(USER_OBJS) $(LIBS)
- @echo 'Finished building target: $@'
- @echo ' '
- $(MAKE) --no-print-directory post-build
-
-# Other Targets
-clean:
- -$(RM) $(OBJS)$(C_DEPS)$(EXECUTABLES) freedv
- -@echo ' '
-
-post-build:
- -@echo 'Install in BeagleBone at /home/debian/bin'
- -scp freedv root@192.168.20.33:/home/debian/bin/
- -@echo ' '
-
-.PHONY: all clean dependents
-.SECONDARY: post-build
-
--include ../makefile.targets
diff --git a/DSP_API/Release/objects.mk b/DSP_API/Release/objects.mk
deleted file mode 100644
index 61d364b..0000000
--- a/DSP_API/Release/objects.mk
+++ /dev/null
@@ -1,8 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
-USER_OBJS :=
-
-LIBS := -lm -lpthread -lrt
-
diff --git a/DSP_API/Release/sources.mk b/DSP_API/Release/sources.mk
deleted file mode 100644
index 7dc98a2..0000000
--- a/DSP_API/Release/sources.mk
+++ /dev/null
@@ -1,19 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
-O_SRCS :=
-C_SRCS :=
-S_UPPER_SRCS :=
-OBJ_SRCS :=
-ASM_SRCS :=
-OBJS :=
-C_DEPS :=
-EXECUTABLES :=
-
-# Every subdirectory with source files must be described here
-SUBDIRS := \
-. \
-SmartSDR_Interface \
-CODEC2_FREEDV \
-
diff --git a/DSP_API/Release/subdir.mk b/DSP_API/Release/subdir.mk
deleted file mode 100644
index d466154..0000000
--- a/DSP_API/Release/subdir.mk
+++ /dev/null
@@ -1,30 +0,0 @@
-################################################################################
-# Automatically-generated file. Do not edit!
-################################################################################
-
-# Add inputs and outputs from these tool invocations to the build variables
-C_SRCS += \
-../circular_buffer.c \
-../main.c \
-../resampler.c
-
-OBJS += \
-./circular_buffer.o \
-./main.o \
-./resampler.o
-
-C_DEPS += \
-./circular_buffer.d \
-./main.d \
-./resampler.d
-
-
-# Each subdirectory must supply rules for building sources it contributes
-%.o: ../%.c
- @echo 'Building file: $<'
- @echo 'Invoking: GCC C Compiler'
- arm-linux-gnueabihf-gcc -static -I"/home/graham/workspace/smartsdr-dsp/DSP_API" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/SmartSDR_Interface" -I"/home/graham/workspace/smartsdr-dsp/DSP_API/CODEC2_FREEDV" -O3 -Wall -c -fmessage-length=0 -MMD -MP -MF"$(@:%.o=%.d)" -MT"$(@:%.o=%.d)" -o "$@" "$<"
- @echo 'Finished building: $<'
- @echo ' '
-
-
diff --git a/DSP_API/SmartSDR_Interface/sched_waveform.c b/DSP_API/SmartSDR_Interface/sched_waveform.c
index 01d189e..485529c 100644
--- a/DSP_API/SmartSDR_Interface/sched_waveform.c
+++ b/DSP_API/SmartSDR_Interface/sched_waveform.c
@@ -304,52 +304,53 @@ void sched_waveform_setOwnCall1( uint32 slice , const char * owncall1 ) {
}
void sched_waveform_setOwnCall2( uint32 slice , const char * owncall2 ) {
- /* Ignore slice for now */
-
char string[10];
- strncpy( string, owncall2, 5 );
- charReplace( string, ' ', ( char ) 0x7F );
- memset( _dstar->outgoing_header.own_call2, ' ', 4 );
/* We limit the copy to the string length so that
* we can fill the rest of the string with spaces to
* comply with DSTAR
*/
- uint32 copy_len = strlen( owncall2 );
-
- if ( copy_len > 5 )
- copy_len = 5;
-
- strncpy( _dstar->outgoing_header.own_call2, string, copy_len );
-
+ memset( _dstar->outgoing_header.own_call2, ' ', 4 );
/* Enforce termination */
_dstar->outgoing_header.own_call2[4] = '\0';
+ if (strlen(owncall2) > 0)
+ {
+ strncpy( string, owncall2, 4);
+ string[4] = 0;
+ charReplace( string, ( char ) 0x7F, ' ' );
+ uint32 copy_len = strlen( owncall2 );
+ if ( copy_len > 4 )
+ copy_len = 4;
+ strncpy( _dstar->outgoing_header.own_call2, string, copy_len );
+ }
+
dstar_dumpHeader( &( _dstar->outgoing_header ) );
}
void sched_waveform_setMessage( uint32 slice, const char * message)
{
- /* Ignore slice for now */
char string[SLOW_DATA_MESSAGE_LENGTH_BYTES + 1 ];
- strncpy( string, message, SLOW_DATA_MESSAGE_LENGTH_BYTES + 1);
- charReplace( string, ' ', ( char ) 0x7F );
- memset(_dstar->slow_encoder->message, ' ', SLOW_DATA_MESSAGE_LENGTH_BYTES);
-
/* We limit the copy to the string length so that
* we can fill the rest of the string with spaces to
* comply with DSTAR
*/
-
- uint32 copy_len = strlen( string );
-
- if ( copy_len > SLOW_DATA_MESSAGE_LENGTH_BYTES )
- copy_len = SLOW_DATA_MESSAGE_LENGTH_BYTES;
-
- strncpy(_dstar->slow_encoder->message, string, copy_len);
-
+ memset(_dstar->slow_encoder->message, ' ', SLOW_DATA_MESSAGE_LENGTH_BYTES);
/* Enforce termination */
_dstar->slow_encoder->message[SLOW_DATA_MESSAGE_LENGTH_BYTES] = '\0';
+ /* Ignore slice for now */
+ if (strlen(message) > 0)
+ {
+ strncpy( string, message, SLOW_DATA_MESSAGE_LENGTH_BYTES);
+ string[SLOW_DATA_MESSAGE_LENGTH_BYTES] = 0;
+ charReplace( string, ( char ) 0x7F, ' ' );
+ uint32 copy_len = strlen( string );
+ if ( copy_len > SLOW_DATA_MESSAGE_LENGTH_BYTES )
+ copy_len = SLOW_DATA_MESSAGE_LENGTH_BYTES;
+ strncpy(_dstar->slow_encoder->message, string, copy_len);
+ }
+
+ output( "TX Message: '%s'\n", _dstar->slow_encoder->message );
}
void sched_waveform_setFD( int fd ) {
@@ -520,8 +521,16 @@ static void * _sched_waveform_thread( void * param ) {
for ( j = 0 ; j < nout ; j++ )
cbWriteShort( RX3_cb, speech_out[j] );
}
+
+ if (_dstar->rx_state == END_PATTERN)
+ {
+ char msg[64];
+ sprintf( msg, "waveform status slice=%d RX=END", _dstar->slice);
+ tc_sendSmartSDRcommand( msg, FALSE, NULL );
+ }
}
+
// Check for >= 160 samples in RX3_cb, convert to floats
// and spin the upsampler. Move output to RX4_cb.
diff --git a/DSP_API/ThumbDV/dstar.c b/DSP_API/ThumbDV/dstar.c
index e3a82bd..300e619 100644
--- a/DSP_API/ThumbDV/dstar.c
+++ b/DSP_API/ThumbDV/dstar.c
@@ -603,7 +603,8 @@ void dstar_updateStatus( DSTAR_MACHINE machine, uint32 slice, enum STATUS_TYPE
}
char status[200] = {0};
- char header_string[200] = {0};
+ char header_string[256] = {0};
+ char message_string[21];
/* Make copy to replace spaces with special char */
@@ -634,19 +635,30 @@ void dstar_updateStatus( DSTAR_MACHINE machine, uint32 slice, enum STATUS_TYPE
charReplace( ( char * )h.destination_rptr, ' ', ( char ) 0x7F );
charReplace( ( char * )h.departure_rptr, ' ', ( char ) 0x7F );
- charReplace( ( char * )h.companion_call, ' ', ( char ) 0x7F );
+ charReplace((char *) h.companion_call, ' ', ( char ) 0x7F );
charReplace( ( char * )h.own_call1, ' ', ( char ) 0x7F );
charReplace( ( char * )h.own_call2, ' ', ( char ) 0x7F );
sprintf( header_string, "destination_rptr_tx=%s departure_rptr_tx=%s companion_call_tx=%s own_call1_tx=%s own_call2_tx=%s",
h.destination_rptr, h.departure_rptr, h.companion_call, h.own_call1, h.own_call2 );
+ if (machine->slow_encoder != NULL && machine->slow_encoder->message[0] != 0)
+ {
+ memcpy( message_string, machine->slow_encoder->message, sizeof( message_string ) );
+ message_string[sizeof( message_string ) - 1] = 0;
+ charReplace( message_string, ' ', ( char ) 0x7F );
+ sprintf( header_string + strlen(header_string), " message_tx=%s", message_string);
+ }
+
sprintf( status, "waveform status slice=%d %s", slice, header_string );
tc_sendSmartSDRcommand( status, FALSE, NULL );
break;
case STATUS_SLOW_DATA_MESSAGE:
- sprintf( status, "waveform status slice=%d message=%s", slice, machine->slow_decoder->message_string);
+ memcpy( message_string, machine->slow_decoder->message_string, sizeof( message_string ) );
+ message_string[sizeof( message_string ) - 1] = 0;
+ charReplace( message_string, ' ', ( char ) 0x7F );
+ sprintf( status, "waveform status slice=%d message=%s", slice, message_string);
tc_sendSmartSDRcommand( status, FALSE, NULL );
break;
}
diff --git a/DSP_API/ThumbDV/slow_data.c b/DSP_API/ThumbDV/slow_data.c
new file mode 100644
index 0000000..99b21f1
--- /dev/null
+++ b/DSP_API/ThumbDV/slow_data.c
@@ -0,0 +1,321 @@
+///*! \file slow_data.c
+// *
+// * Handles scrambling and descrambling of DSTAR Header
+// *
+// * \date 25-AUG-2015
+// * \author Ed Gonzalez KG5FBT
+// */
+
+/* *****************************************************************************
+ *
+ * Copyright (C) 2012-2014 FlexRadio Systems.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * Contact Information:
+ * email: gplflexradiosystems.com
+ * Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
+ *
+ * ************************************************************************** */
+
+
+#include
+#include
+#include
+
+#include "slow_data.h"
+#include "DStarDefines.h"
+#include "dstar.h"
+#include "gmsk_modem.h"
+#include "thumbDV.h"
+
+uint32 slow_data_createDecoder(SLOW_DATA_DECODER slow_decoder)
+{
+ SLOW_DATA_DECODER decoder = ( SLOW_DATA_DECODER ) safe_malloc(sizeof(slow_data_decoder)) ;
+
+ if ( decoder == NULL ) {
+ output("Could not allocate slow data decoder\n");
+ return FAIL;
+ }
+
+ memset(decoder, 0, sizeof(slow_data_decoder));
+
+ decoder->decode_state = FIRST_FRAME;
+
+ slow_decoder = decoder;
+ return SUCCESS;
+}
+
+static void _slow_data_processHeaderBytes(DSTAR_MACHINE dstar)
+{
+ uint32 i = 0;
+ dstar_pfcs pfcs;
+ pfcs.crc16 = 0xFFFF;
+
+ SLOW_DATA_DECODER slow_decoder = (SLOW_DATA_DECODER) dstar->slow_decoder;
+
+ BOOL bits[RADIO_HEADER_LENGTH_BITS] = {0};
+ gmsk_bytesToBits(slow_decoder->header_bytes, bits, RADIO_HEADER_LENGTH_BITS);
+
+ for ( i = 0 ; i < 312 ; i += 8 ) {
+ dstar_pfcsUpdate( &pfcs, bits + i);
+ }
+
+ BOOL pfcs_match = FALSE;
+ pfcs_match = dstar_pfcsCheck( &pfcs, bits + 312 );
+
+ if ( pfcs_match ) {
+ output("SLOW DATA HEADER PARSED\n");
+
+ dstar_processHeader(slow_decoder->header_bytes, &dstar->incoming_header);
+ dstar_updateStatus( dstar, dstar->slice, STATUS_RX );
+ }
+
+ slow_data_resetDecoder(dstar);
+}
+
+static void _slow_data_processMessage(DSTAR_MACHINE dstar)
+{
+ char message[21];
+ uint32 i, j;
+ for ( i = 0 ; i < 4 ; i++ ) {
+ for ( j = 0 ; j < 5 ; j++ ) {
+ message[(i*5) + j] = dstar->slow_decoder->message[i][j];
+ }
+ }
+
+ message[20] = '\0';
+ strncpy(dstar->slow_decoder->message_string, message, 21);
+ output("SLOW DATA MESSAGE PARSED = '%s'\n", message);
+ dstar_updateStatus(dstar, dstar->slice, STATUS_SLOW_DATA_MESSAGE);
+
+ slow_data_resetDecoder(dstar);
+}
+
+void slow_data_createEncodeBytes(DSTAR_MACHINE dstar)
+{
+ uint32 i = 0;
+ uint32 j = 0;
+ SLOW_DATA_ENCODER encoder = dstar->slow_encoder;
+ uint32 message_index = 0;
+ dstar_pfcs pfcs;
+
+ /* Set all bytes to 0x66 */
+ memset(encoder->message_bytes, 0x66, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
+
+ /* Generate Message Bytes */
+ for ( i = 0 ; i < 4 ; i++ ) {
+ encoder->message_bytes[(i * 6)] = SLOW_DATA_TYPE_MESSAGE | i;
+ for ( j = 1 ; j < 6 ; j++ ) {
+ encoder->message_bytes[(i * 6) + j] = encoder->message[message_index++];
+ }
+ }
+
+ thumbDV_dump("MESSAGE BYTES", encoder->message_bytes, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
+
+ /* Generate HEADER Bytes */
+ /* Set all bytes to 0x66 */
+ memset(encoder->header_bytes, 0x66, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
+ uint32 header_index = 0;
+
+ unsigned char header_bytes[RADIO_HEADER_LENGTH_BYTES] = {0};
+ dstar_headerToBytes(&dstar->outgoing_header, header_bytes);
+ pfcs.crc16 = 0xFFFF;
+ dstar_pfcsUpdateBuffer( &pfcs, header_bytes, 312 / 8 );
+ dstar_pfcsResult( &pfcs, header_bytes + 312 / 8 );
+
+ uint32 bits_left = RADIO_HEADER_LENGTH_BYTES;
+ uint32 second_loop_limit = 0;
+ for ( i = 0 ; i < RADIO_HEADER_LENGTH_BYTES / 5 + 1; i++ ) {
+ if ( bits_left >= 5 )
+ second_loop_limit = 6;
+ else
+ second_loop_limit = bits_left;
+ encoder->header_bytes[(i * 6)] = SLOW_DATA_TYPE_HEADER | (second_loop_limit - 1);
+ for ( j = 1 ; j < second_loop_limit ; j++ ) {
+ encoder->header_bytes[(i * 6) + j] = header_bytes[header_index++];
+ }
+
+ bits_left -= 5;
+ }
+
+ thumbDV_dump("Header bytes", encoder->header_bytes, SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC);
+
+
+ slow_data_resetEncoder(dstar);
+
+
+}
+
+void slow_data_getEncodeBytes( DSTAR_MACHINE dstar, unsigned char * bytes , uint32 num_bytes)
+{
+ uint32 i = 0;
+ memset(bytes, 0x66, num_bytes);
+
+ SLOW_DATA_ENCODER encoder = dstar->slow_encoder;
+ switch ( encoder->encode_state ) {
+ case MESSAGE_TX:
+ if ( encoder->message_index != 0 && encoder->message_index % 3 != 0 ) {
+ output("Message indexing problem. message_index = %d\n", encoder->message_index);
+ slow_data_resetEncoder(dstar);
+ break;
+ }
+
+ for ( i = 0 ; i < SLOW_DATA_PACKET_LEN_BYTES ; i++ ) {
+ bytes[i] = encoder->message_bytes[encoder->message_index++];
+ }
+
+ if ( encoder->message_index >= SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC ) {
+ /* Done sending the message change to header state */
+ encoder->message_index = 0;
+ encoder->encode_state = HEADER_TX;
+ }
+
+ break;
+ case HEADER_TX:
+ if ( encoder->header_index != 0 && encoder->header_index % 3 != 0 ) {
+ output("Header indexing problem. header_index = %d\n", encoder->header_index);
+ slow_data_resetEncoder(dstar);
+ break;
+ }
+
+ for ( i = 0 ; i < SLOW_DATA_PACKET_LEN_BYTES ; i++ ) {
+ bytes[i] = encoder->header_bytes[encoder->header_index++];
+ }
+
+ if ( encoder->header_index >= SLOW_DATA_PACKET_LEN_BYTES * FRAMES_BETWEEN_SYNC ) {
+ /* Done sending header. Reset index and keep sending header slow data */
+ encoder->header_index = 0;
+ }
+ break;
+ }
+}
+
+void slow_data_resetEncoder(DSTAR_MACHINE dstar)
+{
+ dstar->slow_encoder->encode_state = MESSAGE_TX;
+ dstar->slow_encoder->message_index = 0;
+ dstar->slow_encoder->header_index = 0;
+}
+
+void slow_data_resetDecoder(DSTAR_MACHINE dstar)
+{
+ dstar->slow_decoder->decode_state = FIRST_FRAME;
+ dstar->slow_decoder->header_array_index = 0;
+ dstar->slow_decoder->message_index = 0;
+}
+
+void slow_data_addDecodeData(DSTAR_MACHINE dstar, unsigned char * data, uint32 data_len)
+{
+ if ( data_len != SLOW_DATA_PACKET_LEN_BYTES ) {
+ output("Invalid data length - slow_data_addData\n");
+ return;
+ }
+
+ SLOW_DATA_DECODER slow_decoder = (SLOW_DATA_DECODER) (dstar->slow_decoder);
+
+ if ( slow_decoder == NULL ) {
+ output("NULL slow_decoder\n");
+ return;
+ }
+
+ uint32 i = 0;
+
+ switch(slow_decoder->decode_state) {
+ case FIRST_FRAME:
+ {
+ //output("FIRST FRAME\n");
+ switch(data[0] & SLOW_DATA_TYPE_MASK ) {
+ case SLOW_DATA_TYPE_HEADER:
+ {
+ for ( i = 1 ; i < 3 ; i++ ) {
+ slow_decoder->header_bytes[slow_decoder->header_array_index++] =
+ data[i];
+ if ( slow_decoder->header_array_index >= RADIO_HEADER_LENGTH_BYTES )
+ {
+ _slow_data_processHeaderBytes(dstar);
+ break;
+ }
+ }
+
+ slow_decoder->decode_state = HEADER_SECOND_FRAME;
+
+
+ break;
+ }
+ case SLOW_DATA_TYPE_MESSAGE:
+ {
+
+ uint32 message_index = data[0] & SLOW_DATA_LENGTH_MASK;
+
+ if ( message_index != slow_decoder->message_index ) {
+ output("Out of order SLOW DATA MESSAGE SKIPPING\n");
+ slow_decoder->message_index = 0;
+ break;
+ }
+
+ for ( i = 1 ; i < 3 ; i++ ) {
+ slow_decoder->message[message_index][i - 1 ] = data[i];
+ }
+
+ slow_decoder->decode_state = MESSAGE_SECOND_FRAME;
+
+ break;
+ }
+ default:
+ //output("SLOW DATA BYTES 0x%X 0x%X 0x%X \n", data[0], data[1], data[2]);
+ break;
+ }
+ break;
+ }
+ case HEADER_SECOND_FRAME:
+ {
+ //output("HEADER SECOND FRAME\n");
+ if ( slow_decoder->header_array_index == 0 ) {
+ /* We reached the end of the array so we need to reset and find the first frame again */
+ slow_decoder->decode_state = FIRST_FRAME;
+ break;
+ }
+
+ for ( i = 0 ; i < 3 ; i++ ) {
+ slow_decoder->header_bytes[slow_decoder->header_array_index++] =
+ data[i];
+ if ( slow_decoder->header_array_index >= RADIO_HEADER_LENGTH_BYTES )
+ {
+ _slow_data_processHeaderBytes(dstar);
+ break;
+ }
+ }
+
+ slow_decoder->decode_state = FIRST_FRAME;
+
+ break;
+ }
+ case MESSAGE_SECOND_FRAME:
+ {
+ for ( i = 0 ; i < 3 ; i++ ) {
+ slow_decoder->message[slow_decoder->message_index][i+2] = data[i];
+ }
+
+ slow_decoder->message_index++;
+
+ if ( slow_decoder->message_index >= 4 ) {
+ _slow_data_processMessage(dstar);
+ }
+
+ slow_decoder->decode_state = FIRST_FRAME;
+
+ break;
+ }
+ }
+
+}
diff --git a/DSP_API/ThumbDV/slow_data.h b/DSP_API/ThumbDV/slow_data.h
new file mode 100644
index 0000000..f3f849d
--- /dev/null
+++ b/DSP_API/ThumbDV/slow_data.h
@@ -0,0 +1,43 @@
+///*! \file slow_data.h
+// *
+// * Handles scrambling and descrambling of DSTAR Header
+// *
+// * \date 25-AUG-2015
+// * \author Ed Gonzalez KG5FBT
+// */
+
+/* *****************************************************************************
+ *
+ * Copyright (C) 2012-2014 FlexRadio Systems.
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * Contact Information:
+ * email: gplflexradiosystems.com
+ * Mail: FlexRadio Systems, Suite 1-150, 4616 W. Howard LN, Austin, TX 78728
+ *
+ * ************************************************************************** */
+
+#ifndef THUMBDV_SLOW_DATA_H_
+#define THUMBDV_SLOW_DATA_H_
+
+#include "dstar.h"
+#include "common.h"
+#include "DStarDefines.h"
+
+void slow_data_addDecodeData(DSTAR_MACHINE dstar, unsigned char * data, uint32 data_len);
+void slow_data_resetDecoder(DSTAR_MACHINE dstar);
+void slow_data_resetEncoder(DSTAR_MACHINE dstar);
+void slow_data_getEncodeBytes( DSTAR_MACHINE dstar, unsigned char * bytes, uint32 num_bytes );
+void slow_data_createEncodeBytes(DSTAR_MACHINE dstar);
+#endif /* THUMBDV_SLOW_DATA_H_*/
+
diff --git a/pc/CODEC2 GUI/CODEC2 GUI/App.config b/pc/CODEC2 GUI/CODEC2 GUI/App.config
new file mode 100644
index 0000000..c67a3ad
--- /dev/null
+++ b/pc/CODEC2 GUI/CODEC2 GUI/App.config
@@ -0,0 +1,43 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ 1000
+
+
+
+
diff --git a/pc/CODEC2 GUI/CODEC2 GUI/AssemblyInfo.cs b/pc/CODEC2 GUI/CODEC2 GUI/AssemblyInfo.cs
new file mode 100644
index 0000000..a360720
--- /dev/null
+++ b/pc/CODEC2 GUI/CODEC2 GUI/AssemblyInfo.cs
@@ -0,0 +1,120 @@
+/*******************************************************************************
+ * AssemblyInfo.cs
+ *
+ * Helper class that holds Assembly Info
+ *
+ * Created on: 2015-08-23
+ * Author: Mark Hanson / AA3RK / MKCM Software, LLC.
+ *
+ *
+ *******************************************************************************
+ *
+ * Copyright (C) 2015 FlexRadio Systems.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * Contact: gplflexradiocom or
+ *
+ * GPL C/O FlexRadio Systems
+ * 4616 W. Howard Lane
+ * Suite 1-150
+ * Austin, TX USA 78728
+ *
+ ******************************************************************************/
+using System;
+using System.IO;
+using System.Reflection;
+
+namespace CODEC2_GUI
+{
+ public class AssemblyInfo
+ {
+ public AssemblyInfo(Assembly assembly)
+ {
+ if (assembly == null)
+ throw new ArgumentNullException("assembly");
+ this.assembly = assembly;
+ }
+
+ private readonly Assembly assembly;
+
+ ///
+ /// Gets the title property
+ ///
+ public string ProductTitle
+ {
+ get
+ {
+ return GetAttributeValue(a => a.Title,
+ Path.GetFileNameWithoutExtension(assembly.CodeBase));
+ }
+ }
+
+ ///
+ /// Gets the application's version
+ ///
+ public string Version
+ {
+ get
+ {
+ string result = string.Empty;
+ Version version = assembly.GetName().Version;
+ if (version != null)
+ return version.ToString();
+ else
+ return "1.0.0.0";
+ }
+ }
+
+ ///
+ /// Gets the description about the application.
+ ///
+ public string Description
+ {
+ get { return GetAttributeValue(a => a.Description); }
+ }
+
+
+ ///
+ /// Gets the product's full name.
+ ///
+ public string Product
+ {
+ get { return GetAttributeValue(a => a.Product); }
+ }
+
+ ///
+ /// Gets the copyright information for the product.
+ ///
+ public string Copyright
+ {
+ get { return GetAttributeValue(a => a.Copyright); }
+ }
+
+ ///
+ /// Gets the company information for the product.
+ ///
+ public string Company
+ {
+ get { return GetAttributeValue(a => a.Company); }
+ }
+
+ protected string GetAttributeValue(Func resolveFunc, string defaultResult = null) where TAttr : Attribute
+ {
+ object[] attributes = assembly.GetCustomAttributes(typeof(TAttr), false);
+ if (attributes.Length > 0)
+ return resolveFunc((TAttr)attributes[0]);
+ else
+ return defaultResult;
+ }
+ }
+}
diff --git a/pc/CODEC2 GUI/CODEC2 GUI/DstarInfo.cs b/pc/CODEC2 GUI/CODEC2 GUI/DstarInfo.cs
new file mode 100644
index 0000000..8b18fd7
--- /dev/null
+++ b/pc/CODEC2 GUI/CODEC2 GUI/DstarInfo.cs
@@ -0,0 +1,524 @@
+/*******************************************************************************
+ * DstarInfo.cs
+ *
+ * Helper class which collects DSTAR information
+ *
+ * Created on: 2015-08-22
+ * Author: Mark Hanson / AA3RK / MKCM Software, LLC.
+ *
+ *
+ *******************************************************************************
+ *
+ * Copyright (C) 2015 FlexRadio Systems.
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see .
+ *
+ * Contact: gplflexradiocom or
+ *
+ * GPL C/O FlexRadio Systems
+ * 4616 W. Howard Lane
+ * Suite 1-150
+ * Austin, TX USA 78728
+ *
+ ******************************************************************************/
+
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Net;
+using System.Net.Http;
+using System.Threading.Tasks;
+using System.IO;
+using System.Net.Http.Headers;
+using System.Reflection;
+using System.Xml;
+
+namespace CODEC2_GUI
+{
+ public class DstarInfo
+ {
+ public DstarInfo()
+ {
+
+ }
+
+ private static HttpClient _client;
+ private static HttpClient client
+ {
+ get
+ {
+ if (_client == null)
+ _client = new HttpClient() { BaseAddress = new Uri("http://apps.dstarinfo.com") };
+ return _client;
+ }
+ }
+ private static string eventvalidation;
+ private static string viewstate;
+ private static string viewstategenerator;
+
+
+ private List Repeaters_;
+ public List Repeaters
+ {
+ get
+ {
+ if (Repeaters_ == null)
+ {
+ LoadRepeaters();
+ if (Repeaters_ == null)
+ Repeaters_ = new List();
+
+ }
+ return Repeaters_;
+ }
+ }
+
+ private List Reflectors_;
+ public List Refelectors
+ {
+ get
+ {
+ if (Reflectors_ == null)
+ {
+ LoadReflectors();
+ if (Reflectors_ == null || Reflectors_.Count == 0)
+ {
+ try
+ {
+ FetchAndSaveReflectorList();
+ }
+ catch { }
+ }
+ }
+ return Reflectors_;
+ }
+ }
+
+ public bool FetchAndSaveRepeaterList(string area)
+ {
+ bool result = false;
+ try
+ {
+ List rptrs = GetDStarRepeaterByArea(area);
+ if (rptrs != null && rptrs.Count > 0)
+ {
+ SaveRepeaters(rptrs);
+ Repeaters_ = rptrs;
+ result = true;
+ }
+ }
+ catch (Exception ex)
+ {
+ string msg = "Fetch and save Repeater list failed!";
+ System.Diagnostics.Debug.WriteLine(string.Format("{0} {1}", msg, ex.Message));
+ throw new ApplicationException(msg, ex);
+ }
+ return result;
+ }
+
+ public bool FetchAndSaveReflectorList()
+ {
+ bool result = false;
+ try
+ {
+ List refs = GetDStarInfoReflectors();
+ if (refs != null && refs.Count > 0)
+ {
+ SaveReflectors(refs);
+ Reflectors_ = refs;
+ result = true;
+ }
+ }
+ catch(Exception ex)
+ {
+ string msg = "Fetch and save Relflector list failed!";
+ System.Diagnostics.Debug.WriteLine(string.Format("{0} {1}", msg, ex.Message));
+ throw new ApplicationException(msg, ex);
+ }
+ return result;
+ }
+
+ public List GetDStarRepeaterAreas()
+ {
+ List rptareas = new List();
+ string htmlAreas = string.Empty;
+
+ try
+ {
+ if (client != null)
+ {
+ HttpRequestMessage request = new HttpRequestMessage(HttpMethod.Get, "D-STAR_Repeater_List.aspx");
+ Task resp = client.SendAsync(request);
+ resp.Wait();
+ resp.Result.EnsureSuccessStatusCode();
+
+ Task strm = resp.Result.Content.ReadAsStreamAsync();
+ strm.Wait();
+ using (StreamReader sr = new StreamReader(strm.Result, System.Text.Encoding.UTF8))
+ {
+ htmlAreas = sr.ReadToEnd();
+ }
+ }
+
+ viewstate = getHiddenValues(htmlAreas, "id=\"__VIEWSTATE\" value=\"");
+ viewstategenerator = getHiddenValues(htmlAreas, "id=\"__VIEWSTATEGENERATOR\" value=\"");
+ eventvalidation = getHiddenValues(htmlAreas, "id=\"__EVENTVALIDATION\" value=\"");
+
+ // parsing HTML select of areas
+ // start by finding "", ofs + 23);
+ if (ofs2 > 0)
+ {
+ string selVals = htmlAreas.Substring(ofs, ofs2 - ofs);
+ int ofs3 = 0;
+ int ofs4 = 0;
+ while (ofs4 < selVals.Length)
+ {
+ ofs4 = selVals.IndexOf("