Use output in dump function and change const to static const

This commit is contained in:
Ed Gonzalez 2015-06-11 09:14:50 -05:00
parent b3c43dafe5
commit 8bfb382d25
5 changed files with 35 additions and 20 deletions

View file

@ -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};

View file

@ -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 ) {

View file

@ -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);

View file

@ -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);

View file

@ -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_ */