diff --git a/DSP_API/ThumbDV/DStarDefines.h b/DSP_API/ThumbDV/DStarDefines.h index fe82e99..64f947d 100644 --- a/DSP_API/ThumbDV/DStarDefines.h +++ b/DSP_API/ThumbDV/DStarDefines.h @@ -22,20 +22,20 @@ #define DSTAR_GMSK_SYMBOL_RATE 4800U #define DSTAR_GMSK_BT 0.5F -const BOOL BIT_SYNC_BITS[] = {TRUE, FALSE, TRUE, FALSE}; +static const BOOL BIT_SYNC_BITS[] = {TRUE, FALSE, TRUE, FALSE}; #define BIT_SYNC_LENGTH_BITS = 4U; -const BOOL FRAME_SYNC_BITS[] = {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, +static const BOOL FRAME_SYNC_BITS[] = {TRUE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, FALSE}; #define FRAME_SYNC_LENGTH_BITS 15U -const unsigned char DATA_SYNC_BYTES[] = {0x55, 0x2D, 0x16}; -const BOOL DATA_SYNC_BITS[] = {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, +static const unsigned char DATA_SYNC_BYTES[] = {0x55, 0x2D, 0x16}; +static const BOOL DATA_SYNC_BITS[] = {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, FALSE, FALSE, FALSE}; -const unsigned char END_PATTERN_BYTES[] = {0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A}; -const BOOL END_PATTERN_BITS[] = {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, +static const unsigned char END_PATTERN_BYTES[] = {0x55, 0x55, 0x55, 0x55, 0xC8, 0x7A}; +static const BOOL END_PATTERN_BITS[] = {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, @@ -45,8 +45,8 @@ const BOOL END_PATTERN_BITS[] = {TRUE, FALSE, TRUE, FALSE, TRUE, FALSE, TRUE, #define END_PATTERN_LENGTH_BITS 48U #define END_PATTERN_LENGTH_BYTES (END_PATTERN_LENGTH_BITS / 8U) -const unsigned char NULL_AMBE_DATA_BYTES[] = {0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8}; -const BOOL NULL_AMBE_DATA_BITS[] = {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, +static const unsigned char NULL_AMBE_DATA_BYTES[] = {0x9E, 0x8D, 0x32, 0x88, 0x26, 0x1A, 0x3F, 0x61, 0xE8}; +static const BOOL NULL_AMBE_DATA_BITS[] = {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, TRUE, FALSE, FALSE, FALSE, TRUE, @@ -57,7 +57,7 @@ const BOOL NULL_AMBE_DATA_BITS[] = {FALSE, TRUE, TRUE, TRUE, TRUE, FALSE, FA FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, TRUE}; // Note that these are already scrambled, 0x66 0x66 0x66 otherwise -const BOOL NULL_SLOW_DATA_BITS[] = {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, +static const BOOL NULL_SLOW_DATA_BITS[] = {FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, TRUE, FALSE, FALSE, FALSE, TRUE, FALSE, TRUE, FALSE, FALSE, TRUE, TRUE, TRUE, TRUE, TRUE, FALSE, TRUE, FALSE, TRUE}; diff --git a/DSP_API/ThumbDV/gmsk_modem.c b/DSP_API/ThumbDV/gmsk_modem.c index 0a31c95..369b2c6 100644 --- a/DSP_API/ThumbDV/gmsk_modem.c +++ b/DSP_API/ThumbDV/gmsk_modem.c @@ -33,7 +33,6 @@ #include "gmsk_modem.h" #include "bit_pattern_matcher.h" - /* Filters */ void gmsk_bitsToByte(BOOL * bits, unsigned char * byte) @@ -54,6 +53,20 @@ void gmsk_bitsToByte(BOOL * bits, unsigned char * byte) *byte = new_byte; } +void gmsk_bitsToBytes(BOOL * bits, unsigned char * bytes, uint32 num_of_bits) +{ + if ( bits == NULL || bytes == NULL) { + output(ANSI_RED "NULL Pointer in bitsToBytes\n" ANSI_WHITE); + return; + } + + uint32 i = 0; + for ( i = 0 ; i < num_of_bits / 8 ; i++ ) { + gmsk_bitsToByte(&bits[i*8], &bytes[i]); + } + +} + void gmsk_byteToBits(unsigned char byte, BOOL * bits, uint32 num_bits) { if ( bits == NULL ) { diff --git a/DSP_API/ThumbDV/gmsk_modem.h b/DSP_API/ThumbDV/gmsk_modem.h index 8819994..d70bf64 100644 --- a/DSP_API/ThumbDV/gmsk_modem.h +++ b/DSP_API/ThumbDV/gmsk_modem.h @@ -62,6 +62,7 @@ typedef struct _gmsk_mod void gmsk_testBitsAndEncodeDecode(void); void gmsk_bitsToByte(BOOL * bits, unsigned char * byte); +void gmsk_bitsToBytes(BOOL * bits, unsigned char * bytes, uint32 num_of_bits); void gmsk_byteToBits(unsigned char byte, BOOL * bits, uint32 num_bits); void gmsk_bytesToBits(unsigned char * bytes, BOOL * bits, uint32 num_bits); diff --git a/DSP_API/ThumbDV/thumbDV.c b/DSP_API/ThumbDV/thumbDV.c index 79c13e5..33240cf 100644 --- a/DSP_API/ThumbDV/thumbDV.c +++ b/DSP_API/ThumbDV/thumbDV.c @@ -219,13 +219,13 @@ static void delay(unsigned int delay) { nanosleep(&tim, &tim2); }; -static void dump(char *text, unsigned char *data, unsigned int length) +void thumbDV_dump(char *text, unsigned char *data, unsigned int length) { unsigned int offset = 0U; unsigned int i; - fputs(text, stdout); - fputc('\n', stdout); + output("%s", text); + output("\n"); while (length > 0U) { unsigned int bytes = (length > 16U) ? 16U : length; @@ -233,23 +233,23 @@ static void dump(char *text, unsigned char *data, unsigned int length) output( "%04X: ", offset); for (i = 0U; i < bytes; i++) - fprintf(stdout, "%02X ", data[offset + i]); + output( "%02X ", data[offset + i]); for (i = bytes; i < 16U; i++) - fputs(" ", stdout); + output(" "); - fputs(" *", stdout); + output(" *"); for (i = 0U; i < bytes; i++) { unsigned char c = data[offset + i]; if (isprint(c)) - fputc(c, stdout); + output("%c",c); else - fputc('.', stdout); + output("."); } - fputs("*\n", stdout); + output("*\n"); offset += 16U; @@ -379,7 +379,7 @@ int thumbDV_processSerial(int serial_fd) packet_type = buffer[3]; //dump("Serial data", buffer, respLen); if ( packet_type == AMBE3000_CTRL_PKT_TYPE ) { - dump("Serial data", buffer, respLen); + thumbDV_dump("Serial data", buffer, respLen); } else if ( packet_type == AMBE3000_CHAN_PKT_TYPE ) { desc = hal_BufferRequest(respLen, sizeof(unsigned char) ); memcpy(desc->buf_ptr, buffer, respLen); diff --git a/DSP_API/ThumbDV/thumbDV.h b/DSP_API/ThumbDV/thumbDV.h index 37fc1e8..01cb012 100644 --- a/DSP_API/ThumbDV/thumbDV.h +++ b/DSP_API/ThumbDV/thumbDV.h @@ -43,4 +43,5 @@ int thumbDV_processSerial(int serial_fd); int thumbDV_encode(int serial_fd, short * speech_in, unsigned char * packet_out, uint8 num_of_samples ); int thumbDV_decode(int serial_fd, unsigned char * packet_in, short * speech_out, uint8 bytes_in_packet); +void thumbDV_dump(char *text, unsigned char *data, unsigned int length); #endif /* THUMBDV_THUMBDV_ */