-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathDVAPDongle.h
130 lines (124 loc) · 2.65 KB
/
DVAPDongle.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#pragma once
/*
* Copyright 2017,2020,2021 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 <stdint.h>
enum REPLY_TYPE
{
RT_TIMEOUT,
RT_ERR,
RT_UNKNOWN,
RT_NAME,
RT_SER,
RT_FW,
RT_START,
RT_STOP,
RT_MODU,
RT_MODE,
RT_SQL,
RT_PWR,
RT_OFF,
RT_FREQ,
RT_FREQ_LIMIT,
RT_STS,
RT_PTT,
RT_ACK,
RT_HDR,
RT_HDR_ACK,
RT_DAT
};
#pragma pack(push,1)
using SDVAP_REGISTER = struct dvp_register_tag
{
uint16_t header;
union
{
uint8_t nul;
struct
{
uint16_t control;
union
{
int8_t byte;
int16_t word;
int32_t dword;
int32_t twod[2];
char sstr[12];
uint8_t ustr[12];
};
} param;
struct
{
uint16_t streamid;
uint8_t framepos;
uint8_t seq;
union
{
struct
{
unsigned char flag[3];
unsigned char rpt2[8];
unsigned char rpt1[8];
unsigned char urcall[8];
unsigned char mycall[8];
unsigned char sfx[4];
unsigned char pfcs[2];
} hdr;
struct
{
unsigned char voice;
unsigned char sdata;
} vad;
};
} frame;
};
};
#pragma pack(pop)
class CDVAPDongle
{
public:
CDVAPDongle();
~CDVAPDongle();
bool Initialize(const char *devpath, const char *serialno, const int frequency, const int offset, const int power, const int squelch);
REPLY_TYPE GetReply(SDVAP_REGISTER &dr);
void Stop();
int KeepAlive();
void SendRegister(SDVAP_REGISTER &dr);
private:
// data
int serfd;
const unsigned int MAX_REPL_CNT;
uint32_t frequency;
int32_t offset;
SDVAP_REGISTER dvapreg;
// functions
bool open_serial(const char *device);
bool open_device(const char *device);
int read_from_dvp(void* buf, unsigned int len);
int write_to_dvp(const void* buf, const unsigned int len);
bool syncit();
bool get_ser(const char *dvp, const char *dvap_serial_number);
bool get_name();
bool get_fw();
bool set_modu();
bool set_mode();
bool set_sql(int squelch);
bool set_pwr(int power);
bool set_off(int offset);
bool set_freq(int frequency);
bool start_dvap();
};