~hmatuschek/+junk/qdmr-package

« back to all changes in this revision

Viewing changes to test/uv390test.cc

  • Committer: Hannes Matuschek
  • Date: 2020-07-07 14:34:22 UTC
  • mto: (17.1.1 qdmr-package)
  • mto: This revision was merged to the branch mainline in revision 10.
  • Revision ID: hmatuschek@gmail.com-20200707143422-1djcxrjkem3k5kb1
Tags: upstream-0.3.0
ImportĀ upstreamĀ versionĀ 0.3.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#include "uv390test.hh"
 
2
#include "config.hh"
 
3
#include <QTest>
 
4
#include "utils.hh"
 
5
#include <QDebug>
 
6
 
 
7
UV390Test::UV390Test(QObject *parent) : QObject(parent)
 
8
{
 
9
  // pass...
 
10
}
 
11
 
 
12
void
 
13
UV390Test::initTestCase() {
 
14
  // Read simple configuration file
 
15
  QString errMessage;
 
16
  QVERIFY(_config.readCSV("://testconfig.conf", errMessage));
 
17
  // Encode config as code-plug
 
18
  QVERIFY(_codeplug.encode(&_config));
 
19
}
 
20
 
 
21
void
 
22
UV390Test::cleanupTestCase() {
 
23
  // clear codeplug
 
24
  _codeplug.clear();
 
25
}
 
26
 
 
27
void
 
28
UV390Test::testRadioName() {
 
29
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x002840+0x70), 16, 0), QString("DM3MAT"));
 
30
}
 
31
 
 
32
void
 
33
UV390Test::testDMRID() {
 
34
  QCOMPARE(decode_dmr_id_bin(_codeplug.data(0x002840+0x44)), 1234567U);
 
35
}
 
36
 
 
37
void
 
38
UV390Test::testIntroLines() {
 
39
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x002840+0x00), 10, 0), QString("ABC"));
 
40
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x002840+0x14), 10, 0), QString("DEF"));
 
41
}
 
42
 
 
43
void
 
44
UV390Test::testGeneralDefaults() {
 
45
  // Check voice announce (off)
 
46
  QCOMPARE((int)*(uint8_t *)_codeplug.data(0x002840+0x42), 0xd8);
 
47
  // Check MIC amplification: 3 in [1..10] => 1 in [0..5]
 
48
  QCOMPARE((int)*(uint8_t *)_codeplug.data(0x002840+0xa0), 0x8f);
 
49
}
 
50
 
 
51
void
 
52
UV390Test::testDigitalContacts() {
 
53
  /*
 
54
   * Test contact 01 (L9)
 
55
   */
 
56
  // Test ID
 
57
  QCOMPARE(decode_dmr_id_bin(_codeplug.data(0x140800+0x00)), 9U);
 
58
  // Type group call, rx tone off
 
59
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x140800+0x03), 0xc1);
 
60
  // Compare name
 
61
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x140800+0x04), 16, 0), QString("Lokal"));
 
62
 
 
63
  /*
 
64
   * Test contact 02 (BB)
 
65
   */
 
66
  // Test ID
 
67
  QCOMPARE(decode_dmr_id_bin(_codeplug.data(0x140824+0x00)), 2621U);
 
68
  // Type group call, rx tone off
 
69
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x140824+0x03), 0xc1);
 
70
  // Compare name
 
71
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x140824+0x04), 16, 0), QString("Bln/Brb"));
 
72
 
 
73
  /*
 
74
   * Test contact 03 (ALL)
 
75
   */
 
76
  // Test ID
 
77
  QCOMPARE(decode_dmr_id_bin(_codeplug.data(0x140848+0x00)), 16777215U);
 
78
  // Type all call, rx tone off
 
79
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x140848+0x03), 0xc3);
 
80
  // Compare name
 
81
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x140848+0x04), 16, 0), QString("All Call"));
 
82
 
 
83
  /*
 
84
   * Test contact 04 (APRS)
 
85
   */
 
86
  // Test ID
 
87
  QCOMPARE(decode_dmr_id_bin(_codeplug.data(0x14086c+0x00)), 262999U);
 
88
  // Type private call, rx tone off
 
89
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x14086c+0x03), 0xc2);
 
90
  // Compare name
 
91
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x14086c+0x04), 16, 0), QString("BM APRS"));
 
92
}
 
93
 
 
94
void
 
95
UV390Test::testRXGroups() {
 
96
  // Check name
 
97
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x00f420+0x00), 16, 0), QString("Berlin/Brand"));
 
98
  // Check members
 
99
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x00f420+0x20), 1);
 
100
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x00f420+0x22), 2);
 
101
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x00f420+0x24), 0);
 
102
}
 
103
 
 
104
void
 
105
UV390Test::testDigitalChannels() {
 
106
  /*
 
107
   * Test Channel 01
 
108
   */
 
109
  // Mode digi, BW 12.5kHz, Autoscan off, lone worker off
 
110
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x00), 0x62);
 
111
  // Talkaround off, RX only off, TS 2, CC 1
 
112
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x01), 0x19);
 
113
  // Priv #0, priv none, prv. call conf. off, data call conf. off
 
114
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x02), 0x00);
 
115
  // rx ref freq low, emrg. ack off, PTT id off (inv)
 
116
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x03), 0xe0);
 
117
  // tx ref freq low, VOX off, admit none
 
118
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x04), 0xe4);
 
119
  // in-call always, turn-off freq off.
 
120
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x05), 0xc0);
 
121
  // TX contact 2
 
122
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x110800+0x06), 0x02);
 
123
  // TOT 45s <-> 0x03
 
124
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x08), 0x03);
 
125
  // TOT re-key delay 0
 
126
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x09), 0x00);
 
127
  // Emerg. sys none
 
128
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x0a), 0x00);
 
129
  // Scanlist none
 
130
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x0b), 0x00);
 
131
  // RX group list 1
 
132
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x0c), 0x01);
 
133
  // GPS system 1
 
134
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x0d), 0x01);
 
135
  // DTMF decode none
 
136
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x0e), 0x00);
 
137
  // Squelch none
 
138
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x0f), 0x00);
 
139
  // RX frequency
 
140
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110800+0x10)), 439.5630);
 
141
  // TX frequency
 
142
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110800+0x14)), 431.9630);
 
143
  // RX CTCSS none
 
144
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110800+0x18)), 0.0);
 
145
  // TX CTCSS none
 
146
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110800+0x1a)), 0.0);
 
147
  // RX DTMF sig. off
 
148
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x1c), 0x00);
 
149
  // TX DTMF sig. off
 
150
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x1d), 0x00);
 
151
  // Power high
 
152
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x1e), 0xff);
 
153
  // GPS on (inv), allow interrupt off (inv), DCDM off (inv), Leader/MS off (inv)
 
154
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110800+0x1f), 0xfc);
 
155
  // Name
 
156
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x110800+0x20), 16, 0), QString("BB DB0LDS TS2"));
 
157
 
 
158
  /*
 
159
   * Test Channel 02
 
160
   */
 
161
  // Mode digi, BW 12.5kHz, Autoscan off, lone worker off
 
162
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x00), 0x62);
 
163
  // Talkaround off, RX only off, TS 2, CC 1
 
164
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x01), 0x19);
 
165
  // Priv #0, priv none, prv. call conf. off, data call conf. off
 
166
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x02), 0x00);
 
167
  // rx ref freq low, emrg. ack off, PTT id off (inv)
 
168
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x03), 0xe0);
 
169
  // tx ref freq low, VOX off, admit none
 
170
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x04), 0xe4);
 
171
  // in-call always, turn-off freq off.
 
172
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x05), 0xc0);
 
173
  // TX contact 2
 
174
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x110840+0x06), 0x02);
 
175
  // TOT 45s <-> 0x03
 
176
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x08), 0x03);
 
177
  // TOT re-key delay 0
 
178
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x09), 0x00);
 
179
  // Emerg. sys none
 
180
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x0a), 0x00);
 
181
  // Scanlist none
 
182
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x0b), 0x00);
 
183
  // RX group list 1
 
184
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x0c), 0x01);
 
185
  // GPS system 0
 
186
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x0d), 0x00);
 
187
  // DTMF decode none
 
188
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x0e), 0x00);
 
189
  // Squelch none
 
190
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x0f), 0x00);
 
191
  // RX frequency
 
192
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110840+0x10)), 439.0870);
 
193
  // TX frequency
 
194
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110840+0x14)), 431.4870);
 
195
  // RX CTCSS none
 
196
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110840+0x18)), 0.0);
 
197
  // TX CTCSS none
 
198
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110840+0x1a)), 0.0);
 
199
  // RX DTMF sig. off
 
200
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x1c), 0x00);
 
201
  // TX DTMF sig. off
 
202
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x1d), 0x00);
 
203
  // Power high
 
204
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x1e), 0xff);
 
205
  // GPS off (inv), allow interrupt off (inv), DCDM off (inv), Leader/MS off (inv)
 
206
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110840+0x1f), 0xff);
 
207
  // Name
 
208
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x110840+0x20), 16, 0), QString("BB DM0TT TS2"));
 
209
 
 
210
  /*
 
211
   * Test Channel 03
 
212
   */
 
213
  // Mode digi, BW 12.5kHz, Autoscan off, lone worker off
 
214
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x00), 0x62);
 
215
  // Talkaround off, RX only off, TS 1, CC 1
 
216
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x01), 0x15);
 
217
  // Priv #0, priv none, prv. call conf. off, data call conf. off
 
218
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x02), 0x00);
 
219
  // rx ref freq low, emrg. ack off, PTT id off (inv)
 
220
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x03), 0xe0);
 
221
  // tx ref freq low, VOX off, admit none
 
222
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x04), 0xe4);
 
223
  // in-call always, turn-off freq off.
 
224
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x05), 0xc0);
 
225
  // TX contact 2
 
226
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x110880+0x06), 0x01);
 
227
  // TOT 45s <-> 0x03
 
228
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x08), 0x03);
 
229
  // TOT re-key delay 0
 
230
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x09), 0x00);
 
231
  // Emerg. sys none
 
232
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x0a), 0x00);
 
233
  // Scanlist none
 
234
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x0b), 0x00);
 
235
  // RX group list 1
 
236
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x0c), 0x01);
 
237
  // GPS system 0
 
238
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x0d), 0x00);
 
239
  // DTMF decode none
 
240
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x0e), 0x00);
 
241
  // Squelch none
 
242
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x0f), 0x00);
 
243
  // RX frequency
 
244
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110880+0x10)), 439.5380);
 
245
  // TX frequency
 
246
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110880+0x14)), 431.9380);
 
247
  // RX CTCSS none
 
248
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110880+0x18)), 0.0);
 
249
  // TX CTCSS none
 
250
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110880+0x1a)), 0.0);
 
251
  // RX DTMF sig. off
 
252
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x1c), 0x00);
 
253
  // TX DTMF sig. off
 
254
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x1d), 0x00);
 
255
  // Power high
 
256
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x1e), 0xff);
 
257
  // GPS off (inv), allow interrupt off (inv), DCDM off (inv), Leader/MS off (inv)
 
258
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110880+0x1f), 0xff);
 
259
  // Name
 
260
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x110880+0x20), 16, 0), QString("TG9 DB0KK TS1"));
 
261
}
 
262
 
 
263
 
 
264
void
 
265
UV390Test::testAnalogChannels() {
 
266
  /*
 
267
   * Test Channel 04
 
268
   */
 
269
  // Mode analog, BW 12.5kHz, Autoscan off, lone worker off
 
270
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x00), 0x61);
 
271
  // Talkaround off, RX only off, TS 1, CC 1
 
272
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x01), 0x15);
 
273
  // Priv #0, priv none, prv. call conf. off, data call conf. off
 
274
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x02), 0x00);
 
275
  // rx ref freq low, emrg. ack off, PTT id off (inv)
 
276
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x03), 0xe0);
 
277
  // tx ref freq low, VOX off, admit CH admit tone
 
278
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x04), 0xa4);
 
279
  // in-call always, turn-off freq off.
 
280
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x05), 0xc0);
 
281
  // TX contact none
 
282
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x1108c0+0x06), 0x00);
 
283
  // TOT 45s <-> 0x03
 
284
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x08), 0x03);
 
285
  // TOT re-key delay 0
 
286
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x09), 0x00);
 
287
  // Emerg. sys none
 
288
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x0a), 0x00);
 
289
  // Scanlist none
 
290
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x0b), 0x00);
 
291
  // RX group list 0
 
292
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x0c), 0x00);
 
293
  // GPS system none
 
294
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x0d), 0x00);
 
295
  // DTMF decode none
 
296
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x0e), 0x00);
 
297
  // Squelch 1
 
298
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x0f), 0x01);
 
299
  // RX frequency
 
300
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x1108c0+0x10)), 439.5625);
 
301
  // TX frequency
 
302
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x1108c0+0x14)), 431.9625);
 
303
  // RX CTCSS none
 
304
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x1108c0+0x18)), 67.0);
 
305
  // TX CTCSS none
 
306
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x1108c0+0x1a)), 67.0);
 
307
  // RX DTMF sig. off
 
308
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x1c), 0x00);
 
309
  // TX DTMF sig. off
 
310
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x1d), 0x00);
 
311
  // Power high
 
312
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x1e), 0xff);
 
313
  // GPS off (inv), allow interrupt off (inv), DCDM off (inv), Leader/MS off (inv)
 
314
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x1108c0+0x1f), 0xff);
 
315
  // Name
 
316
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x1108c0+0x20), 16, 0), QString("DB0LDS"));
 
317
 
 
318
  /*
 
319
   * Test Channel 05
 
320
   */
 
321
  // Mode analog, BW 12.5kHz, Autoscan off, lone worker off
 
322
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x00), 0x61);
 
323
  // Talkaround off, RX only off, TS 1, CC 1
 
324
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x01), 0x15);
 
325
  // Priv #0, priv none, prv. call conf. off, data call conf. off
 
326
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x02), 0x00);
 
327
  // rx ref freq low, emrg. ack off, PTT id off (inv)
 
328
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x03), 0xe0);
 
329
  // tx ref freq low, VOX off, admit CH free
 
330
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x04), 0x64);
 
331
  // in-call always, turn-off freq off.
 
332
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x05), 0xc0);
 
333
  // TX contact none
 
334
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x110900+0x06), 0x00);
 
335
  // TOT 45s <-> 0x03
 
336
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x08), 0x03);
 
337
  // TOT re-key delay 0
 
338
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x09), 0x00);
 
339
  // Emerg. sys none
 
340
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x0a), 0x00);
 
341
  // Scanlist none
 
342
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x0b), 0x00);
 
343
  // RX group list none
 
344
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x0c), 0x00);
 
345
  // GPS system none
 
346
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x0d), 0x00);
 
347
  // DTMF decode none
 
348
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x0e), 0x00);
 
349
  // Squelch 1
 
350
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x0f), 0x01);
 
351
  // RX frequency
 
352
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110900+0x10)), 145.6000);
 
353
  // TX frequency
 
354
  QCOMPARE(decode_frequency(*(uint32_t *)_codeplug.data(0x110900+0x14)), 145.0000);
 
355
  // RX CTCSS none
 
356
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110900+0x18)), 0.0);
 
357
  // TX CTCSS none
 
358
  QCOMPARE(decode_ctcss_tone_table(*(uint16_t *)_codeplug.data(0x110900+0x1a)), 0.0);
 
359
  // RX DTMF sig. off
 
360
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x1c), 0x00);
 
361
  // TX DTMF sig. off
 
362
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x1d), 0x00);
 
363
  // Power high
 
364
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x1e), 0xff);
 
365
  // GPS off (inv), allow interrupt off (inv), DCDM off (inv), Leader/MS off (inv)
 
366
  QCOMPARE((int)*(uint8_t  *)_codeplug.data(0x110900+0x1f), 0xff);
 
367
  // Name
 
368
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x110900+0x20), 16, 0), QString("DB0SP-2"));
 
369
}
 
370
 
 
371
void
 
372
UV390Test::testZones() {
 
373
  // Check name
 
374
  QCOMPARE(decode_unicode((uint16_t *)_codeplug.data(0x0151e0+0x00), 16, 0), QString("KW"));
 
375
  // Check members A
 
376
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x0151e0+0x20), 1);
 
377
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x0151e0+0x22), 3);
 
378
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x0151e0+0x24), 5);
 
379
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x0151e0+0x26), 0);
 
380
  // Check members B
 
381
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x031800+0x60), 2);
 
382
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x031800+0x62), 4);
 
383
}
 
384
 
 
385
void
 
386
UV390Test::testScanLists() {
 
387
  // There is none -> check if first scan list is invalid
 
388
  QCOMPARE((int)*(uint16_t *)_codeplug.data(0x019060+0x00), 0x00);
 
389
}
 
390
 
 
391
void
 
392
UV390Test::testDecode() {
 
393
  /* Decode config */
 
394
  Config decoded;
 
395
  QVERIFY(_codeplug.decode(&decoded));
 
396
 
 
397
  // Compare basic config
 
398
  QCOMPARE(decoded.name(), _config.name());
 
399
  QCOMPARE(decoded.id(), _config.id());
 
400
  QCOMPARE(decoded.introLine1(), _config.introLine1());
 
401
  QCOMPARE(decoded.introLine2(), _config.introLine2());
 
402
  QCOMPARE(decoded.micLevel(), _config.micLevel());
 
403
  QCOMPARE(decoded.speech(), _config.speech());
 
404
 
 
405
  // Compare contacts
 
406
  QCOMPARE(decoded.contacts()->count(), _config.contacts()->count());
 
407
  for (int i=0; i<_config.contacts()->count(); i++) {
 
408
    // Compare name
 
409
    QCOMPARE(decoded.contacts()->contact(i)->name(), _config.contacts()->contact(i)->name());
 
410
    // Compare number
 
411
    QCOMPARE(decoded.contacts()->contact(i)->as<DigitalContact>()->number(),
 
412
             _config.contacts()->contact(i)->as<DigitalContact>()->number());
 
413
    // Compare type
 
414
    QCOMPARE(decoded.contacts()->contact(i)->as<DigitalContact>()->type(),
 
415
             _config.contacts()->contact(i)->as<DigitalContact>()->type());
 
416
    // Compare tone
 
417
    QCOMPARE(decoded.contacts()->contact(i)->rxTone(),
 
418
             _config.contacts()->contact(i)->rxTone());
 
419
  }
 
420
 
 
421
  // Compare RX Groups
 
422
  QCOMPARE(decoded.rxGroupLists()->count(), _config.rxGroupLists()->count());
 
423
  for (int i=0; i<_config.rxGroupLists()->count(); i++) {
 
424
    // Compare name
 
425
    QCOMPARE(decoded.rxGroupLists()->list(i)->name(), _config.rxGroupLists()->list(i)->name());
 
426
    // Compare number of entries
 
427
    QCOMPARE(decoded.rxGroupLists()->list(i)->count(), _config.rxGroupLists()->list(i)->count());
 
428
    // Compare entries
 
429
    for (int j=0; j<_config.rxGroupLists()->list(i)->count(); j++) {
 
430
      QCOMPARE(decoded.contacts()->indexOf(decoded.rxGroupLists()->list(i)->contact(j)),
 
431
               _config.contacts()->indexOf(_config.rxGroupLists()->list(i)->contact(j)));
 
432
    }
 
433
  }
 
434
 
 
435
  // Compare Channels
 
436
  QCOMPARE(decoded.channelList()->count(), _config.channelList()->count());
 
437
  for (int i=0; i<_config.channelList()->count(); i++) {
 
438
    // Compare name
 
439
    QCOMPARE(decoded.channelList()->channel(i)->name(), _config.channelList()->channel(i)->name());
 
440
    // RX Frequency
 
441
    QCOMPARE(decoded.channelList()->channel(i)->rxFrequency(), _config.channelList()->channel(i)->rxFrequency());
 
442
    // TX Frequency
 
443
    QCOMPARE(decoded.channelList()->channel(i)->txFrequency(), _config.channelList()->channel(i)->txFrequency());
 
444
    // Power
 
445
    QCOMPARE(decoded.channelList()->channel(i)->power(), _config.channelList()->channel(i)->power());
 
446
    // TOT
 
447
    QCOMPARE(decoded.channelList()->channel(i)->txTimeout(), _config.channelList()->channel(i)->txTimeout());
 
448
    // RX only flag
 
449
    QCOMPARE(decoded.channelList()->channel(i)->rxOnly(), _config.channelList()->channel(i)->rxOnly());
 
450
    // Scanlist
 
451
    QCOMPARE(decoded.scanlists()->indexOf(decoded.channelList()->channel(i)->scanList()),
 
452
             _config.scanlists()->indexOf(_config.channelList()->channel(i)->scanList()));
 
453
    // Check type
 
454
    QCOMPARE(decoded.channelList()->channel(i)->is<DigitalChannel>(),
 
455
             _config.channelList()->channel(i)->is<DigitalChannel>());
 
456
    // Dispatch by type
 
457
    if (_config.channelList()->channel(i)->is<DigitalChannel>()) {
 
458
      DigitalChannel *dec = decoded.channelList()->channel(i)->as<DigitalChannel>();
 
459
      DigitalChannel *ori = _config.channelList()->channel(i)->as<DigitalChannel>();
 
460
      // Compare admit criterion
 
461
      QCOMPARE(dec->admit(), ori->admit());
 
462
      // color code
 
463
      QCOMPARE(dec->colorCode(), ori->colorCode());
 
464
      // time slot
 
465
      QCOMPARE(dec->timeslot(), ori->timeslot());
 
466
      // RX group list
 
467
      QCOMPARE(decoded.rxGroupLists()->indexOf(dec->rxGroupList()),
 
468
               _config.rxGroupLists()->indexOf(ori->rxGroupList()));
 
469
      // TX contact
 
470
      QCOMPARE(decoded.contacts()->indexOf(dec->txContact()),
 
471
               _config.contacts()->indexOf(ori->txContact()));
 
472
      // do not check GSP system (RD5R has no GPS).
 
473
      QCOMPARE(nullptr != dec->gpsSystem(), nullptr != ori->gpsSystem());
 
474
      QCOMPARE(decoded.gpsSystems()->indexOf(dec->gpsSystem()),
 
475
               _config.gpsSystems()->indexOf(ori->gpsSystem()));
 
476
    } else {
 
477
      AnalogChannel *dec = decoded.channelList()->channel(i)->as<AnalogChannel>();
 
478
      AnalogChannel *ori = _config.channelList()->channel(i)->as<AnalogChannel>();
 
479
      // Compare admit criterion
 
480
      QCOMPARE(dec->admit(), ori->admit());
 
481
      // squelch
 
482
      QCOMPARE(dec->squelch(), ori->squelch());
 
483
      // RX Tone
 
484
      QCOMPARE(dec->rxTone(), ori->rxTone());
 
485
      // TX Tone
 
486
      QCOMPARE(dec->txTone(), ori->txTone());
 
487
      // Bandwidth
 
488
      QCOMPARE(dec->bandwidth(), ori->bandwidth());
 
489
    }
 
490
  }
 
491
 
 
492
  // Compare Zones.
 
493
  QCOMPARE(decoded.zones()->count(), _config.zones()->count());
 
494
  for (int i=0; i<_config.zones()->count(); i++) {
 
495
    QCOMPARE(decoded.zones()->zone(i)->name(), _config.zones()->zone(i)->name());
 
496
    QCOMPARE(decoded.zones()->zone(i)->A()->count(), _config.zones()->zone(i)->A()->count());
 
497
    for (int j=0; j<_config.zones()->zone(0)->A()->count(); j++) {
 
498
      QCOMPARE(decoded.channelList()->indexOf(decoded.zones()->zone(i)->A()->channel(j)),
 
499
               _config.channelList()->indexOf(_config.zones()->zone(i)->A()->channel(j)));
 
500
    }
 
501
    QCOMPARE(decoded.zones()->zone(i)->B()->count(), _config.zones()->zone(i)->B()->count());
 
502
    for (int j=0; j<_config.zones()->zone(0)->B()->count(); j++) {
 
503
      QCOMPARE(decoded.channelList()->indexOf(decoded.zones()->zone(i)->B()->channel(j)),
 
504
               _config.channelList()->indexOf(_config.zones()->zone(i)->B()->channel(j)));
 
505
    }
 
506
  }
 
507
 
 
508
  // Compare scanlist
 
509
  QCOMPARE(decoded.scanlists()->count(), _config.scanlists()->count());
 
510
 
 
511
  // Compare GPS systems
 
512
  QCOMPARE(decoded.gpsSystems()->count(), _config.gpsSystems()->count());
 
513
  for (int i=0; i<_config.gpsSystems()->count(); i++) {
 
514
    // Do not compare GPS system name UV390 cannot save GPS system name.
 
515
    QCOMPARE(decoded.gpsSystems()->gpsSystem(i)->name(), QString("GPS System"));
 
516
    QCOMPARE(decoded.gpsSystems()->gpsSystem(i)->period(), _config.gpsSystems()->gpsSystem(i)->period());
 
517
    QCOMPARE(decoded.contacts()->indexOf(decoded.gpsSystems()->gpsSystem(i)->contact()),
 
518
             _config.contacts()->indexOf(_config.gpsSystems()->gpsSystem(i)->contact()));
 
519
    QCOMPARE(decoded.channelList()->indexOf(decoded.gpsSystems()->gpsSystem(i)->revertChannel()),
 
520
             _config.channelList()->indexOf(_config.gpsSystems()->gpsSystem(i)->revertChannel()));
 
521
  }
 
522
}
 
523
 
 
524
QTEST_GUILESS_MAIN(UV390Test)