1
|
# Copyright 2016-2021:
|
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", "Indego",
|
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_PONMSG = ["Full", "Message", "Battery voltage"]
|
74
|
LIST_REPM = ["Off", "Carrier", "CTCSS or DCS", "Tone", "DTMF"]
|
75
|
LIST_REPS = ["1000 Hz", "1450 Hz", "1750 Hz", "2100Hz"]
|
76
|
LIST_RPTDL = ["Off"] + ["%s ms" % x for x in range(1, 10)]
|
77
|
LIST_SCMODE = ["Off", "PTT-SC", "MEM-SC", "PON-SC"]
|
78
|
LIST_SHIFT = ["Off", "+", "-"]
|
79
|
LIST_SKIPTX = ["Off", "Skip 1", "Skip 2"]
|
80
|
STEPS = [2.5, 5.0, 6.25, 10.0, 12.5, 25.0]
|
81
|
LIST_STEP = [str(x) for x in STEPS]
|
82
|
LIST_SYNC = ["Off", "AB", "CD", "AB+CD"]
|
83
|
# the first 12 TMR choices common to all color display mobile radios
|
84
|
LIST_TMR12 = ["OFF", "M+A", "M+B", "M+C", "M+D", "M+A+B", "M+A+C", "M+A+D",
|
85
|
"M+B+C", "M+B+D", "M+C+D", "M+A+B+C"]
|
86
|
# the 16 choice list for color display mobile radios that correctly implement
|
87
|
# the full 16 TMR choices
|
88
|
LIST_TMR16 = LIST_TMR12 + ["M+A+B+D", "M+A+C+D", "M+B+C+D", "A+B+C+D"]
|
89
|
# the 15 choice list for color mobile radios that are missing the M+A+B+D
|
90
|
# choice in the TMR menu
|
91
|
LIST_TMR15 = LIST_TMR12 + ["M+A+C+D", "M+B+C+D", "A+B+C+D"]
|
92
|
LIST_TMRTX = ["Track", "Fixed"]
|
93
|
LIST_TOT = ["%s sec" % x for x in range(15, 615, 15)]
|
94
|
LIST_TXDISP = ["Power", "Mic Volume"]
|
95
|
LIST_TXP = ["High", "Low"]
|
96
|
LIST_TXP3 = ["High", "Mid", "Low"]
|
97
|
LIST_SCREV = ["TO (timeout)", "CO (carrier operated)", "SE (search)"]
|
98
|
LIST_VFOMR = ["Frequency", "Channel"]
|
99
|
LIST_VOICE = ["Off"] + LIST_LANGUA
|
100
|
LIST_VOX = ["Off"] + ["%s" % x for x in range(1, 11)]
|
101
|
LIST_VOXT = ["%s seconds" % x for x in range(0, 21)]
|
102
|
LIST_WIDE = ["Wide", "Narrow"]
|
103
|
|
104
|
# lists related to DTMF, 2TONE and 5TONE settings
|
105
|
LIST_5TONE_STANDARDS = ["CCIR1", "CCIR2", "PCCIR", "ZVEI1", "ZVEI2", "ZVEI3",
|
106
|
"PZVEI", "DZVEI", "PDZVEI", "EEA", "EIA", "EURO",
|
107
|
"CCITT", "NATEL", "MODAT", "none"]
|
108
|
LIST_5TONE_STANDARDS_without_none = ["CCIR1", "CCIR2", "PCCIR", "ZVEI1",
|
109
|
"ZVEI2", "ZVEI3",
|
110
|
"PZVEI", "DZVEI", "PDZVEI", "EEA", "EIA",
|
111
|
"EURO", "CCITT", "NATEL", "MODAT"]
|
112
|
LIST_5TONE_STANDARD_PERIODS = ["20", "30", "40", "50", "60", "70", "80", "90",
|
113
|
"100", "110", "120", "130", "140", "150", "160",
|
114
|
"170", "180", "190", "200"]
|
115
|
LIST_5TONE_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A",
|
116
|
"B", "C", "D", "E", "F"]
|
117
|
LIST_5TONE_DELAY = ["%s ms" % x for x in range(0, 1010, 10)]
|
118
|
LIST_5TONE_RESET = ["%s ms" % x for x in range(100, 8100, 100)]
|
119
|
LIST_5TONE_RESET_COLOR = ["%s ms" % x for x in range(100, 20100, 100)]
|
120
|
LIST_DTMF_SPEED = ["%s ms" % x for x in range(50, 2010, 10)]
|
121
|
LIST_DTMF_DIGITS = ["0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "A", "B",
|
122
|
"C", "D", "#", "*"]
|
123
|
LIST_DTMF_VALUES = [0x0A, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09,
|
124
|
0x0D, 0x0E, 0x0F, 0x00, 0x0C, 0x0B]
|
125
|
LIST_DTMF_SPECIAL_DIGITS = ["*", "#", "A", "B", "C", "D"]
|
126
|
LIST_DTMF_SPECIAL_VALUES = [0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x00]
|
127
|
LIST_DTMF_DELAY = ["%s ms" % x for x in range(100, 4100, 100)]
|
128
|
CHARSET_DTMF_DIGITS = "0123456789AaBbCcDd#*"
|
129
|
LIST_2TONE_DEC = ["A-B", "A-C", "A-D",
|
130
|
"B-A", "B-C", "B-D",
|
131
|
"C-A", "C-B", "C-D",
|
132
|
"D-A", "D-B", "D-C"]
|
133
|
LIST_2TONE_RESPONSE = ["None", "Alert", "Transpond", "Alert+Transpond"]
|
134
|
|
135
|
# This is a general serial timeout for all serial read functions.
|
136
|
# Practice has show that about 0.7 sec will be enough to cover all radios.
|
137
|
STIMEOUT = 0.7
|
138
|
|
139
|
# this var controls the verbosity in the debug and by default it's low (False)
|
140
|
# make it True and you will to get a very verbose debug.log
|
141
|
debug = False
|
142
|
|
143
|
# valid chars on the LCD, Note that " " (space) is stored as "\xFF"
|
144
|
VALID_CHARS = chirp_common.CHARSET_ALPHANUMERIC + \
|
145
|
"`{|}!\"#$%&'()*+,-./:;<=>?@[]^_"
|
146
|
|
147
|
|
148
|
# #### ID strings #####################################################
|
149
|
|
150
|
# BTECH UV2501 pre-production units
|
151
|
UV2501pp_fp = "M2C294"
|
152
|
# BTECH UV2501 pre-production units 2 + and 1st Gen radios
|
153
|
UV2501pp2_fp = "M29204"
|
154
|
# B-TECH UV-2501 second generation (2G) radios
|
155
|
UV2501G2_fp = "BTG214"
|
156
|
# B-TECH UV-2501 third generation (3G) radios
|
157
|
UV2501G3_fp = "BTG324"
|
158
|
|
159
|
# B-TECH UV-2501+220 pre-production units
|
160
|
UV2501_220pp_fp = "M3C281"
|
161
|
# extra block read for the 2501+220 pre-production units
|
162
|
# the same for all of this radios so far
|
163
|
UV2501_220pp_id = " 280528"
|
164
|
# B-TECH UV-2501+220
|
165
|
UV2501_220_fp = "M3G201"
|
166
|
# new variant, let's call it Generation 2
|
167
|
UV2501_220G2_fp = "BTG211"
|
168
|
# B-TECH UV-2501+220 third generation (3G)
|
169
|
UV2501_220G3_fp = "BTG311"
|
170
|
|
171
|
# B-TECH UV-5001 pre-production units + 1st Gen radios
|
172
|
UV5001pp_fp = "V19204"
|
173
|
# B-TECH UV-5001 alpha units
|
174
|
UV5001alpha_fp = "V28204"
|
175
|
# B-TECH UV-5001 second generation (2G) radios
|
176
|
UV5001G2_fp = "BTG214"
|
177
|
# B-TECH UV-5001 second generation (2G2)
|
178
|
UV5001G22_fp = "V2G204"
|
179
|
# B-TECH UV-5001 third generation (3G)
|
180
|
UV5001G3_fp = "BTG304"
|
181
|
|
182
|
# B-TECH UV-25X2
|
183
|
UV25X2_fp = "UC2012"
|
184
|
|
185
|
# B-TECH UV-25X4
|
186
|
UV25X4_fp = "UC4014"
|
187
|
|
188
|
# B-TECH UV-50X2
|
189
|
UV50X2_fp = "UC2M12"
|
190
|
|
191
|
# B-TECH GMRS-50X1
|
192
|
GMRS50X1_fp = "NC1802"
|
193
|
GMRS50X1_fp1 = "NC1932"
|
194
|
|
195
|
# special var to know when we found a BTECH Gen 3
|
196
|
BTECH3 = [UV2501G3_fp, UV2501_220G3_fp, UV5001G3_fp]
|
197
|
|
198
|
|
199
|
# WACCOM Mini-8900
|
200
|
MINI8900_fp = "M28854"
|
201
|
|
202
|
|
203
|
# QYT KT-UV980
|
204
|
KTUV980_fp = "H28854"
|
205
|
|
206
|
# QYT KT8900
|
207
|
KT8900_fp = "M29154"
|
208
|
# New generations KT8900
|
209
|
KT8900_fp1 = "M2C234"
|
210
|
KT8900_fp2 = "M2G1F4"
|
211
|
KT8900_fp3 = "M2G2F4"
|
212
|
KT8900_fp4 = "M2G304"
|
213
|
KT8900_fp5 = "M2G314"
|
214
|
KT8900_fp6 = "M2G424"
|
215
|
# this radio has an extra ID
|
216
|
KT8900_id = "303688"
|
217
|
# another extra ID in sep/2021
|
218
|
KT8900_id2 = "\x05\x58\x3d\xf0\x10"
|
219
|
|
220
|
# KT8900R
|
221
|
KT8900R_fp = "M3G1F4"
|
222
|
# Second Generation
|
223
|
KT8900R_fp1 = "M3G214"
|
224
|
# another model
|
225
|
KT8900R_fp2 = "M3C234"
|
226
|
# another model G4?
|
227
|
KT8900R_fp3 = "M39164"
|
228
|
# another model
|
229
|
KT8900R_fp4 = "M3G314"
|
230
|
# this radio has an extra ID
|
231
|
KT8900R_id = "280528"
|
232
|
# another extra ID in dec/2018
|
233
|
KT8900R_id2 = "\x05\x58\x3d\xf0\x10"
|
234
|
|
235
|
# KT7900D (quad band)
|
236
|
KT7900D_fp = "VC4004"
|
237
|
KT7900D_fp1 = "VC4284"
|
238
|
KT7900D_fp2 = "VC4264"
|
239
|
KT7900D_fp3 = "VC4114"
|
240
|
KT7900D_fp4 = "VC4104"
|
241
|
KT7900D_fp5 = "VC4254"
|
242
|
KT7900D_fp6 = "VC5264"
|
243
|
|
244
|
# QB25 (quad band) - a clone of KT7900D
|
245
|
QB25_fp = "QB-25"
|
246
|
|
247
|
# KT8900D (dual band)
|
248
|
KT8900D_fp = "VC2002"
|
249
|
KT8900D_fp1 = "VC8632"
|
250
|
KT8900D_fp2 = "VC3402"
|
251
|
KT8900D_fp3 = "VC7062"
|
252
|
|
253
|
# LUITON LT-588UV
|
254
|
LT588UV_fp = "V2G1F4"
|
255
|
# Added by rstrickoff gen 2 id
|
256
|
LT588UV_fp1 = "V2G214"
|
257
|
|
258
|
# QYT KT-8R (quad band ht)
|
259
|
KT8R_fp = "MCB264"
|
260
|
KT8R_fp1 = "MCB284"
|
261
|
KT8R_fp2 = "MC5264"
|
262
|
|
263
|
# QYT KT5800 (dual band)
|
264
|
KT5800_fp = "VCB222"
|
265
|
|
266
|
# QYT KT980Plus (dual band)
|
267
|
KT980PLUS_fp = "VC2002"
|
268
|
KT980PLUS_fp1 = "VC6042"
|
269
|
|
270
|
|
271
|
# ### MAGICS
|
272
|
# for the Waccom Mini-8900
|
273
|
MSTRING_MINI8900 = "\x55\xA5\xB5\x45\x55\x45\x4d\x02"
|
274
|
# for the B-TECH UV-2501+220 (including pre production ones)
|
275
|
MSTRING_220 = "\x55\x20\x15\x12\x12\x01\x4d\x02"
|
276
|
# for the QYT KT8900 & R
|
277
|
MSTRING_KT8900 = "\x55\x20\x15\x09\x16\x45\x4D\x02"
|
278
|
MSTRING_KT8900R = "\x55\x20\x15\x09\x25\x01\x4D\x02"
|
279
|
# magic string for all other models
|
280
|
MSTRING = "\x55\x20\x15\x09\x20\x45\x4d\x02"
|
281
|
# for the QYT KT7900D & KT8900D
|
282
|
MSTRING_KT8900D = "\x55\x20\x16\x08\x01\xFF\xDC\x02"
|
283
|
# for the BTECH UV-25X2 and UV-50X2
|
284
|
MSTRING_UV25X2 = "\x55\x20\x16\x12\x28\xFF\xDC\x02"
|
285
|
# for the BTECH UV-25X4
|
286
|
MSTRING_UV25X4 = "\x55\x20\x16\x11\x18\xFF\xDC\x02"
|
287
|
# for the BTECH GMRS-50X1
|
288
|
MSTRING_GMRS50X1 = "\x55\x20\x18\x10\x18\xFF\xDC\x02"
|
289
|
# for the QYT KT-8R
|
290
|
MSTRING_KT8R = "\x55\x20\x17\x07\x03\xFF\xDC\x02"
|
291
|
|
292
|
|
293
|
def _clean_buffer(radio):
|
294
|
"""Cleaning the read serial buffer, hard timeout to survive an infinite
|
295
|
data stream"""
|
296
|
|
297
|
# touching the serial timeout to optimize the flushing
|
298
|
# restored at the end to the default value
|
299
|
radio.pipe.timeout = 0.1
|
300
|
dump = "1"
|
301
|
datacount = 0
|
302
|
|
303
|
try:
|
304
|
while len(dump) > 0:
|
305
|
dump = radio.pipe.read(100)
|
306
|
datacount += len(dump)
|
307
|
# hard limit to survive a infinite serial data stream
|
308
|
# 5 times bigger than a normal rx block (69 bytes)
|
309
|
if datacount > 345:
|
310
|
seriale = "Please check your serial port selection."
|
311
|
raise errors.RadioError(seriale)
|
312
|
|
313
|
# restore the default serial timeout
|
314
|
radio.pipe.timeout = STIMEOUT
|
315
|
|
316
|
except Exception:
|
317
|
raise errors.RadioError("Unknown error cleaning the serial buffer")
|
318
|
|
319
|
|
320
|
def _rawrecv(radio, amount):
|
321
|
"""Raw read from the radio device, less intensive way"""
|
322
|
|
323
|
data = ""
|
324
|
|
325
|
try:
|
326
|
data = radio.pipe.read(amount)
|
327
|
|
328
|
# DEBUG
|
329
|
if debug is True:
|
330
|
LOG.debug("<== (%d) bytes:\n\n%s" %
|
331
|
(len(data), util.hexprint(data)))
|
332
|
|
333
|
# fail if no data is received
|
334
|
if len(data) == 0:
|
335
|
raise errors.RadioError("No data received from radio")
|
336
|
|
337
|
# notice on the logs if short
|
338
|
if len(data) < amount:
|
339
|
LOG.warn("Short reading %d bytes from the %d requested." %
|
340
|
(len(data), amount))
|
341
|
|
342
|
except:
|
343
|
raise errors.RadioError("Error reading data from radio")
|
344
|
|
345
|
return data
|
346
|
|
347
|
|
348
|
def _send(radio, data):
|
349
|
"""Send data to the radio device"""
|
350
|
|
351
|
try:
|
352
|
for byte in data:
|
353
|
radio.pipe.write(byte)
|
354
|
# Some OS (mainly Linux ones) are too fast on the serial and
|
355
|
# get the MCU inside the radio stuck in the early stages, this
|
356
|
# hits some models more than others.
|
357
|
#
|
358
|
# To cope with that we introduce a delay on the writes.
|
359
|
# Many option have been tested (delaying only after error occures,
|
360
|
# after short reads, only for linux, ...)
|
361
|
# Finally, a static delay was chosen as simplest of all solutions
|
362
|
# (Michael Wagner, OE4AMW)
|
363
|
# (for details, see issue 3993)
|
364
|
sleep(0.002)
|
365
|
|
366
|
# DEBUG
|
367
|
if debug is True:
|
368
|
LOG.debug("==> (%d) bytes:\n\n%s" %
|
369
|
(len(data), util.hexprint(data)))
|
370
|
except:
|
371
|
raise errors.RadioError("Error sending data to radio")
|
372
|
|
373
|
|
374
|
def _make_frame(cmd, addr, length, data=""):
|
375
|
"""Pack the info in the headder format"""
|
376
|
frame = "\x06" + struct.pack(">BHB", ord(cmd), addr, length)
|
377
|
# add the data if set
|
378
|
if len(data) != 0:
|
379
|
frame += data
|
380
|
|
381
|
return frame
|
382
|
|
383
|
|
384
|
def _recv(radio, addr):
|
385
|
"""Get data from the radio all at once to lower syscalls load"""
|
386
|
|
387
|
# Get the full 69 bytes at a time to reduce load
|
388
|
# 1 byte ACK + 4 bytes header + 64 bytes of data (BLOCK_SIZE)
|
389
|
|
390
|
# get the whole block
|
391
|
block = _rawrecv(radio, BLOCK_SIZE + 5)
|
392
|
|
393
|
# basic check
|
394
|
if len(block) < (BLOCK_SIZE + 5):
|
395
|
raise errors.RadioError("Short read of the block 0x%04x" % addr)
|
396
|
|
397
|
# checking for the ack
|
398
|
if block[0] != ACK_CMD:
|
399
|
raise errors.RadioError("Bad ack from radio in block 0x%04x" % addr)
|
400
|
|
401
|
# header validation
|
402
|
c, a, l = struct.unpack(">BHB", block[1:5])
|
403
|
if a != addr or l != BLOCK_SIZE or c != ord("X"):
|
404
|
LOG.debug("Invalid header for block 0x%04x" % addr)
|
405
|
LOG.debug("CMD: %s ADDR: %04x SIZE: %02x" % (c, a, l))
|
406
|
raise errors.RadioError("Invalid header for block 0x%04x:" % addr)
|
407
|
|
408
|
# return the data
|
409
|
return block[5:]
|
410
|
|
411
|
|
412
|
def _start_clone_mode(radio, status):
|
413
|
"""Put the radio in clone mode and get the ident string, 3 tries"""
|
414
|
|
415
|
# cleaning the serial buffer
|
416
|
_clean_buffer(radio)
|
417
|
|
418
|
# prep the data to show in the UI
|
419
|
status.cur = 0
|
420
|
status.msg = "Identifying the radio..."
|
421
|
status.max = 3
|
422
|
radio.status_fn(status)
|
423
|
|
424
|
try:
|
425
|
for a in range(0, status.max):
|
426
|
# Update the UI
|
427
|
status.cur = a + 1
|
428
|
radio.status_fn(status)
|
429
|
|
430
|
# send the magic word
|
431
|
_send(radio, radio._magic)
|
432
|
|
433
|
# Now you get a x06 of ACK if all goes well
|
434
|
ack = radio.pipe.read(1)
|
435
|
|
436
|
if ack == "\x06":
|
437
|
# DEBUG
|
438
|
LOG.info("Magic ACK received")
|
439
|
status.cur = status.max
|
440
|
radio.status_fn(status)
|
441
|
|
442
|
return True
|
443
|
|
444
|
return False
|
445
|
|
446
|
except errors.RadioError:
|
447
|
raise
|
448
|
except Exception, e:
|
449
|
raise errors.RadioError("Error sending Magic to radio:\n%s" % e)
|
450
|
|
451
|
|
452
|
def _do_ident(radio, status, upload=False):
|
453
|
"""Put the radio in PROGRAM mode & identify it"""
|
454
|
# set the serial discipline
|
455
|
radio.pipe.baudrate = 9600
|
456
|
radio.pipe.parity = "N"
|
457
|
|
458
|
# open the radio into program mode
|
459
|
if _start_clone_mode(radio, status) is False:
|
460
|
msg = "Radio did not enter clone mode"
|
461
|
# warning about old versions of QYT KT8900
|
462
|
if radio.MODEL == "KT8900":
|
463
|
msg += ". You may want to try it as a WACCOM MINI-8900, there is a"
|
464
|
msg += " known variant of this radios that is a clone of it."
|
465
|
raise errors.RadioError(msg)
|
466
|
|
467
|
# Ok, get the ident string
|
468
|
ident = _rawrecv(radio, 49)
|
469
|
|
470
|
# basic check for the ident
|
471
|
if len(ident) != 49:
|
472
|
raise errors.RadioError("Radio send a short ident block.")
|
473
|
|
474
|
# check if ident is OK
|
475
|
itis = False
|
476
|
for fp in radio._fileid:
|
477
|
if fp in ident:
|
478
|
# got it!
|
479
|
itis = True
|
480
|
# checking if we are dealing with a Gen 3 BTECH
|
481
|
if radio.VENDOR == "BTECH" and fp in BTECH3:
|
482
|
radio.btech3 = True
|
483
|
|
484
|
break
|
485
|
|
486
|
if itis is False:
|
487
|
LOG.debug("Incorrect model ID, got this:\n\n" + util.hexprint(ident))
|
488
|
raise errors.RadioError("Radio identification failed.")
|
489
|
|
490
|
# some radios needs a extra read and check for a code on it, this ones
|
491
|
# has the check value in the _id2 var, others simply False
|
492
|
if radio._id2 is not False:
|
493
|
# lower the timeout here as this radios are reseting due to timeout
|
494
|
radio.pipe.timeout = 0.05
|
495
|
|
496
|
# query & receive the extra ID
|
497
|
_send(radio, _make_frame("S", 0x3DF0, 16))
|
498
|
id2 = _rawrecv(radio, 21)
|
499
|
|
500
|
# WARNING !!!!!!
|
501
|
# different radios send a response with a different amount of data
|
502
|
# it seems that it's padded with \xff, \x20 and some times with \x00
|
503
|
# we just care about the first 16, our magic string is in there
|
504
|
if len(id2) < 16:
|
505
|
raise errors.RadioError("The extra ID is short, aborting.")
|
506
|
|
507
|
# ok, the correct string must be in the received data
|
508
|
# the radio._id2 var will be always a list
|
509
|
flag2 = False
|
510
|
for _id2 in radio._id2:
|
511
|
if _id2 in id2:
|
512
|
flag2 = True
|
513
|
|
514
|
if not flag2:
|
515
|
LOG.debug("Full *BAD* extra ID on the %s is: \n%s" %
|
516
|
(radio.MODEL, util.hexprint(id2)))
|
517
|
raise errors.RadioError("The extra ID is wrong, aborting.")
|
518
|
|
519
|
# this radios need a extra request/answer here on the upload
|
520
|
# the amount of data received depends of the radio type
|
521
|
#
|
522
|
# also the first block of TX must no have the ACK at the beginning
|
523
|
# see _upload for this.
|
524
|
if upload is True:
|
525
|
# send an ACK
|
526
|
_send(radio, ACK_CMD)
|
527
|
|
528
|
# the amount of data depend on the radio, so far we have two radios
|
529
|
# reading two bytes with an ACK at the end and just ONE with just
|
530
|
# one byte (QYT KT8900)
|
531
|
# the JT-6188 appears a clone of the last, but reads TWO bytes.
|
532
|
#
|
533
|
# we will read two bytes with a custom timeout to not penalize the
|
534
|
# users for this.
|
535
|
#
|
536
|
# we just check for a response and last byte being a ACK, that is
|
537
|
# the common stone for all radios (3 so far)
|
538
|
ack = _rawrecv(radio, 2)
|
539
|
|
540
|
# checking
|
541
|
if len(ack) == 0 or ack[-1:] != ACK_CMD:
|
542
|
raise errors.RadioError("Radio didn't ACK the upload")
|
543
|
|
544
|
# restore the default serial timeout
|
545
|
radio.pipe.timeout = STIMEOUT
|
546
|
|
547
|
# DEBUG
|
548
|
LOG.info("Positive ident, this is a %s %s" % (radio.VENDOR, radio.MODEL))
|
549
|
|
550
|
return True
|
551
|
|
552
|
|
553
|
def _download(radio):
|
554
|
"""Get the memory map"""
|
555
|
|
556
|
# UI progress
|
557
|
status = chirp_common.Status()
|
558
|
|
559
|
# put radio in program mode and identify it
|
560
|
_do_ident(radio, status)
|
561
|
|
562
|
# the models that doesn't have the extra ID have to make a dummy read here
|
563
|
if radio._id2 is False:
|
564
|
_send(radio, _make_frame("S", 0, BLOCK_SIZE))
|
565
|
discard = _rawrecv(radio, BLOCK_SIZE + 5)
|
566
|
|
567
|
if debug is True:
|
568
|
LOG.info("Dummy first block read done, got this:\n\n %s",
|
569
|
util.hexprint(discard))
|
570
|
|
571
|
# reset the progress bar in the UI
|
572
|
status.max = MEM_SIZE / BLOCK_SIZE
|
573
|
status.msg = "Cloning from radio..."
|
574
|
status.cur = 0
|
575
|
radio.status_fn(status)
|
576
|
|
577
|
# cleaning the serial buffer
|
578
|
_clean_buffer(radio)
|
579
|
|
580
|
data = ""
|
581
|
for addr in range(0, MEM_SIZE, BLOCK_SIZE):
|
582
|
# sending the read request
|
583
|
_send(radio, _make_frame("S", addr, BLOCK_SIZE))
|
584
|
|
585
|
# read
|
586
|
d = _recv(radio, addr)
|
587
|
|
588
|
# aggregate the data
|
589
|
data += d
|
590
|
|
591
|
# UI Update
|
592
|
status.cur = addr / BLOCK_SIZE
|
593
|
status.msg = "Cloning from radio..."
|
594
|
radio.status_fn(status)
|
595
|
|
596
|
return data
|
597
|
|
598
|
|
599
|
def _upload(radio):
|
600
|
"""Upload procedure"""
|
601
|
|
602
|
# The UPLOAD mem is restricted to lower than 0x3100,
|
603
|
# so we will overide that here localy
|
604
|
MEM_SIZE = radio.UPLOAD_MEM_SIZE
|
605
|
|
606
|
# UI progress
|
607
|
status = chirp_common.Status()
|
608
|
|
609
|
# put radio in program mode and identify it
|
610
|
_do_ident(radio, status, True)
|
611
|
|
612
|
# get the data to upload to radio
|
613
|
data = radio.get_mmap()
|
614
|
|
615
|
# Reset the UI progress
|
616
|
status.max = MEM_SIZE / TX_BLOCK_SIZE
|
617
|
status.cur = 0
|
618
|
status.msg = "Cloning to radio..."
|
619
|
radio.status_fn(status)
|
620
|
|
621
|
# the radios that doesn't have the extra ID 'may' do a dummy write, I found
|
622
|
# that leveraging the bad ACK and NOT doing the dummy write is ok, as the
|
623
|
# dummy write is accepted (it actually writes to the mem!) by the radio.
|
624
|
|
625
|
# cleaning the serial buffer
|
626
|
_clean_buffer(radio)
|
627
|
|
628
|
# the fun start here
|
629
|
for addr in range(0, MEM_SIZE, TX_BLOCK_SIZE):
|
630
|
# getting the block of data to send
|
631
|
d = data[addr:addr + TX_BLOCK_SIZE]
|
632
|
|
633
|
# build the frame to send
|
634
|
frame = _make_frame("X", addr, TX_BLOCK_SIZE, d)
|
635
|
|
636
|
# first block must not send the ACK at the beginning for the
|
637
|
# ones that has the extra id, since this have to do a extra step
|
638
|
if addr == 0 and radio._id2 is not False:
|
639
|
frame = frame[1:]
|
640
|
|
641
|
# send the frame
|
642
|
_send(radio, frame)
|
643
|
|
644
|
# receiving the response
|
645
|
ack = _rawrecv(radio, 1)
|
646
|
|
647
|
# basic check
|
648
|
if len(ack) != 1:
|
649
|
raise errors.RadioError("No ACK when writing block 0x%04x" % addr)
|
650
|
|
651
|
if ack not in "\x06\x05":
|
652
|
raise errors.RadioError("Bad ACK writing block 0x%04x:" % addr)
|
653
|
|
654
|
# UI Update
|
655
|
status.cur = addr / TX_BLOCK_SIZE
|
656
|
status.msg = "Cloning to radio..."
|
657
|
radio.status_fn(status)
|
658
|
|
659
|
|
660
|
def model_match(cls, data):
|
661
|
"""Match the opened/downloaded image to the correct version"""
|
662
|
rid = data[0x3f70:0x3f76]
|
663
|
|
664
|
if rid in cls._fileid:
|
665
|
return True
|
666
|
|
667
|
return False
|
668
|
|
669
|
|
670
|
def _decode_ranges(low, high):
|
671
|
"""Unpack the data in the ranges zones in the memmap and return
|
672
|
a tuple with the integer corresponding to the Mhz it means"""
|
673
|
ilow = int(low[0]) * 100 + int(low[1]) * 10 + int(low[2])
|
674
|
ihigh = int(high[0]) * 100 + int(high[1]) * 10 + int(high[2])
|
675
|
ilow *= 1000000
|
676
|
ihigh *= 1000000
|
677
|
|
678
|
return (ilow, ihigh)
|
679
|
|
680
|
|
681
|
def _split(rf, f1, f2):
|
682
|
"""Returns False if the two freqs are in the same band (no split)
|
683
|
or True otherwise"""
|
684
|
|
685
|
# determine if the two freqs are in the same band
|
686
|
for low, high in rf.valid_bands:
|
687
|
if f1 >= low and f1 <= high and \
|
688
|
f2 >= low and f2 <= high:
|
689
|
# if the two freqs are on the same Band this is not a split
|
690
|
return False
|
691
|
|
692
|
# if you get here is because the freq pairs are split
|
693
|
return True
|
694
|
|
695
|
|
696
|
class BTechMobileCommon(chirp_common.CloneModeRadio,
|
697
|
chirp_common.ExperimentalRadio):
|
698
|
"""BTECH's UV-5001 and alike radios"""
|
699
|
VENDOR = "BTECH"
|
700
|
MODEL = ""
|
701
|
IDENT = ""
|
702
|
BANDS = 2
|
703
|
COLOR_LCD = False
|
704
|
COLOR_LCD2 = False
|
705
|
COLOR_LCD3 = False
|
706
|
NAME_LENGTH = 6
|
707
|
UPLOAD_MEM_SIZE = 0X3100
|
708
|
_power_levels = [chirp_common.PowerLevel("High", watts=25),
|
709
|
chirp_common.PowerLevel("Low", watts=10)]
|
710
|
_vhf_range = (130000000, 180000000)
|
711
|
_220_range = (200000000, 271000000)
|
712
|
_uhf_range = (400000000, 521000000)
|
713
|
_350_range = (350000000, 391000000)
|
714
|
_upper = 199
|
715
|
_magic = MSTRING
|
716
|
_fileid = None
|
717
|
_id2 = False
|
718
|
btech3 = False
|
719
|
|
720
|
@classmethod
|
721
|
def get_prompts(cls):
|
722
|
rp = chirp_common.RadioPrompts()
|
723
|
rp.experimental = \
|
724
|
('This driver is experimental.\n'
|
725
|
'\n'
|
726
|
'Please keep a copy of your memories with the original software '
|
727
|
'if you treasure them, this driver is new and may contain'
|
728
|
' bugs.\n'
|
729
|
'\n'
|
730
|
)
|
731
|
rp.pre_download = _(dedent("""\
|
732
|
Follow these instructions to download your info:
|
733
|
|
734
|
1 - Turn off your radio
|
735
|
2 - Connect your interface cable
|
736
|
3 - Turn on your radio
|
737
|
4 - Do the download of your radio data
|
738
|
|
739
|
"""))
|
740
|
rp.pre_upload = _(dedent("""\
|
741
|
Follow these instructions to upload your info:
|
742
|
|
743
|
1 - Turn off your radio
|
744
|
2 - Connect your interface cable
|
745
|
3 - Turn on your radio
|
746
|
4 - Do the upload of your radio data
|
747
|
|
748
|
"""))
|
749
|
return rp
|
750
|
|
751
|
def get_features(self):
|
752
|
"""Get the radio's features"""
|
753
|
|
754
|
# we will use the following var as global
|
755
|
global POWER_LEVELS
|
756
|
|
757
|
rf = chirp_common.RadioFeatures()
|
758
|
rf.has_settings = True
|
759
|
rf.has_bank = False
|
760
|
rf.has_tuning_step = False
|
761
|
rf.can_odd_split = True
|
762
|
rf.has_name = True
|
763
|
rf.has_offset = True
|
764
|
rf.has_mode = True
|
765
|
rf.has_dtcs = True
|
766
|
rf.has_rx_dtcs = True
|
767
|
rf.has_dtcs_polarity = True
|
768
|
rf.has_ctone = True
|
769
|
rf.has_cross = True
|
770
|
rf.valid_modes = MODES
|
771
|
rf.valid_characters = VALID_CHARS
|
772
|
rf.valid_name_length = self.NAME_LENGTH
|
773
|
rf.valid_duplexes = ["", "-", "+", "split", "off"]
|
774
|
rf.valid_tmodes = ['', 'Tone', 'TSQL', 'DTCS', 'Cross']
|
775
|
rf.valid_cross_modes = [
|
776
|
"Tone->Tone",
|
777
|
"DTCS->",
|
778
|
"->DTCS",
|
779
|
"Tone->DTCS",
|
780
|
"DTCS->Tone",
|
781
|
"->Tone",
|
782
|
"DTCS->DTCS"]
|
783
|
rf.valid_skips = SKIP_VALUES
|
784
|
rf.valid_dtcs_codes = DTCS
|
785
|
rf.valid_tuning_steps = STEPS
|
786
|
rf.memory_bounds = (0, self._upper)
|
787
|
|
788
|
# power levels
|
789
|
POWER_LEVELS = self._power_levels
|
790
|
rf.valid_power_levels = POWER_LEVELS
|
791
|
|
792
|
# normal dual bands
|
793
|
rf.valid_bands = [self._vhf_range, self._uhf_range]
|
794
|
|
795
|
# 220 band
|
796
|
if self.BANDS == 3 or self.BANDS == 4:
|
797
|
rf.valid_bands.append(self._220_range)
|
798
|
|
799
|
# 350 band
|
800
|
if self.BANDS == 4:
|
801
|
rf.valid_bands.append(self._350_range)
|
802
|
|
803
|
return rf
|
804
|
|
805
|
def sync_in(self):
|
806
|
"""Download from radio"""
|
807
|
data = _download(self)
|
808
|
self._mmap = memmap.MemoryMap(data)
|
809
|
self.process_mmap()
|
810
|
|
811
|
def sync_out(self):
|
812
|
"""Upload to radio"""
|
813
|
try:
|
814
|
_upload(self)
|
815
|
except errors.RadioError:
|
816
|
raise
|
817
|
except Exception, e:
|
818
|
raise errors.RadioError("Error: %s" % e)
|
819
|
|
820
|
def get_raw_memory(self, number):
|
821
|
return repr(self._memobj.memory[number])
|
822
|
|
823
|
def _decode_tone(self, val):
|
824
|
"""Parse the tone data to decode from mem, it returns:
|
825
|
Mode (''|DTCS|Tone), Value (None|###), Polarity (None,N,R)"""
|
826
|
pol = None
|
827
|
|
828
|
if val in [0, 65535]:
|
829
|
return '', None, None
|
830
|
elif val > 0x0258:
|
831
|
a = val / 10.0
|
832
|
return 'Tone', a, pol
|
833
|
else:
|
834
|
if val > 0x69:
|
835
|
index = val - 0x6A
|
836
|
pol = "R"
|
837
|
else:
|
838
|
index = val - 1
|
839
|
pol = "N"
|
840
|
|
841
|
tone = DTCS[index]
|
842
|
return 'DTCS', tone, pol
|
843
|
|
844
|
def _encode_tone(self, memval, mode, val, pol):
|
845
|
"""Parse the tone data to encode from UI to mem"""
|
846
|
if mode == '' or mode is None:
|
847
|
memval.set_raw("\x00\x00")
|
848
|
elif mode == 'Tone':
|
849
|
memval.set_value(val * 10)
|
850
|
elif mode == 'DTCS':
|
851
|
# detect the index in the DTCS list
|
852
|
try:
|
853
|
index = DTCS.index(val)
|
854
|
if pol == "N":
|
855
|
index += 1
|
856
|
else:
|
857
|
index += 0x6A
|
858
|
memval.set_value(index)
|
859
|
except:
|
860
|
msg = "Digital Tone '%d' is not supported" % value
|
861
|
LOG.error(msg)
|
862
|
raise errors.RadioError(msg)
|
863
|
else:
|
864
|
msg = "Internal error: invalid mode '%s'" % mode
|
865
|
LOG.error(msg)
|
866
|
raise errors.InvalidDataError(msg)
|
867
|
|
868
|
def get_memory(self, number):
|
869
|
"""Get the mem representation from the radio image"""
|
870
|
_mem = self._memobj.memory[number]
|
871
|
_names = self._memobj.names[number]
|
872
|
|
873
|
# Create a high-level memory object to return to the UI
|
874
|
mem = chirp_common.Memory()
|
875
|
|
876
|
# Memory number
|
877
|
mem.number = number
|
878
|
|
879
|
if _mem.get_raw()[0] == "\xFF":
|
880
|
mem.empty = True
|
881
|
return mem
|
882
|
|
883
|
# Freq and offset
|
884
|
mem.freq = int(_mem.rxfreq) * 10
|
885
|
# tx freq can be blank
|
886
|
if _mem.get_raw()[4] == "\xFF":
|
887
|
# TX freq not set
|
888
|
mem.offset = 0
|
889
|
mem.duplex = "off"
|
890
|
else:
|
891
|
# TX freq set
|
892
|
offset = (int(_mem.txfreq) * 10) - mem.freq
|
893
|
if offset != 0:
|
894
|
if _split(self.get_features(), mem.freq, int(
|
895
|
_mem.txfreq) * 10):
|
896
|
mem.duplex = "split"
|
897
|
mem.offset = int(_mem.txfreq) * 10
|
898
|
elif offset < 0:
|
899
|
mem.offset = abs(offset)
|
900
|
mem.duplex = "-"
|
901
|
elif offset > 0:
|
902
|
mem.offset = offset
|
903
|
mem.duplex = "+"
|
904
|
else:
|
905
|
mem.offset = 0
|
906
|
|
907
|
# name TAG of the channel
|
908
|
mem.name = str(_names.name).rstrip("\xFF").replace("\xFF", " ")
|
909
|
|
910
|
# power
|
911
|
mem.power = POWER_LEVELS[int(_mem.power)]
|
912
|
|
913
|
# wide/narrow
|
914
|
mem.mode = MODES[int(_mem.wide)]
|
915
|
|
916
|
# skip
|
917
|
mem.skip = SKIP_VALUES[_mem.add]
|
918
|
|
919
|
# tone data
|
920
|
rxtone = txtone = None
|
921
|
txtone = self._decode_tone(_mem.txtone)
|
922
|
rxtone = self._decode_tone(_mem.rxtone)
|
923
|
chirp_common.split_tone_decode(mem, txtone, rxtone)
|
924
|
|
925
|
# Extra
|
926
|
mem.extra = RadioSettingGroup("extra", "Extra")
|
927
|
|
928
|
if not self.COLOR_LCD or \
|
929
|
(self.COLOR_LCD and not self.VENDOR == "BTECH"):
|
930
|
scramble = RadioSetting("scramble", "Scramble",
|
931
|
RadioSettingValueBoolean(bool(
|
932
|
_mem.scramble)))
|
933
|
mem.extra.append(scramble)
|
934
|
|
935
|
bcl = RadioSetting("bcl", "Busy channel lockout",
|
936
|
RadioSettingValueBoolean(bool(_mem.bcl)))
|
937
|
mem.extra.append(bcl)
|
938
|
|
939
|
pttid = RadioSetting("pttid", "PTT ID",
|
940
|
RadioSettingValueList(PTTID_LIST,
|
941
|
PTTID_LIST[_mem.pttid]))
|
942
|
mem.extra.append(pttid)
|
943
|
|
944
|
# validating scode
|
945
|
scode = _mem.scode if _mem.scode != 15 else 0
|
946
|
pttidcode = RadioSetting("scode", "PTT ID signal code",
|
947
|
RadioSettingValueList(
|
948
|
PTTIDCODE_LIST,
|
949
|
PTTIDCODE_LIST[scode]))
|
950
|
mem.extra.append(pttidcode)
|
951
|
|
952
|
optsig = RadioSetting("optsig", "Optional signaling",
|
953
|
RadioSettingValueList(
|
954
|
OPTSIG_LIST,
|
955
|
OPTSIG_LIST[_mem.optsig]))
|
956
|
mem.extra.append(optsig)
|
957
|
|
958
|
spmute = RadioSetting("spmute", "Speaker mute",
|
959
|
RadioSettingValueList(
|
960
|
SPMUTE_LIST,
|
961
|
SPMUTE_LIST[_mem.spmute]))
|
962
|
mem.extra.append(spmute)
|
963
|
|
964
|
return mem
|
965
|
|
966
|
def set_memory(self, mem):
|
967
|
"""Set the memory data in the eeprom img from the UI"""
|
968
|
# get the eprom representation of this channel
|
969
|
_mem = self._memobj.memory[mem.number]
|
970
|
_names = self._memobj.names[mem.number]
|
971
|
|
972
|
mem_was_empty = False
|
973
|
# same method as used in get_memory for determining if mem is empty
|
974
|
# doing this BEFORE overwriting it with new values ...
|
975
|
if _mem.get_raw()[0] == "\xFF":
|
976
|
LOG.debug("This mem was empty before")
|
977
|
mem_was_empty = True
|
978
|
|
979
|
# if empty memmory
|
980
|
if mem.empty:
|
981
|
# the channel itself
|
982
|
_mem.set_raw("\xFF" * 16)
|
983
|
# the name tag
|
984
|
_names.set_raw("\xFF" * 16)
|
985
|
return
|
986
|
|
987
|
if mem_was_empty:
|
988
|
# Zero the whole memory if we're making it unempty for
|
989
|
# the first time
|
990
|
LOG.debug('Zeroing new memory')
|
991
|
_mem.set_raw('\x00' * 16)
|
992
|
|
993
|
# frequency
|
994
|
_mem.rxfreq = mem.freq / 10
|
995
|
|
996
|
# duplex
|
997
|
if mem.duplex == "+":
|
998
|
_mem.txfreq = (mem.freq + mem.offset) / 10
|
999
|
elif mem.duplex == "-":
|
1000
|
_mem.txfreq = (mem.freq - mem.offset) / 10
|
1001
|
elif mem.duplex == "off":
|
1002
|
for i in _mem.txfreq:
|
1003
|
i.set_raw("\xFF")
|
1004
|
elif mem.duplex == "split":
|
1005
|
_mem.txfreq = mem.offset / 10
|
1006
|
else:
|
1007
|
_mem.txfreq = mem.freq / 10
|
1008
|
|
1009
|
# tone data
|
1010
|
((txmode, txtone, txpol), (rxmode, rxtone, rxpol)) = \
|
1011
|
chirp_common.split_tone_encode(mem)
|
1012
|
self._encode_tone(_mem.txtone, txmode, txtone, txpol)
|
1013
|
self._encode_tone(_mem.rxtone, rxmode, rxtone, rxpol)
|
1014
|
|
1015
|
# name TAG of the channel
|
1016
|
if len(mem.name) < self.NAME_LENGTH:
|
1017
|
# we must pad to self.NAME_LENGTH chars, " " = "\xFF"
|
1018
|
mem.name = str(mem.name).ljust(self.NAME_LENGTH, " ")
|
1019
|
_names.name = str(mem.name).replace(" ", "\xFF")
|
1020
|
|
1021
|
# power, # default power level is high
|
1022
|
_mem.power = 0 if mem.power is None else POWER_LEVELS.index(mem.power)
|
1023
|
|
1024
|
# wide/narrow
|
1025
|
_mem.wide = MODES.index(mem.mode)
|
1026
|
|
1027
|
# scan add property
|
1028
|
_mem.add = SKIP_VALUES.index(mem.skip)
|
1029
|
|
1030
|
# reseting unknowns, this have to be set by hand
|
1031
|
_mem.unknown0 = 0
|
1032
|
_mem.unknown1 = 0
|
1033
|
_mem.unknown2 = 0
|
1034
|
_mem.unknown3 = 0
|
1035
|
_mem.unknown4 = 0
|
1036
|
_mem.unknown5 = 0
|
1037
|
_mem.unknown6 = 0
|
1038
|
|
1039
|
def _zero_settings():
|
1040
|
_mem.spmute = 0
|
1041
|
_mem.optsig = 0
|
1042
|
_mem.scramble = 0
|
1043
|
_mem.bcl = 0
|
1044
|
_mem.pttid = 0
|
1045
|
_mem.scode = 0
|
1046
|
|
1047
|
if self.COLOR_LCD and _mem.scramble:
|
1048
|
LOG.info('Resetting scramble bit for BTECH COLOR_LCD variant')
|
1049
|
_mem.scramble = 0
|
1050
|
|
1051
|
# extra settings
|
1052
|
if len(mem.extra) > 0:
|
1053
|
# there are setting, parse
|
1054
|
LOG.debug("Extra-Setting supplied. Setting them.")
|
1055
|
# Zero them all first so any not provided by model don't
|
1056
|
# stay set
|
1057
|
_zero_settings()
|
1058
|
for setting in mem.extra:
|
1059
|
setattr(_mem, setting.get_name(), setting.value)
|
1060
|
else:
|
1061
|
if mem.empty:
|
1062
|
LOG.debug("New mem is empty.")
|
1063
|
else:
|
1064
|
LOG.debug("New mem is NOT empty")
|
1065
|
# set extra-settings to default ONLY when apreviously empty or
|
1066
|
# deleted memory was edited to prevent errors such as #4121
|
1067
|
if mem_was_empty:
|
1068
|
LOG.debug("old mem was empty. Setting default for extras.")
|
1069
|
_zero_settings()
|
1070
|
|
1071
|
return mem
|
1072
|
|
1073
|
def get_settings(self):
|
1074
|
"""Translate the bit in the mem_struct into settings in the UI"""
|
1075
|
_mem = self._memobj
|
1076
|
basic = RadioSettingGroup("basic", "Basic Settings")
|
1077
|
advanced = RadioSettingGroup("advanced", "Advanced Settings")
|
1078
|
other = RadioSettingGroup("other", "Other Settings")
|
1079
|
work = RadioSettingGroup("work", "Work Mode Settings")
|
1080
|
top = RadioSettings(basic, advanced, other, work)
|
1081
|
|
1082
|
# Basic
|
1083
|
if self.COLOR_LCD:
|
1084
|
tmr = RadioSetting("settings.tmr", "Transceiver multi-receive",
|
1085
|
RadioSettingValueList(
|
1086
|
self.LIST_TMR,
|
1087
|
self.LIST_TMR[_mem.settings.tmr]))
|
1088
|
basic.append(tmr)
|
1089
|
else:
|
1090
|
tdr = RadioSetting("settings.tdr", "Transceiver dual receive",
|
1091
|
RadioSettingValueBoolean(_mem.settings.tdr))
|
1092
|
basic.append(tdr)
|
1093
|
|
1094
|
sql = RadioSetting("settings.sql", "Squelch level",
|
1095
|
RadioSettingValueInteger(0, 9, _mem.settings.sql))
|
1096
|
basic.append(sql)
|
1097
|
|
1098
|
if self.MODEL == "GMRS-50X1":
|
1099
|
autolk = RadioSetting("settings.autolk", "Auto keylock",
|
1100
|
RadioSettingValueBoolean(
|
1101
|
_mem.settings.autolk))
|
1102
|
basic.append(autolk)
|
1103
|
|
1104
|
tot = RadioSetting("settings.tot", "Time out timer",
|
1105
|
RadioSettingValueList(
|
1106
|
LIST_TOT,
|
1107
|
LIST_TOT[_mem.settings.tot]))
|
1108
|
basic.append(tot)
|
1109
|
|
1110
|
if self.MODEL == "KT-8R":
|
1111
|
save = RadioSetting("settings.save", "Battery Save",
|
1112
|
RadioSettingValueBoolean(
|
1113
|
_mem.settings.save))
|
1114
|
basic.append(save)
|
1115
|
|
1116
|
if not self.MODEL == "KT-8R":
|
1117
|
if self.VENDOR == "BTECH" or self.COLOR_LCD:
|
1118
|
apo = RadioSetting("settings.apo", "Auto power off timer",
|
1119
|
RadioSettingValueList(
|
1120
|
LIST_APO,
|
1121
|
LIST_APO[_mem.settings.apo]))
|
1122
|
basic.append(apo)
|
1123
|
else:
|
1124
|
toa = RadioSetting("settings.apo", "Time out alert timer",
|
1125
|
RadioSettingValueList(
|
1126
|
LIST_OFF1TO10,
|
1127
|
LIST_OFF1TO10[_mem.settings.apo]))
|
1128
|
basic.append(toa)
|
1129
|
|
1130
|
abr = RadioSetting("settings.abr", "Backlight timer",
|
1131
|
RadioSettingValueList(
|
1132
|
LIST_OFF1TO50,
|
1133
|
LIST_OFF1TO50[_mem.settings.abr]))
|
1134
|
basic.append(abr)
|
1135
|
|
1136
|
beep = RadioSetting("settings.beep", "Key beep",
|
1137
|
RadioSettingValueBoolean(_mem.settings.beep))
|
1138
|
basic.append(beep)
|
1139
|
|
1140
|
if self.MODEL == "KT-8R":
|
1141
|
dsub = RadioSetting("settings.dsub", "CTCSS/DCS code display",
|
1142
|
RadioSettingValueBoolean(
|
1143
|
_mem.settings.dsub))
|
1144
|
basic.append(dsub)
|
1145
|
|
1146
|
if self.MODEL == "KT-8R":
|
1147
|
dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone",
|
1148
|
RadioSettingValueBoolean(
|
1149
|
_mem.settings.dtmfst))
|
1150
|
basic.append(dtmfst)
|
1151
|
else:
|
1152
|
dtmfst = RadioSetting("settings.dtmfst", "DTMF side tone",
|
1153
|
RadioSettingValueList(
|
1154
|
LIST_DTMFST,
|
1155
|
LIST_DTMFST[_mem.settings.dtmfst]))
|
1156
|
basic.append(dtmfst)
|
1157
|
|
1158
|
if not self.COLOR_LCD:
|
1159
|
prisc = RadioSetting("settings.prisc", "Priority scan",
|
1160
|
RadioSettingValueBoolean(
|
1161
|
_mem.settings.prisc))
|
1162
|
basic.append(prisc)
|
1163
|
|
1164
|
prich = RadioSetting("settings.prich", "Priority channel",
|
1165
|
RadioSettingValueInteger(0, self._upper,
|
1166
|
_mem.settings.prich))
|
1167
|
basic.append(prich)
|
1168
|
|
1169
|
screv = RadioSetting("settings.screv", "Scan resume method",
|
1170
|
RadioSettingValueList(
|
1171
|
LIST_SCREV,
|
1172
|
LIST_SCREV[_mem.settings.screv]))
|
1173
|
basic.append(screv)
|
1174
|
|
1175
|
pttlt = RadioSetting("settings.pttlt", "PTT transmit delay",
|
1176
|
RadioSettingValueInteger(0, 30,
|
1177
|
_mem.settings.pttlt))
|
1178
|
basic.append(pttlt)
|
1179
|
|
1180
|
if self.VENDOR == "BTECH" and self.COLOR_LCD:
|
1181
|
emctp = RadioSetting("settings.emctp", "Alarm mode",
|
1182
|
RadioSettingValueList(
|
1183
|
LIST_EMCTPX,
|
1184
|
LIST_EMCTPX[_mem.settings.emctp]))
|
1185
|
basic.append(emctp)
|
1186
|
else:
|
1187
|
emctp = RadioSetting("settings.emctp", "Alarm mode",
|
1188
|
RadioSettingValueList(
|
1189
|
LIST_EMCTP,
|
1190
|
LIST_EMCTP[_mem.settings.emctp]))
|
1191
|
basic.append(emctp)
|
1192
|
|
1193
|
emcch = RadioSetting("settings.emcch", "Alarm channel",
|
1194
|
RadioSettingValueInteger(0, self._upper,
|
1195
|
_mem.settings.emcch))
|
1196
|
basic.append(emcch)
|
1197
|
|
1198
|
if self.COLOR_LCD:
|
1199
|
if _mem.settings.sigbp > 0x01:
|
1200
|
val = 0x00
|
1201
|
else:
|
1202
|
val = _mem.settings.sigbp
|
1203
|
sigbp = RadioSetting("settings.sigbp", "Signal beep",
|
1204
|
RadioSettingValueBoolean(val))
|
1205
|
basic.append(sigbp)
|
1206
|
else:
|
1207
|
ringt = RadioSetting("settings.ringt", "Ring time",
|
1208
|
RadioSettingValueList(
|
1209
|
LIST_OFF1TO9,
|
1210
|
LIST_OFF1TO9[_mem.settings.ringt]))
|
1211
|
basic.append(ringt)
|
1212
|
|
1213
|
camdf = RadioSetting("settings.camdf", "Display mode A",
|
1214
|
RadioSettingValueList(
|
1215
|
LIST_MDF,
|
1216
|
LIST_MDF[_mem.settings.camdf]))
|
1217
|
basic.append(camdf)
|
1218
|
|
1219
|
cbmdf = RadioSetting("settings.cbmdf", "Display mode B",
|
1220
|
RadioSettingValueList(
|
1221
|
LIST_MDF,
|
1222
|
LIST_MDF[_mem.settings.cbmdf]))
|
1223
|
basic.append(cbmdf)
|
1224
|
|
1225
|
if self.COLOR_LCD:
|
1226
|
ccmdf = RadioSetting("settings.ccmdf", "Display mode C",
|
1227
|
RadioSettingValueList(
|
1228
|
LIST_MDF,
|
1229
|
LIST_MDF[_mem.settings.ccmdf]))
|
1230
|
basic.append(ccmdf)
|
1231
|
|
1232
|
cdmdf = RadioSetting("settings.cdmdf", "Display mode D",
|
1233
|
RadioSettingValueList(
|
1234
|
LIST_MDF,
|
1235
|
LIST_MDF[_mem.settings.cdmdf]))
|
1236
|
basic.append(cdmdf)
|
1237
|
|
1238
|
langua = RadioSetting("settings.langua", "Language",
|
1239
|
RadioSettingValueList(
|
1240
|
LIST_LANGUA,
|
1241
|
LIST_LANGUA[_mem.settings.langua]))
|
1242
|
basic.append(langua)
|
1243
|
|
1244
|
if self.MODEL == "KT-8R":
|
1245
|
voice = RadioSetting("settings.voice", "Voice prompt",
|
1246
|
RadioSettingValueList(
|
1247
|
LIST_VOICE,
|
1248
|
LIST_VOICE[_mem.settings.voice]))
|
1249
|
basic.append(voice)
|
1250
|
|
1251
|
vox = RadioSetting("settings.vox", "VOX",
|
1252
|
RadioSettingValueList(
|
1253
|
LIST_VOX,
|
1254
|
LIST_VOX[_mem.settings.vox]))
|
1255
|
basic.append(vox)
|
1256
|
|
1257
|
voxt = RadioSetting("settings.voxt", "VOX delay time",
|
1258
|
RadioSettingValueList(
|
1259
|
LIST_VOXT,
|
1260
|
LIST_VOXT[_mem.settings.voxt]))
|
1261
|
basic.append(voxt)
|
1262
|
|
1263
|
if self.VENDOR == "BTECH":
|
1264
|
if self.COLOR_LCD:
|
1265
|
sync = RadioSetting("settings.sync", "Channel display sync",
|
1266
|
RadioSettingValueList(
|
1267
|
LIST_SYNC,
|
1268
|
LIST_SYNC[_mem.settings.sync]))
|
1269
|
basic.append(sync)
|
1270
|
else:
|
1271
|
sync = RadioSetting("settings.sync", "A/B channel sync",
|
1272
|
RadioSettingValueBoolean(
|
1273
|
_mem.settings.sync))
|
1274
|
basic.append(sync)
|
1275
|
else:
|
1276
|
autolk = RadioSetting("settings.sync", "Auto keylock",
|
1277
|
RadioSettingValueBoolean(
|
1278
|
_mem.settings.sync))
|
1279
|
basic.append(autolk)
|
1280
|
|
1281
|
if not self.COLOR_LCD:
|
1282
|
ponmsg = RadioSetting("settings.ponmsg", "Power-on message",
|
1283
|
RadioSettingValueList(
|
1284
|
LIST_PONMSG,
|
1285
|
LIST_PONMSG[_mem.settings.ponmsg]))
|
1286
|
basic.append(ponmsg)
|
1287
|
|
1288
|
if self.COLOR_LCD and not (self.COLOR_LCD2 or self.COLOR_LCD3):
|
1289
|
mainfc = RadioSetting("settings.mainfc",
|
1290
|
"Main LCD foreground color",
|
1291
|
RadioSettingValueList(
|
1292
|
LIST_COLOR9,
|
1293
|
LIST_COLOR9[_mem.settings.mainfc]))
|
1294
|
basic.append(mainfc)
|
1295
|
|
1296
|
mainbc = RadioSetting("settings.mainbc",
|
1297
|
"Main LCD background color",
|
1298
|
RadioSettingValueList(
|
1299
|
LIST_COLOR9,
|
1300
|
LIST_COLOR9[_mem.settings.mainbc]))
|
1301
|
basic.append(mainbc)
|
1302
|
|
1303
|
menufc = RadioSetting("settings.menufc", "Menu foreground color",
|
1304
|
RadioSettingValueList(
|
1305
|
LIST_COLOR9,
|
1306
|
LIST_COLOR9[_mem.settings.menufc]))
|
1307
|
basic.append(menufc)
|
1308
|
|
1309
|
menubc = RadioSetting("settings.menubc", "Menu background color",
|
1310
|
RadioSettingValueList(
|
1311
|
LIST_COLOR9,
|
1312
|
LIST_COLOR9[_mem.settings.menubc]))
|
1313
|
basic.append(menubc)
|
1314
|
|
1315
|
stafc = RadioSetting("settings.stafc",
|
1316
|
"Top status foreground color",
|
1317
|
RadioSettingValueList(
|
1318
|
LIST_COLOR9,
|
1319
|
LIST_COLOR9[_mem.settings.stafc]))
|
1320
|
basic.append(stafc)
|
1321
|
|
1322
|
stabc = RadioSetting("settings.stabc",
|
1323
|
"Top status background color",
|
1324
|
RadioSettingValueList(
|
1325
|
LIST_COLOR9,
|
1326
|
LIST_COLOR9[_mem.settings.stabc]))
|
1327
|
basic.append(stabc)
|
1328
|
|
1329
|
sigfc = RadioSetting("settings.sigfc",
|
1330
|
"Bottom status foreground color",
|
1331
|
RadioSettingValueList(
|
1332
|
LIST_COLOR9,
|
1333
|
LIST_COLOR9[_mem.settings.sigfc]))
|
1334
|
basic.append(sigfc)
|
1335
|
|
1336
|
sigbc = RadioSetting("settings.sigbc",
|
1337
|
"Bottom status background color",
|
1338
|
RadioSettingValueList(
|
1339
|
LIST_COLOR9,
|
1340
|
LIST_COLOR9[_mem.settings.sigbc]))
|
1341
|
basic.append(sigbc)
|
1342
|
|
1343
|
rxfc = RadioSetting("settings.rxfc", "Receiving character color",
|
1344
|
RadioSettingValueList(
|
1345
|
LIST_COLOR9,
|
1346
|
LIST_COLOR9[_mem.settings.rxfc]))
|
1347
|
basic.append(rxfc)
|
1348
|
|
1349
|
txfc = RadioSetting("settings.txfc",
|
1350
|
"Transmitting character color",
|
1351
|
RadioSettingValueList(
|
1352
|
LIST_COLOR9,
|
1353
|
LIST_COLOR9[_mem.settings.txfc]))
|
1354
|
basic.append(txfc)
|
1355
|
|
1356
|
txdisp = RadioSetting("settings.txdisp",
|
1357
|
"Transmitting status display",
|
1358
|
RadioSettingValueList(
|
1359
|
LIST_TXDISP,
|
1360
|
LIST_TXDISP[_mem.settings.txdisp]))
|
1361
|
basic.append(txdisp)
|
1362
|
elif self.COLOR_LCD2 or self.COLOR_LCD3:
|
1363
|
stfc = RadioSetting("settings.stfc",
|
1364
|
"ST-FC",
|
1365
|
RadioSettingValueList(
|
1366
|
LIST_COLOR8,
|
1367
|
LIST_COLOR8[_mem.settings.stfc]))
|
1368
|
basic.append(stfc)
|
1369
|
|
1370
|
mffc = RadioSetting("settings.mffc",
|
1371
|
"MF-FC",
|
1372
|
RadioSettingValueList(
|
1373
|
LIST_COLOR8,
|
1374
|
LIST_COLOR8[_mem.settings.mffc]))
|
1375
|
basic.append(mffc)
|
1376
|
|
1377
|
sfafc = RadioSetting("settings.sfafc",
|
1378
|
"SFA-FC",
|
1379
|
RadioSettingValueList(
|
1380
|
LIST_COLOR8,
|
1381
|
LIST_COLOR8[_mem.settings.sfafc]))
|
1382
|
basic.append(sfafc)
|
1383
|
|
1384
|
sfbfc = RadioSetting("settings.sfbfc",
|
1385
|
"SFB-FC",
|
1386
|
RadioSettingValueList(
|
1387
|
LIST_COLOR8,
|
1388
|
LIST_COLOR8[_mem.settings.sfbfc]))
|
1389
|
basic.append(sfbfc)
|
1390
|
|
1391
|
sfcfc = RadioSetting("settings.sfcfc",
|
1392
|
"SFC-FC",
|
1393
|
RadioSettingValueList(
|
1394
|
LIST_COLOR8,
|
1395
|
LIST_COLOR8[_mem.settings.sfcfc]))
|
1396
|
basic.append(sfcfc)
|
1397
|
|
1398
|
sfdfc = RadioSetting("settings.sfdfc",
|
1399
|
"SFD-FC",
|
1400
|
RadioSettingValueList(
|
1401
|
LIST_COLOR8,
|
1402
|
LIST_COLOR8[_mem.settings.sfdfc]))
|
1403
|
basic.append(sfdfc)
|
1404
|
|
1405
|
subfc = RadioSetting("settings.subfc",
|
1406
|
"SUB-FC",
|
1407
|
RadioSettingValueList(
|
1408
|
LIST_COLOR8,
|
1409
|
LIST_COLOR8[_mem.settings.subfc]))
|
1410
|
basic.append(subfc)
|
1411
|
|
1412
|
fmfc = RadioSetting("settings.fmfc",
|
1413
|
"FM-FC",
|
1414
|
RadioSettingValueList(
|
1415
|
LIST_COLOR8,
|
1416
|
LIST_COLOR8[_mem.settings.fmfc]))
|
1417
|
basic.append(fmfc)
|
1418
|
|
1419
|
sigfc = RadioSetting("settings.sigfc",
|
1420
|
"SIG-FC",
|
1421
|
RadioSettingValueList(
|
1422
|
LIST_COLOR8,
|
1423
|
LIST_COLOR8[_mem.settings.sigfc]))
|
1424
|
basic.append(sigfc)
|
1425
|
|
1426
|
if not self.MODEL == "KT-8R":
|
1427
|
modfc = RadioSetting("settings.modfc",
|
1428
|
"MOD-FC",
|
1429
|
RadioSettingValueList(
|
1430
|
LIST_COLOR8,
|
1431
|
LIST_COLOR8[_mem.settings.modfc]))
|
1432
|
basic.append(modfc)
|
1433
|
|
1434
|
menufc = RadioSetting("settings.menufc",
|
1435
|
"MENUFC",
|
1436
|
RadioSettingValueList(
|
1437
|
LIST_COLOR8,
|
1438
|
LIST_COLOR8[_mem.settings.menufc]))
|
1439
|
basic.append(menufc)
|
1440
|
|
1441
|
txfc = RadioSetting("settings.txfc",
|
1442
|
"TX-FC",
|
1443
|
RadioSettingValueList(
|
1444
|
LIST_COLOR8,
|
1445
|
LIST_COLOR8[_mem.settings.txfc]))
|
1446
|
basic.append(txfc)
|
1447
|
|
1448
|
if self.MODEL == "KT-8R":
|
1449
|
rxfc = RadioSetting("settings.rxfc",
|
1450
|
"RX-FC",
|
1451
|
RadioSettingValueList(
|
1452
|
LIST_COLOR8,
|
1453
|
LIST_COLOR8[_mem.settings.rxfc]))
|
1454
|
basic.append(rxfc)
|
1455
|
|
1456
|
if not self.MODEL == "KT-8R":
|
1457
|
txdisp = RadioSetting("settings.txdisp",
|
1458
|
"Transmitting status display",
|
1459
|
RadioSettingValueList(
|
1460
|
LIST_TXDISP,
|
1461
|
LIST_TXDISP[_mem.settings.txdisp]))
|
1462
|
basic.append(txdisp)
|
1463
|
else:
|
1464
|
wtled = RadioSetting("settings.wtled", "Standby backlight Color",
|
1465
|
RadioSettingValueList(
|
1466
|
LIST_COLOR4,
|
1467
|
LIST_COLOR4[_mem.settings.wtled]))
|
1468
|
basic.append(wtled)
|
1469
|
|
1470
|
rxled = RadioSetting("settings.rxled", "RX backlight Color",
|
1471
|
RadioSettingValueList(
|
1472
|
LIST_COLOR4,
|
1473
|
LIST_COLOR4[_mem.settings.rxled]))
|
1474
|
basic.append(rxled)
|
1475
|
|
1476
|
txled = RadioSetting("settings.txled", "TX backlight Color",
|
1477
|
RadioSettingValueList(
|
1478
|
LIST_COLOR4,
|
1479
|
LIST_COLOR4[_mem.settings.txled]))
|
1480
|
basic.append(txled)
|
1481
|
|
1482
|
anil = RadioSetting("settings.anil", "ANI length",
|
1483
|
RadioSettingValueList(
|
1484
|
LIST_ANIL,
|
1485
|
LIST_ANIL[_mem.settings.anil]))
|
1486
|
basic.append(anil)
|
1487
|
|
1488
|
reps = RadioSetting("settings.reps", "Relay signal (tone burst)",
|
1489
|
RadioSettingValueList(
|
1490
|
LIST_REPS,
|
1491
|
LIST_REPS[_mem.settings.reps]))
|
1492
|
basic.append(reps)
|
1493
|
|
1494
|
if not self.MODEL == "GMRS-50X1" and not self.MODEL == "KT-8R":
|
1495
|
repm = RadioSetting("settings.repm", "Relay condition",
|
1496
|
RadioSettingValueList(
|
1497
|
LIST_REPM,
|
1498
|
LIST_REPM[_mem.settings.repm]))
|
1499
|
basic.append(repm)
|
1500
|
|
1501
|
if self.VENDOR == "BTECH" or self.COLOR_LCD:
|
1502
|
if self.COLOR_LCD:
|
1503
|
tmrmr = RadioSetting("settings.tmrmr", "TMR return time",
|
1504
|
RadioSettingValueList(
|
1505
|
LIST_OFF1TO50,
|
1506
|
LIST_OFF1TO50[_mem.settings.tmrmr]))
|
1507
|
basic.append(tmrmr)
|
1508
|
else:
|
1509
|
tdrab = RadioSetting("settings.tdrab", "TDR return time",
|
1510
|
RadioSettingValueList(
|
1511
|
LIST_OFF1TO50,
|
1512
|
LIST_OFF1TO50[_mem.settings.tdrab]))
|
1513
|
basic.append(tdrab)
|
1514
|
|
1515
|
ste = RadioSetting("settings.ste", "Squelch tail eliminate",
|
1516
|
RadioSettingValueBoolean(_mem.settings.ste))
|
1517
|
basic.append(ste)
|
1518
|
|
1519
|
rpste = RadioSetting("settings.rpste", "Repeater STE",
|
1520
|
RadioSettingValueList(
|
1521
|
LIST_OFF1TO9,
|
1522
|
LIST_OFF1TO9[_mem.settings.rpste]))
|
1523
|
basic.append(rpste)
|
1524
|
|
1525
|
rptdl = RadioSetting("settings.rptdl", "Repeater STE delay",
|
1526
|
RadioSettingValueList(
|
1527
|
LIST_RPTDL,
|
1528
|
LIST_RPTDL[_mem.settings.rptdl]))
|
1529
|
basic.append(rptdl)
|
1530
|
|
1531
|
if str(_mem.fingerprint.fp) in BTECH3:
|
1532
|
mgain = RadioSetting("settings.mgain", "Mic gain",
|
1533
|
RadioSettingValueInteger(0, 120,
|
1534
|
_mem.settings.mgain))
|
1535
|
basic.append(mgain)
|
1536
|
|
1537
|
if str(_mem.fingerprint.fp) in BTECH3 or self.COLOR_LCD:
|
1538
|
dtmfg = RadioSetting("settings.dtmfg", "DTMF gain",
|
1539
|
RadioSettingValueInteger(0, 60,
|
1540
|
_mem.settings.dtmfg))
|
1541
|
basic.append(dtmfg)
|
1542
|
|
1543
|
if self.VENDOR == "BTECH" and self.COLOR_LCD:
|
1544
|
mgain = RadioSetting("settings.mgain", "Mic gain",
|
1545
|
RadioSettingValueInteger(0, 120,
|
1546
|
_mem.settings.mgain))
|
1547
|
basic.append(mgain)
|
1548
|
|
1549
|
skiptx = RadioSetting("settings.skiptx", "Skip TX",
|
1550
|
RadioSettingValueList(
|
1551
|
LIST_SKIPTX,
|
1552
|
LIST_SKIPTX[_mem.settings.skiptx]))
|
1553
|
basic.append(skiptx)
|
1554
|
|
1555
|
scmode = RadioSetting("settings.scmode", "Scan mode",
|
1556
|
RadioSettingValueList(
|
1557
|
LIST_SCMODE,
|
1558
|
LIST_SCMODE[_mem.settings.scmode]))
|
1559
|
basic.append(scmode)
|
1560
|
|
1561
|
if self.MODEL == "KT-8R":
|
1562
|
tmrtx = RadioSetting("settings.tmrtx", "TX in multi-standby",
|
1563
|
RadioSettingValueList(
|
1564
|
LIST_TMRTX,
|
1565
|
LIST_TMRTX[_mem.settings.tmrtx]))
|
1566
|
basic.append(tmrtx)
|
1567
|
|
1568
|
# Advanced
|
1569
|
def _filter(name):
|
1570
|
filtered = ""
|
1571
|
for char in str(name):
|
1572
|
if char in VALID_CHARS:
|
1573
|
filtered += char
|
1574
|
else:
|
1575
|
filtered += " "
|
1576
|
return filtered
|
1577
|
|
1578
|
if self.COLOR_LCD and not (self.COLOR_LCD2 or self.COLOR_LCD3):
|
1579
|
_msg = self._memobj.poweron_msg
|
1580
|
line1 = RadioSetting("poweron_msg.line1",
|
1581
|
"Power-on message line 1",
|
1582
|
RadioSettingValueString(0, 8, _filter(
|
1583
|
_msg.line1)))
|
1584
|
advanced.append(line1)
|
1585
|
line2 = RadioSetting("poweron_msg.line2",
|
1586
|
"Power-on message line 2",
|
1587
|
RadioSettingValueString(0, 8, _filter(
|
1588
|
_msg.line2)))
|
1589
|
advanced.append(line2)
|
1590
|
line3 = RadioSetting("poweron_msg.line3",
|
1591
|
"Power-on message line 3",
|
1592
|
RadioSettingValueString(0, 8, _filter(
|
1593
|
_msg.line3)))
|
1594
|
advanced.append(line3)
|
1595
|
line4 = RadioSetting("poweron_msg.line4",
|
1596
|
"Power-on message line 4",
|
1597
|
RadioSettingValueString(0, 8, _filter(
|
1598
|
_msg.line4)))
|
1599
|
advanced.append(line4)
|
1600
|
line5 = RadioSetting("poweron_msg.line5",
|
1601
|
"Power-on message line 5",
|
1602
|
RadioSettingValueString(0, 8, _filter(
|
1603
|
_msg.line5)))
|
1604
|
advanced.append(line5)
|
1605
|
line6 = RadioSetting("poweron_msg.line6",
|
1606
|
"Power-on message line 6",
|
1607
|
RadioSettingValueString(0, 8, _filter(
|
1608
|
_msg.line6)))
|
1609
|
advanced.append(line6)
|
1610
|
line7 = RadioSetting("poweron_msg.line7",
|
1611
|
"Power-on message line 7",
|
1612
|
RadioSettingValueString(0, 8, _filter(
|
1613
|
_msg.line7)))
|
1614
|
advanced.append(line7)
|
1615
|
line8 = RadioSetting("poweron_msg.line8", "Static message",
|
1616
|
RadioSettingValueString(0, 8, _filter(
|
1617
|
_msg.line8)))
|
1618
|
advanced.append(line8)
|
1619
|
elif self.COLOR_LCD2 or self.COLOR_LCD3:
|
1620
|
_msg = self._memobj.static_msg
|
1621
|
line = RadioSetting("static_msg.line", "Static message",
|
1622
|
RadioSettingValueString(0, 16, _filter(
|
1623
|
_msg.line)))
|
1624
|
advanced.append(line)
|
1625
|
else:
|
1626
|
_msg = self._memobj.poweron_msg
|
1627
|
line1 = RadioSetting("poweron_msg.line1",
|
1628
|
"Power-on message line 1",
|
1629
|
RadioSettingValueString(0, 6, _filter(
|
1630
|
_msg.line1)))
|
1631
|
advanced.append(line1)
|
1632
|
line2 = RadioSetting("poweron_msg.line2",
|
1633
|
"Power-on message line 2",
|
1634
|
RadioSettingValueString(0, 6, _filter(
|
1635
|
_msg.line2)))
|
1636
|
advanced.append(line2)
|
1637
|
|
1638
|
if self.MODEL in ("UV-2501", "UV-5001"):
|
1639
|
vfomren = RadioSetting("settings2.vfomren", "VFO/MR switching",
|
1640
|
RadioSettingValueBoolean(
|
1641
|
_mem.settings2.vfomren))
|
1642
|
advanced.append(vfomren)
|
1643
|
|
1644
|
reseten = RadioSetting("settings2.reseten", "RESET",
|
1645
|
RadioSettingValueBoolean(
|
1646
|
_mem.settings2.reseten))
|
1647
|
advanced.append(reseten)
|
1648
|
|
1649
|
menuen = RadioSetting("settings2.menuen", "Menu",
|
1650
|
RadioSettingValueBoolean(
|
1651
|
_mem.settings2.menuen))
|
1652
|
advanced.append(menuen)
|
1653
|
|
1654
|
# Other
|
1655
|
def convert_bytes_to_limit(bytes):
|
1656
|
limit = ""
|
1657
|
for byte in bytes:
|
1658
|
if byte < 10:
|
1659
|
limit += chr(byte + 0x30)
|
1660
|
else:
|
1661
|
break
|
1662
|
return limit
|
1663
|
|
1664
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
1665
|
_ranges = self._memobj.ranges220
|
1666
|
ranges = "ranges220"
|
1667
|
else:
|
1668
|
_ranges = self._memobj.ranges
|
1669
|
ranges = "ranges"
|
1670
|
|
1671
|
_limit = convert_bytes_to_limit(_ranges.vhf_low)
|
1672
|
val = RadioSettingValueString(0, 3, _limit)
|
1673
|
val.set_mutable(False)
|
1674
|
vhf_low = RadioSetting("%s.vhf_low" % ranges, "VHF low", val)
|
1675
|
other.append(vhf_low)
|
1676
|
|
1677
|
_limit = convert_bytes_to_limit(_ranges.vhf_high)
|
1678
|
val = RadioSettingValueString(0, 3, _limit)
|
1679
|
val.set_mutable(False)
|
1680
|
vhf_high = RadioSetting("%s.vhf_high" % ranges, "VHF high", val)
|
1681
|
other.append(vhf_high)
|
1682
|
|
1683
|
if self.BANDS == 3 or self.BANDS == 4:
|
1684
|
_limit = convert_bytes_to_limit(_ranges.vhf2_low)
|
1685
|
val = RadioSettingValueString(0, 3, _limit)
|
1686
|
val.set_mutable(False)
|
1687
|
vhf2_low = RadioSetting("%s.vhf2_low" % ranges, "VHF2 low", val)
|
1688
|
other.append(vhf2_low)
|
1689
|
|
1690
|
_limit = convert_bytes_to_limit(_ranges.vhf2_high)
|
1691
|
val = RadioSettingValueString(0, 3, _limit)
|
1692
|
val.set_mutable(False)
|
1693
|
vhf2_high = RadioSetting("%s.vhf2_high" % ranges, "VHF2 high", val)
|
1694
|
other.append(vhf2_high)
|
1695
|
|
1696
|
_limit = convert_bytes_to_limit(_ranges.uhf_low)
|
1697
|
val = RadioSettingValueString(0, 3, _limit)
|
1698
|
val.set_mutable(False)
|
1699
|
uhf_low = RadioSetting("%s.uhf_low" % ranges, "UHF low", val)
|
1700
|
other.append(uhf_low)
|
1701
|
|
1702
|
_limit = convert_bytes_to_limit(_ranges.uhf_high)
|
1703
|
val = RadioSettingValueString(0, 3, _limit)
|
1704
|
val.set_mutable(False)
|
1705
|
uhf_high = RadioSetting("%s.uhf_high" % ranges, "UHF high", val)
|
1706
|
other.append(uhf_high)
|
1707
|
|
1708
|
if self.BANDS == 4:
|
1709
|
_limit = convert_bytes_to_limit(_ranges.uhf2_low)
|
1710
|
val = RadioSettingValueString(0, 3, _limit)
|
1711
|
val.set_mutable(False)
|
1712
|
uhf2_low = RadioSetting("%s.uhf2_low" % ranges, "UHF2 low", val)
|
1713
|
other.append(uhf2_low)
|
1714
|
|
1715
|
_limit = convert_bytes_to_limit(_ranges.uhf2_high)
|
1716
|
val = RadioSettingValueString(0, 3, _limit)
|
1717
|
val.set_mutable(False)
|
1718
|
uhf2_high = RadioSetting("%s.uhf2_high" % ranges, "UHF2 high", val)
|
1719
|
other.append(uhf2_high)
|
1720
|
|
1721
|
val = RadioSettingValueString(0, 6, _filter(_mem.fingerprint.fp))
|
1722
|
val.set_mutable(False)
|
1723
|
fp = RadioSetting("fingerprint.fp", "Fingerprint", val)
|
1724
|
other.append(fp)
|
1725
|
|
1726
|
# Work
|
1727
|
if self.COLOR_LCD:
|
1728
|
dispab = RadioSetting("settings2.dispab", "Display",
|
1729
|
RadioSettingValueList(
|
1730
|
LIST_ABCD,
|
1731
|
LIST_ABCD[_mem.settings2.dispab]))
|
1732
|
work.append(dispab)
|
1733
|
else:
|
1734
|
dispab = RadioSetting("settings2.dispab", "Display",
|
1735
|
RadioSettingValueList(
|
1736
|
LIST_AB,
|
1737
|
LIST_AB[_mem.settings2.dispab]))
|
1738
|
work.append(dispab)
|
1739
|
|
1740
|
if self.COLOR_LCD:
|
1741
|
vfomra = RadioSetting("settings2.vfomra", "VFO/MR A mode",
|
1742
|
RadioSettingValueList(
|
1743
|
LIST_VFOMR,
|
1744
|
LIST_VFOMR[_mem.settings2.vfomra]))
|
1745
|
work.append(vfomra)
|
1746
|
|
1747
|
vfomrb = RadioSetting("settings2.vfomrb", "VFO/MR B mode",
|
1748
|
RadioSettingValueList(
|
1749
|
LIST_VFOMR,
|
1750
|
LIST_VFOMR[_mem.settings2.vfomrb]))
|
1751
|
work.append(vfomrb)
|
1752
|
|
1753
|
vfomrc = RadioSetting("settings2.vfomrc", "VFO/MR C mode",
|
1754
|
RadioSettingValueList(
|
1755
|
LIST_VFOMR,
|
1756
|
LIST_VFOMR[_mem.settings2.vfomrc]))
|
1757
|
work.append(vfomrc)
|
1758
|
|
1759
|
vfomrd = RadioSetting("settings2.vfomrd", "VFO/MR D mode",
|
1760
|
RadioSettingValueList(
|
1761
|
LIST_VFOMR,
|
1762
|
LIST_VFOMR[_mem.settings2.vfomrd]))
|
1763
|
work.append(vfomrd)
|
1764
|
else:
|
1765
|
vfomr = RadioSetting("settings2.vfomr", "VFO/MR mode",
|
1766
|
RadioSettingValueList(
|
1767
|
LIST_VFOMR,
|
1768
|
LIST_VFOMR[_mem.settings2.vfomr]))
|
1769
|
work.append(vfomr)
|
1770
|
|
1771
|
keylock = RadioSetting("settings2.keylock", "Keypad lock",
|
1772
|
RadioSettingValueBoolean(
|
1773
|
_mem.settings2.keylock))
|
1774
|
work.append(keylock)
|
1775
|
|
1776
|
mrcha = RadioSetting("settings2.mrcha", "MR A channel",
|
1777
|
RadioSettingValueInteger(0, self._upper,
|
1778
|
_mem.settings2.mrcha))
|
1779
|
work.append(mrcha)
|
1780
|
|
1781
|
mrchb = RadioSetting("settings2.mrchb", "MR B channel",
|
1782
|
RadioSettingValueInteger(0, self._upper,
|
1783
|
_mem.settings2.mrchb))
|
1784
|
work.append(mrchb)
|
1785
|
|
1786
|
if self.COLOR_LCD:
|
1787
|
mrchc = RadioSetting("settings2.mrchc", "MR C channel",
|
1788
|
RadioSettingValueInteger(
|
1789
|
0, self._upper, _mem.settings2.mrchc))
|
1790
|
work.append(mrchc)
|
1791
|
|
1792
|
mrchd = RadioSetting("settings2.mrchd", "MR D channel",
|
1793
|
RadioSettingValueInteger(
|
1794
|
0, self._upper, _mem.settings2.mrchd))
|
1795
|
work.append(mrchd)
|
1796
|
|
1797
|
def convert_bytes_to_freq(bytes):
|
1798
|
real_freq = 0
|
1799
|
for byte in bytes:
|
1800
|
real_freq = (real_freq * 10) + byte
|
1801
|
return chirp_common.format_freq(real_freq * 10)
|
1802
|
|
1803
|
def my_validate(value):
|
1804
|
_vhf_lower = int(convert_bytes_to_limit(_ranges.vhf_low))
|
1805
|
_vhf_upper = int(convert_bytes_to_limit(_ranges.vhf_high))
|
1806
|
_uhf_lower = int(convert_bytes_to_limit(_ranges.uhf_low))
|
1807
|
_uhf_upper = int(convert_bytes_to_limit(_ranges.uhf_high))
|
1808
|
if self.BANDS == 3 or self.BANDS == 4:
|
1809
|
_vhf2_lower = int(convert_bytes_to_limit(_ranges.vhf2_low))
|
1810
|
_vhf2_upper = int(convert_bytes_to_limit(_ranges.vhf2_high))
|
1811
|
if self.BANDS == 4:
|
1812
|
_uhf2_lower = int(convert_bytes_to_limit(_ranges.uhf2_low))
|
1813
|
_uhf2_upper = int(convert_bytes_to_limit(_ranges.uhf2_high))
|
1814
|
|
1815
|
value = chirp_common.parse_freq(value)
|
1816
|
msg = ("Can't be less then %i.0000")
|
1817
|
if value > 99000000 and value < _vhf_lower * 1000000:
|
1818
|
raise InvalidValueError(msg % (_vhf_lower))
|
1819
|
msg = ("Can't be betweeb %i.9975-%i.0000")
|
1820
|
if self.BANDS == 2:
|
1821
|
if (_vhf_upper + 1) * 1000000 <= value and \
|
1822
|
value < _uhf_lower * 1000000:
|
1823
|
raise InvalidValueError(msg % (_vhf_upper, _uhf_lower))
|
1824
|
if self.BANDS == 3:
|
1825
|
if (_vhf_upper + 1) * 1000000 <= value and \
|
1826
|
value < _vhf2_lower * 1000000:
|
1827
|
raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower))
|
1828
|
if (_vhf2_upper + 1) * 1000000 <= value and \
|
1829
|
value < _uhf_lower * 1000000:
|
1830
|
raise InvalidValueError(msg % (_vhf2_upper, _uhf_lower))
|
1831
|
if self.BANDS == 4:
|
1832
|
if (_vhf_upper + 1) * 1000000 <= value and \
|
1833
|
value < _vhf2_lower * 1000000:
|
1834
|
raise InvalidValueError(msg % (_vhf_upper, _vhf2_lower))
|
1835
|
if (_vhf2_upper + 1) * 1000000 <= value and \
|
1836
|
value < _uhf2_lower * 1000000:
|
1837
|
raise InvalidValueError(msg % (_vhf2_upper, _uhf2_lower))
|
1838
|
if (_uhf2_upper + 1) * 1000000 <= value and \
|
1839
|
value < _uhf_lower * 1000000:
|
1840
|
raise InvalidValueError(msg % (_uhf2_upper, _uhf_lower))
|
1841
|
msg = ("Can't be greater then %i.9975")
|
1842
|
if value > 99000000 and value >= _uhf_upper * 1000000:
|
1843
|
raise InvalidValueError(msg % (_uhf_upper))
|
1844
|
return chirp_common.format_freq(value)
|
1845
|
|
1846
|
def apply_freq(setting, obj):
|
1847
|
value = chirp_common.parse_freq(str(setting.value)) / 10
|
1848
|
for i in range(7, -1, -1):
|
1849
|
obj.freq[i] = value % 10
|
1850
|
value /= 10
|
1851
|
|
1852
|
val1a = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
1853
|
_mem.vfo.a.freq))
|
1854
|
val1a.set_validate_callback(my_validate)
|
1855
|
vfoafreq = RadioSetting("vfo.a.freq", "VFO A frequency", val1a)
|
1856
|
vfoafreq.set_apply_callback(apply_freq, _mem.vfo.a)
|
1857
|
work.append(vfoafreq)
|
1858
|
|
1859
|
val1b = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
1860
|
_mem.vfo.b.freq))
|
1861
|
val1b.set_validate_callback(my_validate)
|
1862
|
vfobfreq = RadioSetting("vfo.b.freq", "VFO B frequency", val1b)
|
1863
|
vfobfreq.set_apply_callback(apply_freq, _mem.vfo.b)
|
1864
|
work.append(vfobfreq)
|
1865
|
|
1866
|
if self.COLOR_LCD:
|
1867
|
val1c = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
1868
|
_mem.vfo.c.freq))
|
1869
|
val1c.set_validate_callback(my_validate)
|
1870
|
vfocfreq = RadioSetting("vfo.c.freq", "VFO C frequency", val1c)
|
1871
|
vfocfreq.set_apply_callback(apply_freq, _mem.vfo.c)
|
1872
|
work.append(vfocfreq)
|
1873
|
|
1874
|
val1d = RadioSettingValueString(0, 10, convert_bytes_to_freq(
|
1875
|
_mem.vfo.d.freq))
|
1876
|
val1d.set_validate_callback(my_validate)
|
1877
|
vfodfreq = RadioSetting("vfo.d.freq", "VFO D frequency", val1d)
|
1878
|
vfodfreq.set_apply_callback(apply_freq, _mem.vfo.d)
|
1879
|
work.append(vfodfreq)
|
1880
|
|
1881
|
if not self.MODEL == "GMRS-50X1":
|
1882
|
vfoashiftd = RadioSetting("vfo.a.shiftd", "VFO A shift",
|
1883
|
RadioSettingValueList(
|
1884
|
LIST_SHIFT,
|
1885
|
LIST_SHIFT[_mem.vfo.a.shiftd]))
|
1886
|
work.append(vfoashiftd)
|
1887
|
|
1888
|
vfobshiftd = RadioSetting("vfo.b.shiftd", "VFO B shift",
|
1889
|
RadioSettingValueList(
|
1890
|
LIST_SHIFT,
|
1891
|
LIST_SHIFT[_mem.vfo.b.shiftd]))
|
1892
|
work.append(vfobshiftd)
|
1893
|
|
1894
|
if self.COLOR_LCD:
|
1895
|
vfocshiftd = RadioSetting("vfo.c.shiftd", "VFO C shift",
|
1896
|
RadioSettingValueList(
|
1897
|
LIST_SHIFT,
|
1898
|
LIST_SHIFT[_mem.vfo.c.shiftd]))
|
1899
|
work.append(vfocshiftd)
|
1900
|
|
1901
|
vfodshiftd = RadioSetting("vfo.d.shiftd", "VFO D shift",
|
1902
|
RadioSettingValueList(
|
1903
|
LIST_SHIFT,
|
1904
|
LIST_SHIFT[_mem.vfo.d.shiftd]))
|
1905
|
work.append(vfodshiftd)
|
1906
|
|
1907
|
def convert_bytes_to_offset(bytes):
|
1908
|
real_offset = 0
|
1909
|
for byte in bytes:
|
1910
|
real_offset = (real_offset * 10) + byte
|
1911
|
return chirp_common.format_freq(real_offset * 1000)
|
1912
|
|
1913
|
def apply_offset(setting, obj):
|
1914
|
value = chirp_common.parse_freq(str(setting.value)) / 1000
|
1915
|
for i in range(5, -1, -1):
|
1916
|
obj.offset[i] = value % 10
|
1917
|
value /= 10
|
1918
|
|
1919
|
if not self.MODEL == "GMRS-50X1":
|
1920
|
if self.COLOR_LCD:
|
1921
|
val1a = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
1922
|
_mem.vfo.a.offset))
|
1923
|
vfoaoffset = RadioSetting("vfo.a.offset",
|
1924
|
"VFO A offset (0.000-999.999)",
|
1925
|
val1a)
|
1926
|
vfoaoffset.set_apply_callback(apply_offset, _mem.vfo.a)
|
1927
|
work.append(vfoaoffset)
|
1928
|
|
1929
|
val1b = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
1930
|
_mem.vfo.b.offset))
|
1931
|
vfoboffset = RadioSetting("vfo.b.offset",
|
1932
|
"VFO B offset (0.000-999.999)",
|
1933
|
val1b)
|
1934
|
vfoboffset.set_apply_callback(apply_offset, _mem.vfo.b)
|
1935
|
work.append(vfoboffset)
|
1936
|
|
1937
|
val1c = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
1938
|
_mem.vfo.c.offset))
|
1939
|
vfocoffset = RadioSetting("vfo.c.offset",
|
1940
|
"VFO C offset (0.000-999.999)",
|
1941
|
val1c)
|
1942
|
vfocoffset.set_apply_callback(apply_offset, _mem.vfo.c)
|
1943
|
work.append(vfocoffset)
|
1944
|
|
1945
|
val1d = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
1946
|
_mem.vfo.d.offset))
|
1947
|
vfodoffset = RadioSetting("vfo.d.offset",
|
1948
|
"VFO D offset (0.000-999.999)",
|
1949
|
val1d)
|
1950
|
vfodoffset.set_apply_callback(apply_offset, _mem.vfo.d)
|
1951
|
work.append(vfodoffset)
|
1952
|
else:
|
1953
|
val1a = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
1954
|
_mem.vfo.a.offset))
|
1955
|
vfoaoffset = RadioSetting("vfo.a.offset",
|
1956
|
"VFO A offset (0.000-99.999)", val1a)
|
1957
|
vfoaoffset.set_apply_callback(apply_offset, _mem.vfo.a)
|
1958
|
work.append(vfoaoffset)
|
1959
|
|
1960
|
val1b = RadioSettingValueString(0, 10, convert_bytes_to_offset(
|
1961
|
_mem.vfo.b.offset))
|
1962
|
vfoboffset = RadioSetting("vfo.b.offset",
|
1963
|
"VFO B offset (0.000-99.999)", val1b)
|
1964
|
vfoboffset.set_apply_callback(apply_offset, _mem.vfo.b)
|
1965
|
work.append(vfoboffset)
|
1966
|
|
1967
|
if not self.MODEL == "GMRS-50X1":
|
1968
|
vfoatxp = RadioSetting("vfo.a.power", "VFO A power",
|
1969
|
RadioSettingValueList(
|
1970
|
LIST_TXP,
|
1971
|
LIST_TXP[_mem.vfo.a.power]))
|
1972
|
work.append(vfoatxp)
|
1973
|
|
1974
|
vfobtxp = RadioSetting("vfo.b.power", "VFO B power",
|
1975
|
RadioSettingValueList(
|
1976
|
LIST_TXP,
|
1977
|
LIST_TXP[_mem.vfo.b.power]))
|
1978
|
work.append(vfobtxp)
|
1979
|
|
1980
|
if self.COLOR_LCD:
|
1981
|
vfoctxp = RadioSetting("vfo.c.power", "VFO C power",
|
1982
|
RadioSettingValueList(
|
1983
|
LIST_TXP,
|
1984
|
LIST_TXP[_mem.vfo.c.power]))
|
1985
|
work.append(vfoctxp)
|
1986
|
|
1987
|
vfodtxp = RadioSetting("vfo.d.power", "VFO D power",
|
1988
|
RadioSettingValueList(
|
1989
|
LIST_TXP,
|
1990
|
LIST_TXP[_mem.vfo.d.power]))
|
1991
|
work.append(vfodtxp)
|
1992
|
|
1993
|
if not self.MODEL == "GMRS-50X1":
|
1994
|
vfoawide = RadioSetting("vfo.a.wide", "VFO A bandwidth",
|
1995
|
RadioSettingValueList(
|
1996
|
LIST_WIDE,
|
1997
|
LIST_WIDE[_mem.vfo.a.wide]))
|
1998
|
work.append(vfoawide)
|
1999
|
|
2000
|
vfobwide = RadioSetting("vfo.b.wide", "VFO B bandwidth",
|
2001
|
RadioSettingValueList(
|
2002
|
LIST_WIDE,
|
2003
|
LIST_WIDE[_mem.vfo.b.wide]))
|
2004
|
work.append(vfobwide)
|
2005
|
|
2006
|
if self.COLOR_LCD:
|
2007
|
vfocwide = RadioSetting("vfo.c.wide", "VFO C bandwidth",
|
2008
|
RadioSettingValueList(
|
2009
|
LIST_WIDE,
|
2010
|
LIST_WIDE[_mem.vfo.c.wide]))
|
2011
|
work.append(vfocwide)
|
2012
|
|
2013
|
vfodwide = RadioSetting("vfo.d.wide", "VFO D bandwidth",
|
2014
|
RadioSettingValueList(
|
2015
|
LIST_WIDE,
|
2016
|
LIST_WIDE[_mem.vfo.d.wide]))
|
2017
|
work.append(vfodwide)
|
2018
|
|
2019
|
vfoastep = RadioSetting("vfo.a.step", "VFO A step",
|
2020
|
RadioSettingValueList(
|
2021
|
LIST_STEP,
|
2022
|
LIST_STEP[_mem.vfo.a.step]))
|
2023
|
work.append(vfoastep)
|
2024
|
|
2025
|
vfobstep = RadioSetting("vfo.b.step", "VFO B step",
|
2026
|
RadioSettingValueList(
|
2027
|
LIST_STEP,
|
2028
|
LIST_STEP[_mem.vfo.b.step]))
|
2029
|
work.append(vfobstep)
|
2030
|
|
2031
|
if self.COLOR_LCD:
|
2032
|
vfocstep = RadioSetting("vfo.c.step", "VFO C step",
|
2033
|
RadioSettingValueList(
|
2034
|
LIST_STEP,
|
2035
|
LIST_STEP[_mem.vfo.c.step]))
|
2036
|
work.append(vfocstep)
|
2037
|
|
2038
|
vfodstep = RadioSetting("vfo.d.step", "VFO D step",
|
2039
|
RadioSettingValueList(
|
2040
|
LIST_STEP,
|
2041
|
LIST_STEP[_mem.vfo.d.step]))
|
2042
|
work.append(vfodstep)
|
2043
|
|
2044
|
vfoaoptsig = RadioSetting("vfo.a.optsig", "VFO A optional signal",
|
2045
|
RadioSettingValueList(
|
2046
|
OPTSIG_LIST,
|
2047
|
OPTSIG_LIST[_mem.vfo.a.optsig]))
|
2048
|
work.append(vfoaoptsig)
|
2049
|
|
2050
|
vfoboptsig = RadioSetting("vfo.b.optsig", "VFO B optional signal",
|
2051
|
RadioSettingValueList(
|
2052
|
OPTSIG_LIST,
|
2053
|
OPTSIG_LIST[_mem.vfo.b.optsig]))
|
2054
|
work.append(vfoboptsig)
|
2055
|
|
2056
|
if self.COLOR_LCD:
|
2057
|
vfocoptsig = RadioSetting("vfo.c.optsig", "VFO C optional signal",
|
2058
|
RadioSettingValueList(
|
2059
|
OPTSIG_LIST,
|
2060
|
OPTSIG_LIST[_mem.vfo.c.optsig]))
|
2061
|
work.append(vfocoptsig)
|
2062
|
|
2063
|
vfodoptsig = RadioSetting("vfo.d.optsig", "VFO D optional signal",
|
2064
|
RadioSettingValueList(
|
2065
|
OPTSIG_LIST,
|
2066
|
OPTSIG_LIST[_mem.vfo.d.optsig]))
|
2067
|
work.append(vfodoptsig)
|
2068
|
|
2069
|
vfoaspmute = RadioSetting("vfo.a.spmute", "VFO A speaker mute",
|
2070
|
RadioSettingValueList(
|
2071
|
SPMUTE_LIST,
|
2072
|
SPMUTE_LIST[_mem.vfo.a.spmute]))
|
2073
|
work.append(vfoaspmute)
|
2074
|
|
2075
|
vfobspmute = RadioSetting("vfo.b.spmute", "VFO B speaker mute",
|
2076
|
RadioSettingValueList(
|
2077
|
SPMUTE_LIST,
|
2078
|
SPMUTE_LIST[_mem.vfo.b.spmute]))
|
2079
|
work.append(vfobspmute)
|
2080
|
|
2081
|
if self.COLOR_LCD:
|
2082
|
vfocspmute = RadioSetting("vfo.c.spmute", "VFO C speaker mute",
|
2083
|
RadioSettingValueList(
|
2084
|
SPMUTE_LIST,
|
2085
|
SPMUTE_LIST[_mem.vfo.c.spmute]))
|
2086
|
work.append(vfocspmute)
|
2087
|
|
2088
|
vfodspmute = RadioSetting("vfo.d.spmute", "VFO D speaker mute",
|
2089
|
RadioSettingValueList(
|
2090
|
SPMUTE_LIST,
|
2091
|
SPMUTE_LIST[_mem.vfo.d.spmute]))
|
2092
|
work.append(vfodspmute)
|
2093
|
|
2094
|
if not self.COLOR_LCD or \
|
2095
|
(self.COLOR_LCD and not self.VENDOR == "BTECH"):
|
2096
|
vfoascr = RadioSetting("vfo.a.scramble", "VFO A scramble",
|
2097
|
RadioSettingValueBoolean(
|
2098
|
_mem.vfo.a.scramble))
|
2099
|
work.append(vfoascr)
|
2100
|
|
2101
|
vfobscr = RadioSetting("vfo.b.scramble", "VFO B scramble",
|
2102
|
RadioSettingValueBoolean(
|
2103
|
_mem.vfo.b.scramble))
|
2104
|
work.append(vfobscr)
|
2105
|
|
2106
|
if self.COLOR_LCD and not self.VENDOR == "BTECH":
|
2107
|
vfocscr = RadioSetting("vfo.c.scramble", "VFO C scramble",
|
2108
|
RadioSettingValueBoolean(
|
2109
|
_mem.vfo.c.scramble))
|
2110
|
work.append(vfocscr)
|
2111
|
|
2112
|
vfodscr = RadioSetting("vfo.d.scramble", "VFO D scramble",
|
2113
|
RadioSettingValueBoolean(
|
2114
|
_mem.vfo.d.scramble))
|
2115
|
work.append(vfodscr)
|
2116
|
|
2117
|
if not self.MODEL == "GMRS-50X1":
|
2118
|
vfoascode = RadioSetting("vfo.a.scode", "VFO A PTT-ID",
|
2119
|
RadioSettingValueList(
|
2120
|
PTTIDCODE_LIST,
|
2121
|
PTTIDCODE_LIST[_mem.vfo.a.scode]))
|
2122
|
work.append(vfoascode)
|
2123
|
|
2124
|
vfobscode = RadioSetting("vfo.b.scode", "VFO B PTT-ID",
|
2125
|
RadioSettingValueList(
|
2126
|
PTTIDCODE_LIST,
|
2127
|
PTTIDCODE_LIST[_mem.vfo.b.scode]))
|
2128
|
work.append(vfobscode)
|
2129
|
|
2130
|
if self.COLOR_LCD:
|
2131
|
vfocscode = RadioSetting("vfo.c.scode", "VFO C PTT-ID",
|
2132
|
RadioSettingValueList(
|
2133
|
PTTIDCODE_LIST,
|
2134
|
PTTIDCODE_LIST[_mem.vfo.c.scode]))
|
2135
|
work.append(vfocscode)
|
2136
|
|
2137
|
vfodscode = RadioSetting("vfo.d.scode", "VFO D PTT-ID",
|
2138
|
RadioSettingValueList(
|
2139
|
PTTIDCODE_LIST,
|
2140
|
PTTIDCODE_LIST[_mem.vfo.d.scode]))
|
2141
|
work.append(vfodscode)
|
2142
|
|
2143
|
if not self.MODEL == "GMRS-50X1":
|
2144
|
pttid = RadioSetting("settings.pttid", "PTT ID",
|
2145
|
RadioSettingValueList(
|
2146
|
PTTID_LIST,
|
2147
|
PTTID_LIST[_mem.settings.pttid]))
|
2148
|
work.append(pttid)
|
2149
|
|
2150
|
if not self.COLOR_LCD:
|
2151
|
# FM presets
|
2152
|
fm_presets = RadioSettingGroup("fm_presets", "FM Presets")
|
2153
|
top.append(fm_presets)
|
2154
|
|
2155
|
def fm_validate(value):
|
2156
|
if value == 0:
|
2157
|
return chirp_common.format_freq(value)
|
2158
|
if not (87.5 <= value and value <= 108.0): # 87.5-108MHz
|
2159
|
msg = ("FM-Preset-Frequency: " +
|
2160
|
"Must be between 87.5 and 108 MHz")
|
2161
|
raise InvalidValueError(msg)
|
2162
|
return value
|
2163
|
|
2164
|
def apply_fm_preset_name(setting, obj):
|
2165
|
valstring = str(setting.value)
|
2166
|
for i in range(0, 6):
|
2167
|
if valstring[i] in VALID_CHARS:
|
2168
|
obj[i] = valstring[i]
|
2169
|
else:
|
2170
|
obj[i] = '0xff'
|
2171
|
|
2172
|
def apply_fm_freq(setting, obj):
|
2173
|
value = chirp_common.parse_freq(str(setting.value)) / 10
|
2174
|
for i in range(7, -1, -1):
|
2175
|
obj.freq[i] = value % 10
|
2176
|
value /= 10
|
2177
|
|
2178
|
_presets = self._memobj.fm_radio_preset
|
2179
|
i = 1
|
2180
|
for preset in _presets:
|
2181
|
line = RadioSetting("fm_presets_" + str(i),
|
2182
|
"Station name " + str(i),
|
2183
|
RadioSettingValueString(0, 6, _filter(
|
2184
|
preset.broadcast_station_name)))
|
2185
|
line.set_apply_callback(apply_fm_preset_name,
|
2186
|
preset.broadcast_station_name)
|
2187
|
|
2188
|
val = RadioSettingValueFloat(0, 108,
|
2189
|
convert_bytes_to_freq(
|
2190
|
preset.freq))
|
2191
|
fmfreq = RadioSetting("fm_presets_" + str(i) + "_freq",
|
2192
|
"Frequency " + str(i), val)
|
2193
|
val.set_validate_callback(fm_validate)
|
2194
|
fmfreq.set_apply_callback(apply_fm_freq, preset)
|
2195
|
fm_presets.append(line)
|
2196
|
fm_presets.append(fmfreq)
|
2197
|
|
2198
|
i = i + 1
|
2199
|
|
2200
|
# DTMF-Setting
|
2201
|
dtmf_enc_settings = RadioSettingGroup("dtmf_enc_settings",
|
2202
|
"DTMF Encoding Settings")
|
2203
|
dtmf_dec_settings = RadioSettingGroup("dtmf_dec_settings",
|
2204
|
"DTMF Decoding Settings")
|
2205
|
top.append(dtmf_enc_settings)
|
2206
|
top.append(dtmf_dec_settings)
|
2207
|
txdisable = RadioSetting("dtmf_settings.txdisable",
|
2208
|
"TX-Disable",
|
2209
|
RadioSettingValueBoolean(
|
2210
|
_mem.dtmf_settings.txdisable))
|
2211
|
dtmf_enc_settings.append(txdisable)
|
2212
|
|
2213
|
rxdisable = RadioSetting("dtmf_settings.rxdisable",
|
2214
|
"RX-Disable",
|
2215
|
RadioSettingValueBoolean(
|
2216
|
_mem.dtmf_settings.rxdisable))
|
2217
|
dtmf_enc_settings.append(rxdisable)
|
2218
|
|
2219
|
if _mem.dtmf_settings.dtmfspeed_on > 0x0F:
|
2220
|
val = 0x03
|
2221
|
else:
|
2222
|
val = _mem.dtmf_settings.dtmfspeed_on
|
2223
|
dtmfspeed_on = RadioSetting(
|
2224
|
"dtmf_settings.dtmfspeed_on",
|
2225
|
"DTMF Speed (On Time)",
|
2226
|
RadioSettingValueList(LIST_DTMF_SPEED,
|
2227
|
LIST_DTMF_SPEED[
|
2228
|
val]))
|
2229
|
dtmf_enc_settings.append(dtmfspeed_on)
|
2230
|
|
2231
|
if _mem.dtmf_settings.dtmfspeed_off > 0x0F:
|
2232
|
val = 0x03
|
2233
|
else:
|
2234
|
val = _mem.dtmf_settings.dtmfspeed_off
|
2235
|
dtmfspeed_off = RadioSetting(
|
2236
|
"dtmf_settings.dtmfspeed_off",
|
2237
|
"DTMF Speed (Off Time)",
|
2238
|
RadioSettingValueList(LIST_DTMF_SPEED,
|
2239
|
LIST_DTMF_SPEED[
|
2240
|
val]))
|
2241
|
dtmf_enc_settings.append(dtmfspeed_off)
|
2242
|
|
2243
|
def memory2string(dmtf_mem):
|
2244
|
dtmf_string = ""
|
2245
|
for digit in dmtf_mem:
|
2246
|
if digit != 255:
|
2247
|
index = LIST_DTMF_VALUES.index(digit)
|
2248
|
dtmf_string = dtmf_string + LIST_DTMF_DIGITS[index]
|
2249
|
return dtmf_string
|
2250
|
|
2251
|
def apply_dmtf_frame(setting, obj):
|
2252
|
LOG.debug("Setting DTMF-Code: " + str(setting.value))
|
2253
|
val_string = str(setting.value)
|
2254
|
for i in range(0, 16):
|
2255
|
obj[i] = 255
|
2256
|
i = 0
|
2257
|
for current_char in val_string:
|
2258
|
current_char = current_char.upper()
|
2259
|
index = LIST_DTMF_DIGITS.index(current_char)
|
2260
|
obj[i] = LIST_DTMF_VALUES[index]
|
2261
|
i = i + 1
|
2262
|
|
2263
|
codes = self._memobj.dtmf_codes
|
2264
|
i = 1
|
2265
|
for dtmfcode in codes:
|
2266
|
val = RadioSettingValueString(0, 16, memory2string(
|
2267
|
dtmfcode.code),
|
2268
|
False, CHARSET_DTMF_DIGITS)
|
2269
|
line = RadioSetting("dtmf_code_" + str(i) + "_code",
|
2270
|
"DMTF Code " + str(i), val)
|
2271
|
line.set_apply_callback(apply_dmtf_frame, dtmfcode.code)
|
2272
|
dtmf_enc_settings.append(line)
|
2273
|
i = i + 1
|
2274
|
|
2275
|
line = RadioSetting("dtmf_settings.mastervice",
|
2276
|
"Master and Vice ID",
|
2277
|
RadioSettingValueBoolean(
|
2278
|
_mem.dtmf_settings.mastervice))
|
2279
|
dtmf_dec_settings.append(line)
|
2280
|
|
2281
|
val = RadioSettingValueString(0, 16, memory2string(
|
2282
|
_mem.dtmf_settings.masterid),
|
2283
|
False, CHARSET_DTMF_DIGITS)
|
2284
|
line = RadioSetting("dtmf_settings.masterid",
|
2285
|
"Master Control ID ", val)
|
2286
|
line.set_apply_callback(apply_dmtf_frame,
|
2287
|
_mem.dtmf_settings.masterid)
|
2288
|
dtmf_dec_settings.append(line)
|
2289
|
|
2290
|
line = RadioSetting("dtmf_settings.minspection",
|
2291
|
"Master Inspection",
|
2292
|
RadioSettingValueBoolean(
|
2293
|
_mem.dtmf_settings.minspection))
|
2294
|
dtmf_dec_settings.append(line)
|
2295
|
|
2296
|
line = RadioSetting("dtmf_settings.mmonitor",
|
2297
|
"Master Monitor",
|
2298
|
RadioSettingValueBoolean(
|
2299
|
_mem.dtmf_settings.mmonitor))
|
2300
|
dtmf_dec_settings.append(line)
|
2301
|
|
2302
|
line = RadioSetting("dtmf_settings.mstun",
|
2303
|
"Master Stun",
|
2304
|
RadioSettingValueBoolean(
|
2305
|
_mem.dtmf_settings.mstun))
|
2306
|
dtmf_dec_settings.append(line)
|
2307
|
|
2308
|
line = RadioSetting("dtmf_settings.mkill",
|
2309
|
"Master Kill",
|
2310
|
RadioSettingValueBoolean(
|
2311
|
_mem.dtmf_settings.mkill))
|
2312
|
dtmf_dec_settings.append(line)
|
2313
|
|
2314
|
line = RadioSetting("dtmf_settings.mrevive",
|
2315
|
"Master Revive",
|
2316
|
RadioSettingValueBoolean(
|
2317
|
_mem.dtmf_settings.mrevive))
|
2318
|
dtmf_dec_settings.append(line)
|
2319
|
|
2320
|
val = RadioSettingValueString(0, 16, memory2string(
|
2321
|
_mem.dtmf_settings.viceid),
|
2322
|
False, CHARSET_DTMF_DIGITS)
|
2323
|
line = RadioSetting("dtmf_settings.viceid",
|
2324
|
"Vice Control ID ", val)
|
2325
|
line.set_apply_callback(apply_dmtf_frame,
|
2326
|
_mem.dtmf_settings.viceid)
|
2327
|
dtmf_dec_settings.append(line)
|
2328
|
|
2329
|
line = RadioSetting("dtmf_settings.vinspection",
|
2330
|
"Vice Inspection",
|
2331
|
RadioSettingValueBoolean(
|
2332
|
_mem.dtmf_settings.vinspection))
|
2333
|
dtmf_dec_settings.append(line)
|
2334
|
|
2335
|
line = RadioSetting("dtmf_settings.vmonitor",
|
2336
|
"Vice Monitor",
|
2337
|
RadioSettingValueBoolean(
|
2338
|
_mem.dtmf_settings.vmonitor))
|
2339
|
dtmf_dec_settings.append(line)
|
2340
|
|
2341
|
line = RadioSetting("dtmf_settings.vstun",
|
2342
|
"Vice Stun",
|
2343
|
RadioSettingValueBoolean(
|
2344
|
_mem.dtmf_settings.vstun))
|
2345
|
dtmf_dec_settings.append(line)
|
2346
|
|
2347
|
line = RadioSetting("dtmf_settings.vkill",
|
2348
|
"Vice Kill",
|
2349
|
RadioSettingValueBoolean(
|
2350
|
_mem.dtmf_settings.vkill))
|
2351
|
dtmf_dec_settings.append(line)
|
2352
|
|
2353
|
line = RadioSetting("dtmf_settings.vrevive",
|
2354
|
"Vice Revive",
|
2355
|
RadioSettingValueBoolean(
|
2356
|
_mem.dtmf_settings.vrevive))
|
2357
|
dtmf_dec_settings.append(line)
|
2358
|
|
2359
|
val = RadioSettingValueString(0, 16, memory2string(
|
2360
|
_mem.dtmf_settings.inspection),
|
2361
|
False, CHARSET_DTMF_DIGITS)
|
2362
|
line = RadioSetting("dtmf_settings.inspection",
|
2363
|
"Inspection", val)
|
2364
|
line.set_apply_callback(apply_dmtf_frame,
|
2365
|
_mem.dtmf_settings.inspection)
|
2366
|
dtmf_dec_settings.append(line)
|
2367
|
|
2368
|
val = RadioSettingValueString(0, 16, memory2string(
|
2369
|
_mem.dtmf_settings.alarmcode),
|
2370
|
False, CHARSET_DTMF_DIGITS)
|
2371
|
line = RadioSetting("dtmf_settings.alarmcode",
|
2372
|
"Alarm", val)
|
2373
|
line.set_apply_callback(apply_dmtf_frame,
|
2374
|
_mem.dtmf_settings.alarmcode)
|
2375
|
dtmf_dec_settings.append(line)
|
2376
|
|
2377
|
val = RadioSettingValueString(0, 16, memory2string(
|
2378
|
_mem.dtmf_settings.kill),
|
2379
|
False, CHARSET_DTMF_DIGITS)
|
2380
|
line = RadioSetting("dtmf_settings.kill",
|
2381
|
"Kill", val)
|
2382
|
line.set_apply_callback(apply_dmtf_frame,
|
2383
|
_mem.dtmf_settings.kill)
|
2384
|
dtmf_dec_settings.append(line)
|
2385
|
|
2386
|
val = RadioSettingValueString(0, 16, memory2string(
|
2387
|
_mem.dtmf_settings.monitor),
|
2388
|
False, CHARSET_DTMF_DIGITS)
|
2389
|
line = RadioSetting("dtmf_settings.monitor",
|
2390
|
"Monitor", val)
|
2391
|
line.set_apply_callback(apply_dmtf_frame,
|
2392
|
_mem.dtmf_settings.monitor)
|
2393
|
dtmf_dec_settings.append(line)
|
2394
|
|
2395
|
val = RadioSettingValueString(0, 16, memory2string(
|
2396
|
_mem.dtmf_settings.stun),
|
2397
|
False, CHARSET_DTMF_DIGITS)
|
2398
|
line = RadioSetting("dtmf_settings.stun",
|
2399
|
"Stun", val)
|
2400
|
line.set_apply_callback(apply_dmtf_frame,
|
2401
|
_mem.dtmf_settings.stun)
|
2402
|
dtmf_dec_settings.append(line)
|
2403
|
|
2404
|
val = RadioSettingValueString(0, 16, memory2string(
|
2405
|
_mem.dtmf_settings.revive),
|
2406
|
False, CHARSET_DTMF_DIGITS)
|
2407
|
line = RadioSetting("dtmf_settings.revive",
|
2408
|
"Revive", val)
|
2409
|
line.set_apply_callback(apply_dmtf_frame,
|
2410
|
_mem.dtmf_settings.revive)
|
2411
|
dtmf_dec_settings.append(line)
|
2412
|
|
2413
|
def apply_dmtf_listvalue(setting, obj):
|
2414
|
LOG.debug("Setting value: " + str(setting.value) + " from list")
|
2415
|
val = str(setting.value)
|
2416
|
index = LIST_DTMF_SPECIAL_DIGITS.index(val)
|
2417
|
val = LIST_DTMF_SPECIAL_VALUES[index]
|
2418
|
obj.set_value(val)
|
2419
|
|
2420
|
if _mem.dtmf_settings.groupcode not in LIST_DTMF_SPECIAL_VALUES:
|
2421
|
val = 0x0B
|
2422
|
else:
|
2423
|
val = _mem.dtmf_settings.groupcode
|
2424
|
idx = LIST_DTMF_SPECIAL_VALUES.index(val)
|
2425
|
line = RadioSetting(
|
2426
|
"dtmf_settings.groupcode",
|
2427
|
"Group Code",
|
2428
|
RadioSettingValueList(LIST_DTMF_SPECIAL_DIGITS,
|
2429
|
LIST_DTMF_SPECIAL_DIGITS[idx]))
|
2430
|
line.set_apply_callback(apply_dmtf_listvalue,
|
2431
|
_mem.dtmf_settings.groupcode)
|
2432
|
dtmf_dec_settings.append(line)
|
2433
|
|
2434
|
if _mem.dtmf_settings.spacecode not in LIST_DTMF_SPECIAL_VALUES:
|
2435
|
val = 0x0C
|
2436
|
else:
|
2437
|
val = _mem.dtmf_settings.spacecode
|
2438
|
idx = LIST_DTMF_SPECIAL_VALUES.index(val)
|
2439
|
line = RadioSetting(
|
2440
|
"dtmf_settings.spacecode",
|
2441
|
"Space Code",
|
2442
|
RadioSettingValueList(LIST_DTMF_SPECIAL_DIGITS,
|
2443
|
LIST_DTMF_SPECIAL_DIGITS[idx]))
|
2444
|
line.set_apply_callback(apply_dmtf_listvalue,
|
2445
|
_mem.dtmf_settings.spacecode)
|
2446
|
dtmf_dec_settings.append(line)
|
2447
|
|
2448
|
if self.COLOR_LCD:
|
2449
|
if _mem.dtmf_settings.resettime > 0x63:
|
2450
|
val = 0x4F
|
2451
|
else:
|
2452
|
val = _mem.dtmf_settings.resettime
|
2453
|
line = RadioSetting(
|
2454
|
"dtmf_settings.resettime",
|
2455
|
"Reset time",
|
2456
|
RadioSettingValueList(LIST_5TONE_RESET_COLOR,
|
2457
|
LIST_5TONE_RESET_COLOR[
|
2458
|
val]))
|
2459
|
dtmf_dec_settings.append(line)
|
2460
|
else:
|
2461
|
line = RadioSetting(
|
2462
|
"dtmf_settings.resettime",
|
2463
|
"Reset time",
|
2464
|
RadioSettingValueList(LIST_5TONE_RESET,
|
2465
|
LIST_5TONE_RESET[
|
2466
|
_mem.dtmf_settings.resettime]))
|
2467
|
dtmf_dec_settings.append(line)
|
2468
|
|
2469
|
if _mem.dtmf_settings.delayproctime > 0x27:
|
2470
|
val = 0x04
|
2471
|
else:
|
2472
|
val = _mem.dtmf_settings.delayproctime
|
2473
|
line = RadioSetting(
|
2474
|
"dtmf_settings.delayproctime",
|
2475
|
"Delay processing time",
|
2476
|
RadioSettingValueList(LIST_DTMF_DELAY,
|
2477
|
LIST_DTMF_DELAY[
|
2478
|
val]))
|
2479
|
dtmf_dec_settings.append(line)
|
2480
|
|
2481
|
# 5 Tone Settings
|
2482
|
stds_5tone = RadioSettingGroup("stds_5tone", "Standards")
|
2483
|
codes_5tone = RadioSettingGroup("codes_5tone", "Codes")
|
2484
|
|
2485
|
group_5tone = RadioSettingGroup("group_5tone", "5 Tone Settings")
|
2486
|
group_5tone.append(stds_5tone)
|
2487
|
group_5tone.append(codes_5tone)
|
2488
|
|
2489
|
top.append(group_5tone)
|
2490
|
|
2491
|
def apply_list_value(setting, obj):
|
2492
|
options = setting.value.get_options()
|
2493
|
obj.set_value(options.index(str(setting.value)))
|
2494
|
|
2495
|
_5tone_standards = self._memobj._5tone_std_settings
|
2496
|
i = 0
|
2497
|
for standard in _5tone_standards:
|
2498
|
std_5tone = RadioSettingGroup("std_5tone_" + str(i),
|
2499
|
LIST_5TONE_STANDARDS[i])
|
2500
|
stds_5tone.append(std_5tone)
|
2501
|
|
2502
|
period = standard.period
|
2503
|
if period == 255:
|
2504
|
LOG.debug("Period for " + LIST_5TONE_STANDARDS[i] +
|
2505
|
" is not yet configured. Setting to 70ms.")
|
2506
|
period = 5
|
2507
|
|
2508
|
if period <= len(LIST_5TONE_STANDARD_PERIODS):
|
2509
|
line = RadioSetting(
|
2510
|
"_5tone_std_settings_" + str(i) + "_period",
|
2511
|
"Period (ms)", RadioSettingValueList
|
2512
|
(LIST_5TONE_STANDARD_PERIODS,
|
2513
|
LIST_5TONE_STANDARD_PERIODS[period]))
|
2514
|
line.set_apply_callback(apply_list_value, standard.period)
|
2515
|
std_5tone.append(line)
|
2516
|
else:
|
2517
|
LOG.debug("Invalid value for 5tone period! Disabling.")
|
2518
|
|
2519
|
group_tone = standard.group_tone
|
2520
|
if group_tone == 255:
|
2521
|
LOG.debug("Group-Tone for " + LIST_5TONE_STANDARDS[i] +
|
2522
|
" is not yet configured. Setting to A.")
|
2523
|
group_tone = 10
|
2524
|
|
2525
|
if group_tone <= len(LIST_5TONE_DIGITS):
|
2526
|
line = RadioSetting(
|
2527
|
"_5tone_std_settings_" + str(i) + "_grouptone",
|
2528
|
"Group Tone",
|
2529
|
RadioSettingValueList(LIST_5TONE_DIGITS,
|
2530
|
LIST_5TONE_DIGITS[
|
2531
|
group_tone]))
|
2532
|
line.set_apply_callback(apply_list_value,
|
2533
|
standard.group_tone)
|
2534
|
std_5tone.append(line)
|
2535
|
else:
|
2536
|
LOG.debug("Invalid value for 5tone digit! Disabling.")
|
2537
|
|
2538
|
repeat_tone = standard.repeat_tone
|
2539
|
if repeat_tone == 255:
|
2540
|
LOG.debug("Repeat-Tone for " + LIST_5TONE_STANDARDS[i] +
|
2541
|
" is not yet configured. Setting to E.")
|
2542
|
repeat_tone = 14
|
2543
|
|
2544
|
if repeat_tone <= len(LIST_5TONE_DIGITS):
|
2545
|
line = RadioSetting(
|
2546
|
"_5tone_std_settings_" + str(i) + "_repttone",
|
2547
|
"Repeat Tone",
|
2548
|
RadioSettingValueList(LIST_5TONE_DIGITS,
|
2549
|
LIST_5TONE_DIGITS[
|
2550
|
repeat_tone]))
|
2551
|
line.set_apply_callback(apply_list_value,
|
2552
|
standard.repeat_tone)
|
2553
|
std_5tone.append(line)
|
2554
|
else:
|
2555
|
LOG.debug("Invalid value for 5tone digit! Disabling.")
|
2556
|
i = i + 1
|
2557
|
|
2558
|
def my_apply_5tonestdlist_value(setting, obj):
|
2559
|
if LIST_5TONE_STANDARDS.index(str(setting.value)) == 15:
|
2560
|
obj.set_value(0xFF)
|
2561
|
else:
|
2562
|
obj.set_value(LIST_5TONE_STANDARDS.
|
2563
|
index(str(setting.value)))
|
2564
|
|
2565
|
def apply_5tone_frame(setting, obj):
|
2566
|
LOG.debug("Setting 5 Tone: " + str(setting.value))
|
2567
|
valstring = str(setting.value)
|
2568
|
if len(valstring) == 0:
|
2569
|
for i in range(0, 5):
|
2570
|
obj[i] = 255
|
2571
|
else:
|
2572
|
validFrame = True
|
2573
|
for i in range(0, 5):
|
2574
|
currentChar = valstring[i].upper()
|
2575
|
if currentChar in LIST_5TONE_DIGITS:
|
2576
|
obj[i] = LIST_5TONE_DIGITS.index(currentChar)
|
2577
|
else:
|
2578
|
validFrame = False
|
2579
|
LOG.debug("invalid char: " + str(currentChar))
|
2580
|
if not validFrame:
|
2581
|
LOG.debug("setting whole frame to FF")
|
2582
|
for i in range(0, 5):
|
2583
|
obj[i] = 255
|
2584
|
|
2585
|
def validate_5tone_frame(value):
|
2586
|
if (len(str(value)) != 5) and (len(str(value)) != 0):
|
2587
|
msg = ("5 Tone must have 5 digits or 0 digits")
|
2588
|
raise InvalidValueError(msg)
|
2589
|
for digit in str(value):
|
2590
|
if digit.upper() not in LIST_5TONE_DIGITS:
|
2591
|
msg = (str(digit) + " is not a valid digit for 5tones")
|
2592
|
raise InvalidValueError(msg)
|
2593
|
return value
|
2594
|
|
2595
|
def frame2string(frame):
|
2596
|
frameString = ""
|
2597
|
for digit in frame:
|
2598
|
if digit != 255:
|
2599
|
frameString = frameString + LIST_5TONE_DIGITS[digit]
|
2600
|
return frameString
|
2601
|
|
2602
|
_5tone_codes = self._memobj._5tone_codes
|
2603
|
i = 1
|
2604
|
for code in _5tone_codes:
|
2605
|
code_5tone = RadioSettingGroup("code_5tone_" + str(i),
|
2606
|
"5 Tone code " + str(i))
|
2607
|
codes_5tone.append(code_5tone)
|
2608
|
if (code.standard == 255):
|
2609
|
currentVal = 15
|
2610
|
else:
|
2611
|
currentVal = code.standard
|
2612
|
line = RadioSetting("_5tone_code_" + str(i) + "_std",
|
2613
|
" Standard",
|
2614
|
RadioSettingValueList(LIST_5TONE_STANDARDS,
|
2615
|
LIST_5TONE_STANDARDS[
|
2616
|
currentVal]))
|
2617
|
line.set_apply_callback(my_apply_5tonestdlist_value,
|
2618
|
code.standard)
|
2619
|
code_5tone.append(line)
|
2620
|
|
2621
|
val = RadioSettingValueString(0, 6,
|
2622
|
frame2string(code.frame1), False)
|
2623
|
line = RadioSetting("_5tone_code_" + str(i) + "_frame1",
|
2624
|
" Frame 1", val)
|
2625
|
val.set_validate_callback(validate_5tone_frame)
|
2626
|
line.set_apply_callback(apply_5tone_frame, code.frame1)
|
2627
|
code_5tone.append(line)
|
2628
|
|
2629
|
val = RadioSettingValueString(0, 6,
|
2630
|
frame2string(code.frame2), False)
|
2631
|
line = RadioSetting("_5tone_code_" + str(i) + "_frame2",
|
2632
|
" Frame 2", val)
|
2633
|
val.set_validate_callback(validate_5tone_frame)
|
2634
|
line.set_apply_callback(apply_5tone_frame, code.frame2)
|
2635
|
code_5tone.append(line)
|
2636
|
|
2637
|
val = RadioSettingValueString(0, 6,
|
2638
|
frame2string(code.frame3), False)
|
2639
|
line = RadioSetting("_5tone_code_" + str(i) + "_frame3",
|
2640
|
" Frame 3", val)
|
2641
|
val.set_validate_callback(validate_5tone_frame)
|
2642
|
line.set_apply_callback(apply_5tone_frame, code.frame3)
|
2643
|
code_5tone.append(line)
|
2644
|
i = i + 1
|
2645
|
|
2646
|
_5_tone_decode1 = RadioSetting(
|
2647
|
"_5tone_settings._5tone_decode_call_frame1",
|
2648
|
"5 Tone decode call Frame 1",
|
2649
|
RadioSettingValueBoolean(
|
2650
|
_mem._5tone_settings._5tone_decode_call_frame1))
|
2651
|
group_5tone.append(_5_tone_decode1)
|
2652
|
|
2653
|
_5_tone_decode2 = RadioSetting(
|
2654
|
"_5tone_settings._5tone_decode_call_frame2",
|
2655
|
"5 Tone decode call Frame 2",
|
2656
|
RadioSettingValueBoolean(
|
2657
|
_mem._5tone_settings._5tone_decode_call_frame2))
|
2658
|
group_5tone.append(_5_tone_decode2)
|
2659
|
|
2660
|
_5_tone_decode3 = RadioSetting(
|
2661
|
"_5tone_settings._5tone_decode_call_frame3",
|
2662
|
"5 Tone decode call Frame 3",
|
2663
|
RadioSettingValueBoolean(
|
2664
|
_mem._5tone_settings._5tone_decode_call_frame3))
|
2665
|
group_5tone.append(_5_tone_decode3)
|
2666
|
|
2667
|
_5_tone_decode_disp1 = RadioSetting(
|
2668
|
"_5tone_settings._5tone_decode_disp_frame1",
|
2669
|
"5 Tone decode disp Frame 1",
|
2670
|
RadioSettingValueBoolean(
|
2671
|
_mem._5tone_settings._5tone_decode_disp_frame1))
|
2672
|
group_5tone.append(_5_tone_decode_disp1)
|
2673
|
|
2674
|
_5_tone_decode_disp2 = RadioSetting(
|
2675
|
"_5tone_settings._5tone_decode_disp_frame2",
|
2676
|
"5 Tone decode disp Frame 2",
|
2677
|
RadioSettingValueBoolean(
|
2678
|
_mem._5tone_settings._5tone_decode_disp_frame2))
|
2679
|
group_5tone.append(_5_tone_decode_disp2)
|
2680
|
|
2681
|
_5_tone_decode_disp3 = RadioSetting(
|
2682
|
"_5tone_settings._5tone_decode_disp_frame3",
|
2683
|
"5 Tone decode disp Frame 3",
|
2684
|
RadioSettingValueBoolean(
|
2685
|
_mem._5tone_settings._5tone_decode_disp_frame3))
|
2686
|
group_5tone.append(_5_tone_decode_disp3)
|
2687
|
|
2688
|
decode_standard = _mem._5tone_settings.decode_standard
|
2689
|
if decode_standard == 255:
|
2690
|
decode_standard = 0
|
2691
|
if decode_standard <= len(LIST_5TONE_STANDARDS_without_none):
|
2692
|
line = RadioSetting("_5tone_settings.decode_standard",
|
2693
|
"5 Tone-decode Standard",
|
2694
|
RadioSettingValueList(
|
2695
|
LIST_5TONE_STANDARDS_without_none,
|
2696
|
LIST_5TONE_STANDARDS_without_none[
|
2697
|
decode_standard]))
|
2698
|
group_5tone.append(line)
|
2699
|
else:
|
2700
|
LOG.debug("Invalid decode std...")
|
2701
|
|
2702
|
_5tone_delay1 = _mem._5tone_settings._5tone_delay1
|
2703
|
if _5tone_delay1 == 255:
|
2704
|
_5tone_delay1 = 20
|
2705
|
|
2706
|
if _5tone_delay1 <= len(LIST_5TONE_DELAY):
|
2707
|
list = RadioSettingValueList(LIST_5TONE_DELAY,
|
2708
|
LIST_5TONE_DELAY[
|
2709
|
_5tone_delay1])
|
2710
|
line = RadioSetting("_5tone_settings._5tone_delay1",
|
2711
|
"5 Tone Delay Frame 1", list)
|
2712
|
group_5tone.append(line)
|
2713
|
else:
|
2714
|
LOG.debug("Invalid value for 5tone delay (frame1) ! Disabling.")
|
2715
|
|
2716
|
_5tone_delay2 = _mem._5tone_settings._5tone_delay2
|
2717
|
if _5tone_delay2 == 255:
|
2718
|
_5tone_delay2 = 20
|
2719
|
LOG.debug("5 Tone delay unconfigured! Resetting to 200ms.")
|
2720
|
|
2721
|
if _5tone_delay2 <= len(LIST_5TONE_DELAY):
|
2722
|
list = RadioSettingValueList(LIST_5TONE_DELAY,
|
2723
|
LIST_5TONE_DELAY[
|
2724
|
_5tone_delay2])
|
2725
|
line = RadioSetting("_5tone_settings._5tone_delay2",
|
2726
|
"5 Tone Delay Frame 2", list)
|
2727
|
group_5tone.append(line)
|
2728
|
else:
|
2729
|
LOG.debug("Invalid value for 5tone delay (frame2)! Disabling.")
|
2730
|
|
2731
|
_5tone_delay3 = _mem._5tone_settings._5tone_delay3
|
2732
|
if _5tone_delay3 == 255:
|
2733
|
_5tone_delay3 = 20
|
2734
|
LOG.debug("5 Tone delay unconfigured! Resetting to 200ms.")
|
2735
|
|
2736
|
if _5tone_delay3 <= len(LIST_5TONE_DELAY):
|
2737
|
list = RadioSettingValueList(LIST_5TONE_DELAY,
|
2738
|
LIST_5TONE_DELAY[
|
2739
|
_5tone_delay3])
|
2740
|
line = RadioSetting("_5tone_settings._5tone_delay3",
|
2741
|
"5 Tone Delay Frame 3", list)
|
2742
|
group_5tone.append(line)
|
2743
|
else:
|
2744
|
LOG.debug("Invalid value for 5tone delay (frame3)! Disabling.")
|
2745
|
|
2746
|
ext_length = _mem._5tone_settings._5tone_first_digit_ext_length
|
2747
|
if ext_length == 255:
|
2748
|
ext_length = 0
|
2749
|
LOG.debug("1st Tone ext lenght unconfigured! Resetting to 0")
|
2750
|
|
2751
|
if ext_length <= len(LIST_5TONE_DELAY):
|
2752
|
list = RadioSettingValueList(
|
2753
|
LIST_5TONE_DELAY,
|
2754
|
LIST_5TONE_DELAY[
|
2755
|
ext_length])
|
2756
|
line = RadioSetting(
|
2757
|
"_5tone_settings._5tone_first_digit_ext_length",
|
2758
|
"First digit extend length", list)
|
2759
|
group_5tone.append(line)
|
2760
|
else:
|
2761
|
LOG.debug("Invalid value for 5tone ext length! Disabling.")
|
2762
|
|
2763
|
decode_reset_time = _mem._5tone_settings.decode_reset_time
|
2764
|
if decode_reset_time == 255:
|
2765
|
decode_reset_time = 59
|
2766
|
LOG.debug("Decode reset time unconfigured. resetting.")
|
2767
|
if decode_reset_time <= len(LIST_5TONE_RESET):
|
2768
|
list = RadioSettingValueList(
|
2769
|
LIST_5TONE_RESET,
|
2770
|
LIST_5TONE_RESET[
|
2771
|
decode_reset_time])
|
2772
|
line = RadioSetting("_5tone_settings.decode_reset_time",
|
2773
|
"Decode reset time", list)
|
2774
|
group_5tone.append(line)
|
2775
|
else:
|
2776
|
LOG.debug("Invalid value decode reset time! Disabling.")
|
2777
|
|
2778
|
# 2 Tone
|
2779
|
encode_2tone = RadioSettingGroup("encode_2tone", "2 Tone Encode")
|
2780
|
decode_2tone = RadioSettingGroup("decode_2tone", "2 Code Decode")
|
2781
|
|
2782
|
top.append(encode_2tone)
|
2783
|
top.append(decode_2tone)
|
2784
|
|
2785
|
duration_1st_tone = self._memobj._2tone.duration_1st_tone
|
2786
|
if duration_1st_tone == 255:
|
2787
|
LOG.debug("Duration of first 2 Tone digit is not yet " +
|
2788
|
"configured. Setting to 600ms")
|
2789
|
duration_1st_tone = 60
|
2790
|
|
2791
|
if duration_1st_tone <= len(LIST_5TONE_DELAY):
|
2792
|
line = RadioSetting("_2tone.duration_1st_tone",
|
2793
|
"Duration 1st Tone",
|
2794
|
RadioSettingValueList(LIST_5TONE_DELAY,
|
2795
|
LIST_5TONE_DELAY[
|
2796
|
duration_1st_tone]))
|
2797
|
encode_2tone.append(line)
|
2798
|
|
2799
|
duration_2nd_tone = self._memobj._2tone.duration_2nd_tone
|
2800
|
if duration_2nd_tone == 255:
|
2801
|
LOG.debug("Duration of second 2 Tone digit is not yet " +
|
2802
|
"configured. Setting to 600ms")
|
2803
|
duration_2nd_tone = 60
|
2804
|
|
2805
|
if duration_2nd_tone <= len(LIST_5TONE_DELAY):
|
2806
|
line = RadioSetting("_2tone.duration_2nd_tone",
|
2807
|
"Duration 2nd Tone",
|
2808
|
RadioSettingValueList(LIST_5TONE_DELAY,
|
2809
|
LIST_5TONE_DELAY[
|
2810
|
duration_2nd_tone]))
|
2811
|
encode_2tone.append(line)
|
2812
|
|
2813
|
duration_gap = self._memobj._2tone.duration_gap
|
2814
|
if duration_gap == 255:
|
2815
|
LOG.debug("Duration of gap is not yet " +
|
2816
|
"configured. Setting to 300ms")
|
2817
|
duration_gap = 30
|
2818
|
|
2819
|
if duration_gap <= len(LIST_5TONE_DELAY):
|
2820
|
line = RadioSetting("_2tone.duration_gap", "Duration of gap",
|
2821
|
RadioSettingValueList(LIST_5TONE_DELAY,
|
2822
|
LIST_5TONE_DELAY[
|
2823
|
duration_gap]))
|
2824
|
encode_2tone.append(line)
|
2825
|
|
2826
|
def _2tone_validate(value):
|
2827
|
if value == 0:
|
2828
|
return 65535
|
2829
|
if value == 65535:
|
2830
|
return value
|
2831
|
if not (300 <= value and value <= 3000):
|
2832
|
msg = ("2 Tone Frequency: Must be between 300 and 3000 Hz")
|
2833
|
raise InvalidValueError(msg)
|
2834
|
return value
|
2835
|
|
2836
|
def apply_2tone_freq(setting, obj):
|
2837
|
val = int(setting.value)
|
2838
|
if (val == 0) or (val == 65535):
|
2839
|
obj.set_value(65535)
|
2840
|
else:
|
2841
|
obj.set_value(val)
|
2842
|
|
2843
|
i = 1
|
2844
|
for code in self._memobj._2tone._2tone_encode:
|
2845
|
code_2tone = RadioSettingGroup("code_2tone_" + str(i),
|
2846
|
"Encode Code " + str(i))
|
2847
|
encode_2tone.append(code_2tone)
|
2848
|
|
2849
|
tmp = code.freq1
|
2850
|
if tmp == 65535:
|
2851
|
tmp = 0
|
2852
|
val1 = RadioSettingValueInteger(0, 65535, tmp)
|
2853
|
freq1 = RadioSetting("2tone_code_" + str(i) + "_freq1",
|
2854
|
"Frequency 1", val1)
|
2855
|
val1.set_validate_callback(_2tone_validate)
|
2856
|
freq1.set_apply_callback(apply_2tone_freq, code.freq1)
|
2857
|
code_2tone.append(freq1)
|
2858
|
|
2859
|
tmp = code.freq2
|
2860
|
if tmp == 65535:
|
2861
|
tmp = 0
|
2862
|
val2 = RadioSettingValueInteger(0, 65535, tmp)
|
2863
|
freq2 = RadioSetting("2tone_code_" + str(i) + "_freq2",
|
2864
|
"Frequency 2", val2)
|
2865
|
val2.set_validate_callback(_2tone_validate)
|
2866
|
freq2.set_apply_callback(apply_2tone_freq, code.freq2)
|
2867
|
code_2tone.append(freq2)
|
2868
|
|
2869
|
i = i + 1
|
2870
|
|
2871
|
decode_reset_time = _mem._2tone.reset_time
|
2872
|
if decode_reset_time == 255:
|
2873
|
decode_reset_time = 59
|
2874
|
LOG.debug("Decode reset time unconfigured. resetting.")
|
2875
|
if decode_reset_time <= len(LIST_5TONE_RESET):
|
2876
|
list = RadioSettingValueList(
|
2877
|
LIST_5TONE_RESET,
|
2878
|
LIST_5TONE_RESET[
|
2879
|
decode_reset_time])
|
2880
|
line = RadioSetting("_2tone.reset_time",
|
2881
|
"Decode reset time", list)
|
2882
|
decode_2tone.append(line)
|
2883
|
else:
|
2884
|
LOG.debug("Invalid value decode reset time! Disabling.")
|
2885
|
|
2886
|
def apply_2tone_freq_pair(setting, obj):
|
2887
|
val = int(setting.value)
|
2888
|
derived_val = 65535
|
2889
|
frqname = str(setting._name[-5:])
|
2890
|
derivedname = "derived_from_" + frqname
|
2891
|
|
2892
|
if (val == 0):
|
2893
|
val = 65535
|
2894
|
derived_val = 65535
|
2895
|
else:
|
2896
|
derived_val = int(round(2304000.0/val))
|
2897
|
|
2898
|
obj[frqname].set_value(val)
|
2899
|
obj[derivedname].set_value(derived_val)
|
2900
|
|
2901
|
LOG.debug("Apply " + frqname + ": " + str(val) + " | " +
|
2902
|
derivedname + ": " + str(derived_val))
|
2903
|
|
2904
|
i = 1
|
2905
|
for decode_code in self._memobj._2tone._2tone_decode:
|
2906
|
_2tone_dec_code = RadioSettingGroup("code_2tone_" + str(i),
|
2907
|
"Decode Code " + str(i))
|
2908
|
decode_2tone.append(_2tone_dec_code)
|
2909
|
|
2910
|
j = 1
|
2911
|
for dec in decode_code.decs:
|
2912
|
val = dec.dec
|
2913
|
if val == 255:
|
2914
|
LOG.debug("Dec for Code " + str(i) + " Dec " + str(j) +
|
2915
|
" is not yet configured. Setting to 0.")
|
2916
|
val = 0
|
2917
|
|
2918
|
if val <= len(LIST_2TONE_DEC):
|
2919
|
line = RadioSetting(
|
2920
|
"_2tone_dec_settings_" + str(i) + "_dec_" + str(j),
|
2921
|
"Dec " + str(j), RadioSettingValueList
|
2922
|
(LIST_2TONE_DEC,
|
2923
|
LIST_2TONE_DEC[val]))
|
2924
|
line.set_apply_callback(apply_list_value, dec.dec)
|
2925
|
_2tone_dec_code.append(line)
|
2926
|
else:
|
2927
|
LOG.debug("Invalid value for 2tone dec! Disabling.")
|
2928
|
|
2929
|
val = dec.response
|
2930
|
if val == 255:
|
2931
|
LOG.debug("Response for Code " + str(i) + " Dec " +
|
2932
|
str(j) + " is not yet configured. Setting to 0.")
|
2933
|
val = 0
|
2934
|
|
2935
|
if val <= len(LIST_2TONE_RESPONSE):
|
2936
|
line = RadioSetting(
|
2937
|
"_2tone_dec_settings_" + str(i) + "_resp_" + str(j),
|
2938
|
"Response " + str(j), RadioSettingValueList
|
2939
|
(LIST_2TONE_RESPONSE,
|
2940
|
LIST_2TONE_RESPONSE[val]))
|
2941
|
line.set_apply_callback(apply_list_value, dec.response)
|
2942
|
_2tone_dec_code.append(line)
|
2943
|
else:
|
2944
|
LOG.debug("Invalid value for 2tone response! Disabling.")
|
2945
|
|
2946
|
val = dec.alert
|
2947
|
if val == 255:
|
2948
|
LOG.debug("Alert for Code " + str(i) + " Dec " + str(j) +
|
2949
|
" is not yet configured. Setting to 0.")
|
2950
|
val = 0
|
2951
|
|
2952
|
if val <= len(PTTIDCODE_LIST):
|
2953
|
line = RadioSetting(
|
2954
|
"_2tone_dec_settings_" + str(i) + "_alert_" + str(j),
|
2955
|
"Alert " + str(j), RadioSettingValueList
|
2956
|
(PTTIDCODE_LIST,
|
2957
|
PTTIDCODE_LIST[val]))
|
2958
|
line.set_apply_callback(apply_list_value, dec.alert)
|
2959
|
_2tone_dec_code.append(line)
|
2960
|
else:
|
2961
|
LOG.debug("Invalid value for 2tone alert! Disabling.")
|
2962
|
j = j + 1
|
2963
|
|
2964
|
freq = self._memobj._2tone.freqs[i-1]
|
2965
|
for char in ['A', 'B', 'C', 'D']:
|
2966
|
setting_name = "freq" + str(char)
|
2967
|
|
2968
|
tmp = freq[setting_name]
|
2969
|
if tmp == 65535:
|
2970
|
tmp = 0
|
2971
|
if tmp != 0:
|
2972
|
expected = int(round(2304000.0/tmp))
|
2973
|
from_mem = freq["derived_from_" + setting_name]
|
2974
|
if expected != from_mem:
|
2975
|
LOG.error("Expected " + str(expected) +
|
2976
|
" but read " + str(from_mem) +
|
2977
|
". Disabling 2Tone Decode Freqs!")
|
2978
|
break
|
2979
|
val = RadioSettingValueInteger(0, 65535, tmp)
|
2980
|
frq = RadioSetting("2tone_dec_" + str(i) + "_freq" + str(char),
|
2981
|
("Decode Frequency " + str(char)), val)
|
2982
|
val.set_validate_callback(_2tone_validate)
|
2983
|
frq.set_apply_callback(apply_2tone_freq_pair, freq)
|
2984
|
_2tone_dec_code.append(frq)
|
2985
|
|
2986
|
i = i + 1
|
2987
|
|
2988
|
return top
|
2989
|
|
2990
|
def set_settings(self, settings):
|
2991
|
_settings = self._memobj.settings
|
2992
|
for element in settings:
|
2993
|
if not isinstance(element, RadioSetting):
|
2994
|
if element.get_name() == "fm_preset":
|
2995
|
self._set_fm_preset(element)
|
2996
|
else:
|
2997
|
self.set_settings(element)
|
2998
|
continue
|
2999
|
else:
|
3000
|
try:
|
3001
|
name = element.get_name()
|
3002
|
if "." in name:
|
3003
|
bits = name.split(".")
|
3004
|
obj = self._memobj
|
3005
|
for bit in bits[:-1]:
|
3006
|
if "/" in bit:
|
3007
|
bit, index = bit.split("/", 1)
|
3008
|
index = int(index)
|
3009
|
obj = getattr(obj, bit)[index]
|
3010
|
else:
|
3011
|
obj = getattr(obj, bit)
|
3012
|
setting = bits[-1]
|
3013
|
else:
|
3014
|
obj = _settings
|
3015
|
setting = element.get_name()
|
3016
|
|
3017
|
if element.has_apply_callback():
|
3018
|
LOG.debug("Using apply callback")
|
3019
|
element.run_apply_callback()
|
3020
|
elif element.value.get_mutable():
|
3021
|
LOG.debug("Setting %s = %s" % (setting, element.value))
|
3022
|
setattr(obj, setting, element.value)
|
3023
|
except Exception, e:
|
3024
|
LOG.debug(element.get_name())
|
3025
|
raise
|
3026
|
|
3027
|
@classmethod
|
3028
|
def match_model(cls, filedata, filename):
|
3029
|
match_size = False
|
3030
|
match_model = False
|
3031
|
|
3032
|
# testing the file data size
|
3033
|
if len(filedata) == MEM_SIZE:
|
3034
|
match_size = True
|
3035
|
|
3036
|
# testing the firmware model fingerprint
|
3037
|
match_model = model_match(cls, filedata)
|
3038
|
|
3039
|
if match_size and match_model:
|
3040
|
return True
|
3041
|
else:
|
3042
|
return False
|
3043
|
|
3044
|
|
3045
|
MEM_FORMAT = """
|
3046
|
#seekto 0x0000;
|
3047
|
struct {
|
3048
|
lbcd rxfreq[4];
|
3049
|
lbcd txfreq[4];
|
3050
|
ul16 rxtone;
|
3051
|
ul16 txtone;
|
3052
|
u8 unknown0:4,
|
3053
|
scode:4;
|
3054
|
u8 unknown1:2,
|
3055
|
spmute:2,
|
3056
|
unknown2:2,
|
3057
|
optsig:2;
|
3058
|
u8 unknown3:3,
|
3059
|
scramble:1,
|
3060
|
unknown4:3,
|
3061
|
power:1;
|
3062
|
u8 unknown5:1,
|
3063
|
wide:1,
|
3064
|
unknown6:2,
|
3065
|
bcl:1,
|
3066
|
add:1,
|
3067
|
pttid:2;
|
3068
|
} memory[200];
|
3069
|
|
3070
|
#seekto 0x0E00;
|
3071
|
struct {
|
3072
|
u8 tdr;
|
3073
|
u8 unknown1;
|
3074
|
u8 sql;
|
3075
|
u8 unknown2[2];
|
3076
|
u8 tot;
|
3077
|
u8 apo; // BTech radios use this as the Auto Power Off time
|
3078
|
// other radios use this as pre-Time Out Alert
|
3079
|
u8 unknown3;
|
3080
|
u8 abr;
|
3081
|
u8 beep;
|
3082
|
u8 unknown4[4];
|
3083
|
u8 dtmfst;
|
3084
|
u8 unknown5[2];
|
3085
|
u8 prisc;
|
3086
|
u8 prich;
|
3087
|
u8 screv;
|
3088
|
u8 unknown6[2];
|
3089
|
u8 pttid;
|
3090
|
u8 pttlt;
|
3091
|
u8 unknown7;
|
3092
|
u8 emctp;
|
3093
|
u8 emcch;
|
3094
|
u8 ringt;
|
3095
|
u8 unknown8;
|
3096
|
u8 camdf;
|
3097
|
u8 cbmdf;
|
3098
|
u8 sync; // BTech radios use this as the display sync setting
|
3099
|
// other radios use this as the auto keypad lock setting
|
3100
|
u8 ponmsg;
|
3101
|
u8 wtled;
|
3102
|
u8 rxled;
|
3103
|
u8 txled;
|
3104
|
u8 unknown9[5];
|
3105
|
u8 anil;
|
3106
|
u8 reps;
|
3107
|
u8 repm;
|
3108
|
u8 tdrab;
|
3109
|
u8 ste;
|
3110
|
u8 rpste;
|
3111
|
u8 rptdl;
|
3112
|
u8 mgain;
|
3113
|
u8 dtmfg;
|
3114
|
} settings;
|
3115
|
|
3116
|
#seekto 0x0E80;
|
3117
|
struct {
|
3118
|
u8 unknown1;
|
3119
|
u8 vfomr;
|
3120
|
u8 keylock;
|
3121
|
u8 unknown2;
|
3122
|
u8 unknown3:4,
|
3123
|
vfomren:1,
|
3124
|
unknown4:1,
|
3125
|
reseten:1,
|
3126
|
menuen:1;
|
3127
|
u8 unknown5[11];
|
3128
|
u8 dispab;
|
3129
|
u8 mrcha;
|
3130
|
u8 mrchb;
|
3131
|
u8 menu;
|
3132
|
} settings2;
|
3133
|
|
3134
|
#seekto 0x0EC0;
|
3135
|
struct {
|
3136
|
char line1[6];
|
3137
|
char line2[6];
|
3138
|
} poweron_msg;
|
3139
|
|
3140
|
struct settings_vfo {
|
3141
|
u8 freq[8];
|
3142
|
u8 offset[6];
|
3143
|
u8 unknown2[2];
|
3144
|
ul16 rxtone;
|
3145
|
ul16 txtone;
|
3146
|
u8 scode;
|
3147
|
u8 spmute;
|
3148
|
u8 optsig;
|
3149
|
u8 scramble;
|
3150
|
u8 wide;
|
3151
|
u8 power;
|
3152
|
u8 shiftd;
|
3153
|
u8 step;
|
3154
|
u8 unknown3[4];
|
3155
|
};
|
3156
|
|
3157
|
#seekto 0x0F00;
|
3158
|
struct {
|
3159
|
struct settings_vfo a;
|
3160
|
struct settings_vfo b;
|
3161
|
} vfo;
|
3162
|
|
3163
|
#seekto 0x1000;
|
3164
|
struct {
|
3165
|
char name[6];
|
3166
|
u8 unknown1[10];
|
3167
|
} names[200];
|
3168
|
|
3169
|
#seekto 0x2400;
|
3170
|
struct {
|
3171
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
3172
|
u8 group_tone;
|
3173
|
u8 repeat_tone;
|
3174
|
u8 unused[13];
|
3175
|
} _5tone_std_settings[15];
|
3176
|
|
3177
|
#seekto 0x2500;
|
3178
|
struct {
|
3179
|
u8 frame1[5];
|
3180
|
u8 frame2[5];
|
3181
|
u8 frame3[5];
|
3182
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
3183
|
} _5tone_codes[15];
|
3184
|
|
3185
|
#seekto 0x25F0;
|
3186
|
struct {
|
3187
|
u8 _5tone_delay1; // * 10ms
|
3188
|
u8 _5tone_delay2; // * 10ms
|
3189
|
u8 _5tone_delay3; // * 10ms
|
3190
|
u8 _5tone_first_digit_ext_length;
|
3191
|
u8 unknown1;
|
3192
|
u8 unknown2;
|
3193
|
u8 unknown3;
|
3194
|
u8 unknown4;
|
3195
|
u8 decode_standard;
|
3196
|
u8 unknown5:5,
|
3197
|
_5tone_decode_call_frame3:1,
|
3198
|
_5tone_decode_call_frame2:1,
|
3199
|
_5tone_decode_call_frame1:1;
|
3200
|
u8 unknown6:5,
|
3201
|
_5tone_decode_disp_frame3:1,
|
3202
|
_5tone_decode_disp_frame2:1,
|
3203
|
_5tone_decode_disp_frame1:1;
|
3204
|
u8 decode_reset_time; // * 100 + 100ms
|
3205
|
} _5tone_settings;
|
3206
|
|
3207
|
#seekto 0x2900;
|
3208
|
struct {
|
3209
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
3210
|
} dtmf_codes[15];
|
3211
|
|
3212
|
#seekto 0x29F0;
|
3213
|
struct {
|
3214
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
3215
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
3216
|
u8 unknown0[14];
|
3217
|
u8 inspection[16];
|
3218
|
u8 monitor[16];
|
3219
|
u8 alarmcode[16];
|
3220
|
u8 stun[16];
|
3221
|
u8 kill[16];
|
3222
|
u8 revive[16];
|
3223
|
u8 unknown1[16];
|
3224
|
u8 unknown2[16];
|
3225
|
u8 unknown3[16];
|
3226
|
u8 unknown4[16];
|
3227
|
u8 unknown5[16];
|
3228
|
u8 unknown6[16];
|
3229
|
u8 unknown7[16];
|
3230
|
u8 masterid[16];
|
3231
|
u8 viceid[16];
|
3232
|
u8 unused01:7,
|
3233
|
mastervice:1;
|
3234
|
u8 unused02:3,
|
3235
|
mrevive:1,
|
3236
|
mkill:1,
|
3237
|
mstun:1,
|
3238
|
mmonitor:1,
|
3239
|
minspection:1;
|
3240
|
u8 unused03:3,
|
3241
|
vrevive:1,
|
3242
|
vkill:1,
|
3243
|
vstun:1,
|
3244
|
vmonitor:1,
|
3245
|
vinspection:1;
|
3246
|
u8 unused04:6,
|
3247
|
txdisable:1,
|
3248
|
rxdisable:1;
|
3249
|
u8 groupcode;
|
3250
|
u8 spacecode;
|
3251
|
u8 delayproctime; // * 100 + 100ms
|
3252
|
u8 resettime; // * 100 + 100ms
|
3253
|
} dtmf_settings;
|
3254
|
|
3255
|
#seekto 0x2D00;
|
3256
|
struct {
|
3257
|
struct {
|
3258
|
ul16 freq1;
|
3259
|
u8 unused01[6];
|
3260
|
ul16 freq2;
|
3261
|
u8 unused02[6];
|
3262
|
} _2tone_encode[15];
|
3263
|
u8 duration_1st_tone; // *10ms
|
3264
|
u8 duration_2nd_tone; // *10ms
|
3265
|
u8 duration_gap; // *10ms
|
3266
|
u8 unused03[13];
|
3267
|
struct {
|
3268
|
struct {
|
3269
|
u8 dec; // one out of LIST_2TONE_DEC
|
3270
|
u8 response; // one out of LIST_2TONE_RESPONSE
|
3271
|
u8 alert; // 1-16
|
3272
|
} decs[4];
|
3273
|
u8 unused04[4];
|
3274
|
} _2tone_decode[15];
|
3275
|
u8 unused05[16];
|
3276
|
|
3277
|
struct {
|
3278
|
ul16 freqA;
|
3279
|
ul16 freqB;
|
3280
|
ul16 freqC;
|
3281
|
ul16 freqD;
|
3282
|
// unknown what those values mean, but they are
|
3283
|
// derived from configured frequencies
|
3284
|
ul16 derived_from_freqA; // 2304000/freqA
|
3285
|
ul16 derived_from_freqB; // 2304000/freqB
|
3286
|
ul16 derived_from_freqC; // 2304000/freqC
|
3287
|
ul16 derived_from_freqD; // 2304000/freqD
|
3288
|
}freqs[15];
|
3289
|
u8 reset_time; // * 100 + 100ms - 100-8000ms
|
3290
|
} _2tone;
|
3291
|
|
3292
|
#seekto 0x3000;
|
3293
|
struct {
|
3294
|
u8 freq[8];
|
3295
|
char broadcast_station_name[6];
|
3296
|
u8 unknown[2];
|
3297
|
} fm_radio_preset[16];
|
3298
|
|
3299
|
#seekto 0x3C90;
|
3300
|
struct {
|
3301
|
u8 vhf_low[3];
|
3302
|
u8 vhf_high[3];
|
3303
|
u8 uhf_low[3];
|
3304
|
u8 uhf_high[3];
|
3305
|
} ranges;
|
3306
|
|
3307
|
// the UV-2501+220 & KT8900R has different zones for storing ranges
|
3308
|
|
3309
|
#seekto 0x3CD0;
|
3310
|
struct {
|
3311
|
u8 vhf_low[3];
|
3312
|
u8 vhf_high[3];
|
3313
|
u8 unknown1[4];
|
3314
|
u8 unknown2[6];
|
3315
|
u8 vhf2_low[3];
|
3316
|
u8 vhf2_high[3];
|
3317
|
u8 unknown3[4];
|
3318
|
u8 unknown4[6];
|
3319
|
u8 uhf_low[3];
|
3320
|
u8 uhf_high[3];
|
3321
|
} ranges220;
|
3322
|
|
3323
|
#seekto 0x3F70;
|
3324
|
struct {
|
3325
|
char fp[6];
|
3326
|
} fingerprint;
|
3327
|
|
3328
|
"""
|
3329
|
|
3330
|
|
3331
|
class BTech(BTechMobileCommon):
|
3332
|
"""BTECH's UV-5001 and alike radios"""
|
3333
|
BANDS = 2
|
3334
|
COLOR_LCD = False
|
3335
|
NAME_LENGTH = 6
|
3336
|
|
3337
|
def set_options(self):
|
3338
|
"""This is to read the options from the image and set it in the
|
3339
|
environment, for now just the limits of the freqs in the VHF/UHF
|
3340
|
ranges"""
|
3341
|
|
3342
|
# setting the correct ranges for each radio type
|
3343
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
3344
|
# the model 2501+220 has a segment in 220
|
3345
|
# and a different position in the memmap
|
3346
|
# also the QYT KT8900R
|
3347
|
ranges = self._memobj.ranges220
|
3348
|
else:
|
3349
|
ranges = self._memobj.ranges
|
3350
|
|
3351
|
# the normal dual bands
|
3352
|
vhf = _decode_ranges(ranges.vhf_low, ranges.vhf_high)
|
3353
|
uhf = _decode_ranges(ranges.uhf_low, ranges.uhf_high)
|
3354
|
|
3355
|
# DEBUG
|
3356
|
LOG.info("Radio ranges: VHF %d to %d" % vhf)
|
3357
|
LOG.info("Radio ranges: UHF %d to %d" % uhf)
|
3358
|
|
3359
|
# 220Mhz radios case
|
3360
|
if self.MODEL in ["UV-2501+220", "KT8900R"]:
|
3361
|
vhf2 = _decode_ranges(ranges.vhf2_low, ranges.vhf2_high)
|
3362
|
LOG.info("Radio ranges: VHF(220) %d to %d" % vhf2)
|
3363
|
self._220_range = vhf2
|
3364
|
|
3365
|
# set the class with the real data
|
3366
|
self._vhf_range = vhf
|
3367
|
self._uhf_range = uhf
|
3368
|
|
3369
|
def process_mmap(self):
|
3370
|
"""Process the mem map into the mem object"""
|
3371
|
|
3372
|
# Get it
|
3373
|
self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
|
3374
|
|
3375
|
# load specific parameters from the radio image
|
3376
|
self.set_options()
|
3377
|
|
3378
|
|
3379
|
# Declaring Aliases (Clones of the real radios)
|
3380
|
class JT2705M(chirp_common.Alias):
|
3381
|
VENDOR = "Jetstream"
|
3382
|
MODEL = "JT2705M"
|
3383
|
|
3384
|
|
3385
|
class JT6188Mini(chirp_common.Alias):
|
3386
|
VENDOR = "Juentai"
|
3387
|
MODEL = "JT-6188 Mini"
|
3388
|
|
3389
|
|
3390
|
class JT6188Plus(chirp_common.Alias):
|
3391
|
VENDOR = "Juentai"
|
3392
|
MODEL = "JT-6188 Plus"
|
3393
|
|
3394
|
|
3395
|
class SSGT890(chirp_common.Alias):
|
3396
|
VENDOR = "Sainsonic"
|
3397
|
MODEL = "GT-890"
|
3398
|
|
3399
|
|
3400
|
class ZastoneMP300(chirp_common.Alias):
|
3401
|
VENDOR = "Zastone"
|
3402
|
MODEL = "MP-300"
|
3403
|
|
3404
|
|
3405
|
# real radios
|
3406
|
@directory.register
|
3407
|
class UV2501(BTech):
|
3408
|
"""Baofeng Tech UV2501"""
|
3409
|
MODEL = "UV-2501"
|
3410
|
_fileid = [UV2501G3_fp,
|
3411
|
UV2501G2_fp,
|
3412
|
UV2501pp2_fp,
|
3413
|
UV2501pp_fp]
|
3414
|
|
3415
|
|
3416
|
@directory.register
|
3417
|
class UV2501_220(BTech):
|
3418
|
"""Baofeng Tech UV2501+220"""
|
3419
|
MODEL = "UV-2501+220"
|
3420
|
BANDS = 3
|
3421
|
_magic = MSTRING_220
|
3422
|
_id2 = [UV2501_220pp_id, ]
|
3423
|
_fileid = [UV2501_220G3_fp,
|
3424
|
UV2501_220G2_fp,
|
3425
|
UV2501_220_fp,
|
3426
|
UV2501_220pp_fp]
|
3427
|
|
3428
|
|
3429
|
@directory.register
|
3430
|
class UV5001(BTech):
|
3431
|
"""Baofeng Tech UV5001"""
|
3432
|
MODEL = "UV-5001"
|
3433
|
_fileid = [UV5001G3_fp,
|
3434
|
UV5001G22_fp,
|
3435
|
UV5001G2_fp,
|
3436
|
UV5001alpha_fp,
|
3437
|
UV5001pp_fp]
|
3438
|
_power_levels = [chirp_common.PowerLevel("High", watts=50),
|
3439
|
chirp_common.PowerLevel("Low", watts=10)]
|
3440
|
|
3441
|
|
3442
|
@directory.register
|
3443
|
class MINI8900(BTech):
|
3444
|
"""WACCOM MINI-8900"""
|
3445
|
VENDOR = "WACCOM"
|
3446
|
MODEL = "MINI-8900"
|
3447
|
_magic = MSTRING_MINI8900
|
3448
|
_fileid = [MINI8900_fp, ]
|
3449
|
# Clones
|
3450
|
ALIASES = [JT6188Plus, ]
|
3451
|
|
3452
|
|
3453
|
@directory.register
|
3454
|
class KTUV980(BTech):
|
3455
|
"""QYT KT-UV980"""
|
3456
|
VENDOR = "QYT"
|
3457
|
MODEL = "KT-UV980"
|
3458
|
_vhf_range = (136000000, 175000000)
|
3459
|
_uhf_range = (400000000, 481000000)
|
3460
|
_magic = MSTRING_MINI8900
|
3461
|
_fileid = [KTUV980_fp, ]
|
3462
|
# Clones
|
3463
|
ALIASES = [JT2705M, ]
|
3464
|
|
3465
|
# Please note that there is a version of this radios that is a clone of the
|
3466
|
# Waccom Mini8900, maybe an early version?
|
3467
|
|
3468
|
|
3469
|
class OTGRadioV1(chirp_common.Alias):
|
3470
|
VENDOR = 'OTGSTUFF'
|
3471
|
MODEL = 'OTG Radio v1'
|
3472
|
|
3473
|
|
3474
|
@directory.register
|
3475
|
class KT9800(BTech):
|
3476
|
"""QYT KT8900"""
|
3477
|
VENDOR = "QYT"
|
3478
|
MODEL = "KT8900"
|
3479
|
_vhf_range = (136000000, 175000000)
|
3480
|
_uhf_range = (400000000, 481000000)
|
3481
|
_magic = MSTRING_KT8900
|
3482
|
_fileid = [KT8900_fp,
|
3483
|
KT8900_fp1,
|
3484
|
KT8900_fp2,
|
3485
|
KT8900_fp3,
|
3486
|
KT8900_fp4,
|
3487
|
KT8900_fp5,
|
3488
|
KT8900_fp6]
|
3489
|
_id2 = [KT8900_id, KT8900_id2]
|
3490
|
# Clones
|
3491
|
ALIASES = [JT6188Mini, SSGT890, ZastoneMP300]
|
3492
|
|
3493
|
|
3494
|
@directory.register
|
3495
|
class KT9800R(BTech):
|
3496
|
"""QYT KT8900R"""
|
3497
|
VENDOR = "QYT"
|
3498
|
MODEL = "KT8900R"
|
3499
|
BANDS = 3
|
3500
|
_vhf_range = (136000000, 175000000)
|
3501
|
_220_range = (240000000, 271000000)
|
3502
|
_uhf_range = (400000000, 481000000)
|
3503
|
_magic = MSTRING_KT8900R
|
3504
|
_fileid = [KT8900R_fp,
|
3505
|
KT8900R_fp1,
|
3506
|
KT8900R_fp2,
|
3507
|
KT8900R_fp3,
|
3508
|
KT8900R_fp4]
|
3509
|
_id2 = [KT8900R_id, KT8900R_id2]
|
3510
|
|
3511
|
|
3512
|
@directory.register
|
3513
|
class LT588UV(BTech):
|
3514
|
"""LUITON LT-588UV"""
|
3515
|
VENDOR = "LUITON"
|
3516
|
MODEL = "LT-588UV"
|
3517
|
_vhf_range = (136000000, 175000000)
|
3518
|
_uhf_range = (400000000, 481000000)
|
3519
|
_magic = MSTRING_KT8900
|
3520
|
_fileid = [LT588UV_fp,
|
3521
|
LT588UV_fp1]
|
3522
|
_power_levels = [chirp_common.PowerLevel("High", watts=60),
|
3523
|
chirp_common.PowerLevel("Low", watts=10)]
|
3524
|
|
3525
|
|
3526
|
COLOR_MEM_FORMAT = """
|
3527
|
#seekto 0x0000;
|
3528
|
struct {
|
3529
|
lbcd rxfreq[4];
|
3530
|
lbcd txfreq[4];
|
3531
|
ul16 rxtone;
|
3532
|
ul16 txtone;
|
3533
|
u8 unknown0:4,
|
3534
|
scode:4;
|
3535
|
u8 unknown1:2,
|
3536
|
spmute:2,
|
3537
|
unknown2:2,
|
3538
|
optsig:2;
|
3539
|
u8 unknown3:3,
|
3540
|
scramble:1,
|
3541
|
unknown4:3,
|
3542
|
power:1;
|
3543
|
u8 unknown5:1,
|
3544
|
wide:1,
|
3545
|
unknown6:2,
|
3546
|
bcl:1,
|
3547
|
add:1,
|
3548
|
pttid:2;
|
3549
|
} memory[200];
|
3550
|
|
3551
|
#seekto 0x0E00;
|
3552
|
struct {
|
3553
|
u8 tmr;
|
3554
|
u8 unknown1;
|
3555
|
u8 sql;
|
3556
|
u8 unknown2[2];
|
3557
|
u8 tot;
|
3558
|
u8 apo;
|
3559
|
u8 unknown3;
|
3560
|
u8 abr;
|
3561
|
u8 beep;
|
3562
|
u8 unknown4[4];
|
3563
|
u8 dtmfst;
|
3564
|
u8 unknown5[2];
|
3565
|
u8 screv;
|
3566
|
u8 unknown6[2];
|
3567
|
u8 pttid;
|
3568
|
u8 pttlt;
|
3569
|
u8 unknown7;
|
3570
|
u8 emctp;
|
3571
|
u8 emcch;
|
3572
|
u8 sigbp;
|
3573
|
u8 unknown8;
|
3574
|
u8 camdf;
|
3575
|
u8 cbmdf;
|
3576
|
u8 ccmdf;
|
3577
|
u8 cdmdf;
|
3578
|
u8 langua;
|
3579
|
u8 sync; // BTech radios use this as the display sync
|
3580
|
// setting, other radios use this as the auto
|
3581
|
// keypad lock setting
|
3582
|
u8 mainfc;
|
3583
|
u8 mainbc;
|
3584
|
u8 menufc;
|
3585
|
u8 menubc;
|
3586
|
u8 stafc;
|
3587
|
u8 stabc;
|
3588
|
u8 sigfc;
|
3589
|
u8 sigbc;
|
3590
|
u8 rxfc;
|
3591
|
u8 txfc;
|
3592
|
u8 txdisp;
|
3593
|
u8 unknown9[5];
|
3594
|
u8 anil;
|
3595
|
u8 reps;
|
3596
|
u8 repm;
|
3597
|
u8 tmrmr;
|
3598
|
u8 ste;
|
3599
|
u8 rpste;
|
3600
|
u8 rptdl;
|
3601
|
u8 dtmfg;
|
3602
|
u8 mgain;
|
3603
|
u8 skiptx;
|
3604
|
u8 scmode;
|
3605
|
} settings;
|
3606
|
|
3607
|
#seekto 0x0E80;
|
3608
|
struct {
|
3609
|
u8 unknown1;
|
3610
|
u8 vfomr;
|
3611
|
u8 keylock;
|
3612
|
u8 unknown2;
|
3613
|
u8 unknown3:4,
|
3614
|
vfomren:1,
|
3615
|
unknown4:1,
|
3616
|
reseten:1,
|
3617
|
menuen:1;
|
3618
|
u8 unknown5[11];
|
3619
|
u8 dispab;
|
3620
|
u8 unknown6[2];
|
3621
|
u8 menu;
|
3622
|
u8 unknown7[7];
|
3623
|
u8 vfomra;
|
3624
|
u8 vfomrb;
|
3625
|
u8 vfomrc;
|
3626
|
u8 vfomrd;
|
3627
|
u8 mrcha;
|
3628
|
u8 mrchb;
|
3629
|
u8 mrchc;
|
3630
|
u8 mrchd;
|
3631
|
} settings2;
|
3632
|
|
3633
|
struct settings_vfo {
|
3634
|
u8 freq[8];
|
3635
|
u8 offset[6];
|
3636
|
u8 unknown2[2];
|
3637
|
ul16 rxtone;
|
3638
|
ul16 txtone;
|
3639
|
u8 scode;
|
3640
|
u8 spmute;
|
3641
|
u8 optsig;
|
3642
|
u8 scramble;
|
3643
|
u8 wide;
|
3644
|
u8 power;
|
3645
|
u8 shiftd;
|
3646
|
u8 step;
|
3647
|
u8 unknown3[4];
|
3648
|
};
|
3649
|
|
3650
|
#seekto 0x0F00;
|
3651
|
struct {
|
3652
|
struct settings_vfo a;
|
3653
|
struct settings_vfo b;
|
3654
|
struct settings_vfo c;
|
3655
|
struct settings_vfo d;
|
3656
|
} vfo;
|
3657
|
|
3658
|
#seekto 0x0F80;
|
3659
|
struct {
|
3660
|
char line1[8];
|
3661
|
char line2[8];
|
3662
|
char line3[8];
|
3663
|
char line4[8];
|
3664
|
char line5[8];
|
3665
|
char line6[8];
|
3666
|
char line7[8];
|
3667
|
char line8[8];
|
3668
|
} poweron_msg;
|
3669
|
|
3670
|
#seekto 0x1000;
|
3671
|
struct {
|
3672
|
char name[8];
|
3673
|
u8 unknown1[8];
|
3674
|
} names[200];
|
3675
|
|
3676
|
#seekto 0x2400;
|
3677
|
struct {
|
3678
|
u8 period; // one out of LIST_5TONE_STANDARD_PERIODS
|
3679
|
u8 group_tone;
|
3680
|
u8 repeat_tone;
|
3681
|
u8 unused[13];
|
3682
|
} _5tone_std_settings[15];
|
3683
|
|
3684
|
#seekto 0x2500;
|
3685
|
struct {
|
3686
|
u8 frame1[5];
|
3687
|
u8 frame2[5];
|
3688
|
u8 frame3[5];
|
3689
|
u8 standard; // one out of LIST_5TONE_STANDARDS
|
3690
|
} _5tone_codes[15];
|
3691
|
|
3692
|
#seekto 0x25F0;
|
3693
|
struct {
|
3694
|
u8 _5tone_delay1; // * 10ms
|
3695
|
u8 _5tone_delay2; // * 10ms
|
3696
|
u8 _5tone_delay3; // * 10ms
|
3697
|
u8 _5tone_first_digit_ext_length;
|
3698
|
u8 unknown1;
|
3699
|
u8 unknown2;
|
3700
|
u8 unknown3;
|
3701
|
u8 unknown4;
|
3702
|
u8 decode_standard;
|
3703
|
u8 unknown5:5,
|
3704
|
_5tone_decode_call_frame3:1,
|
3705
|
_5tone_decode_call_frame2:1,
|
3706
|
_5tone_decode_call_frame1:1;
|
3707
|
u8 unknown6:5,
|
3708
|
_5tone_decode_disp_frame3:1,
|
3709
|
_5tone_decode_disp_frame2:1,
|
3710
|
_5tone_decode_disp_frame1:1;
|
3711
|
u8 decode_reset_time; // * 100 + 100ms
|
3712
|
} _5tone_settings;
|
3713
|
|
3714
|
#seekto 0x2900;
|
3715
|
struct {
|
3716
|
u8 code[16]; // 0=x0A, A=0x0D, B=0x0E, C=0x0F, D=0x00, #=0x0C *=0x0B
|
3717
|
} dtmf_codes[15];
|
3718
|
|
3719
|
#seekto 0x29F0;
|
3720
|
struct {
|
3721
|
u8 dtmfspeed_on; //list with 50..2000ms in steps of 10
|
3722
|
u8 dtmfspeed_off; //list with 50..2000ms in steps of 10
|
3723
|
u8 unknown0[14];
|
3724
|
u8 inspection[16];
|
3725
|
u8 monitor[16];
|