1
|
# Copyright 2016-2022:
|
2
|
# * Pavel Milanes CO7WT, <pavelmc@gmail.com>
|
3
|
# * Jim Unroe KC9HI, <rock.unroe@gmail.com>
|
4
|
#
|
5
|
# This program is free software: you can redistribute it and/or modify
|
6
|
# it under the terms of the GNU General Public License as published by
|
7
|
# the Free Software Foundation, either version 2 of the License, or
|
8
|
# (at your option) any later version.
|
9
|
#
|
10
|
# This program is distributed in the hope that it will be useful,
|
11
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
12
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
13
|
# GNU General Public License for more details.
|
14
|
#
|
15
|
# You should have received a copy of the GNU General Public License
|
16
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
17
|
|
18
|
import time
|
19
|
import struct
|
20
|
import logging
|
21
|
|
22
|
from time import sleep
|
23
|
from chirp import chirp_common, directory, memmap
|
24
|
from chirp import bitwise, errors, util
|
25
|
from chirp.settings import RadioSettingGroup, RadioSetting, \
|
26
|
RadioSettingValueBoolean, RadioSettingValueList, \
|
27
|
RadioSettingValueString, RadioSettingValueInteger, \
|
28
|
RadioSettingValueFloat, RadioSettings, InvalidValueError
|
29
|
from textwrap import dedent
|
30
|
|
31
|
LOG = logging.getLogger(__name__)
|
32
|
|
33
|
# A note about the memmory in these radios
|
34
|
#
|
35
|
# The real memory of these radios extends to 0x4000
|
36
|
# On read the factory software only uses up to 0x3200
|
37
|
# On write it just uploads the contents up to 0x3100
|
38
|
#
|
39
|
# The mem beyond 0x3200 holds the ID data
|
40
|
|
41
|
MEM_SIZE = 0x4000
|
42
|
BLOCK_SIZE = 0x40
|
43
|
TX_BLOCK_SIZE = 0x10
|
44
|
ACK_CMD = "\x06"
|
45
|
MODES = ["FM", "NFM"]
|
46
|
SKIP_VALUES = ["S", ""]
|
47
|
TONES = chirp_common.TONES
|
48
|
DTCS = sorted(chirp_common.DTCS_CODES + [645])
|
49
|
|
50
|
# lists related to "extra" settings
|
51
|
PTTID_LIST = ["OFF", "BOT", "EOT", "BOTH"]
|
52
|
PTTIDCODE_LIST = ["%s" % x for x in range(1, 16)]
|
53
|
OPTSIG_LIST = ["OFF", "DTMF", "2TONE", "5TONE"]
|
54
|
SPMUTE_LIST = ["Tone/DTCS", "Tone/DTCS and Optsig", "Tone/DTCS or Optsig"]
|
55
|
|
56
|
# lists
|
57
|
LIST_AB = ["A", "B"]
|
58
|
LIST_ABCD = LIST_AB + ["C", "D"]
|
59
|
LIST_ANIL = ["3", "4", "5"]
|
60
|
LIST_APO = ["Off"] + ["%s minutes" % x for x in range(30, 330, 30)]
|
61
|
LIST_COLOR4 = ["Off", "Blue", "Orange", "Purple"]
|
62
|
LIST_COLOR8 = ["White", "Red", "Blue", "Green", "Yellow", "Indigo",
|
63
|
"Purple", "Gray"]
|
64
|
LIST_COLOR9 = ["Black"] + LIST_COLOR8
|
65
|
LIST_DTMFST = ["OFF", "Keyboard", "ANI", "Keyboad + ANI"]
|
66
|
LIST_EMCTP = ["TX alarm sound", "TX ANI", "Both"]
|
67
|
LIST_EMCTPX = ["Off"] + LIST_EMCTP
|
68
|
LIST_LANGUA = ["English", "Chinese"]
|
69
|
LIST_MDF = ["Frequency", "Channel", "Name"]
|
70
|
LIST_OFF1TO9 = ["Off"] + ["%s seconds" % x for x in range(1, 10)]
|
71
|
LIST_OFF1TO10 = ["Off"] + ["%s seconds" % x for x in range(1, 11)]
|
72
|
LIST_OFF1TO50 = ["Off"] + ["%s seconds" % x for x in range(1, 51)]
|
73
|
LIST_OFF1TO60 = ["Off"] + ["%s seconds" % x for x in range(1, 61)]
|
74
|
LIST_PONMSG = ["Full", "Message", "Battery voltage"]
|
75
|
LIST_REPM = ["Off", "Carrier", "CTCSS or DCS", "Tone", "DTMF"]
|
76
|
LIST_REPS = ["1000 Hz", "1450 Hz", "1750 Hz", "2100Hz"]
|
77
|
LIST_REPSW = ["Off", "RX", "TX"]
|
78
|
LIST_RPTDL = ["Off"] + ["%s ms" % x for x in range(1, 11)]
|
79
|
LIST_SCMODE = ["Off", "PTT-SC", "MEM-SC", "PON-SC"]
|
80
|
LIST_SHIFT = ["Off", "+", "-"]
|
81
|
LIST_SKIPTX = ["Off", "Skip 1", "Skip 2"]
|
82
|
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
|
83
|
LIST_STEP = [str(x) for x in STEPS]
|
84
|
LIST_SYNC = ["Off", "AB", "CD", "AB+CD"]
|
85
|
LIST_SYNCV2 = ["Off", "AB", "AC", "BC", "ABC"]
|
86
|
# the first 12 TMR choices common to all 4-line color display mobile radios
|
87
|
LIST_TMR12 = ["OFF", "M+A", "M+B", "M+C", "M+D", "M+A+B", "M+A+C", "M+A+D",
|
88
|
"M+B+C", "M+B+D", "M+C+D", "M+A+B+C"]
|
89
|
# the 16 choice list for color display mobile radios that correctly implement
|
90
|
# the full 16 TMR choices
|
91
|
LIST_TMR16 = LIST_TMR12 + ["M+A+B+D", "M+A+C+D", "M+B+C+D", "A+B+C+D"]
|
92
|
# the 15 choice list for color mobile radios that are missing the M+A+B+D
|
93
|
# choice in the TMR menu
|
94
|
LIST_TMR15 = LIST_TMR12 + ["M+A+C+D", "M+B+C+D", "A+B+C+D"]
|
95
|
# the 7 TMR choices for the 3-line color display mobile radios
|
96
|
LIST_TMR7 = ["OFF", "M+A", "M+B", "M+C", "M+AB", "M+AC", "M+BC", "M+ABC"]
|
97
|
LIST_TMRTX = ["Track", "Fixed"]
|
98
|
LIST_TOT = ["%s sec" % x for x in range(15, 615, 15)]
|
99
|
LIST_TXDISP = ["Power", "Mic Volume"]
|
100
|
LIST_TXP = ["High", "Low"]
|
101
|
LIST_TXP3 = ["High", "Mid", "Low"]
|
102
|
LIST_SCREV = ["TO (timeout)", "CO (carrier operated)", "SE (search)"]
|
103
|
LIST_VFOMR = ["Frequency", "Channel"]
|
104
|
LIST_VOICE = ["Off"] + LIST_LANGUA
|
105
|
LIST_VOX = ["Off"] + ["%s" % x for x in range(1, 11)]
|
106
|
LIST_VOXT = ["%s seconds" % x for x in range(0, 21)]
|
107
|
LIST_WIDE = ["Wide", "Narrow"]
|
108
|
|
109
|
# lists related to DTMF, 2TONE and 5TONE settings
|
110
|
LIST_5TONE_STANDARDS = ["CCIR1", "CCIR2", "PCCIR", "ZVEI1", "ZVEI2", "ZVEI3",
|
111
|
"PZVEI", "DZVEI", "PDZVEI", "EEA", "EIA", "EURO",
|
112
|
"CCITT", "NATEL", "MODAT", "none"]
|
113
|
LIST_5TONE_STANDARDS_without_none = ["CCIR1", "CCIR2", "PCCIR", "ZVEI1",
|
114
|
"ZVEI2", "ZVEI3",
|
115
|
"PZVEI", "DZVEI", "PDZVEI", "EEA", "EIA",
|
116
|
"EURO", "CCITT", "NATEL", "MODAT"]
|
117
|
LIST_5TONE_STANDARD_PERIODS = ["20", "30", "40", "50", "60", "70", "80", "90",
|
118
|
"100", "110", "120", "130", "140", "150", "160",
|
119
|
"170", "180", "190", "200"]
|
120
|
LIST_5TONE_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
|
121
|
"B", "C", "D", "E", "F"]
|
122
|
LIST_5TONE_DELAY = ["%s ms" % x for x in range(0, 1010, 10)]
|
123
|
LIST_5TONE_RESET = ["%s ms" % x for x in range(100, 8100, 100)]
|
124
|
LIST_5TONE_RESET_COLOR = ["%s ms" % x for x in range(100, 20100, 100)]
|
125
|
LIST_DTMF_SPEED = ["%s ms" % x for x in range(50, 2010, 10)]
|
126
|
LIST_DTMF_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
|
127
|
"C", "D", "#", "*"]
|
128
|
LIST_DTMF_VALUES = [0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
129
|
0x0D, 0x0E, 0x0F, 0x00, 0x0C, 0x0B]
|
130
|
LIST_DTMF_SPECIAL_DIGITS = ["*", "#", "A", "B", "C", "D"]
|
131
|
LIST_DTMF_SPECIAL_VALUES = [0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00]
|
132
|
LIST_DTMF_DELAY = ["%s ms" % x for x in range(100, 4100, 100)]
|
133
|
CHARSET_DTMF_DIGITS = "0123456789AaBbCcDd#*"
|
134
|
LIST_2TONE_DEC = ["A-B", "A-C", "A-D",
|
135
|
"B-A", "B-C", "B-D",
|
136
|
"C-A", "C-B", "C-D",
|
137
|
"D-A", "D-B", "D-C"]
|
138
|
LIST_2TONE_RESPONSE = ["None", "Alert", "Transpond", "Alert+Transpond"]
|
139
|
|
140
|
# This is a general serial timeout for all serial read functions.
|
141
|
STIMEOUT = 0.25
|
142
|
|
143
|
# this var controls the verbosity in the debug and by default it's low (False)
|
144
|
# make it True and you will to get a very verbose debug.log
|
145
|
debug = False
|
146
|
|
147
|
# valid chars on the LCD, Note that " " (space) is stored as "\xFF"
|
148
|
VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
|
149
|
"`{|}!\"#$%&'()*+,-./:;<=>?@[]^_"
|
150
|
|
151
|
GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
|
152
|
462.6875, 462.7125]
|
153
|
GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
|
154
|
467.6875, 467.7125]
|
155
|
GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
|
156
|
462.6750, 462.7000, 462.7250]
|
157
|
GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
|
158
|
|
159
|
|
160
|
# #### ID strings #####################################################
|
161
|
|
162
|
# BTECH UV2501 pre-production units
|
163
|
UV2501pp_fp = "M2C294"
|
164
|
# BTECH UV2501 pre-production units 2 + and 1st Gen radios
|
165
|
UV2501pp2_fp = "M29204"
|
166
|
# B-TECH UV-2501 second generation (2G) radios
|
167
|
UV2501G2_fp = "BTG214"
|
168
|
# B-TECH UV-2501 third generation (3G) radios
|
169
|
UV2501G3_fp = "BTG324"
|
170
|
|
171
|
# B-TECH UV-2501+220 pre-production units
|
172
|
UV2501_220pp_fp = "M3C281"
|
173
|
# B-TECH UV-2501+220
|
174
|
UV2501_220_fp = "M3G201"
|
175
|
# new variant, let's call it Generation 2
|
176
|
UV2501_220G2_fp = "BTG211"
|
177
|
# B-TECH UV-2501+220 third generation (3G)
|
178
|
UV2501_220G3_fp = "BTG311"
|
179
|
|
180
|
# B-TECH UV-5001 pre-production units + 1st Gen radios
|
181
|
UV5001pp_fp = "V19204"
|
182
|
# B-TECH UV-5001 alpha units
|
183
|
UV5001alpha_fp = "V28204"
|
184
|
# B-TECH UV-5001 second generation (2G) radios
|
185
|
UV5001G2_fp = "BTG214"
|
186
|
# B-TECH UV-5001 second generation (2G2)
|
187
|
UV5001G22_fp = "V2G204"
|
188
|
# B-TECH UV-5001 third generation (3G)
|
189
|
UV5001G3_fp = "BTG304"
|
190
|
|
191
|
# B-TECH UV-25X2
|
192
|
UV25X2_fp = "UC2012"
|
193
|
|
194
|
# B-TECH UV-25X4
|
195
|
UV25X4_fp = "UC4014"
|
196
|
|
197
|
# B-TECH UV-50X2
|
198
|
UV50X2_fp = "UC2M12"
|
199
|
|
200
|
# B-TECH GMRS-50X1
|
201
|
GMRS50X1_fp = "NC1802"
|
202
|
GMRS50X1_fp1 = "NC1932"
|
203
|
|
204
|
# B-TECH GMRS-20V2
|
205
|
GMRS20V2_fp = "WP4204"
|
206
|
GMRS20V2_fp1 = "VW2112"
|
207
|
|
208
|
# special var to know when we found a BTECH Gen 3
|
209
|
BTECH3 = [UV2501G3_fp, UV2501_220G3_fp, UV5001G3_fp]
|
210
|
|
211
|
|
212
|
# WACCOM Mini-8900
|
213
|
MINI8900_fp = "M28854"
|
214
|
|
215
|
|
216
|
# QYT KT-UV980
|
217
|
KTUV980_fp = "H28854"
|
218
|
|
219
|
# QYT KT8900
|
220
|
KT8900_fp = "M29154"
|
221
|
# New generations KT8900
|
222
|
KT8900_fp1 = "M2C234"
|
223
|
KT8900_fp2 = "M2G1F4"
|
224
|
KT8900_fp3 = "M2G2F4"
|
225
|
KT8900_fp4 = "M2G304"
|
226
|
KT8900_fp5 = "M2G314"
|
227
|
KT8900_fp6 = "M2G424"
|
228
|
KT8900_fp7 = "M27184"
|
229
|
|
230
|
# KT8900R
|
231
|
KT8900R_fp = "M3G1F4"
|
232
|
# Second Generation
|
233
|
KT8900R_fp1 = "M3G214"
|
234
|
# another model
|
235
|
KT8900R_fp2 = "M3C234"
|
236
|
# another model G4?
|
237
|
KT8900R_fp3 = "M39164"
|
238
|
# another model
|
239
|
KT8900R_fp4 = "M3G314"
|
240
|
# AC3MB: another id
|
241
|
KT8900R_fp5 = "M3B064"
|
242
|
|
243
|
# KT7900D (quad band)
|
244
|
KT7900D_fp = "VC4004"
|
245
|
KT7900D_fp1 = "VC4284"
|
246
|
KT7900D_fp2 = "VC4264"
|
247
|
KT7900D_fp3 = "VC4114"
|
248
|
KT7900D_fp4 = "VC4104"
|
249
|
KT7900D_fp5 = "VC4254"
|
250
|
KT7900D_fp6 = "VC5264"
|
251
|
KT7900D_fp7 = "VC9204"
|
252
|
KT7900D_fp8 = "VC9214"
|
253
|
|
254
|
# QB25 (quad band) - a clone of KT7900D
|
255
|
QB25_fp = "QB-25"
|
256
|
|
257
|
# KT8900D (dual band)
|
258
|
KT8900D_fp = "VC2002"
|
259
|
KT8900D_fp1 = "VC8632"
|
260
|
KT8900D_fp2 = "VC3402"
|
261
|
KT8900D_fp3 = "VC7062"
|
262
|
|
263
|
# LUITON LT-588UV
|
264
|
LT588UV_fp = "V2G1F4"
|
265
|
# Added by rstrickoff gen 2 id
|
266
|
LT588UV_fp1 = "V2G214"
|
267
|
|
268
|
# QYT KT-8R (quad band ht)
|
269
|
KT8R_fp = "MCB264"
|
270
|
KT8R_fp1 = "MCB284"
|
271
|
KT8R_fp2 = "MC5264"
|
272
|
|
273
|
# QYT KT5800 (dual band)
|
274
|
KT5800_fp = "VCB222"
|
275
|
|
276
|
# QYT KT980Plus (dual band)
|
277
|
KT980PLUS_fp = "VC2002"
|
278
|
KT980PLUS_fp1 = "VC6042"
|
279
|
|
280
|
# Radioddity DB25-G (gmrs)
|
281
|
DB25G_fp = "VC6182"
|
282
|
DB25G_fp1 = "VC7062"
|
283
|
|
284
|
# QYT KT-WP12 and KT-9900
|
285
|
KTWP12_fp = "WP3094"
|
286
|
|
287
|
# Anysecu WP-9900
|
288
|
WP9900_fp = "WP3094"
|
289
|
|
290
|
|
291
|
# ### MAGICS
|
292
|
# for the Waccom Mini-8900
|
293
|
MSTRING_MINI8900 = "\x55\xA5\xB5\x45\x55\x45\x4d\x02"
|
294
|
# for the B-TECH UV-2501+220 (including pre production ones)
|
295
|
MSTRING_220 = "\x55\x20\x15\x12\x12\x01\x4d\x02"
|
296
|
# for the QYT KT8900 & R
|
297
|
MSTRING_KT8900 = "\x55\x20\x15\x09\x16\x45\x4D\x02"
|
298
|
MSTRING_KT8900R = "\x55\x20\x15\x09\x25\x01\x4D\x02"
|
299
|
# magic string for all other models
|
300
|
MSTRING = "\x55\x20\x15\x09\x20\x45\x4d\x02"
|
301
|
# for the QYT KT7900D & KT8900D
|
302
|
MSTRING_KT8900D = "\x55\x20\x16\x08\x01\xFF\xDC\x02"
|
303
|
# for the BTECH UV-25X2 and UV-50X2
|
304
|
MSTRING_UV25X2 = "\x55\x20\x16\x12\x28\xFF\xDC\x02"
|
305
|
# for the BTECH UV-25X4
|
306
|
MSTRING_UV25X4 = "\x55\x20\x16\x11\x18\xFF\xDC\x02"
|
307
|
# for the BTECH GMRS-50X1
|
308
|
MSTRING_GMRS50X1 = "\x55\x20\x18\x10\x18\xFF\xDC\x02"
|
309
|
# for the BTECH GMRS-20V2
|
310
|
MSTRING_GMRS20V2 = "\x55\x20\x21\x03\x27\xFF\xDC\x02"
|
311
|
# for the QYT KT-8R
|
312
|
MSTRING_KT8R = "\x55\x20\x17\x07\x03\xFF\xDC\x02"
|
313
|
# for the QYT KT-WP12, KT-9900 and Anysecu WP-9900
|
314
|
MSTRING_KTWP12 = "\x55\x20\x18\x11\x02\xFF\xDC\x02"
|
315
|
|
316
|
|
317
|
def _clean_buffer(radio):
|
318
|
"""Cleaning the read serial buffer, hard timeout to survive an infinite
|
319
|
data stream"""
|
320
|
|
321
|
# touching the serial timeout to optimize the flushing
|
322
|
# restored at the end to the default value
|
323
|
radio.pipe.timeout = 0.1
|
324
|
dump = "1"
|
325
|
datacount = 0
|
326
|
|
327
|
try:
|
328
|
while len(dump) > 0:
|
329
|
dump = radio.pipe.read(100)
|
330
|
datacount += len(dump)
|
331
|
# hard limit to survive a infinite serial data stream
|
332
|
# 5 times bigger than a normal rx block (69 bytes)
|
333
|
if datacount > 345:
|
334
|
seriale = "Please check your serial port selection."
|
335
|
raise errors.RadioError(seriale)
|
336
|
|
337
|
# restore the default serial timeout
|
338
|
radio.pipe.timeout = STIMEOUT
|
339
|
|
340
|
except Exception:
|
341
|
raise errors.RadioError("Unknown error cleaning the serial buffer")
|
342
|
|
343
|
|
344
|
def _rawrecv(radio, amount):
|
345
|
"""Raw read from the radio device, less intensive way"""
|
346
|
|
347
|
data = ""
|
348
|
|
349
|
try:
|
350
|
data = radio.pipe.read(amount)
|
351
|
|
352
|
# DEBUG
|
353
|
if debug is True:
|
354
|
LOG.debug("<== (%d) bytes:\n\n%s" %
|
355
|
(len(data), util.hexprint(data)))
|
356
|
|
357
|
# fail if no data is received
|
358
|
if len(data) == 0:
|
359
|
raise errors.RadioError("No data received from radio")
|
360
|
|
361
|
# notice on the logs if short
|
362
|
if len(data) < amount:
|
363
|
LOG.warn("Short reading %d bytes from the %d requested." %
|
364
|
(len(data), amount))
|
365
|
|
366
|
except:
|
367
|
raise errors.RadioError("Error reading data from radio")
|
368
|
|
369
|
return data
|
370
|
|
371
|
|
372
|
def _send(radio, data):
|
373
|
"""Send data to the radio device"""
|
374
|
|
375
|
try:
|
376
|
radio.pipe.write(data)
|
377
|
|
378
|
# DEBUG
|
379
|
if debug is True:
|
380
|
LOG.debug("==> (%d) bytes:\n\n%s" %
|
381
|
(len(data), util.hexprint(data)))
|
382
|
except:
|
383
|
raise errors.RadioError("Error sending data to radio")
|
384
|
|
385
|
|
386
|
def _make_frame(cmd, addr, length, data=""):
|
387
|
"""Pack the info in the headder format"""
|
388
|
frame = "\x06" + struct.pack(">BHB", ord(cmd), addr, length)
|
389
|
# add the data if set
|
390
|
if len(data) != 0:
|
391
|
frame += data
|
392
|
|
393
|
return frame
|
394
|
|
395
|
|
396
|
def _recv(radio, addr):
|
397
|
"""Get data from the radio all at once to lower syscalls load"""
|
398
|
|
399
|
# Get the full 69 bytes at a time to reduce load
|
400
|
# 1 byte ACK + 4 bytes header + 64 bytes of data (BLOCK_SIZE)
|
401
|
|
402
|
# get the whole block
|
403
|
block = _rawrecv(radio, BLOCK_SIZE + 5)
|
404
|
|
405
|
# basic check
|
406
|
if len(block) < (BLOCK_SIZE + 5):
|
407
|
raise errors.RadioError("Short read of the block 0x%04x" % addr)
|
408
|
|
409
|
# checking for the ack
|
410
|
if block[0] != ACK_CMD:
|
411
|
raise errors.RadioError("Bad ack from radio in block 0x%04x" % addr)
|
412
|
|
413
|
# header validation
|
414
|
c, a, l = struct.unpack(">BHB", block[1:5])
|
415
|
if a != addr or l != BLOCK_SIZE or c != ord("X"):
|
416
|
LOG.debug("Invalid header for block 0x%04x" % addr)
|
417
|
LOG.debug("CMD: %s ADDR: %04x SIZE: %02x" % (c, a, l))
|
418
|
raise errors.RadioError("Invalid header for block 0x%04x:" % addr)
|
419
|
|
420
|
# return the data
|
421
|
return block[5:]
|
422
|
|
423
|
|
424
|
def _do_ident(radio, status, upload=False):
|
425
|
"""Put the radio in PROGRAM mode & identify it"""
|
426
|
# set the serial discipline
|
427
|
radio.pipe.baudrate = 9600
|
428
|
radio.pipe.parity = "N"
|
429
|
|
430
|
# lengthen the timeout here as these radios are reseting due to timeout
|
431
|
radio.pipe.timeout = 0.75
|
432
|
|
433
|
# send the magic word
|
434
|
_send(radio, radio._magic)
|
435
|
|
436
|
# Now you get a 50 byte reply if all goes well
|
437
|
ident = _rawrecv(radio, 50)
|
438
|
|
439
|
# checking for the ack
|
440
|
if ident[0] != ACK_CMD:
|
441
|
raise errors.RadioError("Bad ack from radio")
|
442
|
|
443
|
# basic check for the ident block
|
444
|
if len(ident) != 50:
|
445
|
raise errors.RadioError("Radio send a short ident block.")
|
446
|
|
447
|
# check if ident is OK
|
448
|
itis = False
|
449
|
for fp in radio._fileid:
|
450
|
if fp in ident:
|
451
|
# got it!
|
452
|
itis = True
|
453
|
# checking if we are dealing with a Gen 3 BTECH
|
454
|
if radio.VENDOR == "BTECH" and fp in BTECH3:
|
455
|
radio.btech3 = True
|
456
|
|
457
|
break
|
458
|
|
459
|
if itis is False:
|
460
|
LOG.debug("Incorrect model ID, got this:\n\n" + util.hexprint(ident))
|
461
|
raise errors.RadioError("Radio identification failed.")
|
462
|
|
463
|
# pause here for the radio to catch up
|
464
|
sleep(0.1)
|
465
|
|
466
|
# the OEM software reads this additional block, so we will, too
|
467
|
|
468
|
# Get the full 21 bytes at a time to reduce load
|
469
|
# 1 byte ACK + 4 bytes header + 16 bytes of data (BLOCK_SIZE)
|
470
|
frame = _make_frame("S", 0x3DF0, 16)
|
471
|
_send(radio, frame)
|
472
|
id2 = _rawrecv(radio, 21)
|
473
|
|
474
|
# restore the default serial timeout
|
475
|
radio.pipe.timeout = STIMEOUT
|
476
|
|
477
|
# checking for the ack
|
478
|
if id2[0] not in "\x06\x05":
|
479
|
raise errors.RadioError("Bad ack from radio")
|
480
|
|
481
|
# basic check for the additional block
|
482
|
if len(id2) < 21:
|
483
|
raise errors.RadioError("The extra ID is short, aborting.")
|
484
|
|
485
|
# this radios need a extra request/answer here on the upload
|
486
|
# the amount of data received depends of the radio type
|
487
|
#
|
488
|
# also the first block of TX must no have the ACK at the beginning
|
489
|
# see _upload for this.
|
490
|
if upload is True:
|
491
|
# send an ACK
|
492
|
_send(radio, ACK_CMD)
|
493
|
|
494
|
# the amount of data depend on the radio, so far we have two radios
|
495
|
# reading two bytes with an ACK at the end and just ONE with just
|
496
|
# one byte (QYT KT8900)
|
497
|
# the JT-6188 appears a clone of the last, but reads TWO bytes.
|
498
|
#
|
499
|
# we will read two bytes with a custom timeout to not penalize the
|
500
|
# users for this.
|
501
|
#
|
502
|
# we just check for a response and last byte being a ACK, that is
|
503
|
# the common stone for all radios (3 so far)
|
504
|
ack = _rawrecv(radio, 2)
|
505
|
|
506
|
# checking
|
507
|
if len(ack) == 0 or ack[-1:] != ACK_CMD:
|
508
|
raise errors.RadioError("Radio didn't ACK the upload")
|
509
|
|
510
|
# DEBUG
|
511
|
LOG.info("Positive ident, this is a %s %s" % (radio.VENDOR, radio.MODEL))
|
512
|
|
513
|
return True
|
514
|
|
515
|
|
516
|
def _download(radio):
|
517
|
"""Get the memory map"""
|
518
|
|
519
|
# UI progress
|
520
|
status = chirp_common.Status()
|
521
|
|
522
|
# put radio in program mode and identify it
|
523
|
_do_ident(radio, status)
|
524
|
|
525
|
# reset the progress bar in the UI
|
526
|
status.max = MEM_SIZE / BLOCK_SIZE
|
527
|
status.msg = "Cloning from radio..."
|
528
|
status.cur = 0
|
529
|
radio.status_fn(status)
|
530
|
|
531
|
data = ""
|
532
|
for addr in range(0, MEM_SIZE, BLOCK_SIZE):
|
533
|
# sending the read request
|
534
|
_send(radio, _make_frame("S", addr, BLOCK_SIZE))
|
535
|
|
536
|
# read
|
537
|
d = _recv(radio, addr)
|
538
|
|
539
|
# aggregate the data
|
540
|
data += d
|
541
|
|
542
|
# UI Update
|
543
|
status.cur = addr / BLOCK_SIZE
|
544
|
status.msg = "Cloning from radio..."
|
545
|
radio.status_fn(status)
|
546
|
|
547
|
return data
|
548
|
|
549
|
|
550
|
def _upload(radio):
|
551
|
"""Upload procedure"""
|
552
|
|
553
|
# The UPLOAD mem is restricted to lower than 0x3100,
|
554
|
# so we will overide that here localy
|
555
|
MEM_SIZE = radio.UPLOAD_MEM_SIZE
|
556
|
|
557
|
# UI progress
|
558
|
status = chirp_common.Status()
|
559
|
|
560
|
# put radio in program mode and identify it
|
561
|
_do_ident(radio, status, True)
|
562
|
|
563
|
# get the data to upload to radio
|
564
|
data = radio.get_mmap()
|
565
|
|
566
|
# Reset the UI progress
|
567
|
status.max = MEM_SIZE / TX_BLOCK_SIZE
|
568
|
status.cur = 0
|
569
|
status.msg = "Cloning to radio..."
|
570
|
radio.status_fn(status)
|
571
|
|
572
|
# the fun start here
|
573
|
for addr in range(0, MEM_SIZE, TX_BLOCK_SIZE):
|
574
|
# getting the block of data to send
|
575
|
d = data[addr:addr + TX_BLOCK_SIZE]
|
576
|
|
577
|
# build the frame to send
|
578
|
frame = _make_frame("X", addr, TX_BLOCK_SIZE, d)
|
579
|
|
580
|
# first block must not send the ACK at the beginning for the
|
581
|
# ones that has the extra id, since this have to do a extra step
|
582
|
if addr == 0:
|
583
|
frame = frame[1:]
|
584
|
|
585
|
# send the frame
|
586
|
_send(radio, frame)
|
587
|
|
588
|
# receiving the response
|
589
|
ack = _rawrecv(radio, 1)
|
590
|
|
591
|
# basic check
|
592
|
if len(ack) != 1:
|
593
|
raise errors.RadioError("No ACK when writing block 0x%04x" % addr)
|
594
|
|
595
|
if ack not in "\x06\x05":
|
596
|
raise errors.RadioError("Bad ACK writing block 0x%04x:" % addr)
|
597
|
|
598
|
# UI Update
|
599
|
status.cur = addr / TX_BLOCK_SIZE
|
600
|
status.msg = "Cloning to radio..."
|
601
|
radio.status_fn(status)
|
602
|
|
603
|
|
604
|
def model_match(cls, data):
|
605
|
"""Match the opened/downloaded image to the correct version"""
|
606
|
rid = data[0x3f70:0x3f76]
|
607
|
|
608
|
if rid in cls._fileid:
|
609
|
return True
|
610
|
|
611
|
return False
|
612
|
|
613
|
|
614
|
def _decode_ranges(low, high):
|
615
|
"""Unpack the data in the ranges zones in the memmap and return
|
616
|
a tuple with the integer corresponding to the Mhz it means"""
|
617
|
ilow = int(low[0]) * 100 + int(low[1]) * 10 + int(low[2])
|
618
|
ihigh = int(high[0]) * 100 + int(high[1]) * 10 + int(high[2])
|
619
|
ilow *= 1000000
|
620
|
ihigh *= 1000000
|
621
|
|
622
|
return (ilow, ihigh)
|
623
|
|
624
|
|
625
|
def _split(rf, f1, f2):
|
626
|
"""Returns False if the two freqs are in the same band (no split)
|
627
|
or True otherwise"""
|
628
|
|
629
|
# determine if the two freqs are in the same band
|
630
|
for low, high in rf.valid_bands:
|
631
|
if f1 >= low and f1 <= high and \
|
632
|
f2 >= low and f2 <= high:
|
633
|
# if the two freqs are on the same Band this is not a split
|
634
|
return False
|
635
|
|
636
|
# if you get here is because the freq pairs are split
|
637
|
return True
|
638
|
|
639
|
|
640
|
class BTechMobileCommon(chirp_common.CloneModeRadio,
|
641
|
chirp_common.ExperimentalRadio):
|
642
|
"""BTECH's UV-5001 and alike radios"""
|
643
|
VENDOR = "BTECH"
|
644
|
MODEL = ""
|
645
|
IDENT = ""
|
646
|
BANDS = 2
|
647
|
COLOR_LCD = False
|
648
|
COLOR_LCD2 = False # BTech Original GMRS Radios
|
649
|
COLOR_LCD3 = False # Color HT Radios
|
650
|
COLOR_LCD4 = False # Waterproof Mobile Radios
|
651
|
NAME_LENGTH = 6
|
652
|
UPLOAD_MEM_SIZE = 0X3100
|
653
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
654
|
chirp_common.PowerLevel("Low", watts=10)]
|
655
|
_vhf_range = (130000000, 180000000)
|
656
|
_220_range = (200000000, 271000000)
|
657
|
_uhf_range = (400000000, 521000000)
|
658
|
_350_range = (350000000, 391000000)
|
659
|
_upper = 199
|
660
|
_magic = MSTRING
|
661
|
_fileid = None
|
662
|
_id2 = False
|
663
|
btech3 = False
|
664
|
_gmrs = False
|
665
|
|
666
|
@classmethod
|
667
|
def get_prompts(cls):
|
668
|
rp = chirp_common.RadioPrompts()
|
669
|
rp.experimental = \
|
670
|
('This driver is experimental.\n'
|
671
|
'\n'
|
672
|
'Please keep a copy of your memories with the original software '
|
673
|
'if you treasure them, this driver is new and may contain'
|
674
|
' bugs.\n'
|
675
|
'\n'
|
676
|
)
|
677
|
rp.pre_download = _(dedent("""\
|
678
|
Follow these instructions to download your info:
|
679
|
|
680
|
1 - Turn off your radio
|
681
|
2 - Connect your interface cable
|
682
|
3 - Turn on your radio
|
683
|
4 - Do the download of your radio data
|
684
|
|
685
|
"""))
|
686
|
rp.pre_upload = _(dedent("""\
|
687
|
Follow these instructions to upload your info:
|
688
|
|
689
|
1 - Turn off your radio
|
690
|
2 - Connect your interface cable
|
691
|
3 - Turn on your radio
|
692
|
4 - Do the upload of your radio data
|
693
|
|
694
|
"""))
|
695
|
return rp
|
696
|
|
697
|
def get_features(self):
|
698
|
"""Get the radio's features"""
|
699
|
|
700
|
# we will use the following var as global
|
701
|
global POWER_LEVELS
|
702
|
|
703
|
rf = chirp_common.RadioFeatures()
|
704
|
rf.has_settings = True
|
705
|
rf.has_bank = False
|
706
|
rf.has_tuning_step = False
|
707
|
rf.can_odd_split = True
|
708
|
rf.has_name = True
|
709
|
rf.has_offset = True
|
710
|
rf.has_mode = True
|
711
|
rf.has_dtcs = True
|
712
|
rf.has_rx_dtcs = True
|
713
|
rf.has_dtcs_polarity = True
|
714
|
rf.has_ctone = True
|
715
|
rf.has_cross = True
|
716
|
rf.valid_modes = MODES
|
717
|
rf.valid_characters = VALID_CHARS
|
718
|
rf.valid_name_length = self.NAME_LENGTH
|
719
|
rf.valid_duplexes = ["", "-", "+", "split", "off"]
|
720
|
rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
|
721
|
rf.valid_cross_modes = [
|
722
|
"Tone->Tone",
|
723
|
"DTCS->",
|
724
|
"->DTCS",
|
725
|
"Tone->DTCS",
|
726
|
"DTCS->Tone",
|
727
|
"->Tone",
|
728
|
"DTCS->DTCS"]
|
729
|
rf.valid_skips = SKIP_VALUES
|
730
|
rf.valid_dtcs_codes = DTCS
|
731
|
rf.valid_tuning_steps = STEPS
|
732
|
rf.memory_bounds = (0, self._upper)
|
733
|
|
734
|
# power levels
|
735
|
POWER_LEVELS = self._power_levels
|
736
|
rf.valid_power_levels = POWER_LEVELS
|
737
|
|
738
|
# normal dual bands
|
739
|
rf.valid_bands = [self._vhf_range, self._uhf_range]
|
740
|
|
741
|
# 220 band
|
742
|
if self.BANDS == 3 or self.BANDS == 4:
|
743
|
rf.valid_bands.append(self._220_range)
|
744
|
|
745
|
# 350 band
|
746
|
if self.BANDS == 4:
|
747
|
rf.valid_bands.append(self._350_range)
|
748
|
|
749
|
return rf
|
750
|
|
751
|
def validate_memory(self, mem):
|
752
|
msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
|
753
|
|
754
|
_msg_duplex1 = 'Memory location only supports "Low"'
|
755
|
_msg_duplex2 = 'Memory location only supports "off"'
|
756
|
_msg_duplex3 = 'Memory location only supports "(None)", "+" or "off"'
|
757
|
|
758
|
return msgs
|
759
|
|
760
|
def sync_in(self):
|
761
|
"""Download from radio"""
|
762
|
data = _download(self)
|
763
|
self._mmap = memmap.MemoryMap(data)
|
764
|
self.process_mmap()
|
765
|
|
766
|
def sync_out(self):
|
767
|
"""Upload to radio"""
|
768
|
try:
|
769
|
_upload(self)
|
770
|
except errors.RadioError:
|
771
|
raise
|
772
|
except Exception, e:
|
773
|
raise errors.RadioError("Error: %s" % e)
|
774
|
|
775
|
def get_raw_memory(self, number):
|
776
|
return repr(self._memobj.memory[number])
|
777
|
|
778
|
def _decode_tone(self, val):
|
779
|
"""Parse the tone data to decode from mem, it returns:
|
780
|
Mode (''|DTCS|Tone), Value (None|###), Polarity (None,N,R)"""
|
781
|
pol = None
|
782
|
|
783
|
if val in [0, 65535]:
|
784
|
return '', None, None
|
785
|
elif val > 0x0258:
|
786
|
a = val / 10.0
|
787
|
return 'Tone', a, pol
|
788
|
else:
|
789
|
if val > 0x69:
|
790
|
index = val - 0x6A
|
791
|
pol = "R"
|
792
|
else:
|
793
|
index = val - 1
|
794
|
pol = "N"
|
795
|
|
796
|
tone = DTCS[index]
|
797
|
return 'DTCS', tone, pol
|
798
|
|
799
|
def _encode_tone(self, memval, mode, val, pol):
|
800
|
"""Parse the tone data to encode from UI to mem"""
|
801
|
if mode == '' or mode is None:
|
802
|
memval.set_raw("\x00\x00")
|
803
|
elif mode == 'Tone':
|
804
|
memval.set_value(val * 10)
|
805
|
elif mode == 'DTCS':
|
806
|
# detect the index in the DTCS list
|
807
|
try:
|
808
|
index = DTCS.index(val)
|
809
|
if pol == "N":
|
810
|
index += 1
|
811
|
else:
|
812
|
index += 0x6A
|
813
|
memval.set_value(index)
|
814
|
except:
|
815
|
msg = "Digital Tone '%d' is not supported" % value
|
816
|
LOG.error(msg)
|
817
|
raise errors.RadioError(msg)
|
818
|
else:
|
819
|
msg = "Internal error: invalid mode '%s'" % mode
|
820
|
LOG.error(msg)
|
821
|
raise errors.InvalidDataError(msg)
|
822
|
|
823
|
def get_memory(self, number):
|
824
|
"""Get the mem representation from the radio image"""
|
825
|
_mem = self._memobj.memory[number]
|
826
|
_names = self._memobj.names[number]
|
827
|
|
828
|
# Create a high-level memory object to return to the UI
|
829
|
mem = chirp_common.Memory()
|
830
|
|
831
|
# Memory number
|
832
|
mem.number = number
|
833
|
|
834
|
if _mem.get_raw()[0] == "\xFF":
|
835
|
mem.empty = True
|
836
|
return mem
|
837
|
|
838
|
# Freq and offset
|
839
|
mem.freq = int(_mem.rxfreq) * 10
|
840
|
# tx freq can be blank
|
841
|
if _mem.get_raw()[4] == "\xFF":
|
842
|
# TX freq not set
|
843
|
mem.offset = 0
|
844
|
mem.duplex = "off"
|
845
|
else:
|
846
|
# TX freq set
|
847
|
offset = (int(_mem.txfreq) * 10) - mem.freq
|
848
|
if offset != 0:
|
849
|
if _split(self.get_features(), mem.freq, int(
|
850
|
_mem.txfreq) * 10):
|
851
|
mem.duplex = "split"
|
852
|
mem.offset = int(_mem.txfreq) * 10
|
853
|
elif offset < 0:
|
854
|
mem.offset = abs(offset)
|
855
|
mem.duplex = "-"
|
856
|
elif offset > 0:
|
857
|
mem.offset = offset
|
858
|
mem.duplex = "+"
|
859
|
else:
|
860
|
mem.offset = 0
|
861
|
|
862
|
# name TAG of the channel
|
863
|
mem.name = str(_names.name).rstrip("\xFF").replace("\xFF", " ")
|
864
|
|
865
|
# power
|
866
|
mem.power = POWER_LEVELS[int(_mem.power)]
|
867
|
|
868
|
# wide/narrow
|
869
|
mem.mode = MODES[int(_mem.wide)]
|
870
|
|
871
|
# skip
|
872
|
mem.skip = SKIP_VALUES[_mem.add]
|
873
|
|
874
|
# tone data
|
875
|
rxtone = txtone = None
|
876
|
txtone = self._decode_tone(_mem.txtone)
|
877
|
rxtone = self._decode_tone(_mem.rxtone)
|
878
|
chirp_common.split_tone_decode(mem, txtone, rxtone)
|
879
|
|
880
|
# Extra
|
881
|
mem.extra = RadioSettingGroup("extra", "Extra")
|
882
|
|
883
|
if not self.COLOR_LCD or \
|
884
|
(self.COLOR_LCD and not self.VENDOR == "BTECH"):
|
885
|
scramble = RadioSetting("scramble", "Scramble",
|
886
|
RadioSettingValueBoolean(bool(
|
887
|
_mem.scramble)))
|
888
|
mem.extra.append(scramble)
|
889
|
|
890
|
bcl = RadioSetting("bcl", "Busy channel lockout",
|
891
|
RadioSettingValueBoolean(bool(_mem.bcl)))
|
892
|
mem.extra.append(bcl)
|
893
|
|
894
|
pttid = RadioSetting("pttid", "PTT ID",
|
895
|
RadioSettingValueList(PTTID_LIST,
|
896
|
PTTID_LIST[_mem.pttid]))
|
897
|
mem.extra.append(pttid)
|
898
|
|
899
|
# validating scode
|
900
|
scode = _mem.scode if _mem.scode != 15 else 0
|
901
|
pttidcode = RadioSetting("scode", "PTT ID signal code",
|
902
|
RadioSettingValueList(
|
903
|
PTTIDCODE_LIST,
|
904
|
PTTIDCODE_LIST[scode]))
|
905
|
mem.extra.append(pttidcode)
|
906
|
|
907
|
optsig = RadioSetting("optsig", "Optional signaling",
|
908
|
RadioSettingValueList(
|
909
|
OPTSIG_LIST,
|
910
|
OPTSIG_LIST[_mem.optsig]))
|
911
|
mem.extra.append(optsig)
|
912
|
|
913
|
spmute = RadioSetting("spmute", "Speaker mute",
|
914
|
RadioSettingValueList(
|
915
|
SPMUTE_LIST,
|
916
|
SPMUTE_LIST[_mem.spmute]))
|
917
|
mem.extra.append(spmute)
|
918
|
|
919
|
return mem
|
920
|
|
921
|
def set_memory(self, mem):
|
922
|
"""Set the memory data in the eeprom img from the UI"""
|
923
|
# get the eprom representation of this channel
|
924
|
_mem = self._memobj.memory[mem.number]
|
925
|
_names = self._memobj.names[mem.number]
|
926
|
|
927
|
mem_was_empty = False
|
928
|
# same method as used in get_memory for determining if mem is empty
|
929
|
# doing this BEFORE overwriting it with new values ...
|
930
|
if _mem.get_raw()[0] == "\xFF":
|
931
|
LOG.debug("This mem was empty before")
|
932
|
mem_was_empty = True
|
933
|
|
934
|
# if empty memmory
|
935
|
if mem.empty:
|
936
|
# the channel itself
|
937
|
_mem.set_raw("\xFF" * 16)
|
938
|
# the name tag
|
939
|
_names.set_raw("\xFF" * 16)
|
940
|
return
|
941
|
|
942
|
if mem_was_empty:
|
943
|
# Zero the whole memory if we're making it unempty for
|
944
|
# the first time
|
945
|
LOG.debug('Zeroing new memory')
|
946
|
_mem.set_raw('\x00' * 16)
|
947
|
|
948
|
if self._gmrs:
|
949
|
if mem.number >= 1 and mem.number <= 30:
|
950
|
GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 1000000)
|
951
|
mem.freq = GMRS_FREQ
|
952
|
if mem.number <= 22:
|
953
|
mem.duplex = ''
|
954
|
mem.offset = 0
|
955
|
mem.mode = "FM"
|
956
|
mem.power = POWER_LEVELS[0]
|
957
|
if mem.number >= 8 and mem.number <= 14:
|
958
|
mem.duplex = 'off'
|
959
|
mem.offset = 0
|
960
|
mem.mode = "NFM"
|
961
|
mem.power = POWER_LEVELS[2]
|
962
|
if mem.number > 22:
|
963
|
mem.duplex = '+'
|
964
|
mem.offset = 5000000
|
965
|
mem.mode = "FM"
|
966
|
mem.power = POWER_LEVELS[0]
|
967
|
elif float(mem.freq) / 1000000 in GMRS_FREQS:
|
968
|
if float(mem.freq) / 1000000 in GMRS_FREQS1:
|
969
|
mem.duplex = ''
|
970
|
mem.offset = 0
|
971
|
mem.mode = "FM"
|
972
|
mem.power = POWER_LEVELS[0]
|
973
|
if float(mem.freq) / 1000000 in GMRS_FREQS2:
|
974
|
mem.duplex = 'off'
|
975
|
mem.offset = 0
|
976
|
mem.mode = "NFM"
|
977
|
mem.power = POWER_LEVELS[2]
|
978
|
if float(mem.freq) / 1000000 in GMRS_FREQS3:
|
979
|
if mem.duplex == '+':
|
980
|
mem.offset = 5000000
|
981
|
else:
|
982
|
mem.offset = 0
|
983
|
mem.mode = "FM"
|
984
|
mem.power = POWER_LEVELS[0]
|
985
|
else:
|
986
|
mem.duplex = 'off'
|
987
|
mem.offset = 0
|
988
|
|
989
|
# frequency
|
990
|
_mem.rxfreq = mem.freq / 10
|
991
|
|
992
|
# duplex
|
993
|
if mem.duplex == "+":
|
994
|
_mem.txfreq = (mem.freq + mem.offset) / 10
|
995
|
elif mem.duplex == "-":
|
996
|
_mem.txfreq = (mem.freq - mem.offset) / 10
|
997
|
elif mem.duplex == "off":
|
998
|
for i in _mem.txfreq:
|
999
|
i.set_raw("\xFF")
|
1000
|
elif mem.duplex == "split":
|
1001
|
_mem.txfreq = mem.offset / 10
|
1002
|
else:
|
1003
|
_mem.txfreq = mem.freq / 10
|
1004
|
|
1005
|
# tone data
|
1006
|
((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \
|
1007
|
chirp_common.split_tone_encode(mem)
|
1008
|
self._encode_tone(_mem.txtone, txmode, txtone, txpol)
|
1009
|
self._encode_tone(_mem.rxtone, rxmode, rxtone, rxpol)
|
1010
|
|
1011
|
# name TAG of the channel
|
1012
|
if len(mem.name) < self.NAME_LENGTH:
|
1013
|
# we must pad to self.NAME_LENGTH chars, " " = "\xFF"
|
1014
|
mem.name = str(mem.name).ljust(self.NAME_LENGTH, " ")
|
1015
|
_names.name = str(mem.name).replace(" ", "\xFF")
|
1016
|
|
1017
|
# power, # default power level is high
|
1018
|
_mem.power = 0 if mem.power is None else POWER_LEVELS.index(mem.power)
|
1019
|
|
1020
|
# wide/narrow
|
1021
|
_mem.wide = MODES.index(mem.mode)
|
1022
|
|
1023
|
# scan add property
|
1024
|
_mem.add = SKIP_VALUES.index(mem.skip)
|
1025
|
|
1026
|
# reseting unknowns, this have to be set by hand
|
1027
|
_mem.unknown0 = 0
|
1028
|
_mem.unknown1 = 0
|
1029
|
_mem.unknown2 = 0
|
1030
|
_mem.unknown3 = 0
|
1031
|
_mem.unknown4 = 0
|
1032
|
_mem.unknown5 = 0
|
1033
|
_mem.unknown6 = 0
|
1034
|
|
1035
|
def _zero_settings():
|
1036
|
_mem.spmute = 0
|
1037
|
_mem.optsig = 0
|
1038
|
_mem.scramble = 0
|
1039
|
_mem.bcl = 0
|
1040
|
_mem.pttid = 0
|
1041
|
_mem.scode = 0
|
1042
|
|
1043
|
if self.COLOR_LCD and _mem.scramble:
|
1044
|
LOG.info('Resetting scramble bit for BTECH COLOR_LCD variant')
|
1045
|
_mem.scramble = 0
|
1046
|
|
1047
|
# extra settings
|
1048
|
if len(mem.extra) > 0:
|
1049
|
# there are setting, parse
|
1050
|
LOG.debug("Extra-Setting supplied. Setting them.")
|
1051
|
# Zero them all first so any not provided by model don't
|
1052
|
# stay set
|
1053
|
_zero_settings()
|
1054
|
for setting in mem.extra:
|
1055
|
setattr(_mem, setting.get_name(), setting.value)
|
1056
|
else:
|
1057
|
if mem.empty:
|
1058
|
LOG.debug("New mem is empty.")
|
1059
|
else:
|
1060
|
LOG.debug("New mem is NOT empty")
|
1061
|
# set extra-settings to default ONLY when apreviously empty or
|
1062
|
# deleted memory was edited to prevent errors such as #4121
|
1063
|
if mem_was_empty:
|
1064
|
LOG.debug("old mem was empty. Setting default for extras.")
|
1065
|
_zero_settings()
|
1066
|
|
1067
|
return mem
|
1068
|
|
1069
|
def get_settings(self):
|
1070
|
"""Translate the bit in the mem_struct into settings in the UI"""
|
1071
|
_mem = self._memobj
|
1072
|
basic = RadioSettingGroup("basic", "Basic Settings")
|
1073
|
advanced = RadioSettingGroup("advanced", "Advanced Settings")
|
1074
|
other = RadioSettingGroup("other", "Other Settings")
|
1075
|
work = RadioSettingGroup("work", "Work Mode Settings")
|
1076
|
top = RadioSettings(basic, advanced, other, work)
|
1077
|
|
1078
|
# Basic
|
1079
|
if self.COLOR_LCD:
|
1080
|
tmr = RadioSetting("settings.tmr", "Transceiver multi-receive",
|
1081
|
RadioSettingValueList(
|
1082
|
self.LIST_TMR,
|
1083
|
self.LIST_TMR[_mem.settings.tmr]))
|
1084
|
basic.append(tmr)
|
1085
|
else:
|
1086
|
tdr = RadioSetting("settings.tdr", "Transceiver dual receive",
|
1087
|
RadioSettingValueBoolean(_mem.settings.tdr))
|
1088
|
basic.append(tdr)
|
1089
|
|
1090
|
sql = RadioSetting("settings.sql", "Squelch level",
|
1091
|
RadioSettingValueInteger(0, 9, _mem.settings.sql))
|
1092
|
basic.append(sql)
|
1093
|
|
1094
|
if self.MODEL == "GMRS-50X1":
|
1095
|
autolk = RadioSetting("settings.autolk", "Auto keylock",
|
1096
|
RadioSettingValueBoolean(
|
1097
|
_mem.settings.autolk))
|
1098
|
basic.append(autolk)
|
1099
|
|
1100
|
if self.MODEL == "DB25-G":
|
1101
|
rs = RadioSettingValueInteger(0, 127, _mem.settings.mgain2)
|
1102
|
mgain2 = RadioSetting("settings.mgain2", "Mic gain", rs)
|
1103
|
basic.append(mgain2)
|
1104
|
|
1105
|
tot = RadioSetting("settings.tot", "Time out timer",
|
1106
|
RadioSettingValueList(
|
1107
|
LIST_TOT,
|
1108
|
LIST_TOT[_mem.settings.tot]))
|
1109
|
basic.append(tot)
|
1110
|
|
1111
|
if self.MODEL == "KT-8R":
|
1112
|
save = RadioSetting("settings.save", "Battery Save",
|
1113
|
RadioSettingValueBoolean(
|
1114
|
_mem.settings.save))
|
1115
|
basic.append(save)
|
1116
|
|
1117
|
model_list = ["KT-8R", "KT-WP12", "WP-9900"]
|
1118
|
if self.MODEL not in model_list:
|
1119
|
if self.VENDOR == "BTECH" or self.COLOR_LCD:
|
1120
|
apo = RadioSetting("settings.apo", "Auto power off timer",
|
1121
|
RadioSettingValueList(
|
1122
|
LIST_APO,
|
1123
|
LIST_APO[_mem.settings.apo]))
|
1124
|
basic.append(apo)
|
1125
|
else:
|
1126
|
toa = RadioSetting("settings.apo", "Time out alert timer",
|
1127
|
RadioSettingValueList(
|
1128
|
LIST_OFF1TO10,
|
1129
|
LIST_OFF1TO10[_mem.settings.apo]))
|
1130
|
basic.append(toa)
|
1131
|
|
1132
|
abr = RadioSetting("settings.abr", "Backlight timer",
|
1133
|
RadioSettingValueList(
|
1134
|
LIST_OFF1TO50,
|
1135
|
LIST_OFF1TO50[_mem.settings.abr]))
|
1136
|
basic.append(abr)
|
1137
|
|
1138
|
beep = RadioSetting("settings.beep", "Key beep",
|
1139
|
RadioSettingValueBoolean(_mem.settings.beep))
|
1140
|
basic.append(beep)
|
1141
|
|
1142
|
if self.MODEL == "GMRS-20V2":
|
1143
|
rs = RadioSettingValueInteger(0, 58, _mem.settings.volume)
|
1144
|
volume = RadioSetting("settings.volume", "Volume", rs)
|
1145
|
basic.append(volume)
|
1146
|
|
1147
|
if self.MODEL == "KT-WP12" or self.MODEL == "WP-9900":
|
1148
|
rs = RadioSettingValueInteger(1, 51, _mem.settings.volume + 1)
|
1149
|
volume = RadioSetting("settings.volume", "Volume", rs)
|
1150
|
basic.append(volume)
|
1151
|
|
1152
|
if self.MODEL == "KT-8R":
|
1153
|
dsub = RadioSetting("settings.dsub", "CTCSS/DCS code display",
|
1154
|
RadioSettingValueBoolean(
|
1155
|
_mem.settings.dsub))
|
1156
|
basic.append(dsub)
|
1157
|
|
1158
|
if self.MODEL == "KT-8R" or self.COLOR_LCD4:
|
1159
|
dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone",
|
1160
|
RadioSettingValueBoolean(
|
1161
|
_mem.settings.dtmfst))
|
1162
|
basic.append(dtmfst)
|
1163
|
else:
|
1164
|
dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone",
|
1165
|
RadioSettingValueList(
|
1166
|
LIST_DTMFST,
|
1167
|
LIST_DTMFST[_mem.settings.dtmfst]))
|
1168
|
basic.append(dtmfst)
|
1169
|
|
1170
|
if not self.COLOR_LCD:
|
1171
|
prisc = RadioSetting("settings.prisc", "Priority scan",
|
1172
|
RadioSettingValueBoolean(
|
1173
|
_mem.settings.prisc))
|
1174
|
basic.append(prisc)
|
1175
|
|
1176
|
prich = RadioSetting("settings.prich", "Priority channel",
|
1177
|
RadioSettingValueInteger(0, self._upper,
|
1178
|
_mem.settings.prich))
|
1179
|
basic.append(prich)
|
1180
|
|
1181
|
screv = RadioSetting("settings.screv", "Scan resume method",
|
1182
|
RadioSettingValueList(
|
1183
|
LIST_SCREV,
|
1184
|
LIST_SCREV[_mem.settings.screv]))
|
1185
|
basic.append(screv)
|
1186
|
|
1187
|
pttlt = RadioSetting("settings.pttlt", "PTT transmit delay",
|
1188
|
RadioSettingValueInteger(0, 30,
|
1189
|
_mem.settings.pttlt))
|
1190
|
basic.append(pttlt)
|
1191
|
|
1192
|
if self.VENDOR == "BTECH" and self.COLOR_LCD and not \
|
1193
|
self.MODEL == "GMRS-20V2":
|
1194
|
emctp = RadioSetting("settings.emctp", "Alarm mode",
|
1195
|
RadioSettingValueList(
|
1196
|
LIST_EMCTPX,
|
1197
|
LIST_EMCTPX[_mem.settings.emctp]))
|
1198
|
basic.append(emctp)
|
1199
|
else:
|
1200
|
emctp = RadioSetting("settings.emctp", "Alarm mode",
|
1201
|
RadioSettingValueList(
|
1202
|
LIST_EMCTP,
|
1203
|
LIST_EMCTP[_mem.settings.emctp]))
|
1204
|
basic.append(emctp)
|
1205
|
|
1206
|
emcch = RadioSetting("settings.emcch", "Alarm channel",
|
1207
|
RadioSettingValueInteger(0, self._upper,
|
1208
|
_mem.settings.emcch))
|
1209
|
basic.append(emcch)
|
1210
|
|
1211
|
if self.COLOR_LCD:
|
1212
|
if _mem.settings.sigbp > 0x01:
|
1213
|
val = 0x00
|
1214
|
else:
|
1215
|
val = _mem.settings.sigbp
|
1216
|
sigbp = RadioSetting("settings.sigbp", "Signal beep",
|
1217
|
RadioSettingValueBoolean(val))
|
1218
|
basic.append(sigbp)
|
1219
|
else:
|
1220
|
ringt = RadioSetting("settings.ringt", "Ring time",
|
1221
|
RadioSettingValueList(
|
1222
|
LIST_OFF1TO9,
|
1223
|
LIST_OFF1TO9[_mem.settings.ringt]))
|
1224
|
basic.append(ringt)
|
1225
|
|
1226
|
camdf = RadioSetting("settings.camdf", "Display mode A",
|
1227
|
RadioSettingValueList(
|
1228
|
LIST_MDF,
|
1229
|
LIST_MDF[_mem.settings.camdf]))
|
1230
|
basic.append(camdf)
|
1231
|
|
1232
|
cbmdf = RadioSetting("settings.cbmdf", "Display mode B",
|
1233
|
RadioSettingValueList(
|
1234
|
LIST_MDF,
|
1235
|
LIST_MDF[_mem.settings.cbmdf]))
|
1236
|
basic.append(cbmdf)
|
1237
|
|
1238
|
if self.COLOR_LCD:
|
1239
|
ccmdf = RadioSetting("settings.ccmdf", "Display mode C",
|
1240
|
RadioSettingValueList(
|
1241
|
LIST_MDF,
|
1242
|
LIST_MDF[_mem.settings.ccmdf]))
|
1243
|
basic.append(ccmdf)
|
1244
|
|
1245
|
if not self.COLOR_LCD4:
|
1246
|
cdmdf = RadioSetting("settings.cdmdf", "Display mode D",
|
1247
|
RadioSettingValueList(
|
1248
|
LIST_MDF,
|
1249
|
LIST_MDF[_mem.settings.cdmdf]))
|
1250
|
basic.append(cdmdf)
|
1251
|
|
1252
|
langua = RadioSetting("settings.langua", "Language",
|
1253
|
RadioSettingValueList(
|
1254
|
LIST_LANGUA,
|
1255
|
LIST_LANGUA[_mem.settings.langua]))
|
1256
|
basic.append(langua)
|
1257
|
|
1258
|
if self.MODEL == "KT-8R":
|
1259
|
voice = RadioSetting("settings.voice", "Voice prompt",
|
1260
|
RadioSettingValueList(
|
1261
|
LIST_VOICE,
|
1262
|
LIST_VOICE[_mem.settings.voice]))
|
1263
|
basic.append(voice)
|
1264
|
|
1265
|
if self.MODEL == "KT-8R" or self.COLOR_LCD4:
|
1266
|
vox = RadioSetting("settings.vox", "VOX",
|
1267
|
RadioSettingValueList(
|
1268
|
LIST_VOX,
|
1269
|
LIST_VOX[_mem.settings.vox]))
|
1270
|
basic.append(vox)
|
1271
|
|
1272
|
voxt = RadioSetting("settings.voxt", "VOX delay time",
|
1273
|
RadioSettingValueList(
|
1274
|
LIST_VOXT,
|
1275
|
LIST_VOXT[_mem.settings.voxt]))
|
1276
|
basic.append(voxt)
|
1277
|
|
1278
|
if self.VENDOR == "BTECH":
|
1279
|
if self.COLOR_LCD:
|
1280
|
if self.MODEL == "GMRS-20V2":
|
1281
|
val = RadioSettingValueList(LIST_SYNCV2,
|
1282
|
LIST_SYNCV2[
|
1283
|
_mem.settings.sync])
|
1284
|
sync = RadioSetting("settings.sync",
|
1285
|
"Channel display sync", val)
|
1286
|
basic.append(sync)
|
1287
|
else:
|
1288
|
val = RadioSettingValueList(LIST_SYNC,
|
1289
|
LIST_SYNC[_mem.settings.sync])
|
1290
|
sync = RadioSetting("settings.sync",
|
1291
|
"Channel display sync", val)
|
1292
|
basic.append(sync)
|
1293
|
else:
|
1294
|
sync = RadioSetting("settings.sync", "A/B channel sync",
|
1295
|
RadioSettingValueBoolean(
|
1296
|
_mem.settings.sync))
|
1297
|
basic.append(sync)
|
1298
|
|
1299
|
if self.COLOR_LCD4:
|
1300
|
autolk = RadioSetting("settings.autolock", "Auto keylock",
|
1301
|
RadioSettingValueBoolean(
|
1302
|
_mem.settings.autolock))
|
1303
|
basic.append(autolk)
|
1304
|
|
1305
|
if not self.COLOR_LCD:
|
1306
|
ponmsg = RadioSetting("settings.ponmsg", "Power-on message",
|
1307
|
RadioSettingValueList(
|
1308
|
LIST_PONMSG,
|
1309
|
LIST_PONMSG[_mem.settings.ponmsg]))
|
1310
|
basic.append(ponmsg)
|
1311
|
|
1312
|
if self.COLOR_LCD and not (self.COLOR_LCD2 or self.COLOR_LCD3 or
|
1313
|
self.COLOR_LCD4):
|
1314
|
mainfc = RadioSetting("settings.mainfc",
|
1315
|
"Main LCD foreground color",
|
1316
|
RadioSettingValueList(
|
1317
|
LIST_COLOR9,
|
1318
|
LIST_COLOR9[_mem.settings.mainfc]))
|
1319
|
basic.append(mainfc)
|
1320
|
|
1321
|
if not self.COLOR_LCD4:
|
1322
|
mainbc = RadioSetting("settings.mainbc",
|
1323
|
"Main LCD background color",
|
1324
|
RadioSettingValueList(
|
1325
|
LIST_COLOR9,
|
1326
|
LIST_COLOR9[_mem.settings.mainbc]))
|
1327
|
basic.append(mainbc)
|
1328
|
|
1329
|
menufc = RadioSetting("settings.menufc", "Menu foreground color",
|
1330
|
RadioSettingValueList(
|
1331
|
LIST_COLOR9,
|
1332
|
LIST_COLOR9[_mem.settings.menufc]))
|
1333
|
basic.append(menufc)
|
1334
|
|
1335
|
if not self.COLOR_LCD4:
|
1336
|
val = RadioSettingValueList(LIST_COLOR9,
|
1337
|
LIST_COLOR9[_mem.settings.menubc])
|
1338
|
menubc = RadioSetting("settings.menubc",
|
1339
|
"Menu background color", val)
|
1340
|
basic.append(menubc)
|
1341
|
|
1342
|
stafc = RadioSetting("settings.stafc",
|
1343
|
"Top status foreground color",
|
1344
|
RadioSettingValueList(
|
1345
|
LIST_COLOR9,
|
1346
|
LIST_COLOR9[_mem.settings.stafc]))
|
1347
|
basic.append(stafc)
|
1348
|
|
1349
|
if not self.COLOR_LCD4:
|
1350
|
stabc = RadioSetting("settings.stabc",
|
1351
|
"Top status background color",
|
1352
|
RadioSettingValueList(
|
1353
|
LIST_COLOR9,
|
1354
|
LIST_COLOR9[_mem.settings.stabc]))
|
1355
|
basic.append(stabc)
|
1356
|
|
1357
|
sigfc = RadioSetting("settings.sigfc",
|
1358
|
"Bottom status foreground color",
|
1359
|
RadioSettingValueList(
|
1360
|
LIST_COLOR9,
|
1361
|
LIST_COLOR9[_mem.settings.sigfc]))
|
1362
|
basic.append(sigfc)
|
1363
|
|
1364
|
if not self.COLOR_LCD4:
|
1365
|
sigbc = RadioSetting("settings.sigbc",
|
1366
|
"Bottom status background color",
|
1367
|
RadioSettingValueList(
|
1368
|
LIST_COLOR9,
|
1369
|
LIST_COLOR9[_mem.settings.sigbc]))
|
1370
|
basic.append(sigbc)
|
1371
|
|
1372
|
rxfc = RadioSetting("settings.rxfc", "Receiving character color",
|
1373
|
RadioSettingValueList(
|
1374
|
LIST_COLOR9,
|
1375
|
LIST_COLOR9[_mem.settings.rxfc]))
|
1376
|
basic.append(rxfc)
|
1377
|
|
1378
|
txfc = RadioSetting("settings.txfc",
|
1379
|
"Transmitting character color",
|
1380
|
RadioSettingValueList(
|
1381
|
LIST_COLOR9,
|
1382
|
LIST_COLOR9[_mem.settings.txfc]))
|
1383
|
basic.append(txfc)
|
1384
|
|
1385
|
if not self.COLOR_LCD4:
|
1386
|
txdisp = RadioSetting("settings.txdisp",
|
1387
|
"Transmitting status display",
|
1388
|
RadioSettingValueList(
|
1389
|
LIST_TXDISP,
|
1390
|
LIST_TXDISP[_mem.settings.txdisp]))
|
1391
|
basic.append(txdisp)
|
1392
|
|
1393
|
elif self.COLOR_LCD2 or self.COLOR_LCD3:
|
1394
|
stfc = RadioSetting("settings.stfc",
|
1395
|
"ST-FC",
|
1396
|
RadioSettingValueList(
|
1397
|
LIST_COLOR8,
|
1398
|
LIST_COLOR8[_mem.settings.stfc]))
|
1399
|
basic.append(stfc)
|
1400
|
|
1401
|
mffc = RadioSetting("settings.mffc",
|
1402
|
"MF-FC",
|
1403
|
RadioSettingValueList(
|
1404
|
LIST_COLOR8,
|
1405
|
LIST_COLOR8[_mem.settings.mffc]))
|
1406
|
basic.append(mffc)
|
1407
|
|
1408
|
sfafc = RadioSetting("settings.sfafc",
|
1409
|
"SFA-FC",
|
1410
|
RadioSettingValueList(
|
1411
|
LIST_COLOR8,
|
1412
|
LIST_COLOR8[_mem.settings.sfafc]))
|
1413
|
basic.append(sfafc)
|
1414
|
|
1415
|
sfbfc = RadioSetting("settings.sfbfc",
|
1416
|
"SFB-FC",
|
1417
|
RadioSettingValueList(
|
1418
|
LIST_COLOR8,
|
1419
|
LIST_COLOR8[_mem.settings.sfbfc]))
|
1420
|
basic.append(sfbfc)
|
1421
|
|
1422
|
sfcfc = RadioSetting("settings.sfcfc",
|
1423
|
"SFC-FC",
|
1424
|
RadioSettingValueList(
|
1425
|
LIST_COLOR8,
|
1426
|
LIST_COLOR8[_mem.settings.sfcfc]))
|
1427
|
basic.append(sfcfc)
|
1428
|
|
1429
|
sfdfc = RadioSetting("settings.sfdfc",
|
1430
|
"SFD-FC",
|
1431
|
RadioSettingValueList(
|
1432
|
LIST_COLOR8,
|
1433
|
LIST_COLOR8[_mem.settings.sfdfc]))
|
1434
|
basic.append(sfdfc)
|
1435
|
|
1436
|
subfc = RadioSetting("settings.subfc",
|
1437
|
"SUB-FC",
|
1438
|
RadioSettingValueList(
|
1439
|
LIST_COLOR8,
|
1440
|
LIST_COLOR8[_mem.settings.subfc]))
|
1441
|
basic.append(subfc)
|
1442
|
|
1443
|
fmfc = RadioSetting("settings.fmfc",
|
1444
|
"FM-FC",
|
1445
|
RadioSettingValueList(
|
1446
|
LIST_COLOR8,
|
1447
|
LIST_COLOR8[_mem.settings.fmfc]))
|
1448
|
basic.append(fmfc)
|
1449
|
|
1450
|
sigfc = RadioSetting("settings.sigfc",
|
1451
|
"SIG-FC",
|
1452
|
RadioSettingValueList(
|
1453
|
LIST_COLOR8,
|
1454
|
LIST_COLOR8[_mem.settings.sigfc]))
|
1455
|
basic.append(sigfc)
|
1456
|
|
1457
|
if not self.MODEL == "KT-8R":
|
1458
|
modfc = RadioSetting("settings.modfc",
|
1459
|
"MOD-FC",
|
1460
|
RadioSettingValueList(
|
1461
|
LIST_COLOR8,
|
1462
|
LIST_COLOR8[_mem.settings.modfc]))
|
1463
|
basic.append(modfc)
|
1464
|
|
1465
|
menufc = RadioSetting("settings.menufc",
|
1466
|
"MENUFC",
|
1467
|
RadioSettingValueList(
|
1468
|
LIST_COLOR8,
|
1469
|
LIST_COLOR8[_mem.settings.menufc]))
|
1470
|
basic.append(menufc)
|
1471
|
|
1472
|
txfc = RadioSetting("settings.txfc",
|
1473
|
"TX-FC",
|
1474
|
RadioSettingValueList(
|
1475
|
LIST_COLOR8,
|
1476
|
LIST_COLOR8[_mem.settings.txfc]))
|
1477
|
basic.append(txfc)
|
1478
|
|
1479
|
if self.MODEL == "KT-8R":
|
1480
|
rxfc = RadioSetting("settings.rxfc",
|
1481
|
"RX-FC",
|
1482
|
RadioSettingValueList(
|
1483
|
LIST_COLOR8,
|
1484
|
LIST_COLOR8[_mem.settings.rxfc]))
|
1485
|
basic.append(rxfc)
|
1486
|
|
1487
|
if not self.MODEL == "KT-8R":
|
1488
|
txdisp = RadioSetting("settings.txdisp",
|
1489
|
"Transmitting status display",
|
1490
|
RadioSettingValueList(
|
1491
|
LIST_TXDISP,
|
1492
|
LIST_TXDISP[_mem.settings.txdisp]))
|
1493
|
basic.append(txdisp)
|
1494
|
elif self.COLOR_LCD4:
|
1495
|
asfc = RadioSetting("settings.asfc",
|
1496
|
"Above Stat fore color",
|
1497
|
RadioSettingValueList(
|
1498
|
LIST_COLOR8,
|
1499
|
LIST_COLOR8[_mem.settings.asfc]))
|
1500
|
basic.append(asfc)
|
1501
|
|
1502
|
mainfc = RadioSetting("settings.mainfc",
|
1503
|
"Main fore color",
|
1504
|
RadioSettingValueList(
|
1505
|
LIST_COLOR8,
|
1506
|
LIST_COLOR8[_mem.settings.mainfc]))
|
1507
|
basic.append(mainfc)
|
1508
|
|
1509
|
a_fc = RadioSetting("settings.a_fc",
|
1510
|
"A - fore color",
|
1511
|
RadioSettingValueList(
|
1512
|
LIST_COLOR8,
|
1513
|
LIST_COLOR8[_mem.settings.a_fc]))
|
1514
|
basic.append(a_fc)
|
1515
|
|
1516
|
b_fc = RadioSetting("settings.b_fc",
|
1517
|
"B - fore color",
|
1518
|
RadioSettingValueList(
|
1519
|
LIST_COLOR8,
|
1520
|
LIST_COLOR8[_mem.settings.b_fc]))
|
1521
|
basic.append(b_fc)
|
1522
|
|
1523
|
c_fc = RadioSetting("settings.c_fc",
|
1524
|
"C - fore color",
|
1525
|
RadioSettingValueList(
|
1526
|
LIST_COLOR8,
|
1527
|
LIST_COLOR8[_mem.settings.c_fc]))
|
1528
|
basic.append(c_fc)
|
1529
|
|
1530
|
subfc = RadioSetting("settings.subfc",
|
1531
|
"Sub fore color",
|
1532
|
RadioSettingValueList(
|
1533
|
LIST_COLOR8,
|
1534
|
LIST_COLOR8[_mem.settings.subfc]))
|
1535
|
basic.append(subfc)
|
1536
|
|
1537
|
battfc = RadioSetting("settings.battfc",
|
1538
|
"Battery fore color",
|
1539
|
RadioSettingValueList(
|
1540
|
LIST_COLOR8,
|
1541
|
LIST_COLOR8[_mem.settings.battfc]))
|
1542
|
basic.append(battfc)
|
1543
|
|
1544
|
sigfc = RadioSetting("settings.sigfc",
|
1545
|
"Signal fore color",
|
1546
|
RadioSettingValueList(
|
1547
|
LIST_COLOR8,
|
1548
|
LIST_COLOR8[_mem.settings.sigfc]))
|
1549
|
basic.append(sigfc)
|
1550
|
|
1551
|
menufc = RadioSetting("settings.menufc",
|
1552
|
"Menu fore color",
|
1553
|
RadioSettingValueList(
|
1554
|
LIST_COLOR8,
|
1555
|
LIST_COLOR8[_mem.settings.menufc]))
|
1556
|
basic.append(menufc)
|
1557
|
|
1558
|
txfc = RadioSetting("settings.txfc",
|
1559
|
"TX fore color",
|
1560
|
RadioSettingValueList(
|
1561
|
LIST_COLOR8,
|
1562
|
LIST_COLOR8[_mem.settings.txfc]))
|
1563
|
basic.append(txfc)
|
1564
|
|
1565
|
rxfc = RadioSetting("settings.rxfc",
|
1566
|
"RX fore color",
|
1567
|
RadioSettingValueList(
|
1568
|
LIST_COLOR8,
|
1569
|
LIST_COLOR8[_mem.settings.rxfc]))
|
1570
|
basic.append(rxfc)
|
1571
|
else:
|
1572
|
wtled = RadioSetting("settings.wtled", "Standby backlight Color",
|
1573
|
RadioSettingValueList(
|
1574
|
LIST_COLOR4,
|
1575
|
LIST_COLOR4[_mem.settings.wtled]))
|
1576
|
basic.append(wtled)
|
1577
|
|
1578
|
rxled = RadioSetting("settings.rxled", "RX backlight Color",
|
1579
|
RadioSettingValueList(
|
1580
|
LIST_COLOR4,
|
1581
|
LIST_COLOR4[_mem.settings.rxled]))
|
1582
|
basic.append(rxled)
|
1583
|
|
1584
|
txled = RadioSetting("settings.txled", "TX backlight Color",
|
1585
|
RadioSettingValueList(
|
1586
|
LIST_COLOR4,
|
1587
|
LIST_COLOR4[_mem.settings.txled]))
|
1588
|
basic.append(txled)
|
1589
|
|
1590
|
anil = RadioSetting("settings.anil", "ANI length",
|
1591
|
RadioSettingValueList(
|
1592
|
LIST_ANIL,
|
1593
|
LIST_ANIL[_mem.settings.anil]))
|
1594
|
basic.append(anil)
|
1595
|
|
1596
|
reps = RadioSetting("settings.reps", "Relay signal (tone burst)",
|
1597
|
RadioSettingValueList(
|
1598
|
LIST_REPS,
|
1599
|
LIST_REPS[_mem.settings.reps]))
|
1600
|
basic.append(reps)
|
1601
|
|
1602
|
if self.COLOR_LCD4:
|
1603
|
dsub = RadioSetting("settings.dsub", "Subtone display",
|
1604
|
RadioSettingValueBoolean(
|
1605
|
_mem.settings.dsub))
|
1606
|
basic.append(dsub)
|
1607
|
|
1608
|
if self.MODEL == "GMRS-20V2":
|
1609
|
repsw = RadioSetting("settings.repsw", "Repeater SW",
|
1610
|
RadioSettingValueList(
|
1611
|
LIST_REPSW,
|
1612
|
LIST_REPSW[_mem.settings.repsw]))
|
1613
|
basic.append(repsw)
|
1614
|
|
1615
|
model_list = ["GMRS-50X1", "KT-8R", "KT-WP12", "WP-9900"]
|
1616
|
if self.MODEL not in model_list:
|
1617
|
repm = RadioSetting("settings.repm", "Relay condition",
|
1618
|
RadioSettingValueList(
|
1619
|
LIST_REPM,
|
1620
|
LIST_REPM[_mem.settings.repm]))
|
1621
|
basic.append(repm)
|
1622
|
|
1623
|
if self.VENDOR == "BTECH" or self.COLOR_LCD:
|
1624
|
if self.COLOR_LCD:
|
1625
|
tmrmr = RadioSetting("settings.tmrmr", "TMR return time",
|
1626
|
RadioSettingValueList(
|
1627
|
LIST_OFF1TO50,
|
1628
|
LIST_OFF1TO50[_mem.settings.tmrmr]))
|
1629
|
basic.append(tmrmr)
|
1630
|
else:
|
1631
|
tdrab = RadioSetting("settings.tdrab", "TDR return time",
|
1632
|
RadioSettingValueList(
|
1633
|
LIST_OFF1TO50,
|
1634
|
LIST_OFF1TO50[_mem.settings.tdrab]))
|
1635
|
basic.append(tdrab)
|
1636
|
|
1637
|
ste = RadioSetting("settings.ste", "Squelch tail eliminate",
|
1638
|
RadioSettingValueBoolean(_mem.settings.ste))
|
1639
|
basic.append(ste)
|
1640
|
|
1641
|
if self.COLOR_LCD4:
|
1642
|
rpste = RadioSetting("settings.rpste", "Repeater STE",
|
1643
|
RadioSettingValueList(
|
1644
|
LIST_OFF1TO10,
|
1645
|
LIST_OFF1TO10[_mem.settings.rpste]))
|
1646
|
basic.append(rpste)
|
1647
|
else:
|
1648
|
rpste = RadioSetting("settings.rpste", "Repeater STE",
|
1649
|
RadioSettingValueList(
|
1650
|
LIST_OFF1TO9,
|
1651
|
LIST_OFF1TO9[_mem.settings.rpste]))
|
1652
|
basic.append(rpste)
|
1653
|
|
1654
|
if self.COLOR_LCD4:
|
1655
|
rptdl = RadioSetting("settings.rptdl", "Repeater STE delay",
|
1656
|
RadioSettingValueList(
|
1657
|
LIST_OFF1TO60,
|
1658
|
LIST_OFF1TO60[_mem.settings.rptdl]))
|
1659
|
basic.append(rptdl)
|
1660
|
else:
|
1661
|
rptdl = RadioSetting("settings.rptdl", "Repeater STE delay",
|
1662
|
RadioSettingValueList(
|
1663
|
LIST_RPTDL,
|
1664
|
LIST_RPTDL[_mem.settings.rptdl]))
|
1665
|
basic.append(rptdl)
|
1666
|
|
1667
|
if self.MODEL == "DB25-G":
|
1668
|
mgain = RadioSetting("settings.mgain", "Auto power-on",
|
1669
|
RadioSettingValueBoolean(_mem.settings.mgain))
|
1670
|
basic.append(mgain)
|
1671
|
|
1672
|
if str(_mem.fingerprint.fp) in BTECH3:
|
1673
|
mgain = RadioSetting("settings.mgain", "Mic gain",
|
1674
|
RadioSettingValueInteger(0, 120,
|
1675
|
_mem.settings.mgain))
|
1676
|
basic.append(mgain)
|
1677
|
|
1678
|
if str(_mem.fingerprint.fp) in BTECH3 or self.COLOR_LCD:
|
1679
|
dtmfg = RadioSetting("settings.dtmfg", "DTMF gain",
|
1680
|
RadioSettingValueInteger(0, 60,
|
1681
|
_mem.settings.dtmfg))
|
1682
|
basic.append(dtmfg)
|
1683
|
|
1684
|
if self.VENDOR == "BTECH" and self.COLOR_LCD:
|
1685
|
mgain = RadioSetting("settings.mgain", "Mic gain",
|
1686
|
RadioSettingValueInteger(0, 127,
|
1687
|
_mem.settings.mgain))
|
1688
|
basic.append(mgain)
|
1689
|
|
1690
|
skiptx = RadioSetting("settings.skiptx", "Skip TX",
|
1691
|
RadioSettingValueList(
|
1692
|
LIST_SKIPTX,
|
1693
|
LIST_SKIPTX[_mem.settings.skiptx]))
|
1694
|
basic.append(skiptx)
|
1695
|
|
1696
|
scmode = RadioSetting("settings.scmode", "Scan mode",
|
1697
|
RadioSettingValueList(
|
1698
|
LIST_SCMODE,
|
1699
|
LIST_SCMODE[_mem.settings.scmode]))
|
1700
|
basic.append(scmode)
|
1701
|
|
1702
|
if self.MODEL == "KT-8R":
|
1703
|
tmrtx = RadioSetting("settings.tmrtx", "TX in multi-standby",
|
1704
|
RadioSettingValueList(
|
1705
|
LIST_TMRTX,
|
1706
|
LIST_TMRTX[_mem.settings.tmrtx]))
|
1707
|
basic.append(tmrtx)
|
1708
|
|
1709
|
# Advanced
|
1710
|
def _filter(name):
|
1711
|
filtered = ""
|
1712
|
for char in str(name):
|
1713
|
if char in VALID_CHARS:
|
1714
|
filtered += char
|
1715
|
else:
|
1716
|
filtered += " "
|
1717
|
return filtered
|
1718
|
|
1719
|
if self.COLOR_LCD and not (self.COLOR_LCD2 or self.COLOR_LCD3 or
|
1720
|
self.COLOR_LCD4):
|
1721
|
_msg = self._memobj.poweron_msg
|
1722
|
line1 = RadioSetting("poweron_msg.line1",
|
1723
|
"Power-on message line 1",
|
1724
|
RadioSettingValueString(0, 8, _filter(
|
1725
|
_msg.line1)))
|
1726
|
advanced.append(line1)
|
1727
|
line2 = RadioSetting("poweron_msg.line2",
|
1728
|
"Power-on message line 2",
|
1729
|
RadioSettingValueString(0, 8, _filter(
|
1730
|
_msg.line2)))
|
1731
|
advanced.append(line2)
|
1732
|
line3 = RadioSetting("poweron_msg.line3",
|
1733
|
"Power-on message line 3",
|
1734
|
RadioSettingValueString(0, 8, _filter(
|
1735
|
_msg.line3)))
|
1736
|
advanced.append(line3)
|
1737
|
line4 = RadioSetting("poweron_msg.line4",
|
1738
|
"Power-on message line 4",
|
1739
|
RadioSettingValueString(0, 8, _filter(
|
1740
|
_msg.line4)))
|
1741
|
advanced.append(line4)
|
1742
|
line5 = RadioSetting("poweron_msg.line5",
|
1743
|
"Power-on message line 5",
|
1744
|
RadioSettingValueString(0, 8, _filter(
|
1745
|
_msg.line5)))
|
1746
|
advanced.append(line5)
|
1747
|
line6 = RadioSetting("poweron_msg.line6",
|
1748
|
"Power-on message line 6",
|
1749
|
RadioSettingValueString(0, 8, _filter(
|
1750
|
_msg.line6)))
|
1751
|
advanced.append(line6)
|
1752
|
line7 = RadioSetting("poweron_msg.line7",
|
1753
|
"Power-on message line 7",
|
1754
|
RadioSettingValueString(0, 8, _filter(
|
1755
|
_msg.line7)))
|
1756
|
advanced.append(line7)
|
1757
|
line8 = RadioSetting("poweron_msg.line8", "Static message",
|
1758
|
RadioSettingValueString(0, 8, _filter(
|
1759
|
_msg.line8)))
|
1760
|
advanced.append(line8)
|
1761
|
elif self.COLOR_LCD2 or self.COLOR_LCD3 or self.COLOR_LCD4:
|
1762
|
_msg = self._memobj.static_msg
|
1763
|
line = RadioSetting("static_msg.line", "Static message",
|
1764
|
RadioSettingValueString(0, 16, _filter(
|
1765
|
_msg.line)))
|
1766
|
advanced.append(line)
|
1767
|
else:
|
1768
|
_msg = self._memobj.poweron_msg
|
1769
|
line1 = RadioSetting("poweron_msg.line1",
|
1770
|
"Power-on message line 1",
|
1771
|
RadioSettingValueString(0, 6, _filter(
|
1772
|
_msg.line1)))
|
1773
|
advanced.append(line1)
|
1774
|
line2 = RadioSetting("poweron_msg.line2",
|
1775
|
"Power-on message line 2",
|
1776
|
RadioSettingValueString(0, 6, _filter(
|
1777
|
_msg.line2)))
|
1778
|
advanced.append(line2)
|
1779
|
|
1780
|
if self.MODEL in ("UV-2501", "UV-5001"):
|
1781
|
vfomren = RadioSetting("settings2.vfomren", "VFO/MR switching",
|
1782
|
RadioSettingValueBoolean(
|
1783
|
_mem.settings2.vfomren))
|
1784
|
advanced.append(vfomren)
|
1785
|
|
1786
|
reseten = RadioSetting("settings2.reseten", "RESET",
|
1787
|
RadioSettingValueBoolean(
|
1788
|
_mem.settings2.reseten))
|
1789
|
advanced.append(reseten)
|
1790
|
|
1791
|
menuen = RadioSetting("settings2.menuen", "Menu",
|
1792
|
RadioSettingValueBoolean(
|
1793
|
_mem.settings2.menuen))
|
1794
|
advanced.append(menuen)
|
1795
|
|
1796
|
# Other
|
1797
|
def convert_bytes_to_limit(bytes):
|
1798
|
limit = ""
|
1799
|
for byte in bytes:
|
1800
|
if byte < 10:
|
1801
|
limit += chr(byte + 0x30)
|
1802
|
else:
|
1803
|
break
|
1804
|
return limit
|
1805
|
|
1806
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
1807
|
_ranges = self._memobj.ranges220
|
1808
|
ranges = "ranges220"
|
1809
|
else:
|
1810
|
_ranges = self._memobj.ranges
|
1811
|
ranges = "ranges"
|
1812
|
|
1813
|
_limit = convert_bytes_to_limit(_ranges.vhf_low)
|
1814
|
val = RadioSettingValueString(0, 3, _limit)
|
1815
|
val.set_mutable(False)
|
1816
|
vhf_low = RadioSetting("%s.vhf_low" % ranges, "VHF low", val)
|
1817
|
other.append(vhf_low)
|
1818
|
|
1819
|
_limit = convert_bytes_to_limit(_ranges.vhf_high)
|
1820
|
val = RadioSettingValueString(0, 3, _limit)
|
1821
|
val.set_mutable(False)
|
1822
|
vhf_high = RadioSetting("%s.vhf_high" % ranges, "VHF high", val)
|
1823
|
other.append(vhf_high)
|
1824
|
|
1825
|
if self.BANDS == 3 or self.BANDS == 4:
|
1826
|
_limit = convert_bytes_to_limit(_ranges.vhf2_low)
|
1827
|
val = RadioSettingValueString(0, 3, _limit)
|
1828
|
val.set_mutable(False)
|
1829
|
vhf2_low = RadioSetting("%s.vhf2_low" % ranges, "VHF2 low", val)
|
1830
|
other.append(vhf2_low)
|
1831
|
|
1832
|
_limit = convert_bytes_to_limit(_ranges.vhf2_high)
|
1833
|
val = RadioSettingValueString(0, 3, _limit)
|
1834
|
val.set_mutable(False)
|
1835
|
vhf2_high = RadioSetting("%s.vhf2_high" % ranges, "VHF2 high", val)
|
1836
|
other.append(vhf2_high)
|
1837
|
|
1838
|
_limit = convert_bytes_to_limit(_ranges.uhf_low)
|
1839
|
val = RadioSettingValueString(0, 3, _limit)
|
1840
|
val.set_mutable(False)
|
1841
|
uhf_low = RadioSetting("%s.uhf_low" % ranges, "UHF low", val)
|
1842
|
other.append(uhf_low)
|
1843
|
|
1844
|
_limit = convert_bytes_to_limit(_ranges.uhf_high)
|
1845
|
val = RadioSettingValueString(0, 3, _limit)
|
1846
|
val.set_mutable(False)
|
1847
|
uhf_high = RadioSetting("%s.uhf_high" % ranges, "UHF high", val)
|
1848
|
other.append(uhf_high)
|
1849
|
|
1850
|
if self.BANDS == 4:
|
1851
|
_limit = convert_bytes_to_limit(_ranges.uhf2_low)
|
1852
|
val = RadioSettingValueString(0, 3, _limit)
|
1853
|
val.set_mutable(False)
|
1854
|
uhf2_low = RadioSetting("%s.uhf2_low" % ranges, "UHF2 low", val)
|
1855
|
other.append(uhf2_low)
|
1856
|
|
1857
|
_limit = convert_bytes_to_limit(_ranges.uhf2_high)
|
1858
|
val = RadioSettingValueString(0, 3, _limit)
|
1859
|
val.set_mutable(False)
|
1860
|
uhf2_high = RadioSetting("%s.uhf2_high" % ranges, "UHF2 high", val)
|
1861
|
other.append(uhf2_high)
|
1862
|
|
1863
|
val = RadioSettingValueString(0, 6, _filter(_mem.fingerprint.fp))
|
1864
|
val.set_mutable(False)
|
1865
|
fp = RadioSetting("fingerprint.fp", "Fingerprint", val)
|
1866
|
other.append(fp)
|
1867
|
|
1868
|
# Work
|
1869
|
if self.COLOR_LCD:
|
1870
|
dispab = RadioSetting("settings2.dispab", "Display",
|
1871
|
RadioSettingValueList(
|
1872
|
LIST_ABCD,
|
1873
|
LIST_ABCD[_mem.settings2.dispab]))
|
1874
|
work.append(dispab)
|
1875
|
else:
|
1876
|
dispab = RadioSetting("settings2.dispab", "Display",
|
1877
|
RadioSettingValueList(
|
1878
|
LIST_AB,
|
1879
|
LIST_AB[_mem.settings2.dispab]))
|
1880
|
work.append(dispab)
|
1881
|
|
1882
|
if self.COLOR_LCD:
|
1883
|
vfomra = RadioSetting("settings2.vfomra", "VFO/MR A mode",
|
1884
|
RadioSettingValueList(
|
1885
|
LIST_VFOMR,
|
1886
|
LIST_VFOMR[_mem.settings2.vfomra]))
|
1887
|
work.append(vfomra)
|
1888
|
|
1889
|
vfomrb = RadioSetting("settings2.vfomrb", "VFO/MR B mode",
|
1890
|
RadioSettingValueList(
|
1891
|
LIST_VFOMR,
|
1892
|
LIST_VFOMR[_mem.settings2.vfomrb]))
|
1893
|
work.append(vfomrb)
|
1894
|
|
1895
|
vfomrc = RadioSetting("settings2.vfomrc", "VFO/MR C mode",
|
1896
|
RadioSettingValueList(
|
1897
|
LIST_VFOMR,
|
1898
|
LIST_VFOMR[_mem.settings2.vfomrc]))
|
1899
|
work.append(vfomrc)
|
1900
|
|
1901
|
if not self.COLOR_LCD4:
|
1902
|
vfomrd = RadioSetting("settings2.vfomrd", "VFO/MR D mode",
|
1903
|
RadioSettingValueList(
|
1904
|
LIST_VFOMR,
|
1905
|
LIST_VFOMR[_mem.settings2.vfomrd]))
|
1906
|
work.append(vfomrd)
|
1907
|
else:
|
1908
|
vfomr = RadioSetting("settings2.vfomr", "VFO/MR mode",
|
1909
|
RadioSettingValueList(
|
1910
|
LIST_VFOMR,
|
1911
|
LIST_VFOMR[_mem.settings2.vfomr]))
|
1912
|
work.append(vfomr)
|
1913
|
|
1914
|
keylock = RadioSetting("settings2.keylock", "Keypad lock",
|
1915
|
RadioSettingValueBoolean(
|
1916
|
_mem.settings2.keylock))
|
1917
|
work.append(keylock)
|
1918
|
|
1919
|
mrcha = RadioSetting("settings2.mrcha", "MR A channel",
|
1920
|
RadioSettingValueInteger(0, self._upper,
|
1921
|
_mem.settings2.mrcha))
|
1922
|
work.append(mrcha)
|
1923
|
|
1924
|
mrchb = RadioSetting("settings2.mrchb", "MR B channel",
|
1925
|
RadioSettingValueInteger(0, self._upper,
|
1926
|
_mem.settings2.mrchb))
|
1927
|
work.append(mrchb)
|
1928
|
|
1929
|
if self.COLOR_LCD:
|
1930
|
mrchc = RadioSetting("settings2.mrchc", "MR C channel",
|
1931
|
RadioSettingValueInteger(
|
1932
|
0, self._upper, _mem.settings2.mrchc))
|
1933
|
work.append(mrchc)
|
1934
|
|
1935
|
if not self.COLOR_LCD4:
|
1936
|
mrchd = RadioSetting("settings2.mrchd", "MR D channel",
|
1937
|
RadioSettingValueInteger(
|
1938
|
0, self._upper, _mem.settings2.mrchd))
|
1939
|
work.append(mrchd)
|
1940
|
|
1941
|
def convert_bytes_to_freq(bytes):
|
1942
|
real_freq = 0
|
1943
|
for byte in bytes:
|
1944
|
real_freq = (real_freq * 10) + byte
|
1945
|
return chirp_common.format_freq(real_freq * 10)
|
1946
|
|
1947
|
def my_validate(value):
|
1948
|
_vhf_lower = int(convert_bytes_to_limit(_ranges.vhf_low))
|
1949
|
_vhf_upper = int(convert_bytes_to_limit(_ranges.vhf_high))
|
1950
|
_uhf_lower = int(convert_bytes_to_limit(_ranges.uhf_low))
|
1951
|
_uhf_upper = int(convert_bytes_to_limit(_ranges.uhf_high))
|
1952
|
if self.BANDS == 3 or self.BANDS == 4:
|
1953
|
_vhf2_lower = int(convert_bytes_to_limit(_ranges.vhf2_low))
|
1954
|
_vhf2_upper = int(convert_bytes_to_limit(_ranges.vhf2_high))
|
1955
|
if self.BANDS == 4:
|
1956
|
_uhf2_lower = int(convert_bytes_to_limit(_ranges.uhf2_low))
|
1957
|
_uhf2_upper = int(convert_bytes_to_limit(_ranges.uhf2_high))
|
1958
|
|
1959
|
value = chirp_common.parse_freq(value)
|
1960
|
msg = ("Can't be less then %i.0000")
|
1961
|
if value > 99000000 and value < _vhf_lower * 1000000:
|
1962
|
raise InvalidValueError(msg % (_vhf_lower))
|
1963
|
msg = ("Can't be betweeb %i.9975-%i.0000")
|
1964
|
if self.BANDS == 2:
|
1965
|
if (_vhf_upper + 1) * 1000000 <= value and \
|
1966
|
value < _uhf_lower * 1000000:
|
1967
|
raise InvalidValueError(msg % (_vhf_upper, _uhf_lower))
|
1968
|
if self.BANDS == 3:
|
1969
|
if (_vhf_upper + 1) * 1000000 <= value and \
|
1970
|
value < _vhf2_lower * 1000000:
|
1971
|
raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower))
|
1972
|
if (_vhf2_upper + 1) * 1000000 <= value and \
|
1973
|
value < _uhf_lower * 1000000:
|
1974
|
raise InvalidValueError(msg % (_vhf2_upper, _uhf_lower))
|
1975
|
if self.BANDS == 4:
|
1976
|
if (_vhf_upper + 1) * 1000000 <= value and \
|
1977
|
value < _vhf2_lower * 1000000:
|
1978
|
raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower))
|
1979
|
if (_vhf2_upper + 1) * 1000000 <= value and \
|
1980
|
value < _uhf2_lower * 1000000:
|
1981
|
raise InvalidValueError(msg % (_vhf2_upper, _uhf2_lower))
|
1982
|
if (_uhf2_upper + 1) * 1000000 <= value and \
|
1983
|
value < _uhf_lower * 1000000:
|
1984
|
raise InvalidValueError(msg % (_uhf2_upper, _uhf_lower))
|
1985
|
msg = ("Can't be greater then %i.9975")
|
1986
|
if value > 99000000 and value >= _uhf_upper * 1000000:
|
1987
|
raise InvalidValueError(msg % (_uhf_upper))
|
1988
|
return chirp_common.format_freq(value)
|
1989
|
|
1990
|
def apply_freq(setting, obj):
|
1991
|
value = chirp_common.parse_freq(str(setting.value)) / 10
|
1992
|
for i in range(7, -1, -1):
|
1993
|
obj.freq[i] = value % 10
|
1994
|
value /= 10
|
1995
|
|
1996
|
val1a = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
1997
|
_mem.vfo.a.freq))
|
1998
|
val1a.set_validate_callback(my_validate)
|
1999
|
vfoafreq = RadioSetting("vfo.a.freq", "VFO A frequency", val1a)
|
2000
|
vfoafreq.set_apply_callback(apply_freq, _mem.vfo.a)
|
2001
|
work.append(vfoafreq)
|
2002
|
|
2003
|
val1b = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
2004
|
_mem.vfo.b.freq))
|
2005
|
val1b.set_validate_callback(my_validate)
|
2006
|
vfobfreq = RadioSetting("vfo.b.freq", "VFO B frequency", val1b)
|
2007
|
vfobfreq.set_apply_callback(apply_freq, _mem.vfo.b)
|
2008
|
work.append(vfobfreq)
|
2009
|
|
2010
|
if self.COLOR_LCD:
|
2011
|
val1c = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
2012
|
_mem.vfo.c.freq))
|
2013
|
val1c.set_validate_callback(my_validate)
|
2014
|
vfocfreq = RadioSetting("vfo.c.freq", "VFO C frequency", val1c)
|
2015
|
vfocfreq.set_apply_callback(apply_freq, _mem.vfo.c)
|
2016
|
work.append(vfocfreq)
|
2017
|
|
2018
|
if not self.COLOR_LCD4:
|
2019
|
val1d = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
2020
|
_mem.vfo.d.freq))
|
2021
|
val1d.set_validate_callback(my_validate)
|
2022
|
vfodfreq = RadioSetting("vfo.d.freq", "VFO D frequency", val1d)
|
2023
|
vfodfreq.set_apply_callback(apply_freq, _mem.vfo.d)
|
2024
|
work.append(vfodfreq)
|
2025
|
|
2026
|
if not self.MODEL == "GMRS-50X1":
|
2027
|
vfoashiftd = RadioSetting("vfo.a.shiftd", "VFO A shift",
|
2028
|
RadioSettingValueList(
|
2029
|
LIST_SHIFT,
|
2030
|
LIST_SHIFT[_mem.vfo.a.shiftd]))
|
2031
|
work.append(vfoashiftd)
|
2032
|
|
2033
|
vfobshiftd = RadioSetting("vfo.b.shiftd", "VFO B shift",
|
2034
|
RadioSettingValueList(
|
2035
|
LIST_SHIFT,
|
2036
|
LIST_SHIFT[_mem.vfo.b.shiftd]))
|
2037
|
work.append(vfobshiftd)
|
2038
|
|
2039
|
if self.COLOR_LCD:
|
2040
|
vfocshiftd = RadioSetting("vfo.c.shiftd", "VFO C shift",
|
2041
|
RadioSettingValueList(
|
2042
|
LIST_SHIFT,
|
2043
|
LIST_SHIFT[_mem.vfo.c.shiftd]))
|
2044
|
work.append(vfocshiftd)
|
2045
|
|
2046
|
if not self.COLOR_LCD4:
|
2047
|
val = RadioSettingValueList(LIST_SHIFT,
|
2048
|
LIST_SHIFT[_mem.vfo.d.shiftd])
|
2049
|
vfodshiftd = RadioSetting("vfo.d.shiftd", "VFO D shift",
|
2050
|
val)
|
2051
|
work.append(vfodshiftd)
|
2052
|
|
2053
|
def convert_bytes_to_offset(bytes):
|
2054
|
real_offset = 0
|
2055
|
for byte in bytes:
|
2056
|
real_offset = (real_offset * 10) + byte
|
2057
|
return chirp_common.format_freq(real_offset * 1000)
|
2058
|
|
2059
|
def apply_offset(setting, obj):
|
2060
|
value = chirp_common.parse_freq(str(setting.value)) / 1000
|
2061
|
for i in range(5, -1, -1):
|
2062
|
obj.offset[i] = value % 10
|
2063
|
value /= 10
|
2064
|
|
2065
|
if not self.MODEL == "GMRS-50X1":
|
2066
|
if self.COLOR_LCD:
|
2067
|
val1a = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
2068
|
_mem.vfo.a.offset))
|
2069
|
vfoaoffset = RadioSetting("vfo.a.offset",
|
2070
|
"VFO A offset (0.000-999.999)",
|
2071
|
val1a)
|
2072
|
vfoaoffset.set_apply_callback(apply_offset, _mem.vfo.a)
|
2073
|
work.append(vfoaoffset)
|
2074
|
|
2075
|
val1b = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
2076
|
_mem.vfo.b.offset))
|
2077
|
vfoboffset = RadioSetting("vfo.b.offset",
|
2078
|
"VFO B offset (0.000-999.999)",
|
2079
|
val1b)
|
2080
|
vfoboffset.set_apply_callback(apply_offset, _mem.vfo.b)
|
2081
|
work.append(vfoboffset)
|
2082
|
|
2083
|
val1c = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
2084
|
_mem.vfo.c.offset))
|
2085
|
vfocoffset = RadioSetting("vfo.c.offset",
|
2086
|
"VFO C offset (0.000-999.999)",
|
2087
|
val1c)
|
2088
|
vfocoffset.set_apply_callback(apply_offset, _mem.vfo.c)
|
2089
|
work.append(vfocoffset)
|
2090
|
|
2091
|
if not self.COLOR_LCD4:
|
2092
|
val1d = RadioSettingValueString(0, 10,
|
2093
|
convert_bytes_to_offset(
|
2094
|
_mem.vfo.d.offset))
|
2095
|
vfodoffset = RadioSetting("vfo.d.offset",
|
2096
|
"VFO D offset (0.000-999.999)",
|
2097
|
val1d)
|
2098
|
vfodoffset.set_apply_callback(apply_offset, _mem.vfo.d)
|
2099
|
work.append(vfodoffset)
|
2100
|
else:
|
2101
|
val1a = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
2102
|
_mem.vfo.a.offset))
|
2103
|
vfoaoffset = RadioSetting("vfo.a.offset",
|
2104
|
"VFO A offset (0.000-99.999)", val1a)
|
2105
|
vfoaoffset.set_apply_callback(apply_offset, _mem.vfo.a)
|
2106
|
work.append(vfoaoffset)
|
2107
|
|
2108
|
val1b = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
2109
|
_mem.vfo.b.offset))
|
2110
|
vfoboffset = RadioSetting("vfo.b.offset",
|
2111
|
"VFO B offset (0.000-99.999)", val1b)
|
2112
|
vfoboffset.set_apply_callback(apply_offset, _mem.vfo.b)
|
2113
|
work.append(vfoboffset)
|
2114
|
|
2115
|
if not self.MODEL == "GMRS-50X1":
|
2116
|
vfoatxp = RadioSetting("vfo.a.power", "VFO A power",
|
2117
|
RadioSettingValueList(
|
2118
|
LIST_TXP,
|
2119
|
LIST_TXP[_mem.vfo.a.power]))
|
2120
|
work.append(vfoatxp)
|
2121
|
|
2122
|
vfobtxp = RadioSetting("vfo.b.power", "VFO B power",
|
2123
|
RadioSettingValueList(
|
2124
|
LIST_TXP,
|
2125
|
LIST_TXP[_mem.vfo.b.power]))
|
2126
|
work.append(vfobtxp)
|
2127
|
|
2128
|
if self.COLOR_LCD:
|
2129
|
vfoctxp = RadioSetting("vfo.c.power", "VFO C power",
|
2130
|
RadioSettingValueList(
|
2131
|
LIST_TXP,
|
2132
|
LIST_TXP[_mem.vfo.c.power]))
|
2133
|
work.append(vfoctxp)
|
2134
|
|
2135
|
if not self.COLOR_LCD4:
|
2136
|
vfodtxp = RadioSetting("vfo.d.power", "VFO D power",
|
2137
|
RadioSettingValueList(
|
2138
|
LIST_TXP,
|
2139
|
LIST_TXP[_mem.vfo.d.power]))
|
2140
|
work.append(vfodtxp)
|
2141
|
|
2142
|
if not self.MODEL == "GMRS-50X1":
|
2143
|
vfoawide = RadioSetting("vfo.a.wide", "VFO A bandwidth",
|
2144
|
RadioSettingValueList(
|
2145
|
LIST_WIDE,
|
2146
|
LIST_WIDE[_mem.vfo.a.wide]))
|
2147
|
work.append(vfoawide)
|
2148
|
|
2149
|
vfobwide = RadioSetting("vfo.b.wide", "VFO B bandwidth",
|
2150
|
RadioSettingValueList(
|
2151
|
LIST_WIDE,
|
2152
|
LIST_WIDE[_mem.vfo.b.wide]))
|
2153
|
work.append(vfobwide)
|
2154
|
|
2155
|
if self.COLOR_LCD:
|
2156
|
vfocwide = RadioSetting("vfo.c.wide", "VFO C bandwidth",
|
2157
|
RadioSettingValueList(
|
2158
|
LIST_WIDE,
|
2159
|
LIST_WIDE[_mem.vfo.c.wide]))
|
2160
|
work.append(vfocwide)
|
2161
|
|
2162
|
if not self.COLOR_LCD4:
|
2163
|
vfodwide = RadioSetting("vfo.d.wide", "VFO D bandwidth",
|
2164
|
RadioSettingValueList(
|
2165
|
LIST_WIDE,
|
2166
|
LIST_WIDE[_mem.vfo.d.wide]))
|
2167
|
work.append(vfodwide)
|
2168
|
|
2169
|
vfoastep = RadioSetting("vfo.a.step", "VFO A step",
|
2170
|
RadioSettingValueList(
|
2171
|
LIST_STEP,
|
2172
|
LIST_STEP[_mem.vfo.a.step]))
|
2173
|
work.append(vfoastep)
|
2174
|
|
2175
|
vfobstep = RadioSetting("vfo.b.step", "VFO B step",
|
2176
|
RadioSettingValueList(
|
2177
|
LIST_STEP,
|
2178
|
LIST_STEP[_mem.vfo.b.step]))
|
2179
|
work.append(vfobstep)
|
2180
|
|
2181
|
if self.COLOR_LCD:
|
2182
|
vfocstep = RadioSetting("vfo.c.step", "VFO C step",
|
2183
|
RadioSettingValueList(
|
2184
|
LIST_STEP,
|
2185
|
LIST_STEP[_mem.vfo.c.step]))
|
2186
|
work.append(vfocstep)
|
2187
|
|
2188
|
if not self.COLOR_LCD4:
|
2189
|
vfodstep = RadioSetting("vfo.d.step", "VFO D step",
|
2190
|
RadioSettingValueList(
|
2191
|
LIST_STEP,
|
2192
|
LIST_STEP[_mem.vfo.d.step]))
|
2193
|
work.append(vfodstep)
|
2194
|
|
2195
|
vfoaoptsig = RadioSetting("vfo.a.optsig", "VFO A optional signal",
|
2196
|
RadioSettingValueList(
|
2197
|
OPTSIG_LIST,
|
2198
|
OPTSIG_LIST[_mem.vfo.a.optsig]))
|
2199
|
work.append(vfoaoptsig)
|
2200
|
|
2201
|
vfoboptsig = RadioSetting("vfo.b.optsig", "VFO B optional signal",
|
2202
|
RadioSettingValueList(
|
2203
|
OPTSIG_LIST,
|
2204
|
OPTSIG_LIST[_mem.vfo.b.optsig]))
|
2205
|
work.append(vfoboptsig)
|
2206
|
|
2207
|
if self.COLOR_LCD:
|
2208
|
vfocoptsig = RadioSetting("vfo.c.optsig", "VFO C optional signal",
|
2209
|
RadioSettingValueList(
|
2210
|
OPTSIG_LIST,
|
2211
|
OPTSIG_LIST[_mem.vfo.c.optsig]))
|
2212
|
work.append(vfocoptsig)
|
2213
|
|
2214
|
if not self.COLOR_LCD4:
|
2215
|
val = RadioSettingValueList(OPTSIG_LIST,
|
2216
|
OPTSIG_LIST[_mem.vfo.d.optsig])
|
2217
|
vfodoptsig = RadioSetting("vfo.d.optsig",
|
2218
|
"VFO D optional signal", val)
|
2219
|
work.append(vfodoptsig)
|
2220
|
|
2221
|
vfoaspmute = RadioSetting("vfo.a.spmute", "VFO A speaker mute",
|
2222
|
RadioSettingValueList(
|
2223
|
SPMUTE_LIST,
|
2224
|
SPMUTE_LIST[_mem.vfo.a.spmute]))
|
2225
|
work.append(vfoaspmute)
|
2226
|
|
2227
|
vfobspmute = RadioSetting("vfo.b.spmute", "VFO B speaker mute",
|
2228
|
RadioSettingValueList(
|
2229
|
SPMUTE_LIST,
|
2230
|
SPMUTE_LIST[_mem.vfo.b.spmute]))
|
2231
|
work.append(vfobspmute)
|
2232
|
|
2233
|
if self.COLOR_LCD:
|
2234
|
vfocspmute = RadioSetting("vfo.c.spmute", "VFO C speaker mute",
|
2235
|
RadioSettingValueList(
|
2236
|
SPMUTE_LIST,
|
2237
|
SPMUTE_LIST[_mem.vfo.c.spmute]))
|
2238
|
work.append(vfocspmute)
|
2239
|
|
2240
|
if not self.COLOR_LCD4:
|
2241
|
vfodspmute = RadioSetting("vfo.d.spmute", "VFO D speaker mute",
|
2242
|
RadioSettingValueList(
|
2243
|
SPMUTE_LIST,
|
2244
|
SPMUTE_LIST[_mem.vfo.d.spmute]))
|
2245
|
work.append(vfodspmute)
|
2246
|
|
2247
|
if not self.COLOR_LCD or \
|
2248
|
(self.COLOR_LCD and not self.VENDOR == "BTECH"):
|
2249
|
vfoascr = RadioSetting("vfo.a.scramble", "VFO A scramble",
|
2250
|
RadioSettingValueBoolean(
|
2251
|
_mem.vfo.a.scramble))
|
2252
|
work.append(vfoascr)
|
2253
|
|
2254
|
vfobscr = RadioSetting("vfo.b.scramble", "VFO B scramble",
|
2255
|
RadioSettingValueBoolean(
|
2256
|
_mem.vfo.b.scramble))
|
2257
|
work.append(vfobscr)
|
2258
|
|
2259
|
if self.COLOR_LCD and not self.VENDOR == "BTECH":
|
2260
|
vfocscr = RadioSetting("vfo.c.scramble", "VFO C scramble",
|
2261
|
RadioSettingValueBoolean(
|
2262
|
_mem.vfo.c.scramble))
|
2263
|
work.append(vfocscr)
|
2264
|
|
2265
|
vfodscr = RadioSetting("vfo.d.scramble", "VFO D scramble",
|
2266
|
RadioSettingValueBoolean(
|
2267
|
_mem.vfo.d.scramble))
|
2268
|
work.append(vfodscr)
|
2269
|
|
2270
|
if not self.MODEL == "GMRS-50X1":
|
2271
|
vfoascode = RadioSetting("vfo.a.scode", "VFO A PTT-ID",
|
2272
|
RadioSettingValueList(
|
2273
|
PTTIDCODE_LIST,
|
2274
|
PTTIDCODE_LIST[_mem.vfo.a.scode]))
|
2275
|
work.append(vfoascode)
|
2276
|
|
2277
|
vfobscode = RadioSetting("vfo.b.scode", "VFO B PTT-ID",
|
2278
|
RadioSettingValueList(
|
2279
|
PTTIDCODE_LIST,
|
2280
|
PTTIDCODE_LIST[_mem.vfo.b.scode]))
|
2281
|
work.append(vfobscode)
|
2282
|
|
2283
|
if self.COLOR_LCD:
|
2284
|
vfocscode = RadioSetting("vfo.c.scode", "VFO C PTT-ID",
|
2285
|
RadioSettingValueList(
|
2286
|
PTTIDCODE_LIST,
|
2287
|
PTTIDCODE_LIST[_mem.vfo.c.scode]))
|
2288
|
work.append(vfocscode)
|
2289
|
|
2290
|
if not self.COLOR_LCD4:
|
2291
|
val = RadioSettingValueList(PTTIDCODE_LIST,
|
2292
|
PTTIDCODE_LIST[
|
2293
|
_mem.vfo.d.scode])
|
2294
|
vfodscode = RadioSetting("vfo.d.scode", "VFO D PTT-ID",
|
2295
|
val)
|
2296
|
work.append(vfodscode)
|
2297
|
|
2298
|
if not self.MODEL == "GMRS-50X1":
|
2299
|
pttid = RadioSetting("settings.pttid", "PTT ID",
|
2300
|
RadioSettingValueList(
|
2301
|
PTTID_LIST,
|
2302
|
PTTID_LIST[_mem.settings.pttid]))
|
2303
|
work.append(pttid)
|
2304
|
|
2305
|
if not self.COLOR_LCD:
|
2306
|
# FM presets
|
2307
|
fm_presets = RadioSettingGroup("fm_presets", "FM Presets")
|
2308
|
top.append(fm_presets)
|
2309
|
|
2310
|
def fm_validate(value):
|
2311
|
if value == 0:
|
2312
|
return chirp_common.format_freq(value)
|
2313
|
if not (87.5 <= value and value <= 108.0): # 87.5-108MHz
|
2314
|
msg = ("FM-Preset-Frequency: " +
|
2315
|
"Must be between 87.5 and 108 MHz")
|
2316
|
raise InvalidValueError(msg)
|
2317
|
return value
|
2318
|
|
2319
|
def apply_fm_preset_name(setting, obj):
|
2320
|
valstring = str(setting.value)
|
2321
|
for i in range(0, 6):
|
2322
|
if valstring[i] in VALID_CHARS:
|
2323
|
obj[i] = valstring[i]
|
2324
|
else:
|
2325
|
obj[i] = '0xff'
|
2326
|
|
2327
|
def apply_fm_freq(setting, obj):
|
2328
|
value = chirp_common.parse_freq(str(setting.value)) / 10
|
2329
|
for i in range(7, -1, -1):
|
2330
|
obj.freq[i] = value % 10
|
2331
|
value /= 10
|
2332
|
|
2333
|
_presets = self._memobj.fm_radio_preset
|
2334
|
i = 1
|
2335
|
for preset in _presets:
|
2336
|
line = RadioSetting("fm_presets_" + str(i),
|
2337
|
"Station name " + str(i),
|
2338
|
RadioSettingValueString(0, 6, _filter(
|
2339
|
preset.broadcast_station_name)))
|
2340
|
line.set_apply_callback(apply_fm_preset_name,
|
2341
|
preset.broadcast_station_name)
|
2342
|
|
2343
|
val = RadioSettingValueFloat(0, 108,
|
2344
|
convert_bytes_to_freq(
|
2345
|
preset.freq))
|
2346
|
fmfreq = RadioSetting("fm_presets_" + str(i) + "_freq",
|
2347
|
"Frequency " + str(i), val)
|
2348
|
val.set_validate_callback(fm_validate)
|
2349
|
fmfreq.set_apply_callback(apply_fm_freq, preset)
|
2350
|
fm_presets.append(line)
|
2351
|
fm_presets.append(fmfreq)
|
2352
|
|
2353
|
i = i + 1
|
2354
|
|
2355
|
# DTMF-Setting
|
2356
|
dtmf_enc_settings = RadioSettingGroup("dtmf_enc_settings",
|
2357
|
"DTMF Encoding Settings")
|
2358
|
dtmf_dec_settings = RadioSettingGroup("dtmf_dec_settings",
|
2359
|
"DTMF Decoding Settings")
|
2360
|
top.append(dtmf_enc_settings)
|
2361
|
top.append(dtmf_dec_settings)
|
2362
|
txdisable = RadioSetting("dtmf_settings.txdisable",
|
2363
|
"TX-Disable",
|
2364
|
RadioSettingValueBoolean(
|
2365
|
_mem.dtmf_settings.txdisable))
|
2366
|
dtmf_enc_settings.append(txdisable)
|
2367
|
|
2368
|
rxdisable = RadioSetting("dtmf_settings.rxdisable",
|
2369
|
"RX-Disable",
|
2370
|
RadioSettingValueBoolean(
|
2371
|
_mem.dtmf_settings.rxdisable))
|
2372
|
dtmf_enc_settings.append(rxdisable)
|
2373
|
|
2374
|
if _mem.dtmf_settings.dtmfspeed_on > 0x0F:
|
2375
|
val = 0x03
|
2376
|
else:
|
2377
|
val = _mem.dtmf_settings.dtmfspeed_on
|
2378
|
dtmfspeed_on = RadioSetting(
|
2379
|
"dtmf_settings.dtmfspeed_on",
|
2380
|
"DTMF Speed (On Time)",
|
2381
|
RadioSettingValueList(LIST_DTMF_SPEED,
|
2382
|
LIST_DTMF_SPEED[
|
2383
|
val]))
|
2384
|
dtmf_enc_settings.append(dtmfspeed_on)
|
2385
|
|
2386
|
if _mem.dtmf_settings.dtmfspeed_off > 0x0F:
|
2387
|
val = 0x03
|
2388
|
else:
|
2389
|
val = _mem.dtmf_settings.dtmfspeed_off
|
2390
|
dtmfspeed_off = RadioSetting(
|
2391
|
"dtmf_settings.dtmfspeed_off",
|
2392
|
"DTMF Speed (Off Time)",
|
2393
|
RadioSettingValueList(LIST_DTMF_SPEED,
|
2394
|
LIST_DTMF_SPEED[
|
2395
|
val]))
|
2396
|
dtmf_enc_settings.append(dtmfspeed_off)
|
2397
|
|
2398
|
def memory2string(dmtf_mem):
|
2399
|
dtmf_string = ""
|
2400
|
for digit in dmtf_mem:
|
2401
|
if digit != 255:
|
2402
|
index = LIST_DTMF_VALUES.index(digit)
|
2403
|
dtmf_string = dtmf_string + LIST_DTMF_DIGITS[index]
|
2404
|
return dtmf_string
|
2405
|
|
2406
|
def apply_dmtf_frame(setting, obj):
|
2407
|
LOG.debug("Setting DTMF-Code: " + str(setting.value))
|
2408
|
val_string = str(setting.value)
|
2409
|
for i in range(0, 16):
|
2410
|
obj[i] = 255
|
2411
|
i = 0
|
2412
|
for current_char in val_string:
|
2413
|
current_char = current_char.upper()
|
2414
|
index = LIST_DTMF_DIGITS.index(current_char)
|
2415
|
obj[i] = LIST_DTMF_VALUES[index]
|
2416
|
i = i + 1
|
2417
|
|
2418
|
codes = self._memobj.dtmf_codes
|
2419
|
i = 1
|
2420
|
for dtmfcode in codes:
|
2421
|
val = RadioSettingValueString(0, 16, memory2string(
|
2422
|
dtmfcode.code),
|
2423
|
False, CHARSET_DTMF_DIGITS)
|
2424
|
line = RadioSetting("dtmf_code_" + str(i) + "_code",
|
2425
|
"DMTF Code " + str(i), val)
|
2426
|
line.set_apply_callback(apply_dmtf_frame, dtmfcode.code)
|
2427
|
dtmf_enc_settings.append(line)
|
2428
|
i = i + 1
|
2429
|
|
2430
|
line = RadioSetting("dtmf_settings.mastervice",
|
2431
|
"Master and Vice ID",
|
2432
|
RadioSettingValueBoolean(
|
2433
|
_mem.dtmf_settings.mastervice))
|
2434
|
dtmf_dec_settings.append(line)
|
2435
|
|
2436
|
val = RadioSettingValueString(0, 16, memory2string(
|
2437
|
_mem.dtmf_settings.masterid),
|
2438
|
False, CHARSET_DTMF_DIGITS)
|
2439
|
line = RadioSetting("dtmf_settings.masterid",
|
2440
|
"Master Control ID ", val)
|
2441
|
line.set_apply_callback(apply_dmtf_frame,
|
2442
|
_mem.dtmf_settings.masterid)
|
2443
|
dtmf_dec_settings.append(line)
|
2444
|
|
2445
|
line = RadioSetting("dtmf_settings.minspection",
|
2446
|
"Master Inspection",
|
2447
|
RadioSettingValueBoolean(
|
2448
|
_mem.dtmf_settings.minspection))
|
2449
|
dtmf_dec_settings.append(line)
|
2450
|
|
2451
|
line = RadioSetting("dtmf_settings.mmonitor",
|
2452
|
"Master Monitor",
|
2453
|
RadioSettingValueBoolean(
|
2454
|
_mem.dtmf_settings.mmonitor))
|
2455
|
dtmf_dec_settings.append(line)
|
2456
|
|
2457
|
line = RadioSetting("dtmf_settings.mstun",
|
2458
|
"Master Stun",
|
2459
|
RadioSettingValueBoolean(
|
2460
|
_mem.dtmf_settings.mstun))
|
2461
|
dtmf_dec_settings.append(line)
|
2462
|
|
2463
|
line = RadioSetting("dtmf_settings.mkill",
|
2464
|
"Master Kill",
|
2465
|
RadioSettingValueBoolean(
|
2466
|
_mem.dtmf_settings.mkill))
|
2467
|
dtmf_dec_settings.append(line)
|
2468
|
|
2469
|
line = RadioSetting("dtmf_settings.mrevive",
|
2470
|
"Master Revive",
|
2471
|
RadioSettingValueBoolean(
|
2472
|
_mem.dtmf_settings.mrevive))
|
2473
|
dtmf_dec_settings.append(line)
|
2474
|
|
2475
|
val = RadioSettingValueString(0, 16, memory2string(
|
2476
|
_mem.dtmf_settings.viceid),
|
2477
|
False, CHARSET_DTMF_DIGITS)
|
2478
|
line = RadioSetting("dtmf_settings.viceid",
|
2479
|
"Vice Control ID ", val)
|
2480
|
line.set_apply_callback(apply_dmtf_frame,
|
2481
|
_mem.dtmf_settings.viceid)
|
2482
|
dtmf_dec_settings.append(line)
|
2483
|
|
2484
|
line = RadioSetting("dtmf_settings.vinspection",
|
2485
|
"Vice Inspection",
|
2486
|
RadioSettingValueBoolean(
|
2487
|
_mem.dtmf_settings.vinspection))
|
2488
|
dtmf_dec_settings.append(line)
|
2489
|
|
2490
|
line = RadioSetting("dtmf_settings.vmonitor",
|
2491
|
"Vice Monitor",
|
2492
|
RadioSettingValueBoolean(
|
2493
|
_mem.dtmf_settings.vmonitor))
|
2494
|
dtmf_dec_settings.append(line)
|
2495
|
|
2496
|
line = RadioSetting("dtmf_settings.vstun",
|
2497
|
"Vice Stun",
|
2498
|
RadioSettingValueBoolean(
|
2499
|
_mem.dtmf_settings.vstun))
|
2500
|
dtmf_dec_settings.append(line)
|
2501
|
|
2502
|
line = RadioSetting("dtmf_settings.vkill",
|
2503
|
"Vice Kill",
|
2504
|
RadioSettingValueBoolean(
|
2505
|
_mem.dtmf_settings.vkill))
|
2506
|
dtmf_dec_settings.append(line)
|
2507
|
|
2508
|
line = RadioSetting("dtmf_settings.vrevive",
|
2509
|
"Vice Revive",
|
2510
|
RadioSettingValueBoolean(
|
2511
|
_mem.dtmf_settings.vrevive))
|
2512
|
dtmf_dec_settings.append(line)
|
2513
|
|
2514
|
val = RadioSettingValueString(0, 16, memory2string(
|
2515
|
_mem.dtmf_settings.inspection),
|
2516
|
False, CHARSET_DTMF_DIGITS)
|
2517
|
line = RadioSetting("dtmf_settings.inspection",
|
2518
|
"Inspection", val)
|
2519
|
line.set_apply_callback(apply_dmtf_frame,
|
2520
|
_mem.dtmf_settings.inspection)
|
2521
|
dtmf_dec_settings.append(line)
|
2522
|
|
2523
|
val = RadioSettingValueString(0, 16, memory2string(
|
2524
|
_mem.dtmf_settings.alarmcode),
|
2525
|
False, CHARSET_DTMF_DIGITS)
|
2526
|
line = RadioSetting("dtmf_settings.alarmcode",
|
2527
|
"Alarm", val)
|
2528
|
line.set_apply_callback(apply_dmtf_frame,
|
2529
|
_mem.dtmf_settings.alarmcode)
|
2530
|
dtmf_dec_settings.append(line)
|
2531
|
|
2532
|
val = RadioSettingValueString(0, 16, memory2string(
|
2533
|
_mem.dtmf_settings.kill),
|
2534
|
False, CHARSET_DTMF_DIGITS)
|
2535
|
line = RadioSetting("dtmf_settings.kill",
|
2536
|
"Kill", val)
|
2537
|
line.set_apply_callback(apply_dmtf_frame,
|
2538
|
_mem.dtmf_settings.kill)
|
2539
|
dtmf_dec_settings.append(line)
|
2540
|
|
2541
|
val = RadioSettingValueString(0, 16, memory2string(
|
2542
|
_mem.dtmf_settings.monitor),
|
2543
|
False, CHARSET_DTMF_DIGITS)
|
2544
|
line = RadioSetting("dtmf_settings.monitor",
|
2545
|
"Monitor", val)
|
2546
|
line.set_apply_callback(apply_dmtf_frame,
|
2547
|
_mem.dtmf_settings.monitor)
|
2548
|
dtmf_dec_settings.append(line)
|
2549
|
|
2550
|
val = RadioSettingValueString(0, 16, memory2string(
|
2551
|
_mem.dtmf_settings.stun),
|
2552
|
False, CHARSET_DTMF_DIGITS)
|
2553
|
line = RadioSetting("dtmf_settings.stun",
|
2554
|
"Stun", val)
|
2555
|
line.set_apply_callback(apply_dmtf_frame,
|
2556
|
_mem.dtmf_settings.stun)
|
2557
|
dtmf_dec_settings.append(line)
|
2558
|
|
2559
|
val = RadioSettingValueString(0, 16, memory2string(
|
2560
|
_mem.dtmf_settings.revive),
|
2561
|
False, CHARSET_DTMF_DIGITS)
|
2562
|
line = RadioSetting("dtmf_settings.revive",
|
2563
|
"Revive", val)
|
2564
|
line.set_apply_callback(apply_dmtf_frame,
|
2565
|
_mem.dtmf_settings.revive)
|
2566
|
dtmf_dec_settings.append(line)
|
2567
|
|
2568
|
def apply_dmtf_listvalue(setting, obj):
|
2569
|
LOG.debug("Setting value: " + str(setting.value) + " from list")
|
2570
|
val = str(setting.value)
|
2571
|
index = LIST_DTMF_SPECIAL_DIGITS.index(val)
|
2572
|
val = LIST_DTMF_SPECIAL_VALUES[index]
|
2573
|
obj.set_value(val)
|
2574
|
|
2575
|
if _mem.dtmf_settings.groupcode not in LIST_DTMF_SPECIAL_VALUES:
|
2576
|
val = 0x0B
|
2577
|
else:
|
2578
|
val = _mem.dtmf_settings.groupcode
|
2579
|
idx = LIST_DTMF_SPECIAL_VALUES.index(val)
|
2580
|
line = RadioSetting(
|
2581
|
"dtmf_settings.groupcode",
|
2582
|
"Group Code",
|
2583
|
RadioSettingValueList(LIST_DTMF_SPECIAL_DIGITS,
|
2584
|
LIST_DTMF_SPECIAL_DIGITS[idx]))
|
2585
|
line.set_apply_callback(apply_dmtf_listvalue,
|
2586
|
_mem.dtmf_settings.groupcode)
|
2587
|
dtmf_dec_settings.append(line)
|
2588
|
|
2589
|
if _mem.dtmf_settings.spacecode not in LIST_DTMF_SPECIAL_VALUES:
|
2590
|
val = 0x0C
|
2591
|
else:
|
2592
|
val = _mem.dtmf_settings.spacecode
|
2593
|
idx = LIST_DTMF_SPECIAL_VALUES.index(val)
|
2594
|
line = RadioSetting(
|
2595
|
"dtmf_settings.spacecode",
|
2596
|
"Space Code",
|
2597
|
RadioSettingValueList(LIST_DTMF_SPECIAL_DIGITS,
|
2598
|
LIST_DTMF_SPECIAL_DIGITS[idx]))
|
2599
|
line.set_apply_callback(apply_dmtf_listvalue,
|
2600
|
_mem.dtmf_settings.spacecode)
|
2601
|
dtmf_dec_settings.append(line)
|
2602
|
|
2603
|
if self.COLOR_LCD:
|
2604
|
if _mem.dtmf_settings.resettime > 0x63:
|
2605
|
val = 0x4F
|
2606
|
else:
|
2607
|
val = _mem.dtmf_settings.resettime
|
2608
|
line = RadioSetting(
|
2609
|
"dtmf_settings.resettime",
|
2610
|
"Reset time",
|
2611
|
RadioSettingValueList(LIST_5TONE_RESET_COLOR,
|
2612
|
LIST_5TONE_RESET_COLOR[
|
2613
|
val]))
|
2614
|
dtmf_dec_settings.append(line)
|
2615
|
else:
|
2616
|
line = RadioSetting(
|
2617
|
"dtmf_settings.resettime",
|
2618
|
"Reset time",
|
2619
|
RadioSettingValueList(LIST_5TONE_RESET,
|
2620
|
LIST_5TONE_RESET[
|
2621
|
_mem.dtmf_settings.resettime]))
|
2622
|
dtmf_dec_settings.append(line)
|
2623
|
|
2624
|
if _mem.dtmf_settings.delayproctime > 0x27:
|
2625
|
val = 0x04
|
2626
|
else:
|
2627
|
val = _mem.dtmf_settings.delayproctime
|
2628
|
line = RadioSetting(
|
2629
|
"dtmf_settings.delayproctime",
|
2630
|
"Delay processing time",
|
2631
|
RadioSettingValueList(LIST_DTMF_DELAY,
|
2632
|
LIST_DTMF_DELAY[
|
2633
|
val]))
|
2634
|
dtmf_dec_settings.append(line)
|
2635
|
|
2636
|
# 5 Tone Settings
|
2637
|
stds_5tone = RadioSettingGroup("stds_5tone", "Standards")
|
2638
|
codes_5tone = RadioSettingGroup("codes_5tone", "Codes")
|
2639
|
|
2640
|
group_5tone = RadioSettingGroup("group_5tone", "5 Tone Settings")
|
2641
|
group_5tone.append(stds_5tone)
|
2642
|
group_5tone.append(codes_5tone)
|
2643
|
|
2644
|
top.append(group_5tone)
|
2645
|
|
2646
|
def apply_list_value(setting, obj):
|
2647
|
options = setting.value.get_options()
|
2648
|
obj.set_value(options.index(str(setting.value)))
|
2649
|
|
2650
|
_5tone_standards = self._memobj._5tone_std_settings
|
2651
|
i = 0
|
2652
|
for standard in _5tone_standards:
|
2653
|
std_5tone = RadioSettingGroup("std_5tone_" + str(i),
|
2654
|
LIST_5TONE_STANDARDS[i])
|
2655
|
stds_5tone.append(std_5tone)
|
2656
|
|
2657
|
period = standard.period
|
2658
|
if period == 255:
|
2659
|
LOG.debug("Period for " + LIST_5TONE_STANDARDS[i] +
|
2660
|
" is not yet configured. Setting to 70ms.")
|
2661
|
period = 5
|
2662
|
|
2663
|
if period <= len(LIST_5TONE_STANDARD_PERIODS):
|
2664
|
line = RadioSetting(
|
2665
|
"_5tone_std_settings_" + str(i) + "_period",
|
2666
|
"Period (ms)", RadioSettingValueList
|
2667
|
(LIST_5TONE_STANDARD_PERIODS,
|
2668
|
LIST_5TONE_STANDARD_PERIODS[period]))
|
2669
|
line.set_apply_callback(apply_list_value, standard.period)
|
2670
|
std_5tone.append(line)
|
2671
|
else:
|
2672
|
LOG.debug("Invalid value for 5tone period! Disabling.")
|
2673
|
|
2674
|
group_tone = standard.group_tone
|
2675
|
if group_tone == 255:
|
2676
|
LOG.debug("Group-Tone for " + LIST_5TONE_STANDARDS[i] +
|
2677
|
" is not yet configured. Setting to A.")
|
2678
|
group_tone = 10
|
2679
|
|
2680
|
if group_tone <= len(LIST_5TONE_DIGITS):
|
2681
|
line = RadioSetting(
|
2682
|
"_5tone_std_settings_" + str(i) + "_grouptone",
|
2683
|
"Group Tone",
|
2684
|
RadioSettingValueList(LIST_5TONE_DIGITS,
|
2685
|
LIST_5TONE_DIGITS[
|
2686
|
group_tone]))
|
2687
|
line.set_apply_callback(apply_list_value,
|
2688
|
standard.group_tone)
|
2689
|
std_5tone.append(line)
|
2690
|
else:
|
2691
|
LOG.debug("Invalid value for 5tone digit! Disabling.")
|
2692
|
|
2693
|
repeat_tone = standard.repeat_tone
|
2694
|
if repeat_tone == 255:
|
2695
|
LOG.debug("Repeat-Tone for " + LIST_5TONE_STANDARDS[i] +
|
2696
|
" is not yet configured. Setting to E.")
|
2697
|
repeat_tone = 14
|
2698
|
|
2699
|
if repeat_tone <= len(LIST_5TONE_DIGITS):
|
2700
|
line = RadioSetting(
|
2701
|
"_5tone_std_settings_" + str(i) + "_repttone",
|
2702
|
"Repeat Tone",
|
2703
|
RadioSettingValueList(LIST_5TONE_DIGITS,
|
2704
|
LIST_5TONE_DIGITS[
|
2705
|
repeat_tone]))
|
2706
|
line.set_apply_callback(apply_list_value,
|
2707
|
standard.repeat_tone)
|
2708
|
std_5tone.append(line)
|
2709
|
else:
|
2710
|
LOG.debug("Invalid value for 5tone digit! Disabling.")
|
2711
|
i = i + 1
|
2712
|
|
2713
|
def my_apply_5tonestdlist_value(setting, obj):
|
2714
|
if LIST_5TONE_STANDARDS.index(str(setting.value)) == 15:
|
2715
|
obj.set_value(0xFF)
|
2716
|
else:
|
2717
|
obj.set_value(LIST_5TONE_STANDARDS.
|
2718
|
index(str(setting.value)))
|
2719
|
|
2720
|
def apply_5tone_frame(setting, obj):
|
2721
|
LOG.debug("Setting 5 Tone: " + str(setting.value))
|
2722
|
valstring = str(setting.value)
|
2723
|
if len(valstring) == 0:
|
2724
|
for i in range(0, 5):
|
2725
|
obj[i] = 255
|
2726
|
else:
|
2727
|
validFrame = True
|
2728
|
for i in range(0, 5):
|
2729
|
currentChar = valstring[i].upper()
|
2730
|
if currentChar in LIST_5TONE_DIGITS:
|
2731
|
obj[i] = LIST_5TONE_DIGITS.index(currentChar)
|
2732
|
else:
|
2733
|
validFrame = False
|
2734
|
LOG.debug("invalid char: " + str(currentChar))
|
2735
|
if not validFrame:
|
2736
|
LOG.debug("setting whole frame to FF")
|
2737
|
for i in range(0, 5):
|
2738
|
obj[i] = 255
|
2739
|
|
2740
|
def validate_5tone_frame(value):
|
2741
|
if (len(str(value)) != 5) and (len(str(value)) != 0):
|
2742
|
msg = ("5 Tone must have 5 digits or 0 digits")
|
2743
|
raise InvalidValueError(msg)
|
2744
|
for digit in str(value):
|
2745
|
if digit.upper() not in LIST_5TONE_DIGITS:
|
2746
|
msg = (str(digit) + " is not a valid digit for 5tones")
|
2747
|
raise InvalidValueError(msg)
|
2748
|
return value
|
2749
|
|
2750
|
def frame2string(frame):
|
2751
|
frameString = ""
|
2752
|
for digit in frame:
|
2753
|
if digit != 255:
|
2754
|
frameString = frameString + LIST_5TONE_DIGITS[digit]
|
2755
|
return frameString
|
2756
|
|
2757
|
_5tone_codes = self._memobj._5tone_codes
|
2758
|
i = 1
|
2759
|
for code in _5tone_codes:
|
2760
|
code_5tone = RadioSettingGroup("code_5tone_" + str(i),
|
2761
|
"5 Tone code " + str(i))
|
2762
|
codes_5tone.append(code_5tone)
|
2763
|
if (code.standard == 255):
|
2764
|
currentVal = 15
|
2765
|
else:
|
2766
|
currentVal = code.standard
|
2767
|
line = RadioSetting("_5tone_code_" + str(i) + "_std",
|
2768
|
" Standard",
|
2769
|
RadioSettingValueList(LIST_5TONE_STANDARDS,
|
2770
|
LIST_5TONE_STANDARDS[
|
2771
|
currentVal]))
|
2772
|
line.set_apply_callback(my_apply_5tonestdlist_value,
|
2773
|
code.standard)
|
2774
|
code_5tone.append(line)
|
2775
|
|
2776
|
val = RadioSettingValueString(0, 6,
|
2777
|
frame2string(code.frame1), False)
|
2778
|
line = RadioSetting("_5tone_code_" + str(i) + "_frame1",
|
2779
|
" Frame 1", val)
|
2780
|
val.set_validate_callback(validate_5tone_frame)
|
2781
|
line.set_apply_callback(apply_5tone_frame, code.frame1)
|
2782
|
code_5tone.append(line)
|
2783
|
|
2784
|
val = RadioSettingValueString(0, 6,
|
2785
|
frame2string(code.frame2), False)
|
2786
|
line = RadioSetting("_5tone_code_" + str(i) + "_frame2",
|
2787
|
" Frame 2", val)
|
2788
|
val.set_validate_callback(validate_5tone_frame)
|
2789
|
line.set_apply_callback(apply_5tone_frame, code.frame2)
|
2790
|
code_5tone.append(line)
|
2791
|
|
2792
|
val = RadioSettingValueString(0, 6,
|
2793
|
frame2string(code.frame3), False)
|
2794
|
line = RadioSetting("_5tone_code_" + str(i) + "_frame3",
|
2795
|
" Frame 3", val)
|
2796
|
val.set_validate_callback(validate_5tone_frame)
|
2797
|
line.set_apply_callback(apply_5tone_frame, code.frame3)
|
2798
|
code_5tone.append(line)
|
2799
|
i = i + 1
|
2800
|
|
2801
|
_5_tone_decode1 = RadioSetting(
|
2802
|
"_5tone_settings._5tone_decode_call_frame1",
|
2803
|
"5 Tone decode call Frame 1",
|
2804
|
RadioSettingValueBoolean(
|
2805
|
_mem._5tone_settings._5tone_decode_call_frame1))
|
2806
|
group_5tone.append(_5_tone_decode1)
|
2807
|
|
2808
|
_5_tone_decode2 = RadioSetting(
|
2809
|
"_5tone_settings._5tone_decode_call_frame2",
|
2810
|
"5 Tone decode call Frame 2",
|
2811
|
RadioSettingValueBoolean(
|
2812
|
_mem._5tone_settings._5tone_decode_call_frame2))
|
2813
|
group_5tone.append(_5_tone_decode2)
|
2814
|
|
2815
|
_5_tone_decode3 = RadioSetting(
|
2816
|
"_5tone_settings._5tone_decode_call_frame3",
|
2817
|
"5 Tone decode call Frame 3",
|
2818
|
RadioSettingValueBoolean(
|
2819
|
_mem._5tone_settings._5tone_decode_call_frame3))
|
2820
|
group_5tone.append(_5_tone_decode3)
|
2821
|
|
2822
|
_5_tone_decode_disp1 = RadioSetting(
|
2823
|
"_5tone_settings._5tone_decode_disp_frame1",
|
2824
|
"5 Tone decode disp Frame 1",
|
2825
|
RadioSettingValueBoolean(
|
2826
|
_mem._5tone_settings._5tone_decode_disp_frame1))
|
2827
|
group_5tone.append(_5_tone_decode_disp1)
|
2828
|
|
2829
|
_5_tone_decode_disp2 = RadioSetting(
|
2830
|
"_5tone_settings._5tone_decode_disp_frame2",
|
2831
|
"5 Tone decode disp Frame 2",
|
2832
|
RadioSettingValueBoolean(
|
2833
|
_mem._5tone_settings._5tone_decode_disp_frame2))
|
2834
|
group_5tone.append(_5_tone_decode_disp2)
|
2835
|
|
2836
|
_5_tone_decode_disp3 = RadioSetting(
|
2837
|
"_5tone_settings._5tone_decode_disp_frame3",
|
2838
|
"5 Tone decode disp Frame 3",
|
2839
|
RadioSettingValueBoolean(
|
2840
|
_mem._5tone_settings._5tone_decode_disp_frame3))
|
2841
|
group_5tone.append(_5_tone_decode_disp3)
|
2842
|
|
2843
|
decode_standard = _mem._5tone_settings.decode_standard
|
2844
|
if decode_standard == 255:
|
2845
|
decode_standard = 0
|
2846
|
if decode_standard <= len(LIST_5TONE_STANDARDS_without_none):
|
2847
|
line = RadioSetting("_5tone_settings.decode_standard",
|
2848
|
"5 Tone-decode Standard",
|
2849
|
RadioSettingValueList(
|
2850
|
LIST_5TONE_STANDARDS_without_none,
|
2851
|
LIST_5TONE_STANDARDS_without_none[
|
2852
|
decode_standard]))
|
2853
|
group_5tone.append(line)
|
2854
|
else:
|
2855
|
LOG.debug("Invalid decode std...")
|
2856
|
|
2857
|
_5tone_delay1 = _mem._5tone_settings._5tone_delay1
|
2858
|
if _5tone_delay1 == 255:
|
2859
|
_5tone_delay1 = 20
|
2860
|
|
2861
|
if _5tone_delay1 <= len(LIST_5TONE_DELAY):
|
2862
|
list = RadioSettingValueList(LIST_5TONE_DELAY,
|
2863
|
LIST_5TONE_DELAY[
|
2864
|
_5tone_delay1])
|
2865
|
line = RadioSetting("_5tone_settings._5tone_delay1",
|
2866
|
"5 Tone Delay Frame 1", list)
|
2867
|
group_5tone.append(line)
|
2868
|
else:
|
2869
|
LOG.debug(
|
2870
|
"Invalid value for 5tone delay (frame1) ! Disabling.")
|
2871
|
|
2872
|
_5tone_delay2 = _mem._5tone_settings._5tone_delay2
|
2873
|
if _5tone_delay2 == 255:
|
2874
|
_5tone_delay2 = 20
|
2875
|
LOG.debug("5 Tone delay unconfigured! Resetting to 200ms.")
|
2876
|
|
2877
|
if _5tone_delay2 <= len(LIST_5TONE_DELAY):
|
2878
|
list = RadioSettingValueList(LIST_5TONE_DELAY,
|
2879
|
LIST_5TONE_DELAY[
|
2880
|
_5tone_delay2])
|
2881
|
line = RadioSetting("_5tone_settings._5tone_delay2",
|
2882
|
"5 Tone Delay Frame 2", list)
|
2883
|
group_5tone.append(line)
|
2884
|
else:
|
2885
|
LOG.debug("Invalid value for 5tone delay (frame2)! Disabling.")
|
2886
|
|
2887
|
_5tone_delay3 = _mem._5tone_settings._5tone_delay3
|
2888
|
if _5tone_delay3 == 255:
|
2889
|
_5tone_delay3 = 20
|
2890
|
LOG.debug("5 Tone delay unconfigured! Resetting to 200ms.")
|
2891
|
|
2892
|
if _5tone_delay3 <= len(LIST_5TONE_DELAY):
|
2893
|
list = RadioSettingValueList(LIST_5TONE_DELAY,
|
2894
|
LIST_5TONE_DELAY[
|
2895
|
_5tone_delay3])
|
2896
|
line = RadioSetting("_5tone_settings._5tone_delay3",
|
2897
|
"5 Tone Delay Frame 3", list)
|
2898
|
group_5tone.append(line)
|
2899
|
else:
|
2900
|
LOG.debug("Invalid value for 5tone delay (frame3)! Disabling.")
|
2901
|
|
2902
|
ext_length = _mem._5tone_settings._5tone_first_digit_ext_length
|
2903
|
if ext_length == 255:
|
2904
|
ext_length = 0
|
2905
|
LOG.debug("1st Tone ext lenght unconfigured! Resetting to 0")
|
2906
|
|
2907
|
if ext_length <= len(LIST_5TONE_DELAY):
|
2908
|
list = RadioSettingValueList(
|
2909
|
LIST_5TONE_DELAY,
|
2910
|
LIST_5TONE_DELAY[
|
2911
|
ext_length])
|
2912
|
line = RadioSetting(
|
2913
|
"_5tone_settings._5tone_first_digit_ext_length",
|
2914
|
"First digit extend length", list)
|
2915
|
group_5tone.append(line)
|
2916
|
else:
|
2917
|
LOG.debug("Invalid value for 5tone ext length! Disabling.")
|
2918
|
|
2919
|
decode_reset_time = _mem._5tone_settings.decode_reset_time
|
2920
|
if decode_reset_time == 255:
|
2921
|
decode_reset_time = 59
|
2922
|
LOG.debug("Decode reset time unconfigured. resetting.")
|
2923
|
if decode_reset_time <= len(LIST_5TONE_RESET):
|
2924
|
list = RadioSettingValueList(
|
2925
|
LIST_5TONE_RESET,
|
2926
|
LIST_5TONE_RESET[
|
2927
|
decode_reset_time])
|
2928
|
line = RadioSetting("_5tone_settings.decode_reset_time",
|
2929
|
"Decode reset time", list)
|
2930
|
group_5tone.append(line)
|
2931
|
else:
|
2932
|
LOG.debug("Invalid value decode reset time! Disabling.")
|
2933
|
|
2934
|
# 2 Tone
|
2935
|
encode_2tone = RadioSettingGroup("encode_2tone", "2 Tone Encode")
|
2936
|
decode_2tone = RadioSettingGroup("decode_2tone", "2 Code Decode")
|
2937
|
|
2938
|
top.append(encode_2tone)
|
2939
|
top.append(decode_2tone)
|
2940
|
|
2941
|
duration_1st_tone = self._memobj._2tone.duration_1st_tone
|
2942
|
if duration_1st_tone == 255:
|
2943
|
LOG.debug("Duration of first 2 Tone digit is not yet " +
|
2944
|
"configured. Setting to 600ms")
|
2945
|
duration_1st_tone = 60
|
2946
|
|
2947
|
if duration_1st_tone <= len(LIST_5TONE_DELAY):
|
2948
|
val = RadioSettingValueList(LIST_5TONE_DELAY,
|
2949
|
LIST_5TONE_DELAY[
|
2950
|
duration_1st_tone])
|
2951
|
line = RadioSetting("_2tone.duration_1st_tone",
|
2952
|
"Duration 1st Tone", val)
|
2953
|
encode_2tone.append(line)
|
2954
|
|
2955
|
duration_2nd_tone = self._memobj._2tone.duration_2nd_tone
|
2956
|
if duration_2nd_tone == 255:
|
2957
|
LOG.debug("Duration of second 2 Tone digit is not yet " +
|
2958
|
"configured. Setting to 600ms")
|
2959
|
duration_2nd_tone = 60
|
2960
|
|
2961
|
if duration_2nd_tone <= len(LIST_5TONE_DELAY):
|
2962
|
val = RadioSettingValueList(LIST_5TONE_DELAY,
|
2963
|
LIST_5TONE_DELAY[
|
2964
|
duration_2nd_tone])
|
2965
|
line = RadioSetting("_2tone.duration_2nd_tone",
|
2966
|
"Duration 2nd Tone", val)
|
2967
|
encode_2tone.append(line)
|
2968
|
|
2969
|
duration_gap = self._memobj._2tone.duration_gap
|
2970
|
if duration_gap == 255:
|
2971
|
LOG.debug("Duration of gap is not yet " +
|
2972
|
"configured. Setting to 300ms")
|
2973
|
duration_gap = 30
|
2974
|
|
2975
|
if duration_gap <= len(LIST_5TONE_DELAY):
|
2976
|
line = RadioSetting("_2tone.duration_gap", "Duration of gap",
|
2977
|
RadioSettingValueList(LIST_5TONE_DELAY,
|
2978
|
LIST_5TONE_DELAY[
|
2979
|
duration_gap]))
|
2980
|
encode_2tone.append(line)
|
2981
|
|
2982
|
def _2tone_validate(value):
|
2983
|
if value == 0:
|
2984
|
return 65535
|
2985
|
if value == 65535:
|
2986
|
return value
|
2987
|
if not (300 <= value and value <= 3000):
|
2988
|
msg = ("2 Tone Frequency: Must be between 300 and 3000 Hz")
|
2989
|
raise InvalidValueError(msg)
|
2990
|
return value
|
2991
|
|
2992
|
def apply_2tone_freq(setting, obj):
|
2993
|
val = int(setting.value)
|
2994
|
if (val == 0) or (val == 65535):
|
2995
|
obj.set_value(65535)
|
2996
|
else:
|
2997
|
obj.set_value(val)
|
2998
|
|
2999
|
i = 1
|
3000
|
for code in self._memobj._2tone._2tone_encode:
|
3001
|
code_2tone = RadioSettingGroup("code_2tone_" + str(i),
|
3002
|
"Encode Code " + str(i))
|
3003
|
encode_2tone.append(code_2tone)
|
3004
|
|
3005
|
tmp = code.freq1
|
3006
|
if tmp == 65535:
|
3007
|
tmp = 0
|
3008
|
val1 = RadioSettingValueInteger(0, 65535, tmp)
|
3009
|
freq1 = RadioSetting("2tone_code_" + str(i) + "_freq1",
|
3010
|
"Frequency 1", val1)
|
3011
|
val1.set_validate_callback(_2tone_validate)
|
3012
|
freq1.set_apply_callback(apply_2tone_freq, code.freq1)
|
3013
|
code_2tone.append(freq1)
|
3014
|
|
3015
|
tmp = code.freq2
|
3016
|
if tmp == 65535:
|
3017
|
tmp = 0
|
3018
|
val2 = RadioSettingValueInteger(0, 65535, tmp)
|
3019
|
freq2 = RadioSetting("2tone_code_" + str(i) + "_freq2",
|
3020
|
"Frequency 2", val2)
|
3021
|
val2.set_validate_callback(_2tone_validate)
|
3022
|
freq2.set_apply_callback(apply_2tone_freq, code.freq2)
|
3023
|
code_2tone.append(freq2)
|
3024
|
|
3025
|
i = i + 1
|
3026
|
|
3027
|
decode_reset_time = _mem._2tone.reset_time
|
3028
|
if decode_reset_time == 255:
|
3029
|
decode_reset_time = 59
|
3030
|
LOG.debug("Decode reset time unconfigured. resetting.")
|
3031
|
if decode_reset_time <= len(LIST_5TONE_RESET):
|
3032
|
list = RadioSettingValueList(
|
3033
|
LIST_5TONE_RESET,
|
3034
|
LIST_5TONE_RESET[
|
3035
|
decode_reset_time])
|
3036
|
line = RadioSetting("_2tone.reset_time",
|
3037
|
"Decode reset time", list)
|
3038
|
decode_2tone.append(line)
|
3039
|
else:
|
3040
|
LOG.debug("Invalid value decode reset time! Disabling.")
|
3041
|
|
3042
|
def apply_2tone_freq_pair(setting, obj):
|
3043
|
val = int(setting.value)
|
3044
|
derived_val = 65535
|
3045
|
frqname = str(setting._name[-5:])
|
3046
|
derivedname = "derived_from_" + frqname
|
3047
|
|
3048
|
if (val == 0):
|
3049
|
val = 65535
|
3050
|
derived_val = 65535
|
3051
|
else:
|
3052
|
derived_val = int(round(2304000.0/val))
|
3053
|
|
3054
|
obj[frqname].set_value(val)
|
3055
|
obj[derivedname].set_value(derived_val)
|
3056
|
|
3057
|
LOG.debug("Apply " + frqname + ": " + str(val) + " | " +
|
3058
|
derivedname + ": " + str(derived_val))
|
3059
|
|
3060
|
i = 1
|
3061
|
for decode_code in self._memobj._2tone._2tone_decode:
|
3062
|
_2tone_dec_code = RadioSettingGroup("code_2tone_" + str(i),
|
3063
|
"Decode Code " + str(i))
|
3064
|
decode_2tone.append(_2tone_dec_code)
|
3065
|
|
3066
|
j = 1
|
3067
|
for dec in decode_code.decs:
|
3068
|
val = dec.dec
|
3069
|
if val == 255:
|
3070
|
LOG.debug("Dec for Code " + str(i) + " Dec " + str(j) +
|
3071
|
" is not yet configured. Setting to 0.")
|
3072
|
val = 0
|
3073
|
|
3074
|
if val <= len(LIST_2TONE_DEC):
|
3075
|
line = RadioSetting(
|
3076
|
"_2tone_dec_settings_" + str(i) + "_dec_" + str(j),
|
3077
|
"Dec " + str(j), RadioSettingValueList
|
3078
|
(LIST_2TONE_DEC,
|
3079
|
LIST_2TONE_DEC[val]))
|
3080
|
line.set_apply_callback(apply_list_value, dec.dec)
|
3081
|
_2tone_dec_code.append(line)
|
3082
|
else:
|
3083
|
LOG.debug("Invalid value for 2tone dec! Disabling.")
|
3084
|
|
3085
|
val = dec.response
|
3086
|
if val == 255:
|
3087
|
LOG.debug("Response for Code " +
|
3088
|
str(i) + " Dec " + str(j) +
|
3089
|
" is not yet configured. Setting to 0.")
|
3090
|
val = 0
|
3091
|
|
3092
|
if val <= len(LIST_2TONE_RESPONSE):
|
3093
|
line = RadioSetting(
|
3094
|
"_2tone_dec_settings_" +
|
3095
|
str(i) + "_resp_" + str(j),
|
3096
|
"Response " + str(j), RadioSettingValueList
|
3097
|
(LIST_2TONE_RESPONSE,
|
3098
|
LIST_2TONE_RESPONSE[val]))
|
3099
|
line.set_apply_callback(apply_list_value, dec.response)
|
3100
|
_2tone_dec_code.append(line)
|
3101
|
else:
|
3102
|
LOG.debug(
|
3103
|
"Invalid value for 2tone response! Disabling.")
|
3104
|
|
3105
|
val = dec.alert
|
3106
|
if val == 255:
|
3107
|
LOG.debug("Alert for Code " +
|
3108
|
str(i) + " Dec " + str(j) +
|
3109
|
" is not yet configured. Setting to 0.")
|
3110
|
val = 0
|
3111
|
|
3112
|
if val <= len(PTTIDCODE_LIST):
|
3113
|
line = RadioSetting(
|
3114
|
"_2tone_dec_settings_" +
|
3115
|
str(i) + "_alert_" + str(j),
|
3116
|
"Alert " + str(j), RadioSettingValueList
|
3117
|
(PTTIDCODE_LIST,
|
3118
|
PTTIDCODE_LIST[val]))
|
3119
|
line.set_apply_callback(apply_list_value, dec.alert)
|
3120
|
_2tone_dec_code.append(line)
|
3121
|
else:
|
3122
|
LOG.debug("Invalid value for 2tone alert! Disabling.")
|
3123
|
j = j + 1
|
3124
|
|
3125
|
freq = self._memobj._2tone.freqs[i-1]
|
3126
|
for char in ['A', 'B', 'C', 'D']:
|
3127
|
setting_name = "freq" + str(char)
|
3128
|
|
3129
|
tmp = freq[setting_name]
|
3130
|
if tmp == 65535:
|
3131
|
tmp = 0
|
3132
|
if tmp != 0:
|
3133
|
expected = int(round(2304000.0/tmp))
|
3134
|
from_mem = freq["derived_from_" + setting_name]
|
3135
|
if expected != from_mem:
|
3136
|
LOG.error("Expected " + str(expected) +
|
3137
|
" but read " + str(from_mem) +
|
3138
|
". Disabling 2Tone Decode Freqs!")
|
3139
|
break
|
3140
|
val = RadioSettingValueInteger(0, 65535, tmp)
|
3141
|
frq = RadioSetting("2tone_dec_" + str(i) +
|
3142
|
"_freq" + str(char),
|
3143
|
("Decode Frequency " + str(char)), val)
|
3144
|
val.set_validate_callback(_2tone_validate)
|
3145
|
frq.set_apply_callback(apply_2tone_freq_pair, freq)
|
3146
|
_2tone_dec_code.append(frq)
|
3147
|
|
3148
|
i = i + 1
|
3149
|
|
3150
|
return top
|
3151
|
|
3152
|
def set_settings(self, settings):
|
3153
|
_settings = self._memobj.settings
|
3154
|
for element in settings:
|
3155
|
if not isinstance(element, RadioSetting):
|
3156
|
if element.get_name() == "fm_preset":
|
3157
|
self._set_fm_preset(element)
|
3158
|
else:
|
3159
|
self.set_settings(element)
|
3160
|
continue
|
3161
|
else:
|
3162
|
try:
|
3163
|
name = element.get_name()
|
3164
|
if "." in name:
|
3165
|
bits = name.split(".")
|
3166
|
obj = self._memobj
|
3167
|
for bit in bits[:-1]:
|
3168
|
if "/" in bit:
|
3169
|
bit, index = bit.split("/", 1)
|
3170
|
index = int(index)
|
3171
|
obj = getattr(obj, bit)[index]
|
3172
|
else:
|
3173
|
obj = getattr(obj, bit)
|
3174
|
setting = bits[-1]
|
3175
|
else:
|
3176
|
obj = _settings
|
3177
|
setting = element.get_name()
|
3178
|
|
3179
|
if element.has_apply_callback():
|
3180
|
LOG.debug("Using apply callback")
|
3181
|
element.run_apply_callback()
|
3182
|
elif setting == "volume" and self.MODEL == "KT-WP12":
|
3183
|
setattr(obj, setting, int(element.value) - 1)
|
3184
|
elif setting == "volume" and self.MODEL == "WP-9900":
|
3185
|
setattr(obj, setting, int(element.value) - 1)
|
3186
|
elif element.value.get_mutable():
|
3187
|
LOG.debug("Setting %s = %s" % (setting, element.value))
|
3188
|
setattr(obj, setting, element.value)
|
3189
|
except Exception, e:
|
3190
|
LOG.debug(element.get_name())
|
3191
|
raise
|
3192
|
|
3193
|
@classmethod
|
3194
|
def match_model(cls, filedata, filename):
|
3195
|
match_size = False
|
3196
|
match_model = False
|
3197
|
|
3198
|
# testing the file data size
|
3199
|
if len(filedata) == MEM_SIZE:
|
3200
|
match_size = True
|
3201
|
|
3202
|
# testing the firmware model fingerprint
|
3203
|
match_model = model_match(cls, filedata)
|
3204
|
|
3205
|
if match_size and match_model:
|
3206
|
return True
|
3207
|
else:
|
3208
|
return False
|
3209
|
|
3210
|
|
3211
|
MEM_FORMAT = """
|
3212
|
#seekto 0x0000;
|
3213
|
struct {
|
3214
|
lbcd rxfreq[4];
|
3215
|
lbcd txfreq[4];
|
3216
|
ul16 rxtone;
|
3217
|
ul16 txtone;
|
3218
|
u8 unknown0:4,
|
3219
|
scode:4;
|
3220
|
u8 unknown1:2,
|
3221
|
spmute:2,
|
3222
|
unknown2:2,
|
3223
|
optsig:2;
|
3224
|
u8 unknown3:3,
|
3225
|
scramble:1,
|
3226
|
unknown4:3,
|
3227
|
power:1;
|
3228
|
u8 unknown5:1,
|
3229
|
wide:1,
|
3230
|
unknown6:2,
|
3231
|
bcl:1,
|
3232
|
add:1,
|
3233
|
pttid:2;
|
3234
|
} memory[200];
|
3235
|
|
3236
|
#seekto 0x0E00;
|
3237
|
struct {
|
3238
|
u8 tdr;
|
3239
|
u8 unknown1;
|
3240
|
u8 sql;
|
3241
|
u8 unknown2[2];
|
3242
|
u8 tot;
|
3243
|
u8 apo; // BTech radios use this as the Auto Power Off time
|
3244
|
// other radios use this as pre-Time Out Alert
|
3245
|
u8 unknown3;
|
3246
|
u8 abr;
|
3247
|
u8 beep;
|
3248
|
u8 unknown4[4];
|
3249
|
u8 dtmfst;
|
3250
|
u8 unknown5[2];
|
3251
|
u8 prisc;
|
3252
|
u8 prich;
|
3253
|
u8 screv;
|
3254
|
u8 unknown6[2];
|
3255
|
u8 pttid;
|
3256
|
u8 pttlt;
|
3257
|
u8 unknown7;
|
3258
|
u8 emctp;
|
3259
|
u8 emcch;
|
3260
|
u8 ringt;
|
3261
|
u8 unknown8;
|
3262
|
u8 camdf;
|
3263
|
u8 cbmdf;
|
3264
|
u8 sync; // BTech radios use this as the display sync setting
|
3265
|
// other radios use this as the auto keypad lock setting
|
3266
|
u8 ponmsg;
|
3267
|
u8 wtled;
|
3268
|
u8 rxled;
|
3269
|
u8 txled;
|
3270
|
u8 unknown9[5];
|
3271
|
u8 anil;
|
3272
|
u8 reps;
|
3273
|
u8 repm;
|
3274
|
u8 tdrab;
|
3275
|
u8 ste;
|
3276
|
u8 rpste;
|
3277
|
u8 rptdl;
|
3278
|
u8 mgain;
|
3279
|
u8 dtmfg;
|
3280
|
} settings;
|
3281
|
|
3282
|
#seekto 0x0E80;
|
3283
|
struct {
|
3284
|
u8 unknown1;
|
3285
|
u8 vfomr;
|
3286
|
u8 keylock;
|
3287
|
u8 unknown2;
|
3288
|
u8 unknown3:4,
|
3289
|
vfomren:1,
|
3290
|
unknown4:1,
|
3291
|
reseten:1,
|
3292
|
menuen:1;
|
3293
|
u8 unknown5[11];
|
3294
|
u8 dispab;
|
3295
|
u8 mrcha;
|
3296
|
u8 mrchb;
|
3297
|
u8 menu;
|
3298
|
} settings2;
|
3299
|
|
3300
|
#seekto 0x0EC0;
|
3301
|
struct {
|
3302
|
char line1[6];
|
3303
|
char line2[6];
|
3304
|
} poweron_msg;
|
3305
|
|
3306
|
struct settings_vfo {
|
3307
|
u8 freq[8];
|
3308
|
u8 offset[6];
|
3309
|
u8 unknown2[2];
|
3310
|
ul16 rxtone;
|
3311
|
ul16 txtone;
|
3312
|
u8 scode;
|
3313
|
u8 spmute;
|
3314
|
u8 optsig;
|
3315
|
u8 scramble;
|
3316
|
u8 wide;
|
3317
|
u8 power;
|
3318
|
u8 shiftd;
|
3319
|
u8 step;
|
3320
|
u8 unknown3[4];
|
3321
|
};
|
3322
|
|
3323
|
#seekto 0x0F00;
|
3324
|
struct {
|
3325
|
struct settings_vfo a;
|
3326
|
struct settings_vfo b;
|
3327
|
} vfo;
|
3328
|
|
3329
|
#seekto 0x1000;
|
3330
|
struct {
|
3331
|
char name[6];
|
3332
|
u8 unknown1[10];
|
3333
|
} names[200];
|
3334
|
|
3335
|
#seekto 0x2400;
|
3336
|
struct {
|
3337
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
3338
|
u8 group_tone;
|
3339
|
u8 repeat_tone;
|
3340
|
u8 unused[13];
|
3341
|
} _5tone_std_settings[15];
|
3342
|
|
3343
|
#seekto 0x2500;
|
3344
|
struct {
|
3345
|
u8 frame1[5];
|
3346
|
u8 frame2[5];
|
3347
|
u8 frame3[5];
|
3348
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
3349
|
} _5tone_codes[15];
|
3350
|
|
3351
|
#seekto 0x25F0;
|
3352
|
struct {
|
3353
|
u8 _5tone_delay1; // * 10ms
|
3354
|
u8 _5tone_delay2; // * 10ms
|
3355
|
u8 _5tone_delay3; // * 10ms
|
3356
|
u8 _5tone_first_digit_ext_length;
|
3357
|
u8 unknown1;
|
3358
|
u8 unknown2;
|
3359
|
u8 unknown3;
|
3360
|
u8 unknown4;
|
3361
|
u8 decode_standard;
|
3362
|
u8 unknown5:5,
|
3363
|
_5tone_decode_call_frame3:1,
|
3364
|
_5tone_decode_call_frame2:1,
|
3365
|
_5tone_decode_call_frame1:1;
|
3366
|
u8 unknown6:5,
|
3367
|
_5tone_decode_disp_frame3:1,
|
3368
|
_5tone_decode_disp_frame2:1,
|
3369
|
_5tone_decode_disp_frame1:1;
|
3370
|
u8 decode_reset_time; // * 100 + 100ms
|
3371
|
} _5tone_settings;
|
3372
|
|
3373
|
#seekto 0x2900;
|
3374
|
struct {
|
3375
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
3376
|
} dtmf_codes[15];
|
3377
|
|
3378
|
#seekto 0x29F0;
|
3379
|
struct {
|
3380
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
3381
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
3382
|
u8 unknown0[14];
|
3383
|
u8 inspection[16];
|
3384
|
u8 monitor[16];
|
3385
|
u8 alarmcode[16];
|
3386
|
u8 stun[16];
|
3387
|
u8 kill[16];
|
3388
|
u8 revive[16];
|
3389
|
u8 unknown1[16];
|
3390
|
u8 unknown2[16];
|
3391
|
u8 unknown3[16];
|
3392
|
u8 unknown4[16];
|
3393
|
u8 unknown5[16];
|
3394
|
u8 unknown6[16];
|
3395
|
u8 unknown7[16];
|
3396
|
u8 masterid[16];
|
3397
|
u8 viceid[16];
|
3398
|
u8 unused01:7,
|
3399
|
mastervice:1;
|
3400
|
u8 unused02:3,
|
3401
|
mrevive:1,
|
3402
|
mkill:1,
|
3403
|
mstun:1,
|
3404
|
mmonitor:1,
|
3405
|
minspection:1;
|
3406
|
u8 unused03:3,
|
3407
|
vrevive:1,
|
3408
|
vkill:1,
|
3409
|
vstun:1,
|
3410
|
vmonitor:1,
|
3411
|
vinspection:1;
|
3412
|
u8 unused04:6,
|
3413
|
txdisable:1,
|
3414
|
rxdisable:1;
|
3415
|
u8 groupcode;
|
3416
|
u8 spacecode;
|
3417
|
u8 delayproctime; // * 100 + 100ms
|
3418
|
u8 resettime; // * 100 + 100ms
|
3419
|
} dtmf_settings;
|
3420
|
|
3421
|
#seekto 0x2D00;
|
3422
|
struct {
|
3423
|
struct {
|
3424
|
ul16 freq1;
|
3425
|
u8 unused01[6];
|
3426
|
ul16 freq2;
|
3427
|
u8 unused02[6];
|
3428
|
} _2tone_encode[15];
|
3429
|
u8 duration_1st_tone; // *10ms
|
3430
|
u8 duration_2nd_tone; // *10ms
|
3431
|
u8 duration_gap; // *10ms
|
3432
|
u8 unused03[13];
|
3433
|
struct {
|
3434
|
struct {
|
3435
|
u8 dec; // one out of LIST_2TONE_DEC
|
3436
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
3437
|
u8 alert; // 1-16
|
3438
|
} decs[4];
|
3439
|
u8 unused04[4];
|
3440
|
} _2tone_decode[15];
|
3441
|
u8 unused05[16];
|
3442
|
|
3443
|
struct {
|
3444
|
ul16 freqA;
|
3445
|
ul16 freqB;
|
3446
|
ul16 freqC;
|
3447
|
ul16 freqD;
|
3448
|
// unknown what those values mean, but they are
|
3449
|
// derived from configured frequencies
|
3450
|
ul16 derived_from_freqA; // 2304000/freqA
|
3451
|
ul16 derived_from_freqB; // 2304000/freqB
|
3452
|
ul16 derived_from_freqC; // 2304000/freqC
|
3453
|
ul16 derived_from_freqD; // 2304000/freqD
|
3454
|
}freqs[15];
|
3455
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
3456
|
} _2tone;
|
3457
|
|
3458
|
#seekto 0x3000;
|
3459
|
struct {
|
3460
|
u8 freq[8];
|
3461
|
char broadcast_station_name[6];
|
3462
|
u8 unknown[2];
|
3463
|
} fm_radio_preset[16];
|
3464
|
|
3465
|
#seekto 0x3C90;
|
3466
|
struct {
|
3467
|
u8 vhf_low[3];
|
3468
|
u8 vhf_high[3];
|
3469
|
u8 uhf_low[3];
|
3470
|
u8 uhf_high[3];
|
3471
|
} ranges;
|
3472
|
|
3473
|
// the UV-2501+220 & KT8900R has different zones for storing ranges
|
3474
|
|
3475
|
#seekto 0x3CD0;
|
3476
|
struct {
|
3477
|
u8 vhf_low[3];
|
3478
|
u8 vhf_high[3];
|
3479
|
u8 unknown1[4];
|
3480
|
u8 unknown2[6];
|
3481
|
u8 vhf2_low[3];
|
3482
|
u8 vhf2_high[3];
|
3483
|
u8 unknown3[4];
|
3484
|
u8 unknown4[6];
|
3485
|
u8 uhf_low[3];
|
3486
|
u8 uhf_high[3];
|
3487
|
} ranges220;
|
3488
|
|
3489
|
#seekto 0x3F70;
|
3490
|
struct {
|
3491
|
char fp[6];
|
3492
|
} fingerprint;
|
3493
|
|
3494
|
"""
|
3495
|
|
3496
|
|
3497
|
class BTech(BTechMobileCommon):
|
3498
|
"""BTECH's UV-5001 and alike radios"""
|
3499
|
BANDS = 2
|
3500
|
COLOR_LCD = False
|
3501
|
NAME_LENGTH = 6
|
3502
|
|
3503
|
def set_options(self):
|
3504
|
"""This is to read the options from the image and set it in the
|
3505
|
environment, for now just the limits of the freqs in the VHF/UHF
|
3506
|
ranges"""
|
3507
|
|
3508
|
# setting the correct ranges for each radio type
|
3509
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
3510
|
# the model 2501+220 has a segment in 220
|
3511
|
# and a different position in the memmap
|
3512
|
# also the QYT KT8900R
|
3513
|
ranges = self._memobj.ranges220
|
3514
|
else:
|
3515
|
ranges = self._memobj.ranges
|
3516
|
|
3517
|
# the normal dual bands
|
3518
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
3519
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
3520
|
|
3521
|
# DEBUG
|
3522
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
3523
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
3524
|
|
3525
|
# 220Mhz radios case
|
3526
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
3527
|
vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
|
3528
|
LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
|
3529
|
self._220_range = vhf2
|
3530
|
|
3531
|
# set the class with the real data
|
3532
|
self._vhf_range = vhf
|
3533
|
self._uhf_range = uhf
|
3534
|
|
3535
|
def process_mmap(self):
|
3536
|
"""Process the mem map into the mem object"""
|
3537
|
|
3538
|
# Get it
|
3539
|
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
|
3540
|
|
3541
|
# load specific parameters from the radio image
|
3542
|
self.set_options()
|
3543
|
|
3544
|
|
3545
|
# Declaring Aliases (Clones of the real radios)
|
3546
|
class JT2705M(chirp_common.Alias):
|
3547
|
VENDOR = "Jetstream"
|
3548
|
MODEL = "JT2705M"
|
3549
|
|
3550
|
|
3551
|
class JT6188Mini(chirp_common.Alias):
|
3552
|
VENDOR = "Juentai"
|
3553
|
MODEL = "JT-6188 Mini"
|
3554
|
|
3555
|
|
3556
|
class JT6188Plus(chirp_common.Alias):
|
3557
|
VENDOR = "Juentai"
|
3558
|
MODEL = "JT-6188 Plus"
|
3559
|
|
3560
|
|
3561
|
class SSGT890(chirp_common.Alias):
|
3562
|
VENDOR = "Sainsonic"
|
3563
|
MODEL = "GT-890"
|
3564
|
|
3565
|
|
3566
|
class ZastoneMP300(chirp_common.Alias):
|
3567
|
VENDOR = "Zastone"
|
3568
|
MODEL = "MP-300"
|
3569
|
|
3570
|
|
3571
|
# real radios
|
3572
|
@directory.register
|
3573
|
class UV2501(BTech):
|
3574
|
"""Baofeng Tech UV2501"""
|
3575
|
MODEL = "UV-2501"
|
3576
|
_fileid = [UV2501G3_fp,
|
3577
|
UV2501G2_fp,
|
3578
|
UV2501pp2_fp,
|
3579
|
UV2501pp_fp]
|
3580
|
|
3581
|
|
3582
|
@directory.register
|
3583
|
class UV2501_220(BTech):
|
3584
|
"""Baofeng Tech UV2501+220"""
|
3585
|
MODEL = "UV-2501+220"
|
3586
|
BANDS = 3
|
3587
|
_magic = MSTRING_220
|
3588
|
_fileid = [UV2501_220G3_fp,
|
3589
|
UV2501_220G2_fp,
|
3590
|
UV2501_220_fp,
|
3591
|
UV2501_220pp_fp]
|
3592
|
|
3593
|
|
3594
|
@directory.register
|
3595
|
class UV5001(BTech):
|
3596
|
"""Baofeng Tech UV5001"""
|
3597
|
MODEL = "UV-5001"
|
3598
|
_fileid = [UV5001G3_fp,
|
3599
|
UV5001G22_fp,
|
3600
|
UV5001G2_fp,
|
3601
|
UV5001alpha_fp,
|
3602
|
UV5001pp_fp]
|
3603
|
_power_levels = [chirp_common.PowerLevel("High", watts=50),
|
3604
|
chirp_common.PowerLevel("Low", watts=10)]
|
3605
|
|
3606
|
|
3607
|
@directory.register
|
3608
|
class MINI8900(BTech):
|
3609
|
"""WACCOM MINI-8900"""
|
3610
|
VENDOR = "WACCOM"
|
3611
|
MODEL = "MINI-8900"
|
3612
|
_magic = MSTRING_MINI8900
|
3613
|
_fileid = [MINI8900_fp, ]
|
3614
|
# Clones
|
3615
|
ALIASES = [JT6188Plus, ]
|
3616
|
|
3617
|
|
3618
|
@directory.register
|
3619
|
class KTUV980(BTech):
|
3620
|
"""QYT KT-UV980"""
|
3621
|
VENDOR = "QYT"
|
3622
|
MODEL = "KT-UV980"
|
3623
|
_vhf_range = (136000000, 175000000)
|
3624
|
_uhf_range = (400000000, 481000000)
|
3625
|
_magic = MSTRING_MINI8900
|
3626
|
_fileid = [KTUV980_fp, ]
|
3627
|
# Clones
|
3628
|
ALIASES = [JT2705M, ]
|
3629
|
|
3630
|
# Please note that there is a version of this radios that is a clone of the
|
3631
|
# Waccom Mini8900, maybe an early version?
|
3632
|
|
3633
|
|
3634
|
class OTGRadioV1(chirp_common.Alias):
|
3635
|
VENDOR = 'OTGSTUFF'
|
3636
|
MODEL = 'OTG Radio v1'
|
3637
|
|
3638
|
|
3639
|
@directory.register
|
3640
|
class KT9800(BTech):
|
3641
|
"""QYT KT8900"""
|
3642
|
VENDOR = "QYT"
|
3643
|
MODEL = "KT8900"
|
3644
|
_vhf_range = (136000000, 175000000)
|
3645
|
_uhf_range = (400000000, 481000000)
|
3646
|
_magic = MSTRING_KT8900
|
3647
|
_fileid = [KT8900_fp,
|
3648
|
KT8900_fp1,
|
3649
|
KT8900_fp2,
|
3650
|
KT8900_fp3,
|
3651
|
KT8900_fp4,
|
3652
|
KT8900_fp5,
|
3653
|
KT8900_fp6,
|
3654
|
KT8900_fp7]
|
3655
|
# Clones
|
3656
|
ALIASES = [JT6188Mini, SSGT890, ZastoneMP300]
|
3657
|
|
3658
|
|
3659
|
@directory.register
|
3660
|
class KT9800R(BTech):
|
3661
|
"""QYT KT8900R"""
|
3662
|
VENDOR = "QYT"
|
3663
|
MODEL = "KT8900R"
|
3664
|
BANDS = 3
|
3665
|
_vhf_range = (136000000, 175000000)
|
3666
|
_220_range = (240000000, 271000000)
|
3667
|
_uhf_range = (400000000, 481000000)
|
3668
|
_magic = MSTRING_KT8900R
|
3669
|
_fileid = [KT8900R_fp,
|
3670
|
KT8900R_fp1,
|
3671
|
KT8900R_fp2,
|
3672
|
KT8900R_fp3,
|
3673
|
KT8900R_fp4,
|
3674
|
KT8900R_fp5]
|
3675
|
|
3676
|
|
3677
|
@directory.register
|
3678
|
class LT588UV(BTech):
|
3679
|
"""LUITON LT-588UV"""
|
3680
|
VENDOR = "LUITON"
|
3681
|
MODEL = "LT-588UV"
|
3682
|
_vhf_range = (136000000, 175000000)
|
3683
|
_uhf_range = (400000000, 481000000)
|
3684
|
_magic = MSTRING_KT8900
|
3685
|
_fileid = [LT588UV_fp,
|
3686
|
LT588UV_fp1]
|
3687
|
_power_levels = [chirp_common.PowerLevel("High", watts=60),
|
3688
|
chirp_common.PowerLevel("Low", watts=10)]
|
3689
|
|
3690
|
|
3691
|
COLOR_MEM_FORMAT = """
|
3692
|
#seekto 0x0000;
|
3693
|
struct {
|
3694
|
lbcd rxfreq[4];
|
3695
|
lbcd txfreq[4];
|
3696
|
ul16 rxtone;
|
3697
|
ul16 txtone;
|
3698
|
u8 unknown0:4,
|
3699
|
scode:4;
|
3700
|
u8 unknown1:2,
|
3701
|
spmute:2,
|
3702
|
unknown2:2,
|
3703
|
optsig:2;
|
3704
|
u8 unknown3:3,
|
3705
|
scramble:1,
|
3706
|
unknown4:2,
|
3707
|
power:2;
|
3708
|
u8 unknown5:1,
|
3709
|
wide:1,
|
3710
|
unknown6:2,
|
3711
|
bcl:1,
|
3712
|
add:1,
|
3713
|
pttid:2;
|
3714
|
} memory[200];
|
3715
|
|
3716
|
#seekto 0x0E00;
|
3717
|
struct {
|
3718
|
u8 tmr;
|
3719
|
u8 unknown1;
|
3720
|
u8 sql;
|
3721
|
u8 unknown2;
|
3722
|
u8 mgain2;
|
3723
|
u8 tot;
|
3724
|
u8 apo;
|
3725
|
u8 unknown3;
|
3726
|
u8 abr;
|
3727
|
u8 beep;
|
3728
|
u8 unknown4[4];
|
3729
|
u8 dtmfst;
|
3730
|
u8 unknown5[2];
|
3731
|
u8 screv;
|
3732
|
u8 unknown6[2];
|
3733
|
u8 pttid;
|
3734
|
u8 pttlt;
|
3735
|
u8 unknown7;
|
3736
|
u8 emctp;
|
3737
|
u8 emcch;
|
3738
|
u8 sigbp;
|
3739
|
u8 unknown8;
|
3740
|
u8 camdf;
|
3741
|
u8 cbmdf;
|
3742
|
u8 ccmdf;
|
3743
|
u8 cdmdf;
|
3744
|
u8 langua;
|
3745
|
u8 sync; // BTech radios use this as the display sync
|
3746
|
// setting, other radios use this as the auto
|
3747
|
// keypad lock setting
|
3748
|
u8 mainfc;
|
3749
|
u8 mainbc;
|
3750
|
u8 menufc;
|
3751
|
u8 menubc;
|
3752
|
u8 stafc;
|
3753
|
u8 stabc;
|
3754
|
u8 sigfc;
|
3755
|
u8 sigbc;
|
3756
|
u8 rxfc;
|
3757
|
u8 txfc;
|
3758
|
u8 txdisp;
|
3759
|
u8 unknown9[5];
|
3760
|
u8 anil;
|
3761
|
u8 reps;
|
3762
|
u8 repm;
|
3763
|
u8 tmrmr;
|
3764
|
u8 ste;
|
3765
|
u8 rpste;
|
3766
|
u8 rptdl;
|
3767
|
u8 dtmfg;
|
3768
|
u8 mgain; // used by db25-g for ponyey
|
3769
|
u8 skiptx;
|
3770
|
u8 scmode;
|
3771
|
} settings;
|
3772
|
|
3773
|
#seekto 0x0E80;
|
3774
|
struct {
|
3775
|
u8 unknown1;
|
3776
|
u8 vfomr;
|
3777
|
u8 keylock;
|
3778
|
u8 unknown2;
|
3779
|
u8 unknown3:4,
|
3780
|
vfomren:1,
|
3781
|
unknown4:1,
|
3782
|
reseten:1,
|
3783
|
menuen:1;
|
3784
|
u8 unknown5[11];
|
3785
|
u8 dispab;
|
3786
|
u8 unknown6[2];
|
3787
|
u8 menu;
|
3788
|
u8 unknown7[7];
|
3789
|
u8 vfomra;
|
3790
|
u8 vfomrb;
|
3791
|
u8 vfomrc;
|
3792
|
u8 vfomrd;
|
3793
|
u8 mrcha;
|
3794
|
u8 mrchb;
|
3795
|
u8 mrchc;
|
3796
|
u8 mrchd;
|
3797
|
} settings2;
|
3798
|
|
3799
|
struct settings_vfo {
|
3800
|
u8 freq[8];
|
3801
|
u8 offset[6];
|
3802
|
u8 unknown2[2];
|
3803
|
ul16 rxtone;
|
3804
|
ul16 txtone;
|
3805
|
u8 scode;
|
3806
|
u8 spmute;
|
3807
|
u8 optsig;
|
3808
|
u8 scramble;
|
3809
|
u8 wide;
|
3810
|
u8 power;
|
3811
|
u8 shiftd;
|
3812
|
u8 step;
|
3813
|
u8 unknown3[4];
|
3814
|
};
|
3815
|
|
3816
|
#seekto 0x0F00;
|
3817
|
struct {
|
3818
|
struct settings_vfo a;
|
3819
|
struct settings_vfo b;
|
3820
|
struct settings_vfo c;
|
3821
|
struct settings_vfo d;
|
3822
|
} vfo;
|
3823
|
|
3824
|
#seekto 0x0F80;
|
3825
|
struct {
|
3826
|
char line1[8];
|
3827
|
char line2[8];
|
3828
|
char line3[8];
|
3829
|
char line4[8];
|
3830
|
char line5[8];
|
3831
|
char line6[8];
|
3832
|
char line7[8];
|
3833
|
char line8[8];
|
3834
|
} poweron_msg;
|
3835
|
|
3836
|
#seekto 0x1000;
|
3837
|
struct {
|
3838
|
char name[8];
|
3839
|
u8 unknown1[8];
|
3840
|
} names[200];
|
3841
|
|
3842
|
#seekto 0x2400;
|
3843
|
struct {
|
3844
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
3845
|
u8 group_tone;
|
3846
|
u8 repeat_tone;
|
3847
|
u8 unused[13];
|
3848
|
} _5tone_std_settings[15];
|
3849
|
|
3850
|
#seekto 0x2500;
|
3851
|
struct {
|
3852
|
u8 frame1[5];
|
3853
|
u8 frame2[5];
|
3854
|
u8 frame3[5];
|
3855
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
3856
|
} _5tone_codes[15];
|
3857
|
|
3858
|
#seekto 0x25F0;
|
3859
|
struct {
|
3860
|
u8 _5tone_delay1; // * 10ms
|
3861
|
u8 _5tone_delay2; // * 10ms
|
3862
|
u8 _5tone_delay3; // * 10ms
|
3863
|
u8 _5tone_first_digit_ext_length;
|
3864
|
u8 unknown1;
|
3865
|
u8 unknown2;
|
3866
|
u8 unknown3;
|
3867
|
u8 unknown4;
|
3868
|
u8 decode_standard;
|
3869
|
u8 unknown5:5,
|
3870
|
_5tone_decode_call_frame3:1,
|
3871
|
_5tone_decode_call_frame2:1,
|
3872
|
_5tone_decode_call_frame1:1;
|
3873
|
u8 unknown6:5,
|
3874
|
_5tone_decode_disp_frame3:1,
|
3875
|
_5tone_decode_disp_frame2:1,
|
3876
|
_5tone_decode_disp_frame1:1;
|
3877
|
u8 decode_reset_time; // * 100 + 100ms
|
3878
|
} _5tone_settings;
|
3879
|
|
3880
|
#seekto 0x2900;
|
3881
|
struct {
|
3882
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
3883
|
} dtmf_codes[15];
|
3884
|
|
3885
|
#seekto 0x29F0;
|
3886
|
struct {
|
3887
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
3888
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
3889
|
u8 unknown0[14];
|
3890
|
u8 inspection[16];
|
3891
|
u8 monitor[16];
|
3892
|
u8 alarmcode[16];
|
3893
|
u8 stun[16];
|
3894
|
u8 kill[16];
|
3895
|
u8 revive[16];
|
3896
|
u8 unknown1[16];
|
3897
|
u8 unknown2[16];
|
3898
|
u8 unknown3[16];
|
3899
|
u8 unknown4[16];
|
3900
|
u8 unknown5[16];
|
3901
|
u8 unknown6[16];
|
3902
|
u8 unknown7[16];
|
3903
|
u8 masterid[16];
|
3904
|
u8 viceid[16];
|
3905
|
u8 unused01:7,
|
3906
|
mastervice:1;
|
3907
|
u8 unused02:3,
|
3908
|
mrevive:1,
|
3909
|
mkill:1,
|
3910
|
mstun:1,
|
3911
|
mmonitor:1,
|
3912
|
minspection:1;
|
3913
|
u8 unused03:3,
|
3914
|
vrevive:1,
|
3915
|
vkill:1,
|
3916
|
vstun:1,
|
3917
|
vmonitor:1,
|
3918
|
vinspection:1;
|
3919
|
u8 unused04:6,
|
3920
|
txdisable:1,
|
3921
|
rxdisable:1;
|
3922
|
u8 groupcode;
|
3923
|
u8 spacecode;
|
3924
|
u8 delayproctime; // * 100 + 100ms
|
3925
|
u8 resettime; // * 100 + 100ms
|
3926
|
} dtmf_settings;
|
3927
|
|
3928
|
#seekto 0x2D00;
|
3929
|
struct {
|
3930
|
struct {
|
3931
|
ul16 freq1;
|
3932
|
u8 unused01[6];
|
3933
|
ul16 freq2;
|
3934
|
u8 unused02[6];
|
3935
|
} _2tone_encode[15];
|
3936
|
u8 duration_1st_tone; // *10ms
|
3937
|
u8 duration_2nd_tone; // *10ms
|
3938
|
u8 duration_gap; // *10ms
|
3939
|
u8 unused03[13];
|
3940
|
struct {
|
3941
|
struct {
|
3942
|
u8 dec; // one out of LIST_2TONE_DEC
|
3943
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
3944
|
u8 alert; // 1-16
|
3945
|
} decs[4];
|
3946
|
u8 unused04[4];
|
3947
|
} _2tone_decode[15];
|
3948
|
u8 unused05[16];
|
3949
|
|
3950
|
struct {
|
3951
|
ul16 freqA;
|
3952
|
ul16 freqB;
|
3953
|
ul16 freqC;
|
3954
|
ul16 freqD;
|
3955
|
// unknown what those values mean, but they are
|
3956
|
// derived from configured frequencies
|
3957
|
ul16 derived_from_freqA; // 2304000/freqA
|
3958
|
ul16 derived_from_freqB; // 2304000/freqB
|
3959
|
ul16 derived_from_freqC; // 2304000/freqC
|
3960
|
ul16 derived_from_freqD; // 2304000/freqD
|
3961
|
}freqs[15];
|
3962
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
3963
|
} _2tone;
|
3964
|
|
3965
|
#seekto 0x3D80;
|
3966
|
struct {
|
3967
|
u8 vhf_low[3];
|
3968
|
u8 vhf_high[3];
|
3969
|
u8 unknown1[4];
|
3970
|
u8 unknown2[6];
|
3971
|
u8 vhf2_low[3];
|
3972
|
u8 vhf2_high[3];
|
3973
|
u8 unknown3[4];
|
3974
|
u8 unknown4[6];
|
3975
|
u8 uhf_low[3];
|
3976
|
u8 uhf_high[3];
|
3977
|
u8 unknown5[4];
|
3978
|
u8 unknown6[6];
|
3979
|
u8 uhf2_low[3];
|
3980
|
u8 uhf2_high[3];
|
3981
|
} ranges;
|
3982
|
|
3983
|
#seekto 0x3F70;
|
3984
|
struct {
|
3985
|
char fp[6];
|
3986
|
} fingerprint;
|
3987
|
|
3988
|
"""
|
3989
|
|
3990
|
|
3991
|
class BTechColor(BTechMobileCommon):
|
3992
|
"""BTECH's Color LCD Mobile and alike radios"""
|
3993
|
COLOR_LCD = True
|
3994
|
NAME_LENGTH = 8
|
3995
|
LIST_TMR = LIST_TMR16
|
3996
|
|
3997
|
def process_mmap(self):
|
3998
|
"""Process the mem map into the mem object"""
|
3999
|
|
4000
|
# Get it
|
4001
|
self._memobj = bitwise.parse(COLOR_MEM_FORMAT, self._mmap)
|
4002
|
|
4003
|
# load specific parameters from the radio image
|
4004
|
self.set_options()
|
4005
|
|
4006
|
def set_options(self):
|
4007
|
"""This is to read the options from the image and set it in the
|
4008
|
environment, for now just the limits of the freqs in the VHF/UHF
|
4009
|
ranges"""
|
4010
|
|
4011
|
# setting the correct ranges for each radio type
|
4012
|
ranges = self._memobj.ranges
|
4013
|
|
4014
|
# the normal dual bands
|
4015
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
4016
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
4017
|
|
4018
|
# DEBUG
|
4019
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
4020
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
4021
|
|
4022
|
# the additional bands
|
4023
|
if self.MODEL in ["UV-25X4", "KT7900D"]:
|
4024
|
# 200Mhz band
|
4025
|
vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
|
4026
|
LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
|
4027
|
self._220_range = vhf2
|
4028
|
|
4029
|
# 350Mhz band
|
4030
|
uhf2 = _decode_ranges(ranges.uhf2_low, ranges.uhf2_high)
|
4031
|
LOG.info("Radio ranges: UHF(350) %d to %d" % uhf2)
|
4032
|
self._350_range = uhf2
|
4033
|
|
4034
|
# set the class with the real data
|
4035
|
self._vhf_range = vhf
|
4036
|
self._uhf_range = uhf
|
4037
|
|
4038
|
|
4039
|
# Declaring Aliases (Clones of the real radios)
|
4040
|
class SKT8900D(chirp_common.Alias):
|
4041
|
VENDOR = "Surecom"
|
4042
|
MODEL = "S-KT8900D"
|
4043
|
|
4044
|
|
4045
|
class QB25(chirp_common.Alias):
|
4046
|
VENDOR = "Radioddity"
|
4047
|
MODEL = "QB25"
|
4048
|
|
4049
|
|
4050
|
# real radios
|
4051
|
@directory.register
|
4052
|
class UV25X2(BTechColor):
|
4053
|
"""Baofeng Tech UV25X2"""
|
4054
|
MODEL = "UV-25X2"
|
4055
|
BANDS = 2
|
4056
|
_vhf_range = (130000000, 180000000)
|
4057
|
_uhf_range = (400000000, 521000000)
|
4058
|
_magic = MSTRING_UV25X2
|
4059
|
_fileid = [UV25X2_fp, ]
|
4060
|
|
4061
|
|
4062
|
@directory.register
|
4063
|
class UV25X4(BTechColor):
|
4064
|
"""Baofeng Tech UV25X4"""
|
4065
|
MODEL = "UV-25X4"
|
4066
|
BANDS = 4
|
4067
|
_vhf_range = (130000000, 180000000)
|
4068
|
_220_range = (200000000, 271000000)
|
4069
|
_uhf_range = (400000000, 521000000)
|
4070
|
_350_range = (350000000, 391000000)
|
4071
|
_magic = MSTRING_UV25X4
|
4072
|
_fileid = [UV25X4_fp, ]
|
4073
|
|
4074
|
|
4075
|
@directory.register
|
4076
|
class UV50X2(BTechColor):
|
4077
|
"""Baofeng Tech UV50X2"""
|
4078
|
MODEL = "UV-50X2"
|
4079
|
BANDS = 2
|
4080
|
_vhf_range = (130000000, 180000000)
|
4081
|
_uhf_range = (400000000, 521000000)
|
4082
|
_magic = MSTRING_UV25X2
|
4083
|
_fileid = [UV50X2_fp, ]
|
4084
|
_power_levels = [chirp_common.PowerLevel("High", watts=50),
|
4085
|
chirp_common.PowerLevel("Low", watts=10)]
|
4086
|
|
4087
|
|
4088
|
@directory.register
|
4089
|
class KT7900D(BTechColor):
|
4090
|
"""QYT KT7900D"""
|
4091
|
VENDOR = "QYT"
|
4092
|
MODEL = "KT7900D"
|
4093
|
BANDS = 4
|
4094
|
LIST_TMR = LIST_TMR15
|
4095
|
_vhf_range = (136000000, 175000000)
|
4096
|
_220_range = (200000000, 271000000)
|
4097
|
_uhf_range = (400000000, 481000000)
|
4098
|
_350_range = (350000000, 371000000)
|
4099
|
_magic = MSTRING_KT8900D
|
4100
|
_fileid = [KT7900D_fp, KT7900D_fp1, KT7900D_fp2, KT7900D_fp3, KT7900D_fp4,
|
4101
|
KT7900D_fp5, KT7900D_fp6, KT7900D_fp7, KT7900D_fp8, QB25_fp, ]
|
4102
|
# Clones
|
4103
|
ALIASES = [SKT8900D, QB25, ]
|
4104
|
|
4105
|
|
4106
|
@directory.register
|
4107
|
class KT8900D(BTechColor):
|
4108
|
"""QYT KT8900D"""
|
4109
|
VENDOR = "QYT"
|
4110
|
MODEL = "KT8900D"
|
4111
|
BANDS = 2
|
4112
|
LIST_TMR = LIST_TMR15
|
4113
|
_vhf_range = (136000000, 175000000)
|
4114
|
_uhf_range = (400000000, 481000000)
|
4115
|
_magic = MSTRING_KT8900D
|
4116
|
_fileid = [KT8900D_fp3, KT8900D_fp2, KT8900D_fp1, KT8900D_fp]
|
4117
|
|
4118
|
# Clones
|
4119
|
ALIASES = [OTGRadioV1]
|
4120
|
|
4121
|
|
4122
|
@directory.register
|
4123
|
class KT5800(BTechColor):
|
4124
|
"""QYT KT5800"""
|
4125
|
VENDOR = "QYT"
|
4126
|
MODEL = "KT5800"
|
4127
|
BANDS = 2
|
4128
|
LIST_TMR = LIST_TMR15
|
4129
|
_vhf_range = (136000000, 175000000)
|
4130
|
_uhf_range = (400000000, 481000000)
|
4131
|
_magic = MSTRING_KT8900D
|
4132
|
_fileid = [KT5800_fp, ]
|
4133
|
|
4134
|
|
4135
|
@directory.register
|
4136
|
class KT980PLUS(BTechColor):
|
4137
|
"""QYT KT980PLUS"""
|
4138
|
VENDOR = "QYT"
|
4139
|
MODEL = "KT980PLUS"
|
4140
|
BANDS = 2
|
4141
|
LIST_TMR = LIST_TMR15
|
4142
|
_vhf_range = (136000000, 175000000)
|
4143
|
_uhf_range = (400000000, 481000000)
|
4144
|
_magic = MSTRING_KT8900D
|
4145
|
_fileid = [KT980PLUS_fp1, KT980PLUS_fp]
|
4146
|
_power_levels = [chirp_common.PowerLevel("High", watts=75),
|
4147
|
chirp_common.PowerLevel("Low", watts=55)]
|
4148
|
|
4149
|
@classmethod
|
4150
|
def match_model(cls, filedata, filename):
|
4151
|
# This model is only ever matched via metadata
|
4152
|
return False
|
4153
|
|
4154
|
|
4155
|
@directory.register
|
4156
|
class DB25G(BTechColor):
|
4157
|
"""Radioddity DB25-G"""
|
4158
|
VENDOR = "Radioddity"
|
4159
|
MODEL = "DB25-G"
|
4160
|
BANDS = 2
|
4161
|
LIST_TMR = LIST_TMR15
|
4162
|
_vhf_range = (136000000, 175000000)
|
4163
|
_uhf_range = (400000000, 481000000)
|
4164
|
_magic = MSTRING_KT8900D
|
4165
|
_fileid = [DB25G_fp1, DB25G_fp]
|
4166
|
_gmrs = True
|
4167
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
4168
|
chirp_common.PowerLevel("Mid", watts=15),
|
4169
|
chirp_common.PowerLevel("Low", watts=5)]
|
4170
|
|
4171
|
@classmethod
|
4172
|
def match_model(cls, filedata, filename):
|
4173
|
# This model is only ever matched via metadata
|
4174
|
return False
|
4175
|
|
4176
|
|
4177
|
GMRS_MEM_FORMAT = """
|
4178
|
#seekto 0x0000;
|
4179
|
struct {
|
4180
|
lbcd rxfreq[4];
|
4181
|
lbcd txfreq[4];
|
4182
|
ul16 rxtone;
|
4183
|
ul16 txtone;
|
4184
|
u8 unknown0:4,
|
4185
|
scode:4;
|
4186
|
u8 unknown1:2,
|
4187
|
spmute:2,
|
4188
|
unknown2:2,
|
4189
|
optsig:2;
|
4190
|
u8 unknown3:3,
|
4191
|
scramble:1,
|
4192
|
unknown4:2,
|
4193
|
power:2;
|
4194
|
u8 unknown5:1,
|
4195
|
wide:1,
|
4196
|
unknown6:2,
|
4197
|
bcl:1,
|
4198
|
add:1,
|
4199
|
pttid:2;
|
4200
|
} memory[256];
|
4201
|
|
4202
|
#seekto 0x1000;
|
4203
|
struct {
|
4204
|
char name[7];
|
4205
|
u8 unknown1[9];
|
4206
|
} names[256];
|
4207
|
|
4208
|
#seekto 0x2400;
|
4209
|
struct {
|
4210
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
4211
|
u8 group_tone;
|
4212
|
u8 repeat_tone;
|
4213
|
u8 unused[13];
|
4214
|
} _5tone_std_settings[15];
|
4215
|
|
4216
|
#seekto 0x2500;
|
4217
|
struct {
|
4218
|
u8 frame1[5];
|
4219
|
u8 frame2[5];
|
4220
|
u8 frame3[5];
|
4221
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
4222
|
} _5tone_codes[15];
|
4223
|
|
4224
|
#seekto 0x25F0;
|
4225
|
struct {
|
4226
|
u8 _5tone_delay1; // * 10ms
|
4227
|
u8 _5tone_delay2; // * 10ms
|
4228
|
u8 _5tone_delay3; // * 10ms
|
4229
|
u8 _5tone_first_digit_ext_length;
|
4230
|
u8 unknown1;
|
4231
|
u8 unknown2;
|
4232
|
u8 unknown3;
|
4233
|
u8 unknown4;
|
4234
|
u8 decode_standard;
|
4235
|
u8 unknown5:5,
|
4236
|
_5tone_decode_call_frame3:1,
|
4237
|
_5tone_decode_call_frame2:1,
|
4238
|
_5tone_decode_call_frame1:1;
|
4239
|
u8 unknown6:5,
|
4240
|
_5tone_decode_disp_frame3:1,
|
4241
|
_5tone_decode_disp_frame2:1,
|
4242
|
_5tone_decode_disp_frame1:1;
|
4243
|
u8 decode_reset_time; // * 100 + 100ms
|
4244
|
} _5tone_settings;
|
4245
|
|
4246
|
#seekto 0x2900;
|
4247
|
struct {
|
4248
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
4249
|
} dtmf_codes[15];
|
4250
|
|
4251
|
#seekto 0x29F0;
|
4252
|
struct {
|
4253
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
4254
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
4255
|
u8 unknown0[14];
|
4256
|
u8 inspection[16];
|
4257
|
u8 monitor[16];
|
4258
|
u8 alarmcode[16];
|
4259
|
u8 stun[16];
|
4260
|
u8 kill[16];
|
4261
|
u8 revive[16];
|
4262
|
u8 unknown1[16];
|
4263
|
u8 unknown2[16];
|
4264
|
u8 unknown3[16];
|
4265
|
u8 unknown4[16];
|
4266
|
u8 unknown5[16];
|
4267
|
u8 unknown6[16];
|
4268
|
u8 unknown7[16];
|
4269
|
u8 masterid[16];
|
4270
|
u8 viceid[16];
|
4271
|
u8 unused01:7,
|
4272
|
mastervice:1;
|
4273
|
u8 unused02:3,
|
4274
|
mrevive:1,
|
4275
|
mkill:1,
|
4276
|
mstun:1,
|
4277
|
mmonitor:1,
|
4278
|
minspection:1;
|
4279
|
u8 unused03:3,
|
4280
|
vrevive:1,
|
4281
|
vkill:1,
|
4282
|
vstun:1,
|
4283
|
vmonitor:1,
|
4284
|
vinspection:1;
|
4285
|
u8 unused04:6,
|
4286
|
txdisable:1,
|
4287
|
rxdisable:1;
|
4288
|
u8 groupcode;
|
4289
|
u8 spacecode;
|
4290
|
u8 delayproctime; // * 100 + 100ms
|
4291
|
u8 resettime; // * 100 + 100ms
|
4292
|
} dtmf_settings;
|
4293
|
|
4294
|
#seekto 0x2D00;
|
4295
|
struct {
|
4296
|
struct {
|
4297
|
ul16 freq1;
|
4298
|
u8 unused01[6];
|
4299
|
ul16 freq2;
|
4300
|
u8 unused02[6];
|
4301
|
} _2tone_encode[15];
|
4302
|
u8 duration_1st_tone; // *10ms
|
4303
|
u8 duration_2nd_tone; // *10ms
|
4304
|
u8 duration_gap; // *10ms
|
4305
|
u8 unused03[13];
|
4306
|
struct {
|
4307
|
struct {
|
4308
|
u8 dec; // one out of LIST_2TONE_DEC
|
4309
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
4310
|
u8 alert; // 1-16
|
4311
|
} decs[4];
|
4312
|
u8 unused04[4];
|
4313
|
} _2tone_decode[15];
|
4314
|
u8 unused05[16];
|
4315
|
|
4316
|
struct {
|
4317
|
ul16 freqA;
|
4318
|
ul16 freqB;
|
4319
|
ul16 freqC;
|
4320
|
ul16 freqD;
|
4321
|
// unknown what those values mean, but they are
|
4322
|
// derived from configured frequencies
|
4323
|
ul16 derived_from_freqA; // 2304000/freqA
|
4324
|
ul16 derived_from_freqB; // 2304000/freqB
|
4325
|
ul16 derived_from_freqC; // 2304000/freqC
|
4326
|
ul16 derived_from_freqD; // 2304000/freqD
|
4327
|
}freqs[15];
|
4328
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
4329
|
} _2tone;
|
4330
|
|
4331
|
#seekto 0x3000;
|
4332
|
struct {
|
4333
|
u8 freq[8];
|
4334
|
char broadcast_station_name[6];
|
4335
|
u8 unknown[2];
|
4336
|
} fm_radio_preset[16];
|
4337
|
|
4338
|
#seekto 0x3200;
|
4339
|
struct {
|
4340
|
u8 tmr;
|
4341
|
u8 unknown1;
|
4342
|
u8 sql;
|
4343
|
u8 unknown2;
|
4344
|
u8 autolk;
|
4345
|
u8 tot;
|
4346
|
u8 apo;
|
4347
|
u8 unknown3;
|
4348
|
u8 abr;
|
4349
|
u8 beep;
|
4350
|
u8 unknown4[4];
|
4351
|
u8 dtmfst;
|
4352
|
u8 unknown5[2];
|
4353
|
u8 screv;
|
4354
|
u8 unknown6[2];
|
4355
|
u8 pttid;
|
4356
|
u8 pttlt;
|
4357
|
u8 unknown7;
|
4358
|
u8 emctp;
|
4359
|
u8 emcch;
|
4360
|
u8 sigbp;
|
4361
|
u8 unknown8;
|
4362
|
u8 camdf;
|
4363
|
u8 cbmdf;
|
4364
|
u8 ccmdf;
|
4365
|
u8 cdmdf;
|
4366
|
u8 langua;
|
4367
|
u8 sync;
|
4368
|
|
4369
|
|
4370
|
u8 stfc;
|
4371
|
u8 mffc;
|
4372
|
u8 sfafc;
|
4373
|
u8 sfbfc;
|
4374
|
u8 sfcfc;
|
4375
|
u8 sfdfc;
|
4376
|
u8 subfc;
|
4377
|
u8 fmfc;
|
4378
|
u8 sigfc;
|
4379
|
u8 modfc;
|
4380
|
u8 menufc;
|
4381
|
u8 txfc;
|
4382
|
u8 txdisp;
|
4383
|
u8 unknown9[5];
|
4384
|
u8 anil;
|
4385
|
u8 reps;
|
4386
|
u8 repm;
|
4387
|
u8 tmrmr;
|
4388
|
u8 ste;
|
4389
|
u8 rpste;
|
4390
|
u8 rptdl;
|
4391
|
u8 dtmfg;
|
4392
|
u8 mgain;
|
4393
|
u8 skiptx;
|
4394
|
u8 scmode;
|
4395
|
} settings;
|
4396
|
|
4397
|
#seekto 0x3280;
|
4398
|
struct {
|
4399
|
u8 unknown1;
|
4400
|
u8 vfomr;
|
4401
|
u8 keylock;
|
4402
|
u8 unknown2;
|
4403
|
u8 unknown3:4,
|
4404
|
vfomren:1,
|
4405
|
unknown4:1,
|
4406
|
reseten:1,
|
4407
|
menuen:1;
|
4408
|
u8 unknown5[11];
|
4409
|
u8 dispab;
|
4410
|
u8 unknown6[2];
|
4411
|
u8 smenu;
|
4412
|
u8 unknown7[7];
|
4413
|
u8 vfomra;
|
4414
|
u8 vfomrb;
|
4415
|
u8 vfomrc;
|
4416
|
u8 vfomrd;
|
4417
|
u8 mrcha;
|
4418
|
u8 mrchb;
|
4419
|
u8 mrchc;
|
4420
|
u8 mrchd;
|
4421
|
} settings2;
|
4422
|
|
4423
|
struct settings_vfo {
|
4424
|
u8 freq[8];
|
4425
|
u8 offset[6];
|
4426
|
u8 unknown2[2];
|
4427
|
ul16 rxtone;
|
4428
|
ul16 txtone;
|
4429
|
u8 scode;
|
4430
|
u8 spmute;
|
4431
|
u8 optsig;
|
4432
|
u8 scramble;
|
4433
|
u8 wide;
|
4434
|
u8 power;
|
4435
|
u8 shiftd;
|
4436
|
u8 step;
|
4437
|
u8 unknown3[4];
|
4438
|
};
|
4439
|
|
4440
|
#seekto 0x3300;
|
4441
|
struct {
|
4442
|
struct settings_vfo a;
|
4443
|
struct settings_vfo b;
|
4444
|
struct settings_vfo c;
|
4445
|
struct settings_vfo d;
|
4446
|
} vfo;
|
4447
|
|
4448
|
#seekto 0x3D80;
|
4449
|
struct {
|
4450
|
u8 vhf_low[3];
|
4451
|
u8 vhf_high[3];
|
4452
|
u8 unknown1[4];
|
4453
|
u8 unknown2[6];
|
4454
|
u8 vhf2_low[3];
|
4455
|
u8 vhf2_high[3];
|
4456
|
u8 unknown3[4];
|
4457
|
u8 unknown4[6];
|
4458
|
u8 uhf_low[3];
|
4459
|
u8 uhf_high[3];
|
4460
|
u8 unknown5[4];
|
4461
|
u8 unknown6[6];
|
4462
|
u8 uhf2_low[3];
|
4463
|
u8 uhf2_high[3];
|
4464
|
} ranges;
|
4465
|
|
4466
|
#seekto 0x33B0;
|
4467
|
struct {
|
4468
|
char line[16];
|
4469
|
} static_msg;
|
4470
|
|
4471
|
#seekto 0x3F70;
|
4472
|
struct {
|
4473
|
char fp[6];
|
4474
|
} fingerprint;
|
4475
|
|
4476
|
"""
|
4477
|
|
4478
|
|
4479
|
class BTechGMRS(BTechMobileCommon):
|
4480
|
"""BTECH's GMRS Mobile"""
|
4481
|
COLOR_LCD = True
|
4482
|
COLOR_LCD2 = True
|
4483
|
NAME_LENGTH = 7
|
4484
|
UPLOAD_MEM_SIZE = 0X3400
|
4485
|
|
4486
|
def process_mmap(self):
|
4487
|
"""Process the mem map into the mem object"""
|
4488
|
|
4489
|
# Get it
|
4490
|
self._memobj = bitwise.parse(GMRS_MEM_FORMAT, self._mmap)
|
4491
|
|
4492
|
# load specific parameters from the radio image
|
4493
|
self.set_options()
|
4494
|
|
4495
|
def set_options(self):
|
4496
|
"""This is to read the options from the image and set it in the
|
4497
|
environment, for now just the limits of the freqs in the VHF/UHF
|
4498
|
ranges"""
|
4499
|
|
4500
|
# setting the correct ranges for each radio type
|
4501
|
ranges = self._memobj.ranges
|
4502
|
|
4503
|
# the normal dual bands
|
4504
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
4505
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
4506
|
|
4507
|
# DEBUG
|
4508
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
4509
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
4510
|
|
4511
|
# set the class with the real data
|
4512
|
self._vhf_range = vhf
|
4513
|
self._uhf_range = uhf
|
4514
|
|
4515
|
|
4516
|
# real radios
|
4517
|
@directory.register
|
4518
|
class GMRS50X1(BTechGMRS):
|
4519
|
"""Baofeng Tech GMRS50X1"""
|
4520
|
MODEL = "GMRS-50X1"
|
4521
|
BANDS = 2
|
4522
|
LIST_TMR = LIST_TMR16
|
4523
|
_power_levels = [chirp_common.PowerLevel("High", watts=50),
|
4524
|
chirp_common.PowerLevel("Mid", watts=10),
|
4525
|
chirp_common.PowerLevel("Low", watts=5)]
|
4526
|
_vhf_range = (136000000, 175000000)
|
4527
|
_uhf_range = (400000000, 521000000)
|
4528
|
_upper = 255
|
4529
|
_magic = MSTRING_GMRS50X1
|
4530
|
_fileid = [GMRS50X1_fp1, GMRS50X1_fp, ]
|
4531
|
|
4532
|
|
4533
|
COLORHT_MEM_FORMAT = """
|
4534
|
#seekto 0x0000;
|
4535
|
struct {
|
4536
|
lbcd rxfreq[4];
|
4537
|
lbcd txfreq[4];
|
4538
|
ul16 rxtone;
|
4539
|
ul16 txtone;
|
4540
|
u8 unknown0:4,
|
4541
|
scode:4;
|
4542
|
u8 unknown1:2,
|
4543
|
spmute:2,
|
4544
|
unknown2:2,
|
4545
|
optsig:2;
|
4546
|
u8 unknown3:3,
|
4547
|
scramble:1,
|
4548
|
unknown4:3,
|
4549
|
power:1;
|
4550
|
u8 unknown5:1,
|
4551
|
wide:1,
|
4552
|
unknown6:2,
|
4553
|
bcl:1,
|
4554
|
add:1,
|
4555
|
pttid:2;
|
4556
|
} memory[200];
|
4557
|
|
4558
|
#seekto 0x0E00;
|
4559
|
struct {
|
4560
|
u8 tmr;
|
4561
|
u8 unknownE01;
|
4562
|
u8 sql;
|
4563
|
u8 unknownE03[2];
|
4564
|
u8 tot;
|
4565
|
u8 save;
|
4566
|
u8 unknownE07;
|
4567
|
u8 abr;
|
4568
|
u8 beep;
|
4569
|
u8 unknownE0A[4];
|
4570
|
u8 dsub;
|
4571
|
u8 dtmfst;
|
4572
|
u8 screv;
|
4573
|
u8 unknownE11[3];
|
4574
|
u8 pttid;
|
4575
|
u8 unknownE15;
|
4576
|
u8 pttlt;
|
4577
|
u8 unknownE17;
|
4578
|
u8 emctp;
|
4579
|
u8 emcch;
|
4580
|
u8 sigbp;
|
4581
|
u8 unknownE1B;
|
4582
|
u8 camdf;
|
4583
|
u8 cbmdf;
|
4584
|
u8 ccmdf;
|
4585
|
u8 cdmdf;
|
4586
|
u8 langua;
|
4587
|
u8 voice;
|
4588
|
u8 vox;
|
4589
|
u8 voxt;
|
4590
|
u8 sync; // BTech radios use this as the display sync setting
|
4591
|
// other radios use this as the auto keypad lock setting
|
4592
|
u8 stfc;
|
4593
|
u8 mffc;
|
4594
|
u8 sfafc;
|
4595
|
u8 sfbfc;
|
4596
|
u8 sfcfc;
|
4597
|
u8 sfdfc;
|
4598
|
u8 subfc;
|
4599
|
u8 fmfc;
|
4600
|
u8 sigfc;
|
4601
|
u8 menufc;
|
4602
|
u8 txfc;
|
4603
|
u8 rxfc;
|
4604
|
u8 unknownE31[5];
|
4605
|
u8 anil;
|
4606
|
u8 reps;
|
4607
|
u8 tmrmr;
|
4608
|
u8 ste;
|
4609
|
u8 rpste;
|
4610
|
u8 rptdl;
|
4611
|
u8 dtmfg;
|
4612
|
u8 tmrtx;
|
4613
|
} settings;
|
4614
|
|
4615
|
#seekto 0x0E80;
|
4616
|
struct {
|
4617
|
u8 unknown1;
|
4618
|
u8 vfomr;
|
4619
|
u8 keylock;
|
4620
|
u8 unknown2;
|
4621
|
u8 unknown3:4,
|
4622
|
vfomren:1,
|
4623
|
unknown4:1,
|
4624
|
reseten:1,
|
4625
|
menuen:1;
|
4626
|
u8 unknown5[11];
|
4627
|
u8 dispab;
|
4628
|
u8 unknown6[2];
|
4629
|
u8 menu;
|
4630
|
u8 unknown7[7];
|
4631
|
u8 vfomra;
|
4632
|
u8 vfomrb;
|
4633
|
u8 vfomrc;
|
4634
|
u8 vfomrd;
|
4635
|
u8 mrcha;
|
4636
|
u8 mrchb;
|
4637
|
u8 mrchc;
|
4638
|
u8 mrchd;
|
4639
|
} settings2;
|
4640
|
|
4641
|
struct settings_vfo {
|
4642
|
u8 freq[8];
|
4643
|
u8 offset[6];
|
4644
|
u8 unknown2[2];
|
4645
|
ul16 rxtone;
|
4646
|
ul16 txtone;
|
4647
|
u8 scode;
|
4648
|
u8 spmute;
|
4649
|
u8 optsig;
|
4650
|
u8 scramble;
|
4651
|
u8 wide;
|
4652
|
u8 power;
|
4653
|
u8 shiftd;
|
4654
|
u8 step;
|
4655
|
u8 unknown3[4];
|
4656
|
};
|
4657
|
|
4658
|
#seekto 0x0F00;
|
4659
|
struct {
|
4660
|
struct settings_vfo a;
|
4661
|
struct settings_vfo b;
|
4662
|
struct settings_vfo c;
|
4663
|
struct settings_vfo d;
|
4664
|
} vfo;
|
4665
|
|
4666
|
#seekto 0x0FE0;
|
4667
|
struct {
|
4668
|
char line[16];
|
4669
|
} static_msg;
|
4670
|
|
4671
|
#seekto 0x1000;
|
4672
|
struct {
|
4673
|
char name[8];
|
4674
|
u8 unknown1[8];
|
4675
|
} names[200];
|
4676
|
|
4677
|
#seekto 0x2400;
|
4678
|
struct {
|
4679
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
4680
|
u8 group_tone;
|
4681
|
u8 repeat_tone;
|
4682
|
u8 unused[13];
|
4683
|
} _5tone_std_settings[15];
|
4684
|
|
4685
|
#seekto 0x2500;
|
4686
|
struct {
|
4687
|
u8 frame1[5];
|
4688
|
u8 frame2[5];
|
4689
|
u8 frame3[5];
|
4690
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
4691
|
} _5tone_codes[15];
|
4692
|
|
4693
|
#seekto 0x25F0;
|
4694
|
struct {
|
4695
|
u8 _5tone_delay1; // * 10ms
|
4696
|
u8 _5tone_delay2; // * 10ms
|
4697
|
u8 _5tone_delay3; // * 10ms
|
4698
|
u8 _5tone_first_digit_ext_length;
|
4699
|
u8 unknown1;
|
4700
|
u8 unknown2;
|
4701
|
u8 unknown3;
|
4702
|
u8 unknown4;
|
4703
|
u8 decode_standard;
|
4704
|
u8 unknown5:5,
|
4705
|
_5tone_decode_call_frame3:1,
|
4706
|
_5tone_decode_call_frame2:1,
|
4707
|
_5tone_decode_call_frame1:1;
|
4708
|
u8 unknown6:5,
|
4709
|
_5tone_decode_disp_frame3:1,
|
4710
|
_5tone_decode_disp_frame2:1,
|
4711
|
_5tone_decode_disp_frame1:1;
|
4712
|
u8 decode_reset_time; // * 100 + 100ms
|
4713
|
} _5tone_settings;
|
4714
|
|
4715
|
#seekto 0x2900;
|
4716
|
struct {
|
4717
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
4718
|
} dtmf_codes[15];
|
4719
|
|
4720
|
#seekto 0x29F0;
|
4721
|
struct {
|
4722
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
4723
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
4724
|
u8 unknown0[14];
|
4725
|
u8 inspection[16];
|
4726
|
u8 monitor[16];
|
4727
|
u8 alarmcode[16];
|
4728
|
u8 stun[16];
|
4729
|
u8 kill[16];
|
4730
|
u8 revive[16];
|
4731
|
u8 unknown1[16];
|
4732
|
u8 unknown2[16];
|
4733
|
u8 unknown3[16];
|
4734
|
u8 unknown4[16];
|
4735
|
u8 unknown5[16];
|
4736
|
u8 unknown6[16];
|
4737
|
u8 unknown7[16];
|
4738
|
u8 masterid[16];
|
4739
|
u8 viceid[16];
|
4740
|
u8 unused01:7,
|
4741
|
mastervice:1;
|
4742
|
u8 unused02:3,
|
4743
|
mrevive:1,
|
4744
|
mkill:1,
|
4745
|
mstun:1,
|
4746
|
mmonitor:1,
|
4747
|
minspection:1;
|
4748
|
u8 unused03:3,
|
4749
|
vrevive:1,
|
4750
|
vkill:1,
|
4751
|
vstun:1,
|
4752
|
vmonitor:1,
|
4753
|
vinspection:1;
|
4754
|
u8 unused04:6,
|
4755
|
txdisable:1,
|
4756
|
rxdisable:1;
|
4757
|
u8 groupcode;
|
4758
|
u8 spacecode;
|
4759
|
u8 delayproctime; // * 100 + 100ms
|
4760
|
u8 resettime; // * 100 + 100ms
|
4761
|
} dtmf_settings;
|
4762
|
|
4763
|
#seekto 0x2D00;
|
4764
|
struct {
|
4765
|
struct {
|
4766
|
ul16 freq1;
|
4767
|
u8 unused01[6];
|
4768
|
ul16 freq2;
|
4769
|
u8 unused02[6];
|
4770
|
} _2tone_encode[15];
|
4771
|
u8 duration_1st_tone; // *10ms
|
4772
|
u8 duration_2nd_tone; // *10ms
|
4773
|
u8 duration_gap; // *10ms
|
4774
|
u8 unused03[13];
|
4775
|
struct {
|
4776
|
struct {
|
4777
|
u8 dec; // one out of LIST_2TONE_DEC
|
4778
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
4779
|
u8 alert; // 1-16
|
4780
|
} decs[4];
|
4781
|
u8 unused04[4];
|
4782
|
} _2tone_decode[15];
|
4783
|
u8 unused05[16];
|
4784
|
|
4785
|
struct {
|
4786
|
ul16 freqA;
|
4787
|
ul16 freqB;
|
4788
|
ul16 freqC;
|
4789
|
ul16 freqD;
|
4790
|
// unknown what those values mean, but they are
|
4791
|
// derived from configured frequencies
|
4792
|
ul16 derived_from_freqA; // 2304000/freqA
|
4793
|
ul16 derived_from_freqB; // 2304000/freqB
|
4794
|
ul16 derived_from_freqC; // 2304000/freqC
|
4795
|
ul16 derived_from_freqD; // 2304000/freqD
|
4796
|
}freqs[15];
|
4797
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
4798
|
} _2tone;
|
4799
|
|
4800
|
#seekto 0x3D80;
|
4801
|
struct {
|
4802
|
u8 vhf_low[3];
|
4803
|
u8 vhf_high[3];
|
4804
|
u8 unknown1[4];
|
4805
|
u8 unknown2[6];
|
4806
|
u8 vhf2_low[3];
|
4807
|
u8 vhf2_high[3];
|
4808
|
u8 unknown3[4];
|
4809
|
u8 unknown4[6];
|
4810
|
u8 uhf_low[3];
|
4811
|
u8 uhf_high[3];
|
4812
|
u8 unknown5[4];
|
4813
|
u8 unknown6[6];
|
4814
|
u8 uhf2_low[3];
|
4815
|
u8 uhf2_high[3];
|
4816
|
} ranges;
|
4817
|
|
4818
|
#seekto 0x3F70;
|
4819
|
struct {
|
4820
|
char fp[6];
|
4821
|
} fingerprint;
|
4822
|
|
4823
|
"""
|
4824
|
|
4825
|
|
4826
|
class QYTColorHT(BTechMobileCommon):
|
4827
|
"""QTY's Color LCD Handheld and alike radios"""
|
4828
|
COLOR_LCD = True
|
4829
|
COLOR_LCD3 = True
|
4830
|
NAME_LENGTH = 8
|
4831
|
LIST_TMR = LIST_TMR15
|
4832
|
|
4833
|
def process_mmap(self):
|
4834
|
"""Process the mem map into the mem object"""
|
4835
|
|
4836
|
# Get it
|
4837
|
self._memobj = bitwise.parse(COLORHT_MEM_FORMAT, self._mmap)
|
4838
|
|
4839
|
# load specific parameters from the radio image
|
4840
|
self.set_options()
|
4841
|
|
4842
|
def set_options(self):
|
4843
|
"""This is to read the options from the image and set it in the
|
4844
|
environment, for now just the limits of the freqs in the VHF/UHF
|
4845
|
ranges"""
|
4846
|
|
4847
|
# setting the correct ranges for each radio type
|
4848
|
ranges = self._memobj.ranges
|
4849
|
|
4850
|
# the normal dual bands
|
4851
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
4852
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
4853
|
|
4854
|
# DEBUG
|
4855
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
4856
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
4857
|
|
4858
|
# the additional bands
|
4859
|
if self.MODEL in ["KT-8R"]:
|
4860
|
# 200Mhz band
|
4861
|
vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
|
4862
|
LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
|
4863
|
self._220_range = vhf2
|
4864
|
|
4865
|
# 350Mhz band
|
4866
|
uhf2 = _decode_ranges(ranges.uhf2_low, ranges.uhf2_high)
|
4867
|
LOG.info("Radio ranges: UHF(350) %d to %d" % uhf2)
|
4868
|
self._350_range = uhf2
|
4869
|
|
4870
|
# set the class with the real data
|
4871
|
self._vhf_range = vhf
|
4872
|
self._uhf_range = uhf
|
4873
|
|
4874
|
|
4875
|
# real radios
|
4876
|
@directory.register
|
4877
|
class KT8R(QYTColorHT):
|
4878
|
"""QYT KT8R"""
|
4879
|
VENDOR = "QYT"
|
4880
|
MODEL = "KT-8R"
|
4881
|
BANDS = 4
|
4882
|
LIST_TMR = LIST_TMR16
|
4883
|
_vhf_range = (136000000, 175000000)
|
4884
|
_220_range = (200000000, 261000000)
|
4885
|
_uhf_range = (400000000, 481000000)
|
4886
|
_350_range = (350000000, 391000000)
|
4887
|
_magic = MSTRING_KT8R
|
4888
|
_fileid = [KT8R_fp2, KT8R_fp1, KT8R_fp, ]
|
4889
|
_power_levels = [chirp_common.PowerLevel("High", watts=5),
|
4890
|
chirp_common.PowerLevel("Low", watts=1)]
|
4891
|
|
4892
|
|
4893
|
COLOR9900_MEM_FORMAT = """
|
4894
|
#seekto 0x0000;
|
4895
|
struct {
|
4896
|
lbcd rxfreq[4];
|
4897
|
lbcd txfreq[4];
|
4898
|
ul16 rxtone;
|
4899
|
ul16 txtone;
|
4900
|
u8 unknown0:4,
|
4901
|
scode:4;
|
4902
|
u8 unknown1:2,
|
4903
|
spmute:2,
|
4904
|
unknown2:2,
|
4905
|
optsig:2;
|
4906
|
u8 unknown3:3,
|
4907
|
scramble:1,
|
4908
|
unknown4:2,
|
4909
|
power:2;
|
4910
|
u8 unknown5:1,
|
4911
|
wide:1,
|
4912
|
unknown6:2,
|
4913
|
bcl:1,
|
4914
|
add:1,
|
4915
|
pttid:2;
|
4916
|
} memory[200];
|
4917
|
|
4918
|
#seekto 0x0E00;
|
4919
|
struct {
|
4920
|
u8 tmr;
|
4921
|
u8 unknown1;
|
4922
|
u8 sql;
|
4923
|
u8 unknown2[2];
|
4924
|
u8 tot;
|
4925
|
u8 volume;
|
4926
|
u8 unknown3;
|
4927
|
u8 abr;
|
4928
|
u8 beep;
|
4929
|
u8 unknown4[4];
|
4930
|
u8 dsub;
|
4931
|
u8 dtmfst;
|
4932
|
u8 unknown_e10;
|
4933
|
u8 unknown_e11;
|
4934
|
u8 screv;
|
4935
|
u8 unknown_e13;
|
4936
|
u8 unknown_e14;
|
4937
|
u8 pttid;
|
4938
|
u8 pttlt;
|
4939
|
u8 unknown7;
|
4940
|
u8 emctp;
|
4941
|
u8 emcch;
|
4942
|
u8 sigbp;
|
4943
|
u8 unknown8;
|
4944
|
u8 camdf;
|
4945
|
u8 cbmdf;
|
4946
|
u8 ccmdf;
|
4947
|
u8 language;
|
4948
|
u8 tmrtx;
|
4949
|
u8 vox;
|
4950
|
u8 voxt;
|
4951
|
u8 autolock;
|
4952
|
u8 asfc;
|
4953
|
u8 mainfc;
|
4954
|
u8 a_fc;
|
4955
|
u8 b_fc;
|
4956
|
u8 c_fc;
|
4957
|
u8 subfc;
|
4958
|
u8 battfc;
|
4959
|
u8 sigfc;
|
4960
|
u8 menufc;
|
4961
|
u8 txfc;
|
4962
|
u8 rxfc;
|
4963
|
u8 unknown_e2f;
|
4964
|
u8 unknown_e30;
|
4965
|
u8 unknown9[3];
|
4966
|
u8 anil;
|
4967
|
u8 reps;
|
4968
|
u8 tmrmr;
|
4969
|
u8 ste;
|
4970
|
u8 rpste;
|
4971
|
u8 rptdl;
|
4972
|
u8 dtmfg;
|
4973
|
} settings;
|
4974
|
|
4975
|
#seekto 0x0E80;
|
4976
|
struct {
|
4977
|
u8 unknown1;
|
4978
|
u8 vfomr;
|
4979
|
u8 keylock;
|
4980
|
u8 unknown2;
|
4981
|
u8 unknown3:4,
|
4982
|
vfomren:1,
|
4983
|
unknown4:1,
|
4984
|
reseten:1,
|
4985
|
menuen:1;
|
4986
|
u8 unknown5[11];
|
4987
|
u8 dispab;
|
4988
|
u8 unknown6[2];
|
4989
|
u8 menu;
|
4990
|
u8 unknown7[7];
|
4991
|
u8 vfomra;
|
4992
|
u8 vfomrb;
|
4993
|
u8 vfomrc;
|
4994
|
u8 vfomrd;
|
4995
|
u8 mrcha;
|
4996
|
u8 mrchb;
|
4997
|
u8 mrchc;
|
4998
|
u8 mrchd;
|
4999
|
} settings2;
|
5000
|
|
5001
|
struct settings_vfo {
|
5002
|
u8 freq[8];
|
5003
|
u8 offset[6];
|
5004
|
u8 unknown2[2];
|
5005
|
ul16 rxtone;
|
5006
|
ul16 txtone;
|
5007
|
u8 scode;
|
5008
|
u8 spmute;
|
5009
|
u8 optsig;
|
5010
|
u8 scramble;
|
5011
|
u8 wide;
|
5012
|
u8 power;
|
5013
|
u8 shiftd;
|
5014
|
u8 step;
|
5015
|
u8 unknown3[4];
|
5016
|
};
|
5017
|
|
5018
|
#seekto 0x0F00;
|
5019
|
struct {
|
5020
|
struct settings_vfo a;
|
5021
|
struct settings_vfo b;
|
5022
|
struct settings_vfo c;
|
5023
|
struct settings_vfo d;
|
5024
|
} vfo;
|
5025
|
|
5026
|
#seekto 0x0F80;
|
5027
|
struct {
|
5028
|
char line1[8];
|
5029
|
char line2[8];
|
5030
|
char line3[8];
|
5031
|
char line4[8];
|
5032
|
char line5[8];
|
5033
|
char line6[8];
|
5034
|
char line7[8];
|
5035
|
char line8[8];
|
5036
|
} poweron_msg;
|
5037
|
|
5038
|
#seekto 0x0FE0;
|
5039
|
struct {
|
5040
|
char line[16];
|
5041
|
} static_msg;
|
5042
|
|
5043
|
#seekto 0x1000;
|
5044
|
struct {
|
5045
|
char name[7];
|
5046
|
u8 unknown1[9];
|
5047
|
} names[200];
|
5048
|
|
5049
|
#seekto 0x2400;
|
5050
|
struct {
|
5051
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
5052
|
u8 group_tone;
|
5053
|
u8 repeat_tone;
|
5054
|
u8 unused[13];
|
5055
|
} _5tone_std_settings[15];
|
5056
|
|
5057
|
#seekto 0x2500;
|
5058
|
struct {
|
5059
|
u8 frame1[5];
|
5060
|
u8 frame2[5];
|
5061
|
u8 frame3[5];
|
5062
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
5063
|
} _5tone_codes[15];
|
5064
|
|
5065
|
#seekto 0x25F0;
|
5066
|
struct {
|
5067
|
u8 _5tone_delay1; // * 10ms
|
5068
|
u8 _5tone_delay2; // * 10ms
|
5069
|
u8 _5tone_delay3; // * 10ms
|
5070
|
u8 _5tone_first_digit_ext_length;
|
5071
|
u8 unknown1;
|
5072
|
u8 unknown2;
|
5073
|
u8 unknown3;
|
5074
|
u8 unknown4;
|
5075
|
u8 decode_standard;
|
5076
|
u8 unknown5:5,
|
5077
|
_5tone_decode_call_frame3:1,
|
5078
|
_5tone_decode_call_frame2:1,
|
5079
|
_5tone_decode_call_frame1:1;
|
5080
|
u8 unknown6:5,
|
5081
|
_5tone_decode_disp_frame3:1,
|
5082
|
_5tone_decode_disp_frame2:1,
|
5083
|
_5tone_decode_disp_frame1:1;
|
5084
|
u8 decode_reset_time; // * 100 + 100ms
|
5085
|
} _5tone_settings;
|
5086
|
|
5087
|
#seekto 0x2900;
|
5088
|
struct {
|
5089
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
5090
|
} dtmf_codes[15];
|
5091
|
|
5092
|
#seekto 0x29F0;
|
5093
|
struct {
|
5094
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10 // 9f0
|
5095
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10 // 9f1
|
5096
|
u8 unknown0[14]; // 9f2-9ff
|
5097
|
u8 inspection[16]; // a00-a0f
|
5098
|
u8 monitor[16]; // a10-a1f
|
5099
|
u8 alarmcode[16]; // a20-a2f
|
5100
|
u8 stun[16]; // a30-a3f
|
5101
|
u8 kill[16]; // a40-a4f
|
5102
|
u8 revive[16]; // a50-a5f
|
5103
|
u8 unknown1[16]; // a60-a6f
|
5104
|
u8 unknown2[16]; // a70-a7f
|
5105
|
u8 unknown3[16]; // a80-a8f
|
5106
|
u8 unknown4[16]; // a90-a9f
|
5107
|
u8 unknown5[16]; // aa0-aaf
|
5108
|
u8 unknown6[16]; // ab0-abf
|
5109
|
u8 unknown7[16]; // ac0-acf
|
5110
|
u8 masterid[16]; // ad0-adf
|
5111
|
u8 viceid[16]; // ae0-aef
|
5112
|
u8 unused01:7, // af0
|
5113
|
mastervice:1;
|
5114
|
u8 unused02:3, // af1
|
5115
|
mrevive:1,
|
5116
|
mkill:1,
|
5117
|
mstun:1,
|
5118
|
mmonitor:1,
|
5119
|
minspection:1;
|
5120
|
u8 unused03:3, // af2
|
5121
|
vrevive:1,
|
5122
|
vkill:1,
|
5123
|
vstun:1,
|
5124
|
vmonitor:1,
|
5125
|
vinspection:1;
|
5126
|
u8 unused04:6, // af3
|
5127
|
txdisable:1,
|
5128
|
rxdisable:1;
|
5129
|
u8 groupcode; // af4
|
5130
|
u8 spacecode; // af5
|
5131
|
u8 delayproctime; // * 100 + 100ms // af6
|
5132
|
u8 resettime; // * 100 + 100ms // af7
|
5133
|
} dtmf_settings;
|
5134
|
|
5135
|
#seekto 0x2D00;
|
5136
|
struct {
|
5137
|
struct {
|
5138
|
ul16 freq1;
|
5139
|
u8 unused01[6];
|
5140
|
ul16 freq2;
|
5141
|
u8 unused02[6];
|
5142
|
} _2tone_encode[15];
|
5143
|
u8 duration_1st_tone; // *10ms
|
5144
|
u8 duration_2nd_tone; // *10ms
|
5145
|
u8 duration_gap; // *10ms
|
5146
|
u8 unused03[13];
|
5147
|
struct {
|
5148
|
struct {
|
5149
|
u8 dec; // one out of LIST_2TONE_DEC
|
5150
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
5151
|
u8 alert; // 1-16
|
5152
|
} decs[4];
|
5153
|
u8 unused04[4];
|
5154
|
} _2tone_decode[15];
|
5155
|
u8 unused05[16];
|
5156
|
|
5157
|
struct {
|
5158
|
ul16 freqA;
|
5159
|
ul16 freqB;
|
5160
|
ul16 freqC;
|
5161
|
ul16 freqD;
|
5162
|
// unknown what those values mean, but they are
|
5163
|
// derived from configured frequencies
|
5164
|
ul16 derived_from_freqA; // 2304000/freqA
|
5165
|
ul16 derived_from_freqB; // 2304000/freqB
|
5166
|
ul16 derived_from_freqC; // 2304000/freqC
|
5167
|
ul16 derived_from_freqD; // 2304000/freqD
|
5168
|
}freqs[15];
|
5169
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
5170
|
} _2tone;
|
5171
|
|
5172
|
#seekto 0x3D80;
|
5173
|
struct {
|
5174
|
u8 vhf_low[3];
|
5175
|
u8 vhf_high[3];
|
5176
|
u8 unknown1[4];
|
5177
|
u8 unknown2[6];
|
5178
|
u8 vhf2_low[3];
|
5179
|
u8 vhf2_high[3];
|
5180
|
u8 unknown3[4];
|
5181
|
u8 unknown4[6];
|
5182
|
u8 uhf_low[3];
|
5183
|
u8 uhf_high[3];
|
5184
|
u8 unknown5[4];
|
5185
|
u8 unknown6[6];
|
5186
|
u8 uhf2_low[3];
|
5187
|
u8 uhf2_high[3];
|
5188
|
} ranges;
|
5189
|
|
5190
|
#seekto 0x3F70;
|
5191
|
struct {
|
5192
|
char fp[6];
|
5193
|
} fingerprint;
|
5194
|
|
5195
|
"""
|
5196
|
|
5197
|
|
5198
|
COLOR20V2_MEM_FORMAT = """
|
5199
|
#seekto 0x0000;
|
5200
|
struct {
|
5201
|
lbcd rxfreq[4];
|
5202
|
lbcd txfreq[4];
|
5203
|
ul16 rxtone;
|
5204
|
ul16 txtone;
|
5205
|
u8 unknown0:4,
|
5206
|
scode:4;
|
5207
|
u8 unknown1:2,
|
5208
|
spmute:2,
|
5209
|
unknown2:2,
|
5210
|
optsig:2;
|
5211
|
u8 unknown3:3,
|
5212
|
scramble:1,
|
5213
|
unknown4:2,
|
5214
|
power:2;
|
5215
|
u8 unknown5:1,
|
5216
|
wide:1,
|
5217
|
unknown6:2,
|
5218
|
bcl:1,
|
5219
|
add:1,
|
5220
|
pttid:2;
|
5221
|
} memory[200];
|
5222
|
|
5223
|
#seekto 0x0E00;
|
5224
|
struct {
|
5225
|
u8 tmr;
|
5226
|
u8 unknown1;
|
5227
|
u8 sql;
|
5228
|
u8 unknown2;
|
5229
|
u8 autolock;
|
5230
|
u8 tot;
|
5231
|
u8 apo;
|
5232
|
u8 unknown3;
|
5233
|
u8 abr;
|
5234
|
u8 beep;
|
5235
|
u8 unknown4[4];
|
5236
|
u8 dtmfst;
|
5237
|
u8 unknown5[2];
|
5238
|
u8 screv;
|
5239
|
u8 unknown6[2];
|
5240
|
u8 pttid;
|
5241
|
u8 pttlt;
|
5242
|
u8 unknown7;
|
5243
|
u8 emctp;
|
5244
|
u8 emcch;
|
5245
|
u8 sigbp;
|
5246
|
u8 unknown8;
|
5247
|
u8 camdf;
|
5248
|
u8 cbmdf;
|
5249
|
u8 ccmdf;
|
5250
|
u8 vox;
|
5251
|
u8 voxt;
|
5252
|
u8 sync;
|
5253
|
u8 asfc;
|
5254
|
u8 mainfc;
|
5255
|
u8 a_fc;
|
5256
|
u8 b_fc;
|
5257
|
u8 c_fc;
|
5258
|
u8 subfc;
|
5259
|
u8 battfc;
|
5260
|
u8 sigfc;
|
5261
|
u8 menufc;
|
5262
|
u8 txfc;
|
5263
|
u8 rxfc;
|
5264
|
u8 repsw;
|
5265
|
u8 dsub;
|
5266
|
u8 unknown9[5];
|
5267
|
u8 anil;
|
5268
|
u8 reps;
|
5269
|
u8 repm;
|
5270
|
u8 tmrmr;
|
5271
|
u8 ste;
|
5272
|
u8 rpste;
|
5273
|
u8 rptdl;
|
5274
|
u8 dtmfg;
|
5275
|
u8 mgain;
|
5276
|
u8 skiptx;
|
5277
|
u8 scmode;
|
5278
|
u8 tmrtx;
|
5279
|
u8 volume;
|
5280
|
u8 unknown_10;
|
5281
|
u8 save;
|
5282
|
} settings;
|
5283
|
|
5284
|
#seekto 0x0E80;
|
5285
|
struct {
|
5286
|
u8 unknown1;
|
5287
|
u8 vfomr;
|
5288
|
u8 keylock;
|
5289
|
u8 unknown2;
|
5290
|
u8 unknown3:4,
|
5291
|
vfomren:1,
|
5292
|
unknown4:1,
|
5293
|
reseten:1,
|
5294
|
menuen:1;
|
5295
|
u8 unknown5[11];
|
5296
|
u8 dispab;
|
5297
|
u8 unknown6[2];
|
5298
|
u8 menu;
|
5299
|
u8 unknown7[7];
|
5300
|
u8 vfomra;
|
5301
|
u8 vfomrb;
|
5302
|
u8 vfomrc;
|
5303
|
u8 vfomrd;
|
5304
|
u8 mrcha;
|
5305
|
u8 mrchb;
|
5306
|
u8 mrchc;
|
5307
|
u8 mrchd;
|
5308
|
} settings2;
|
5309
|
|
5310
|
struct settings_vfo {
|
5311
|
u8 freq[8];
|
5312
|
u8 offset[6];
|
5313
|
u8 unknown2[2];
|
5314
|
ul16 rxtone;
|
5315
|
ul16 txtone;
|
5316
|
u8 scode;
|
5317
|
u8 spmute;
|
5318
|
u8 optsig;
|
5319
|
u8 scramble;
|
5320
|
u8 wide;
|
5321
|
u8 power;
|
5322
|
u8 shiftd;
|
5323
|
u8 step;
|
5324
|
u8 unknown3[4];
|
5325
|
};
|
5326
|
|
5327
|
#seekto 0x0F00;
|
5328
|
struct {
|
5329
|
struct settings_vfo a;
|
5330
|
struct settings_vfo b;
|
5331
|
struct settings_vfo c;
|
5332
|
struct settings_vfo d;
|
5333
|
} vfo;
|
5334
|
|
5335
|
#seekto 0x0F80;
|
5336
|
struct {
|
5337
|
char line1[8];
|
5338
|
char line2[8];
|
5339
|
char line3[8];
|
5340
|
char line4[8];
|
5341
|
char line5[8];
|
5342
|
char line6[8];
|
5343
|
char line7[8];
|
5344
|
char line8[8];
|
5345
|
} poweron_msg;
|
5346
|
|
5347
|
#seekto 0x0FE0;
|
5348
|
struct {
|
5349
|
char line[16];
|
5350
|
} static_msg;
|
5351
|
|
5352
|
#seekto 0x1000;
|
5353
|
struct {
|
5354
|
char name[7];
|
5355
|
u8 unknown1[9];
|
5356
|
} names[200];
|
5357
|
|
5358
|
#seekto 0x2400;
|
5359
|
struct {
|
5360
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
5361
|
u8 group_tone;
|
5362
|
u8 repeat_tone;
|
5363
|
u8 unused[13];
|
5364
|
} _5tone_std_settings[15];
|
5365
|
|
5366
|
#seekto 0x2500;
|
5367
|
struct {
|
5368
|
u8 frame1[5];
|
5369
|
u8 frame2[5];
|
5370
|
u8 frame3[5];
|
5371
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
5372
|
} _5tone_codes[15];
|
5373
|
|
5374
|
#seekto 0x25F0;
|
5375
|
struct {
|
5376
|
u8 _5tone_delay1; // * 10ms
|
5377
|
u8 _5tone_delay2; // * 10ms
|
5378
|
u8 _5tone_delay3; // * 10ms
|
5379
|
u8 _5tone_first_digit_ext_length;
|
5380
|
u8 unknown1;
|
5381
|
u8 unknown2;
|
5382
|
u8 unknown3;
|
5383
|
u8 unknown4;
|
5384
|
u8 decode_standard;
|
5385
|
u8 unknown5:5,
|
5386
|
_5tone_decode_call_frame3:1,
|
5387
|
_5tone_decode_call_frame2:1,
|
5388
|
_5tone_decode_call_frame1:1;
|
5389
|
u8 unknown6:5,
|
5390
|
_5tone_decode_disp_frame3:1,
|
5391
|
_5tone_decode_disp_frame2:1,
|
5392
|
_5tone_decode_disp_frame1:1;
|
5393
|
u8 decode_reset_time; // * 100 + 100ms
|
5394
|
} _5tone_settings;
|
5395
|
|
5396
|
#seekto 0x2900;
|
5397
|
struct {
|
5398
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
5399
|
} dtmf_codes[15];
|
5400
|
|
5401
|
#seekto 0x29F0;
|
5402
|
struct {
|
5403
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10 // 9f0
|
5404
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10 // 9f1
|
5405
|
u8 unknown0[14]; // 9f2-9ff
|
5406
|
u8 inspection[16]; // a00-a0f
|
5407
|
u8 monitor[16]; // a10-a1f
|
5408
|
u8 alarmcode[16]; // a20-a2f
|
5409
|
u8 stun[16]; // a30-a3f
|
5410
|
u8 kill[16]; // a40-a4f
|
5411
|
u8 revive[16]; // a50-a5f
|
5412
|
u8 unknown1[16]; // a60-a6f
|
5413
|
u8 unknown2[16]; // a70-a7f
|
5414
|
u8 unknown3[16]; // a80-a8f
|
5415
|
u8 unknown4[16]; // a90-a9f
|
5416
|
u8 unknown5[16]; // aa0-aaf
|
5417
|
u8 unknown6[16]; // ab0-abf
|
5418
|
u8 unknown7[16]; // ac0-acf
|
5419
|
u8 masterid[16]; // ad0-adf
|
5420
|
u8 viceid[16]; // ae0-aef
|
5421
|
u8 unused01:7, // af0
|
5422
|
mastervice:1;
|
5423
|
u8 unused02:3, // af1
|
5424
|
mrevive:1,
|
5425
|
mkill:1,
|
5426
|
mstun:1,
|
5427
|
mmonitor:1,
|
5428
|
minspection:1;
|
5429
|
u8 unused03:3, // af2
|
5430
|
vrevive:1,
|
5431
|
vkill:1,
|
5432
|
vstun:1,
|
5433
|
vmonitor:1,
|
5434
|
vinspection:1;
|
5435
|
u8 unused04:6, // af3
|
5436
|
txdisable:1,
|
5437
|
rxdisable:1;
|
5438
|
u8 groupcode; // af4
|
5439
|
u8 spacecode; // af5
|
5440
|
u8 delayproctime; // * 100 + 100ms // af6
|
5441
|
u8 resettime; // * 100 + 100ms // af7
|
5442
|
} dtmf_settings;
|
5443
|
|
5444
|
#seekto 0x2D00;
|
5445
|
struct {
|
5446
|
struct {
|
5447
|
ul16 freq1;
|
5448
|
u8 unused01[6];
|
5449
|
ul16 freq2;
|
5450
|
u8 unused02[6];
|
5451
|
} _2tone_encode[15];
|
5452
|
u8 duration_1st_tone; // *10ms
|
5453
|
u8 duration_2nd_tone; // *10ms
|
5454
|
u8 duration_gap; // *10ms
|
5455
|
u8 unused03[13];
|
5456
|
struct {
|
5457
|
struct {
|
5458
|
u8 dec; // one out of LIST_2TONE_DEC
|
5459
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
5460
|
u8 alert; // 1-16
|
5461
|
} decs[4];
|
5462
|
u8 unused04[4];
|
5463
|
} _2tone_decode[15];
|
5464
|
u8 unused05[16];
|
5465
|
|
5466
|
struct {
|
5467
|
ul16 freqA;
|
5468
|
ul16 freqB;
|
5469
|
ul16 freqC;
|
5470
|
ul16 freqD;
|
5471
|
// unknown what those values mean, but they are
|
5472
|
// derived from configured frequencies
|
5473
|
ul16 derived_from_freqA; // 2304000/freqA
|
5474
|
ul16 derived_from_freqB; // 2304000/freqB
|
5475
|
ul16 derived_from_freqC; // 2304000/freqC
|
5476
|
ul16 derived_from_freqD; // 2304000/freqD
|
5477
|
}freqs[15];
|
5478
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
5479
|
} _2tone;
|
5480
|
|
5481
|
#seekto 0x3D80;
|
5482
|
struct {
|
5483
|
u8 vhf_low[3];
|
5484
|
u8 vhf_high[3];
|
5485
|
u8 unknown1[4];
|
5486
|
u8 unknown2[6];
|
5487
|
u8 vhf2_low[3];
|
5488
|
u8 vhf2_high[3];
|
5489
|
u8 unknown3[4];
|
5490
|
u8 unknown4[6];
|
5491
|
u8 uhf_low[3];
|
5492
|
u8 uhf_high[3];
|
5493
|
u8 unknown5[4];
|
5494
|
u8 unknown6[6];
|
5495
|
u8 uhf2_low[3];
|
5496
|
u8 uhf2_high[3];
|
5497
|
} ranges;
|
5498
|
|
5499
|
#seekto 0x3F70;
|
5500
|
struct {
|
5501
|
char fp[6];
|
5502
|
} fingerprint;
|
5503
|
|
5504
|
"""
|
5505
|
|
5506
|
|
5507
|
class BTechColorWP(BTechMobileCommon):
|
5508
|
"""BTECH's Color WP Mobile and alike radios"""
|
5509
|
COLOR_LCD = True
|
5510
|
COLOR_LCD4 = True
|
5511
|
NAME_LENGTH = 7
|
5512
|
LIST_TMR = LIST_TMR7
|
5513
|
|
5514
|
def set_options(self):
|
5515
|
"""This is to read the options from the image and set it in the
|
5516
|
environment, for now just the limits of the freqs in the VHF/UHF
|
5517
|
ranges"""
|
5518
|
|
5519
|
# setting the correct ranges for each radio type
|
5520
|
ranges = self._memobj.ranges
|
5521
|
|
5522
|
# the normal dual bands
|
5523
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
5524
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
5525
|
|
5526
|
# DEBUG
|
5527
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
5528
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
5529
|
|
5530
|
# set the class with the real data
|
5531
|
self._vhf_range = vhf
|
5532
|
self._uhf_range = uhf
|
5533
|
|
5534
|
|
5535
|
# real radios
|
5536
|
@directory.register
|
5537
|
class KTWP12(BTechColorWP):
|
5538
|
"""QYT KT-WP12"""
|
5539
|
VENDOR = "QYT"
|
5540
|
MODEL = "KT-WP12"
|
5541
|
BANDS = 2
|
5542
|
UPLOAD_MEM_SIZE = 0X3100
|
5543
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
5544
|
chirp_common.PowerLevel("Low", watts=5)]
|
5545
|
_upper = 199
|
5546
|
_magic = MSTRING_KTWP12
|
5547
|
_fileid = [KTWP12_fp, ]
|
5548
|
_gmrs = False
|
5549
|
|
5550
|
def process_mmap(self):
|
5551
|
"""Process the mem map into the mem object"""
|
5552
|
|
5553
|
# Get it
|
5554
|
self._memobj = bitwise.parse(COLOR9900_MEM_FORMAT, self._mmap)
|
5555
|
|
5556
|
# load specific parameters from the radio image
|
5557
|
self.set_options()
|
5558
|
|
5559
|
|
5560
|
@directory.register
|
5561
|
class WP9900(BTechColorWP):
|
5562
|
"""Anysecu WP-9900"""
|
5563
|
VENDOR = "Anysecu"
|
5564
|
MODEL = "WP-9900"
|
5565
|
BANDS = 2
|
5566
|
UPLOAD_MEM_SIZE = 0X3100
|
5567
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
5568
|
chirp_common.PowerLevel("Low", watts=5)]
|
5569
|
_upper = 199
|
5570
|
_magic = MSTRING_KTWP12
|
5571
|
_fileid = [WP9900_fp, ]
|
5572
|
_gmrs = False
|
5573
|
|
5574
|
def process_mmap(self):
|
5575
|
"""Process the mem map into the mem object"""
|
5576
|
|
5577
|
# Get it
|
5578
|
self._memobj = bitwise.parse(COLOR9900_MEM_FORMAT, self._mmap)
|
5579
|
|
5580
|
# load specific parameters from the radio image
|
5581
|
self.set_options()
|
5582
|
|
5583
|
|
5584
|
@directory.register
|
5585
|
class GMRS20V2(BTechColorWP):
|
5586
|
"""Baofeng Tech GMRS-20V2"""
|
5587
|
MODEL = "GMRS-20V2"
|
5588
|
BANDS = 2
|
5589
|
UPLOAD_MEM_SIZE = 0X3100
|
5590
|
_power_levels = [chirp_common.PowerLevel("High", watts=20),
|
5591
|
chirp_common.PowerLevel("", watts=6),
|
5592
|
chirp_common.PowerLevel("Low", watts=5)]
|
5593
|
_upper = 199
|
5594
|
_magic = MSTRING_GMRS20V2
|
5595
|
_fileid = [GMRS20V2_fp1, GMRS20V2_fp, ]
|
5596
|
_gmrs = True
|
5597
|
|
5598
|
def process_mmap(self):
|
5599
|
"""Process the mem map into the mem object"""
|
5600
|
|
5601
|
# Get it
|
5602
|
self._memobj = bitwise.parse(COLOR20V2_MEM_FORMAT, self._mmap)
|
5603
|
|
5604
|
# load specific parameters from the radio image
|
5605
|
self.set_options()
|