|
|
|
|
@ -1,8 +1,21 @@
|
|
|
|
|
/*
|
|
|
|
|
* DVRPTR Repeater for Linux
|
|
|
|
|
* Autor: DG1HT DH2YBE KI4LKF N7TAE
|
|
|
|
|
* Copyright (C) 2020 by Thomas Early N7TAE
|
|
|
|
|
*
|
|
|
|
|
--------------------------------------------------------------------------------------------------------*/
|
|
|
|
|
* 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 2 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, write to the Free Software
|
|
|
|
|
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <ctype.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
@ -21,104 +34,17 @@
|
|
|
|
|
#include <termios.h>
|
|
|
|
|
#include <wchar.h>
|
|
|
|
|
#include <sys/file.h>
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
|
|
#include "Random.h"
|
|
|
|
|
#include "UnixPacketSock.h"
|
|
|
|
|
#include "QnetConfigure.h"
|
|
|
|
|
#include "QnetTypeDefs.h"
|
|
|
|
|
#include "DStarDecode.h"
|
|
|
|
|
#include "QnetDVRPTR.h"
|
|
|
|
|
|
|
|
|
|
#define DVRPTR_VERSION "QnetDVRPTR-523"
|
|
|
|
|
#define DVRPTR_VERSION "QnetDVRPTR-526"
|
|
|
|
|
|
|
|
|
|
#define BAUD B115200
|
|
|
|
|
#define CALL_SIZE 8
|
|
|
|
|
#define IP_SIZE 15
|
|
|
|
|
|
|
|
|
|
/*** BER stuff ***/
|
|
|
|
|
static int ber_data[3];
|
|
|
|
|
static int ber_errs;
|
|
|
|
|
static int num_dv_frames;
|
|
|
|
|
static int num_bit_errors;
|
|
|
|
|
|
|
|
|
|
short block = 0;
|
|
|
|
|
short old_seq_no = 0;
|
|
|
|
|
|
|
|
|
|
short seq_no1 = 1;
|
|
|
|
|
short seq_no2 = 1;
|
|
|
|
|
short seq_no3 = 0;
|
|
|
|
|
int fd_ser = -1;
|
|
|
|
|
bool busy20000 = false;
|
|
|
|
|
|
|
|
|
|
static int rqst_count = 6;
|
|
|
|
|
static unsigned short streamid = 0x0;
|
|
|
|
|
static unsigned char start_Header[8]= {0xD0,0x03,0x00,0x16,0x01,0x00,0x00,0x00};
|
|
|
|
|
static unsigned char ptt_off[8]= {0xD0,0x03,0x00,0x1A,0x01,0xff,0x00,0x00};
|
|
|
|
|
|
|
|
|
|
static bool ReadConfig(const char *cfgFile);
|
|
|
|
|
static void readFrom20000();
|
|
|
|
|
static bool check_serial();
|
|
|
|
|
|
|
|
|
|
SDSVT Send_Network_Header;
|
|
|
|
|
SDSVT Send_Network_Audio;
|
|
|
|
|
|
|
|
|
|
static int inactiveMax = 3200;
|
|
|
|
|
|
|
|
|
|
static unsigned char Send_Modem_Header[52];
|
|
|
|
|
|
|
|
|
|
static unsigned char writevoice[24];
|
|
|
|
|
static unsigned char writevoice1[24];
|
|
|
|
|
|
|
|
|
|
// Modem INIT
|
|
|
|
|
static unsigned char Modem_Init0[6]= {0xD0,0x01,0x00,0x11,0x00,0x00};
|
|
|
|
|
static unsigned char Modem_Init1[7]= {0xD0,0x02,0x00,0x10,0x03,0x00,0x00}; // RX TX Enable
|
|
|
|
|
static unsigned char Modem_Init2[12]= {0xD0,0x07,0x00,0x14,0xC0,0x04,0x00,0x57,0x53,0x00,0x00,0x00}; // Modem Init
|
|
|
|
|
static unsigned char Modem_STATUS[6]= {0xD0,0x01,0x00,0x10,0x00,0x00}; // Status Abfragr
|
|
|
|
|
static unsigned char Modem_SERIAL[6]= {0xD0,0x01,0x00,0x12,0x00,0x00};
|
|
|
|
|
|
|
|
|
|
static int assigned_module;
|
|
|
|
|
static std::string togate;
|
|
|
|
|
CUnixPacketClient ToGate;
|
|
|
|
|
|
|
|
|
|
static std::string DVRPTR_SERIAL;
|
|
|
|
|
static char DVCALL[CALL_SIZE + 1];
|
|
|
|
|
static char RPTR[CALL_SIZE + 1];
|
|
|
|
|
static char DVRPTR_MOD = 'B';
|
|
|
|
|
static int RF_AUDIO_Level = 10;
|
|
|
|
|
static bool DUPLEX = true;
|
|
|
|
|
static int ACK_DELAY = 200000;
|
|
|
|
|
static int DELAY_BETWEEN = 20000;
|
|
|
|
|
static bool RPTR_ACK = false;
|
|
|
|
|
static char ENABLE_RF[CALL_SIZE + 1];
|
|
|
|
|
static char DISABLE_RF[CALL_SIZE + 1];
|
|
|
|
|
static bool IS_ENABLED = true;
|
|
|
|
|
static bool ok = false;
|
|
|
|
|
static bool RX_Inverse = true;
|
|
|
|
|
static bool TX_Inverse = true;
|
|
|
|
|
static int TX_DELAY; /* in milliseconds */
|
|
|
|
|
static unsigned char SND_TERM_ID = 0x00;
|
|
|
|
|
static char DVCALL_and_G[9];
|
|
|
|
|
static char DVCALL_and_MOD[9];
|
|
|
|
|
static int REMOTE_TIMEOUT = 1; /* 1 second */
|
|
|
|
|
static int RQST_COUNT = 6;
|
|
|
|
|
static u_int16_t streamid_raw = 0;
|
|
|
|
|
static char myRPT2[10]; //RX from HF RPT2
|
|
|
|
|
static char myRPT1[10]; //RX from HF RPT1
|
|
|
|
|
static char myUR[10];
|
|
|
|
|
static char myCall[10];
|
|
|
|
|
static char myCall2[10];
|
|
|
|
|
|
|
|
|
|
char cbuf[250];
|
|
|
|
|
|
|
|
|
|
static SDSVT recv_buf;
|
|
|
|
|
|
|
|
|
|
//! 32-bit union.
|
|
|
|
|
typedef union {
|
|
|
|
|
uint32_t u32;
|
|
|
|
|
uint16_t u16[2];
|
|
|
|
|
uint8_t u8[4];
|
|
|
|
|
} Union32;
|
|
|
|
|
|
|
|
|
|
static const uint32_t ENCODING_TABLE_24128[] = {
|
|
|
|
|
0x000000U, 0x0018EBU, 0x00293EU, 0x0031D5U, 0x004A97U, 0x00527CU, 0x0063A9U, 0x007B42U, 0x008DC6U, 0x00952DU,
|
|
|
|
|
0x00A4F8U, 0x00BC13U, 0x00C751U, 0x00DFBAU, 0x00EE6FU, 0x00F684U, 0x010367U, 0x011B8CU, 0x012A59U, 0x0132B2U,
|
|
|
|
|
@ -532,8 +458,31 @@ static const uint32_t ENCODING_TABLE_24128[] = {
|
|
|
|
|
0xFFAD83U, 0xFFB568U, 0xFFCE2AU, 0xFFD6C1U, 0xFFE714U, 0xFFFFFFU
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Compute the syndrome corresponding to the given pattern, i.e., the
|
|
|
|
|
* remainder after dividing the pattern (when considering it as the vector
|
|
|
|
|
* representation of a polynomial) by the generator polynomial, GENPOL.
|
|
|
|
|
* In the program this pattern has several meanings: (1) pattern = infomation
|
|
|
|
|
* bits, when constructing the encoding table; (2) pattern = error pattern,
|
|
|
|
|
* when constructing the decoding table; and (3) pattern = received vector, to
|
|
|
|
|
* obtain its syndrome in decoding.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
uint32_t CQnetDVRPTR::get_syndrome_23127(uint32_t pattern)
|
|
|
|
|
{
|
|
|
|
|
uint32_t aux = GORLAY_X22;
|
|
|
|
|
if (pattern >= GORLAY_X11) {
|
|
|
|
|
while (pattern & GORLAY_MASK12) {
|
|
|
|
|
while ((aux & pattern)==0) aux >>= 1;
|
|
|
|
|
pattern ^= (aux / GORLAY_X11) * GORLAY_GENPOL;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const uint32_t DECODING_TABLE_23127[] = {
|
|
|
|
|
unsigned int CQnetDVRPTR::gorlay_decode23127(unsigned int code)
|
|
|
|
|
{
|
|
|
|
|
const uint32_t DECODING_TABLE_23127[] = {
|
|
|
|
|
0x000000U, 0x000001U, 0x000002U, 0x000003U, 0x000004U, 0x000005U, 0x000006U, 0x000007U, 0x000008U, 0x000009U,
|
|
|
|
|
0x00000AU, 0x00000BU, 0x00000CU, 0x00000DU, 0x00000EU, 0x024020U, 0x000010U, 0x000011U, 0x000012U, 0x000013U,
|
|
|
|
|
0x000014U, 0x000015U, 0x000016U, 0x412000U, 0x000018U, 0x000019U, 0x00001AU, 0x180800U, 0x00001CU, 0x200300U,
|
|
|
|
|
@ -741,52 +690,23 @@ static const uint32_t DECODING_TABLE_23127[] = {
|
|
|
|
|
0x011001U, 0x011000U, 0x080420U, 0x011002U, 0x100048U, 0x011004U, 0x204200U, 0x028080U
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define GORLAY_X22 0x00400000 // vector representation of X^{22}
|
|
|
|
|
#define GORLAY_X11 0x00000800 // vector representation of X^{11}
|
|
|
|
|
#define GORLAY_MASK12 0xfffff800 // auxiliary vector for testing
|
|
|
|
|
#define GORLAY_GENPOL 0x00000c75 // generator polinomial, g(x)
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* Compute the syndrome corresponding to the given pattern, i.e., the
|
|
|
|
|
* remainder after dividing the pattern (when considering it as the vector
|
|
|
|
|
* representation of a polynomial) by the generator polynomial, GENPOL.
|
|
|
|
|
* In the program this pattern has several meanings: (1) pattern = infomation
|
|
|
|
|
* bits, when constructing the encoding table; (2) pattern = error pattern,
|
|
|
|
|
* when constructing the decoding table; and (3) pattern = received vector, to
|
|
|
|
|
* obtain its syndrome in decoding.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
static uint32_t get_syndrome_23127(uint32_t pattern)
|
|
|
|
|
{
|
|
|
|
|
uint32_t aux = GORLAY_X22;
|
|
|
|
|
if (pattern >= GORLAY_X11) {
|
|
|
|
|
while (pattern & GORLAY_MASK12) {
|
|
|
|
|
while ((aux & pattern)==0) aux >>= 1;
|
|
|
|
|
pattern ^= (aux / GORLAY_X11) * GORLAY_GENPOL;
|
|
|
|
|
} // ehliw
|
|
|
|
|
} // fi pattern doesn't fit
|
|
|
|
|
return pattern;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
unsigned int gorlay_decode23127(unsigned int code)
|
|
|
|
|
{
|
|
|
|
|
uint32_t syndrome = get_syndrome_23127(code);
|
|
|
|
|
uint32_t error_pattern = DECODING_TABLE_23127[syndrome];
|
|
|
|
|
code ^= error_pattern;
|
|
|
|
|
return code >> 11;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__inline unsigned int gorlay_encode24128(unsigned int data)
|
|
|
|
|
unsigned int CQnetDVRPTR::gorlay_encode24128(unsigned int data)
|
|
|
|
|
{
|
|
|
|
|
return ENCODING_TABLE_24128[data];
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
__inline unsigned int gorlay_decode24128(unsigned int code)
|
|
|
|
|
unsigned int CQnetDVRPTR::gorlay_decode24128(unsigned int code)
|
|
|
|
|
{
|
|
|
|
|
return gorlay_decode23127(code >> 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static const uint32_t PRNG_TABLE[] = {
|
|
|
|
|
const uint32_t PRNG_TABLE[] = {
|
|
|
|
|
0x42CC47U, 0x19D6FEU, 0x304729U, 0x6B2CD0U, 0x60BF47U, 0x39650EU, 0x7354F1U, 0xEACF60U, 0x819C9FU, 0xDE25CEU,
|
|
|
|
|
0xD7B745U, 0x8CC8B8U, 0x8D592BU, 0xF71257U, 0xBCA084U, 0xA5B329U, 0xEE6AFAU, 0xF7D9A7U, 0xBCC21CU, 0x4712D9U,
|
|
|
|
|
0x4F2922U, 0x14FA37U, 0x5D43ECU, 0x564115U, 0x299A92U, 0x20A9EBU, 0x7B707DU, 0x3BE3A4U, 0x20D95BU, 0x6B085AU,
|
|
|
|
|
@ -1199,15 +1119,7 @@ static const uint32_t PRNG_TABLE[] = {
|
|
|
|
|
0xF9A540U, 0x205ED9U, 0x634EB6U, 0x5A9567U, 0x11A6D8U, 0x0B3F09U
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
typedef unsigned char tambevoicefec[9];
|
|
|
|
|
typedef unsigned char tambevoice[6];
|
|
|
|
|
|
|
|
|
|
#define interleaveambe12(bp) { bp+=12; if (bp>71) bp -= 71; }
|
|
|
|
|
|
|
|
|
|
static CDStarDecode decode;
|
|
|
|
|
|
|
|
|
|
static void ambefec_deinterleave(tambevoicefec result, const tambevoicefec voice)
|
|
|
|
|
void CQnetDVRPTR::ambefec_deinterleave(tambevoicefec result, const tambevoicefec voice)
|
|
|
|
|
{
|
|
|
|
|
uint32_t bitpos, bytcnt;
|
|
|
|
|
memset(result, 0, sizeof(tambevoicefec)); // init result
|
|
|
|
|
@ -1233,7 +1145,7 @@ static void ambefec_deinterleave(tambevoicefec result, const tambevoicefec voice
|
|
|
|
|
} // rof
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void ambefec_interleave(tambevoicefec result, const tambevoicefec raw_voice)
|
|
|
|
|
void CQnetDVRPTR::ambefec_interleave(tambevoicefec result, const tambevoicefec raw_voice)
|
|
|
|
|
{
|
|
|
|
|
uint32_t bitpos, bytcnt;
|
|
|
|
|
bitpos = 0;
|
|
|
|
|
@ -1258,7 +1170,7 @@ static void ambefec_interleave(tambevoicefec result, const tambevoicefec raw_voi
|
|
|
|
|
} // rof
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ambefec_regenerate(tambevoicefec voice)
|
|
|
|
|
void CQnetDVRPTR::ambefec_regenerate(tambevoicefec voice)
|
|
|
|
|
{
|
|
|
|
|
tambevoicefec decoded;
|
|
|
|
|
uint32_t data, datb, encoded_dat;
|
|
|
|
|
@ -1277,51 +1189,35 @@ void ambefec_regenerate(tambevoicefec voice)
|
|
|
|
|
ambefec_interleave(voice, decoded);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static unsigned char silence[12] = { 0x9e,0x8d,0x32,0x88,0x26,0x1a,0x3f,0x61,0xe8,0x70,0x4f,0x93 };
|
|
|
|
|
|
|
|
|
|
static unsigned short crc_tabccitt[256] = {
|
|
|
|
|
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,
|
|
|
|
|
0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
|
|
|
|
|
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,
|
|
|
|
|
0x9cc9,0x8d40,0xbfdb,0xae52,0xdaed,0xcb64,0xf9ff,0xe876,
|
|
|
|
|
0x2102,0x308b,0x0210,0x1399,0x6726,0x76af,0x4434,0x55bd,
|
|
|
|
|
0xad4a,0xbcc3,0x8e58,0x9fd1,0xeb6e,0xfae7,0xc87c,0xd9f5,
|
|
|
|
|
0x3183,0x200a,0x1291,0x0318,0x77a7,0x662e,0x54b5,0x453c,
|
|
|
|
|
0xbdcb,0xac42,0x9ed9,0x8f50,0xfbef,0xea66,0xd8fd,0xc974,
|
|
|
|
|
0x4204,0x538d,0x6116,0x709f,0x0420,0x15a9,0x2732,0x36bb,
|
|
|
|
|
0xce4c,0xdfc5,0xed5e,0xfcd7,0x8868,0x99e1,0xab7a,0xbaf3,
|
|
|
|
|
0x5285,0x430c,0x7197,0x601e,0x14a1,0x0528,0x37b3,0x263a,
|
|
|
|
|
0xdecd,0xcf44,0xfddf,0xec56,0x98e9,0x8960,0xbbfb,0xaa72,
|
|
|
|
|
0x6306,0x728f,0x4014,0x519d,0x2522,0x34ab,0x0630,0x17b9,
|
|
|
|
|
0xef4e,0xfec7,0xcc5c,0xddd5,0xa96a,0xb8e3,0x8a78,0x9bf1,
|
|
|
|
|
0x7387,0x620e,0x5095,0x411c,0x35a3,0x242a,0x16b1,0x0738,
|
|
|
|
|
0xffcf,0xee46,0xdcdd,0xcd54,0xb9eb,0xa862,0x9af9,0x8b70,
|
|
|
|
|
0x8408,0x9581,0xa71a,0xb693,0xc22c,0xd3a5,0xe13e,0xf0b7,
|
|
|
|
|
0x0840,0x19c9,0x2b52,0x3adb,0x4e64,0x5fed,0x6d76,0x7cff,
|
|
|
|
|
0x9489,0x8500,0xb79b,0xa612,0xd2ad,0xc324,0xf1bf,0xe036,
|
|
|
|
|
0x18c1,0x0948,0x3bd3,0x2a5a,0x5ee5,0x4f6c,0x7df7,0x6c7e,
|
|
|
|
|
0xa50a,0xb483,0x8618,0x9791,0xe32e,0xf2a7,0xc03c,0xd1b5,
|
|
|
|
|
0x2942,0x38cb,0x0a50,0x1bd9,0x6f66,0x7eef,0x4c74,0x5dfd,
|
|
|
|
|
0xb58b,0xa402,0x9699,0x8710,0xf3af,0xe226,0xd0bd,0xc134,
|
|
|
|
|
0x39c3,0x284a,0x1ad1,0x0b58,0x7fe7,0x6e6e,0x5cf5,0x4d7c,
|
|
|
|
|
0xc60c,0xd785,0xe51e,0xf497,0x8028,0x91a1,0xa33a,0xb2b3,
|
|
|
|
|
0x4a44,0x5bcd,0x6956,0x78df,0x0c60,0x1de9,0x2f72,0x3efb,
|
|
|
|
|
0xd68d,0xc704,0xf59f,0xe416,0x90a9,0x8120,0xb3bb,0xa232,
|
|
|
|
|
0x5ac5,0x4b4c,0x79d7,0x685e,0x1ce1,0x0d68,0x3ff3,0x2e7a,
|
|
|
|
|
0xe70e,0xf687,0xc41c,0xd595,0xa12a,0xb0a3,0x8238,0x93b1,
|
|
|
|
|
0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
|
|
|
|
|
0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x92b9,0x8330,
|
|
|
|
|
0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78
|
|
|
|
|
};
|
|
|
|
|
const unsigned char silence[12] = { 0x9e,0x8d,0x32,0x88,0x26,0x1a,0x3f,0x61,0xe8,0x70,0x4f,0x93 };
|
|
|
|
|
|
|
|
|
|
static void CleanCall(std::string &callsign) {
|
|
|
|
|
void CQnetDVRPTR::CleanCall(std::string &callsign) {
|
|
|
|
|
for (auto it=callsign.begin(); it!=callsign.end(); it++)
|
|
|
|
|
if (islower(*it))
|
|
|
|
|
*it = toupper(*it);
|
|
|
|
|
callsign.resize(CALL_SIZE, ' ');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void calcPFCS(unsigned char packet[58])//Netzwerk CRC
|
|
|
|
|
const unsigned short crc_tabccitt[256] = {
|
|
|
|
|
0x0000,0x1189,0x2312,0x329b,0x4624,0x57ad,0x6536,0x74bf,0x8c48,0x9dc1,0xaf5a,0xbed3,0xca6c,0xdbe5,0xe97e,0xf8f7,
|
|
|
|
|
0x1081,0x0108,0x3393,0x221a,0x56a5,0x472c,0x75b7,0x643e,0x9cc9,0x8d40,0xbfdb,0xae52,0xdaed,0xcb64,0xf9ff,0xe876,
|
|
|
|
|
0x2102,0x308b,0x0210,0x1399,0x6726,0x76af,0x4434,0x55bd,0xad4a,0xbcc3,0x8e58,0x9fd1,0xeb6e,0xfae7,0xc87c,0xd9f5,
|
|
|
|
|
0x3183,0x200a,0x1291,0x0318,0x77a7,0x662e,0x54b5,0x453c,0xbdcb,0xac42,0x9ed9,0x8f50,0xfbef,0xea66,0xd8fd,0xc974,
|
|
|
|
|
0x4204,0x538d,0x6116,0x709f,0x0420,0x15a9,0x2732,0x36bb,0xce4c,0xdfc5,0xed5e,0xfcd7,0x8868,0x99e1,0xab7a,0xbaf3,
|
|
|
|
|
0x5285,0x430c,0x7197,0x601e,0x14a1,0x0528,0x37b3,0x263a,0xdecd,0xcf44,0xfddf,0xec56,0x98e9,0x8960,0xbbfb,0xaa72,
|
|
|
|
|
0x6306,0x728f,0x4014,0x519d,0x2522,0x34ab,0x0630,0x17b9,0xef4e,0xfec7,0xcc5c,0xddd5,0xa96a,0xb8e3,0x8a78,0x9bf1,
|
|
|
|
|
0x7387,0x620e,0x5095,0x411c,0x35a3,0x242a,0x16b1,0x0738,0xffcf,0xee46,0xdcdd,0xcd54,0xb9eb,0xa862,0x9af9,0x8b70,
|
|
|
|
|
0x8408,0x9581,0xa71a,0xb693,0xc22c,0xd3a5,0xe13e,0xf0b7,0x0840,0x19c9,0x2b52,0x3adb,0x4e64,0x5fed,0x6d76,0x7cff,
|
|
|
|
|
0x9489,0x8500,0xb79b,0xa612,0xd2ad,0xc324,0xf1bf,0xe036,0x18c1,0x0948,0x3bd3,0x2a5a,0x5ee5,0x4f6c,0x7df7,0x6c7e,
|
|
|
|
|
0xa50a,0xb483,0x8618,0x9791,0xe32e,0xf2a7,0xc03c,0xd1b5,0x2942,0x38cb,0x0a50,0x1bd9,0x6f66,0x7eef,0x4c74,0x5dfd,
|
|
|
|
|
0xb58b,0xa402,0x9699,0x8710,0xf3af,0xe226,0xd0bd,0xc134,0x39c3,0x284a,0x1ad1,0x0b58,0x7fe7,0x6e6e,0x5cf5,0x4d7c,
|
|
|
|
|
0xc60c,0xd785,0xe51e,0xf497,0x8028,0x91a1,0xa33a,0xb2b3,0x4a44,0x5bcd,0x6956,0x78df,0x0c60,0x1de9,0x2f72,0x3efb,
|
|
|
|
|
0xd68d,0xc704,0xf59f,0xe416,0x90a9,0x8120,0xb3bb,0xa232,0x5ac5,0x4b4c,0x79d7,0x685e,0x1ce1,0x0d68,0x3ff3,0x2e7a,
|
|
|
|
|
0xe70e,0xf687,0xc41c,0xd595,0xa12a,0xb0a3,0x8238,0x93b1,0x6b46,0x7acf,0x4854,0x59dd,0x2d62,0x3ceb,0x0e70,0x1ff9,
|
|
|
|
|
0xf78f,0xe606,0xd49d,0xc514,0xb1ab,0xa022,0x92b9,0x8330,0x7bc7,0x6a4e,0x58d5,0x495c,0x3de3,0x2c6a,0x1ef1,0x0f78
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
void CQnetDVRPTR::calcPFCS(unsigned char *packet) //Netzwerk CRC
|
|
|
|
|
{
|
|
|
|
|
unsigned short crc_dstar_ffff = 0xffff;
|
|
|
|
|
unsigned short tmp, short_c;
|
|
|
|
|
@ -1342,7 +1238,7 @@ static void calcPFCS(unsigned char packet[58])//Netzwerk CRC
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* process configuration file */
|
|
|
|
|
static bool ReadConfig(const char *cfgFile)
|
|
|
|
|
bool CQnetDVRPTR::ReadConfig(const char *cfgFile)
|
|
|
|
|
{
|
|
|
|
|
CQnetConfigure cfg;
|
|
|
|
|
|
|
|
|
|
@ -1444,7 +1340,7 @@ static bool ReadConfig(const char *cfgFile)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
char *cleanstr (char *Text)
|
|
|
|
|
char *CQnetDVRPTR::cleanstr(char *Text)
|
|
|
|
|
{
|
|
|
|
|
static char cbuf[250];
|
|
|
|
|
memset(cbuf, 0U, 250U);
|
|
|
|
|
@ -1466,7 +1362,7 @@ char *cleanstr (char *Text)
|
|
|
|
|
return (cbuf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int open_port(char *dvrptr_device)
|
|
|
|
|
int CQnetDVRPTR::open_port(char *dvrptr_device)
|
|
|
|
|
{
|
|
|
|
|
int fd_ser = -1;
|
|
|
|
|
struct termios terminal;
|
|
|
|
|
@ -1491,7 +1387,7 @@ int open_port(char *dvrptr_device)
|
|
|
|
|
return fd_ser;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int read_port(int *fd_ser,unsigned char* buffera)
|
|
|
|
|
int CQnetDVRPTR::read_port(int *fd_ser,unsigned char* buffera)
|
|
|
|
|
{
|
|
|
|
|
int a;
|
|
|
|
|
fd_set rfds;
|
|
|
|
|
@ -1510,7 +1406,7 @@ int read_port(int *fd_ser,unsigned char* buffera)
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void send_ack(char *a_call, float ber)
|
|
|
|
|
void CQnetDVRPTR::send_ack(char *a_call, float ber)
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
@ -1678,7 +1574,7 @@ static void send_ack(char *a_call, float ber)
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static void readFrom20000()
|
|
|
|
|
void CQnetDVRPTR::readFrom20000()
|
|
|
|
|
{
|
|
|
|
|
int len;
|
|
|
|
|
fd_set readfd;
|
|
|
|
|
@ -1690,7 +1586,7 @@ static void readFrom20000()
|
|
|
|
|
bool written_to_q = false;
|
|
|
|
|
|
|
|
|
|
int fd = ToGate.GetFD();
|
|
|
|
|
while (true) {
|
|
|
|
|
while (keep_running) {
|
|
|
|
|
written_to_q = false;
|
|
|
|
|
|
|
|
|
|
tv.tv_sec = 0;
|
|
|
|
|
@ -1889,18 +1785,14 @@ static void readFrom20000()
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool check_serial()
|
|
|
|
|
bool CQnetDVRPTR::check_serial()
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
char dvrptr_device[FILENAME_MAX + 1];
|
|
|
|
|
int InitCount = 1;
|
|
|
|
|
InitCount = 1;
|
|
|
|
|
bool match = false;
|
|
|
|
|
unsigned char puffer[200];
|
|
|
|
|
// int bytes2;
|
|
|
|
|
short loop_count = 0;
|
|
|
|
|
char temp_dvrptr_serial[16];
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 32; i++) {
|
|
|
|
|
for (int i = 0; i < 32; i++) {
|
|
|
|
|
sprintf(dvrptr_device, "/dev/ttyACM%d", i);
|
|
|
|
|
if (access(dvrptr_device, R_OK | W_OK) != 0)
|
|
|
|
|
continue;
|
|
|
|
|
@ -1927,7 +1819,7 @@ bool check_serial()
|
|
|
|
|
}
|
|
|
|
|
printf("Device %s now locked for exclusive use\n", dvrptr_device);
|
|
|
|
|
|
|
|
|
|
loop_count = 0;
|
|
|
|
|
int loop_count = 0;
|
|
|
|
|
while (true) {
|
|
|
|
|
if (InitCount == 4 ) {
|
|
|
|
|
write(fd_ser, Modem_SERIAL, sizeof (Modem_SERIAL));
|
|
|
|
|
@ -1967,6 +1859,7 @@ bool check_serial()
|
|
|
|
|
(puffer[2] == 0x00) &&
|
|
|
|
|
(puffer[3] == 0x92)) {
|
|
|
|
|
puffer[1] = 0x00;
|
|
|
|
|
char temp_dvrptr_serial[16];
|
|
|
|
|
sprintf(temp_dvrptr_serial, "%02X.%02X.%02X.%02X", puffer[4], puffer[5], puffer[6], puffer[7]);
|
|
|
|
|
printf("Device %s has serial=[%s]\n", dvrptr_device, temp_dvrptr_serial);
|
|
|
|
|
if (strcmp(temp_dvrptr_serial, DVRPTR_SERIAL.c_str()) == 0) {
|
|
|
|
|
@ -1999,24 +1892,11 @@ bool check_serial()
|
|
|
|
|
|
|
|
|
|
int main(int argc, const char **argv)
|
|
|
|
|
{
|
|
|
|
|
int bytes2;
|
|
|
|
|
int i;
|
|
|
|
|
int InitCount = 1;
|
|
|
|
|
short seq_no = 0;
|
|
|
|
|
unsigned char puffer[200];
|
|
|
|
|
char Temp_Text[200];
|
|
|
|
|
time_t last_RF_time = 0;
|
|
|
|
|
time_t tNow = 0;
|
|
|
|
|
time_t time_rqst = 0;
|
|
|
|
|
|
|
|
|
|
int fw_version;
|
|
|
|
|
char fw_string[10];
|
|
|
|
|
|
|
|
|
|
setvbuf(stdout, NULL, _IOLBF, 0);
|
|
|
|
|
printf("dvrptr VERSION %s\n", DVRPTR_VERSION);
|
|
|
|
|
|
|
|
|
|
if (argc != 2) {
|
|
|
|
|
fprintf(stderr, "Usage: %s dvrptr.cfg\n", argv[0]);
|
|
|
|
|
fprintf(stderr, "Usage: %s <config_file>\n", argv[0]);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@ -2034,41 +1914,53 @@ int main(int argc, const char **argv)
|
|
|
|
|
}
|
|
|
|
|
qn += 8;
|
|
|
|
|
|
|
|
|
|
int mod;
|
|
|
|
|
switch (*qn) {
|
|
|
|
|
case NULL:
|
|
|
|
|
assigned_module = -1;
|
|
|
|
|
mod = -1;
|
|
|
|
|
break;
|
|
|
|
|
case 'a':
|
|
|
|
|
assigned_module = 0;
|
|
|
|
|
mod = 0;
|
|
|
|
|
break;
|
|
|
|
|
case 'b':
|
|
|
|
|
assigned_module = 1;
|
|
|
|
|
mod = 1;
|
|
|
|
|
break;
|
|
|
|
|
case 'c':
|
|
|
|
|
assigned_module = 2;
|
|
|
|
|
mod = 2;
|
|
|
|
|
break;
|
|
|
|
|
default:
|
|
|
|
|
fprintf(stderr, "ERROR: '%s' is not a valid module\nassigned module must be a, b or c\n", argv[1]);
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ReadConfig(argv[1])) {
|
|
|
|
|
fprintf(stderr, "Failed to process config file %s\n", argv[2]);
|
|
|
|
|
return 1;
|
|
|
|
|
CQnetDVRPTR dvrptr;
|
|
|
|
|
if (dvrptr.Init(argv[1], mod))
|
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
|
dvrptr.Run();
|
|
|
|
|
|
|
|
|
|
return EXIT_SUCCESS;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bool CQnetDVRPTR::Init(const char *file, int mod)
|
|
|
|
|
{
|
|
|
|
|
assigned_module = mod;
|
|
|
|
|
if (ReadConfig(file)) {
|
|
|
|
|
fprintf(stderr, "Failed to process config file %s\n", file);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!check_serial()) {
|
|
|
|
|
fprintf(stderr, "Cant find any FREE ACMx device that matches\n");
|
|
|
|
|
return 1;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (strlen(DVCALL) != 8) {
|
|
|
|
|
fprintf(stderr, "Bad DVCALL value, length must be exactly 8 bytes\n");
|
|
|
|
|
return 1;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
if ((DVRPTR_MOD != 'A') && (DVRPTR_MOD != 'B') && (DVRPTR_MOD != 'C')) {
|
|
|
|
|
fprintf(stderr, "Bad DVCALL_MOD value, must be one of A or B or C\n");
|
|
|
|
|
return 1;
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (DVRPTR_MOD == 'A')
|
|
|
|
|
@ -2084,8 +1976,8 @@ int main(int argc, const char **argv)
|
|
|
|
|
strcpy(DVCALL_and_MOD, DVCALL);
|
|
|
|
|
DVCALL_and_MOD[7] = DVRPTR_MOD;
|
|
|
|
|
|
|
|
|
|
if (ToGate.Open(togate.c_str()))
|
|
|
|
|
return 1;
|
|
|
|
|
if (ToGate.Open(togate.c_str(), this))
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
|
|
if (RX_Inverse == true) {
|
|
|
|
|
Modem_Init2[6]=0x01;
|
|
|
|
|
@ -2097,13 +1989,18 @@ int main(int argc, const char **argv)
|
|
|
|
|
else
|
|
|
|
|
Modem_Init2[6]=0x02;
|
|
|
|
|
}
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
time(&tNow);
|
|
|
|
|
void CQnetDVRPTR::Run()
|
|
|
|
|
{
|
|
|
|
|
time_t tNow = time(NULL);
|
|
|
|
|
CRandom Random;
|
|
|
|
|
|
|
|
|
|
time(&time_rqst);
|
|
|
|
|
time_t time_rqst = tNow;
|
|
|
|
|
time_t last_RF_time = tNow;
|
|
|
|
|
|
|
|
|
|
while (true) {
|
|
|
|
|
while (keep_running) {
|
|
|
|
|
time(&tNow);
|
|
|
|
|
if ((tNow - time_rqst) > 2) {
|
|
|
|
|
if (rqst_count < (RQST_COUNT - 2))
|
|
|
|
|
@ -2137,7 +2034,11 @@ int main(int argc, const char **argv)
|
|
|
|
|
InitCount = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
bytes2 = read_port(&fd_ser,puffer);
|
|
|
|
|
unsigned char puffer[200];
|
|
|
|
|
int bytes2 = read_port(&fd_ser, puffer);
|
|
|
|
|
char Temp_Text[200];
|
|
|
|
|
int seq_no = 0;
|
|
|
|
|
bool ok = false;
|
|
|
|
|
|
|
|
|
|
if (bytes2 > 0) {
|
|
|
|
|
switch (bytes2) {
|
|
|
|
|
@ -2263,7 +2164,7 @@ int main(int argc, const char **argv)
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (ok) {
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
|
if (!isupper(myCall[i]) &&
|
|
|
|
|
!isdigit(myCall[i]) &&
|
|
|
|
|
(myCall[i] != ' ')) {
|
|
|
|
|
@ -2274,7 +2175,7 @@ int main(int argc, const char **argv)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++) {
|
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
|
|
|
if (!isupper(myCall2[i]) &&
|
|
|
|
|
!isdigit(myCall2[i]) &&
|
|
|
|
|
(myCall2[i] != ' ')) {
|
|
|
|
|
@ -2283,7 +2184,7 @@ int main(int argc, const char **argv)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (i = 0; i < 8; i++) {
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
|
if (!isupper(myUR[i]) &&
|
|
|
|
|
!isdigit(myUR[i]) &&
|
|
|
|
|
(myUR[i] != ' ') &&
|
|
|
|
|
@ -2469,7 +2370,8 @@ int main(int argc, const char **argv)
|
|
|
|
|
|
|
|
|
|
printf("DVRPTR Hardware ver: %.20s\n",puffer+6 );
|
|
|
|
|
|
|
|
|
|
fw_version = puffer[4] + (puffer[5] << 8);
|
|
|
|
|
int fw_version = puffer[4] + (puffer[5] << 8);
|
|
|
|
|
char fw_string[10];
|
|
|
|
|
fw_string[0] = ((fw_version >> 12) & 0x0f) + '0';
|
|
|
|
|
fw_string[1] = '.';
|
|
|
|
|
fw_string[2] = ((fw_version >> 8) & 0x0f) + '0';
|
|
|
|
|
@ -2554,5 +2456,5 @@ int main(int argc, const char **argv)
|
|
|
|
|
ToGate.Close();
|
|
|
|
|
printf("dvrptr exiting...\n");
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|