retevis_rt21v_dl_only_#4.py

Jim Unroe, 12/07/2021 06:10 pm

Download (40.3 kB)

 
1
# Copyright 2021 Jim Unroe <rock.unroe@gmail.com>
2
#
3
# This program is free software: you can redistribute it and/or modify
4
# it under the terms of the GNU General Public License as published by
5
# the Free Software Foundation, either version 2 of the License, or
6
# (at your option) any later version.
7
#
8
# This program is distributed in the hope that it will be useful,
9
# but WITHOUT ANY WARRANTY; without even the implied warranty of
10
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11
# GNU General Public License for more details.
12
#
13
# You should have received a copy of the GNU General Public License
14
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
15

    
16
import time
17
import os
18
import struct
19
import logging
20

    
21
from chirp import (
22
    bitwise,
23
    chirp_common,
24
    directory,
25
    errors,
26
    memmap,
27
    util,
28
)
29
from chirp.settings import (
30
    RadioSetting,
31
    RadioSettingGroup,
32
    RadioSettings,
33
    RadioSettingValueBoolean,
34
    RadioSettingValueInteger,
35
    RadioSettingValueList,
36
    RadioSettingValueString,
37
)
38

    
39
LOG = logging.getLogger(__name__)
40

    
41
MEM_FORMAT = """
42
#seekto 0x0010;
43
struct {
44
  lbcd rxfreq[4];       // RX Frequency           0-3
45
  lbcd txfreq[4];       // TX Frequency           4-7
46
  ul16 rx_tone;         // PL/DPL Decode          8-9
47
  ul16 tx_tone;         // PL/DPL Encode          A-B
48
  u8 unknown1:3,        //                        C
49
     bcl:2,             // Busy Lock
50
     unknown2:3;
51
  u8 unknown3:2,        //                        D
52
     highpower:1,       // Power Level
53
     wide:1,            // Bandwidth
54
     unknown4:4;
55
  u8 scramble_type:4,   // Scramble Type          E
56
     unknown5:4;
57
  u8 unknown6:4,
58
     scramble_type2:4;  // Scramble Type 2        F
59
} memory[16];
60

    
61
#seekto 0x011D;
62
struct {
63
  u8 unused:4,
64
     pf1:4;             // Programmable Function Key 1
65
} keys;
66

    
67
#seekto 0x012C;
68
struct {
69
  u8 use_scramble;      // Scramble Enable
70
  u8 unknown1[2];
71
  u8 voice;             // Voice Annunciation
72
  u8 tot;               // Time-out Timer
73
  u8 totalert;          // Time-out Timer Pre-alert
74
  u8 unknown2[2];
75
  u8 squelch;           // Squelch Level
76
  u8 save;              // Battery Saver
77
  u8 unknown3[3];
78
  u8 use_vox;           // VOX Enable
79
  u8 vox;               // VOX Gain
80
} settings;
81

    
82
#seekto 0x017E;
83
u8 skipflags[2];       // SCAN_ADD
84
"""
85

    
86
MEM_FORMAT_RB17A = """
87
struct memory {
88
  lbcd rxfreq[4];      // 0-3
89
  lbcd txfreq[4];      // 4-7
90
  ul16 rx_tone;        // 8-9
91
  ul16 tx_tone;        // A-B
92
  u8 unknown1:1,       // C
93
     compander:1,      // Compand
94
     bcl:2,            // Busy Channel Lock-out
95
     cdcss:1,          // Cdcss Mode
96
     scramble_type:3;  // Scramble Type
97
  u8 unknown2:4,       // D
98
     middlepower:1,    // Power Level-Middle
99
     unknown3:1,       //
100
     highpower:1,      // Power Level-High/Low
101
     wide:1;           // Bandwidth
102
  u8 unknown4;         // E
103
  u8 unknown5;         // F
104
};
105

    
106
#seekto 0x0010;
107
  struct memory lomems[16];
108

    
109
#seekto 0x0200;
110
  struct memory himems[14];
111

    
112
#seekto 0x011D;
113
struct {
114
  u8 pf1;              // 011D PF1 Key
115
  u8 topkey;           // 011E Top Key
116
} keys;
117

    
118
#seekto 0x012C;
119
struct {
120
  u8 use_scramble;     // 012C Scramble Enable
121
  u8 channel;          // 012D Channel Number
122
  u8 alarm;            // 012E Alarm Type
123
  u8 voice;            // 012F Voice Annunciation
124
  u8 tot;              // 0130 Time-out Timer
125
  u8 totalert;         // 0131 Time-out Timer Pre-alert
126
  u8 unknown2[2];
127
  u8 squelch;          // 0134 Squelch Level
128
  u8 save;             // 0135 Battery Saver
129
  u8 unknown3[3];
130
  u8 use_vox;          // 0139 VOX Enable
131
  u8 vox;              // 013A VOX Gain
132
} settings;
133

    
134
#seekto 0x017E;
135
u8 skipflags[4];       // Scan Add
136
"""
137

    
138
MEM_FORMAT_RB26 = """
139
#seekto 0x0000;
140
struct {
141
  lbcd rxfreq[4];      // RX Frequency           0-3
142
  lbcd txfreq[4];      // TX Frequency           4-7
143
  ul16 rx_tone;        // PL/DPL Decode          8-9
144
  ul16 tx_tone;        // PL/DPL Encode          A-B
145
  u8 compander:1,      // Compander              C
146
     unknown1:1,       //
147
     highpower:1,      // Power Level
148
     wide:1,           // Bandwidth
149
     bcl:1,            // Busy Lock  OFF=0 ON=1
150
     unknown2:3;       //
151
  u8 reserved[3];      // Reserved               D-F
152
} memory[30];
153

    
154
#seekto 0x002D;
155
struct {
156
  u8 unknown_1:1,      //                        002D
157
     chnumberd:1,      // Channel Number Disable
158
     gain:1,           // MIC Gain
159
     savem:1,          // Battery Save Mode
160
     save:1,           // Battery Save
161
     beep:1,           // Beep
162
     voice:1,          // Voice Prompts
163
     unknown_2:1;      //
164
  u8 squelch;          // Squelch                002E
165
  u8 tot;              // Time-out Timer         002F
166
  u8 channel_4[13];    //                        0030-003C
167
  u8 unknown_3[3];     //                        003D-003F
168
  u8 channel_5[13];    //                        0040-004C
169
  u8 unknown_4;        //                        004D
170
  u8 unknown_5[2];     //                        004E-004F
171
  u8 channel_6[13];    //                        0050-005C
172
  u8 unknown_6;        //                        005D
173
  u8 unknown_7[2];     //                        005E-005F
174
  u8 channel_7[13];    //                        0060-006C
175
  u8 warn;             // Warn Mode              006D
176
  u8 pf1;              // Key Set PF1            006E
177
  u8 pf2;              // Key Set PF2            006F
178
  u8 channel_8[13];    //                        0070-007C
179
  u8 unknown_8;        //                        007D
180
  u8 tail;             // QT/DQT Tail(inverted)  007E
181
} settings;
182

    
183
#seekto 0x01F0;
184
u8 skipflags[4];       // Scan Add
185

    
186
#seekto 0x029F;
187
struct {
188
  u8 chnumber;         // Channel Number         029F
189
} settings2;
190

    
191
#seekto 0x031D;
192
struct {
193
  u8 unused:7,         //                        031D
194
     vox:1;            // Vox
195
  u8 voxl;             // Vox Level              031E
196
  u8 voxd;             // Vox Delay              031F
197
} settings3;
198
"""
199

    
200
MEM_FORMAT_RT76 = """
201
#seekto 0x0000;
202
struct {
203
  lbcd rxfreq[4];      // RX Frequency           0-3
204
  lbcd txfreq[4];      // TX Frequency           4-7
205
  ul16 rx_tone;        // PL/DPL Decode          8-9
206
  ul16 tx_tone;        // PL/DPL Encode          A-B
207
  u8 compander:1,      // Compander              C
208
     unknown1:1,       //
209
     highpower:1,      // Power Level
210
     wide:1,           // Bandwidth
211
     unknown2:4;       //
212
  u8 reserved[3];      // Reserved               D-F
213
} memory[30];
214

    
215
#seekto 0x002D;
216
struct {
217
  u8 unknown_1:1,      //                        002D
218
     chnumberd:1,      // Channel Number Disable
219
     gain:1,           // MIC Gain                                 ---
220
     savem:1,          // Battery Save Mode                        ---
221
     save:1,           // Battery Save                             ---
222
     beep:1,           // Beep                                     ---
223
     voice:2;          // Voice Prompts                            ---
224
  u8 squelch;          // Squelch                002E              ---
225
  u8 tot;              // Time-out Timer         002F              ---
226
  u8 channel_4[13];    //                        0030-003C
227
  u8 unused:7,         //                        003D
228
     vox:1;            // Vox                                      ---
229
  u8 voxl;             // Vox Level              003E              ---
230
  u8 voxd;             // Vox Delay              003F              ---
231
  u8 channel_5[13];    //                        0040-004C
232
  u8 unknown_4;        //                        004D
233
  u8 unknown_5[2];     //                        004E-004F
234
  u8 channel_6[13];    //                        0050-005C
235
  u8 chnumber;         // Channel Number         005D              ---
236
  u8 unknown_7[2];     //                        005E-005F
237
  u8 channel_7[13];    //                        0060-006C
238
  u8 warn;             //                        006D              ---
239
} settings;
240
"""
241

    
242
CMD_ACK = "\x06"
243

    
244
ALARM_LIST = ["Local Alarm", "Remote Alarm"]
245
BCL_LIST = ["Off", "Carrier", "QT/DQT"]
246
CDCSS_LIST = ["Normal Code", "Special Code 2", "Special Code 1"]
247
GAIN_LIST = ["Standard", "Enhanced"]
248
PFKEY_LIST = ["None", "Monitor", "Lamp", "Warn", "VOX", "VOX Delay",
249
              "Key Lock", "Scan"]
250
SAVE_LIST = ["Standard", "Super"]
251
SCRAMBLE_LIST = ["%s" % x for x in range(1, 9)]
252
TIMEOUTTIMER_LIST = ["%s seconds" % x for x in range(15, 615, 15)]
253
TOTALERT_LIST = ["Off"] + ["%s seconds" % x for x in range(1, 11)]
254
VOICE_LIST = ["Off", "Chinese", "English"]
255
VOICE_LIST2 = ["Off", "English"]
256
VOICE_LIST3 = VOICE_LIST2 + ["Chinese"]
257
VOX_LIST = ["OFF"] + ["%s" % x for x in range(1, 17)]
258
VOXD_LIST = ["0.5", "1.0", "1.5", "2.0", "2.5", "3.0"]
259
VOXL_LIST = ["OFF"] + ["%s" % x for x in range(1, 9)]
260
WARN_LIST = ["OFF", "Native Warn", "Remote Warn"]
261
PF1_CHOICES = ["None", "Monitor", "Scan", "Scramble", "Alarm"]
262
PF1_VALUES = [0x0F, 0x04, 0x06, 0x08, 0x0C]
263
TOPKEY_CHOICES = ["None", "Alarming"]
264
TOPKEY_VALUES = [0xFF, 0x0C]
265

    
266
SETTING_LISTS = {
267
    "alarm": ALARM_LIST,
268
    "bcl": BCL_LIST,
269
    "cdcss": CDCSS_LIST,
270
    "gain": GAIN_LIST,
271
    "pfkey": PFKEY_LIST,
272
    "save": SAVE_LIST,
273
    "scramble": SCRAMBLE_LIST,
274
    "tot": TIMEOUTTIMER_LIST,
275
    "totalert": TOTALERT_LIST,
276
    "voice": VOICE_LIST,
277
    "voice": VOICE_LIST2,
278
    "voice": VOICE_LIST3,
279
    "vox": VOX_LIST,
280
    "voxd": VOXD_LIST,
281
    "voxl": VOXL_LIST,
282
    "warn": WARN_LIST,
283
    }
284

    
285
GMRS_FREQS1 = [462.5625, 462.5875, 462.6125, 462.6375, 462.6625,
286
               462.6875, 462.7125]
287
GMRS_FREQS2 = [467.5625, 467.5875, 467.6125, 467.6375, 467.6625,
288
               467.6875, 467.7125]
289
GMRS_FREQS3 = [462.5500, 462.5750, 462.6000, 462.6250, 462.6500,
290
               462.6750, 462.7000, 462.7250]
291
GMRS_FREQS = GMRS_FREQS1 + GMRS_FREQS2 + GMRS_FREQS3 * 2
292

    
293

    
294
def _enter_programming_mode(radio):
295
    serial = radio.pipe
296

    
297
    exito = False
298
    for i in range(0, 5):
299
        serial.write(radio._magic)
300
        ack = serial.read(1)
301
        if ack == "\x00":
302
            ack = serial.read(1)
303

    
304
        try:
305
            if ack == CMD_ACK:
306
                exito = True
307
                break
308
        except:
309
            LOG.debug("Attempt #%s, failed, trying again" % i)
310
            pass
311

    
312
    # check if we had EXITO
313
    if exito is False:
314
        msg = "The radio did not accept program mode after five tries.\n"
315
        msg += "Check you interface cable and power cycle your radio."
316
        raise errors.RadioError(msg)
317

    
318
    try:
319
        serial.write("\x02")
320
        ident = serial.read(8)
321
    except:
322
        raise errors.RadioError("Error communicating with radio")
323

    
324
    if not ident == radio._fingerprint:
325
        LOG.debug(util.hexprint(ident))
326
        raise errors.RadioError("Radio returned unknown identification string")
327

    
328
    try:
329
        serial.write(CMD_ACK)
330
        ack = serial.read(1)
331
    except:
332
        raise errors.RadioError("Error communicating with radio")
333

    
334
    if ack != CMD_ACK:
335
        raise errors.RadioError("Radio refused to enter programming mode")
336

    
337

    
338
def _exit_programming_mode(radio):
339
    serial = radio.pipe
340
    try:
341
        serial.write("E")
342
    except:
343
        raise errors.RadioError("Radio refused to exit programming mode")
344

    
345

    
346
def _read_block(radio, block_addr, block_size):
347
    serial = radio.pipe
348

    
349
    cmd = struct.pack(">cHb", 'R', block_addr, block_size)
350
    expectedresponse = "W" + cmd[1:]
351
    LOG.debug("Reading block %04x..." % (block_addr))
352

    
353
    try:
354
        serial.write(cmd)
355
        response = serial.read(4 + block_size)
356
        if response[:4] != expectedresponse:
357
            raise Exception("Error reading block %04x." % (block_addr))
358

    
359
        block_data = response[4:]
360

    
361
        serial.write(CMD_ACK)
362
        ack = serial.read(1)
363
    except:
364
        raise errors.RadioError("Failed to read block at %04x" % block_addr)
365

    
366
    if ack != CMD_ACK:
367
        raise Exception("No ACK reading block %04x." % (block_addr))
368

    
369
    return block_data
370

    
371

    
372
def _rb26_read_block(radio, block_addr, block_size):
373
    serial = radio.pipe
374

    
375
    cmd = struct.pack(">cHb", 'R', block_addr, block_size)
376
    expectedresponse = "W" + cmd[1:]
377
    LOG.debug("Reading block %04x..." % (block_addr))
378

    
379
    try:
380
        serial.write(cmd)
381
        response = serial.read(4 + block_size)
382
        if response[:4] != expectedresponse:
383
            raise Exception("Error reading block %04x." % (block_addr))
384

    
385
        block_data = response[4:]
386

    
387
        if block_addr != 0:
388
            serial.write(CMD_ACK)
389
            ack = serial.read(1)
390
    except:
391
        raise errors.RadioError("Failed to read block at %04x" % block_addr)
392

    
393
    if block_addr != 0:
394
        if ack != CMD_ACK:
395
            raise Exception("No ACK reading block %04x." % (block_addr))
396

    
397
    return block_data
398

    
399

    
400
def _write_block(radio, block_addr, block_size):
401
    serial = radio.pipe
402

    
403
    cmd = struct.pack(">cHb", 'W', block_addr, block_size)
404
    data = radio.get_mmap()[block_addr:block_addr + block_size]
405

    
406
    LOG.debug("Writing Data:")
407
    LOG.debug(util.hexprint(cmd + data))
408

    
409
    try:
410
        serial.write(cmd + data)
411
        if serial.read(1) != CMD_ACK:
412
            raise Exception("No ACK")
413
    except:
414
        raise errors.RadioError("Failed to send block "
415
                                "to radio at %04x" % block_addr)
416

    
417

    
418
def do_download(radio):
419
    LOG.debug("download")
420
    _enter_programming_mode(radio)
421

    
422
    data = ""
423

    
424
    status = chirp_common.Status()
425
    status.msg = "Cloning from radio"
426

    
427
    status.cur = 0
428
    status.max = radio._memsize
429

    
430
    for addr in range(0, radio._memsize, radio.BLOCK_SIZE):
431
        status.cur = addr + radio.BLOCK_SIZE
432
        radio.status_fn(status)
433

    
434
        if radio.MODEL == "RB26" or radio.MODEL == "RT76":
435
            block = _rb26_read_block(radio, addr, radio.BLOCK_SIZE)
436
        else:
437
            block = _read_block(radio, addr, radio.BLOCK_SIZE)
438
        data += block
439

    
440
        LOG.debug("Address: %04x" % addr)
441
        LOG.debug(util.hexprint(block))
442

    
443
    _exit_programming_mode(radio)
444

    
445
    return memmap.MemoryMap(data)
446

    
447

    
448
def do_upload(radio):
449
    status = chirp_common.Status()
450
    status.msg = "Uploading to radio"
451

    
452
    _enter_programming_mode(radio)
453

    
454
    status.cur = 0
455
    status.max = radio._memsize
456

    
457
    ##for start_addr, end_addr in radio._ranges:
458
    ##    for addr in range(start_addr, end_addr, radio.BLOCK_SIZE_UP):
459
    ##        status.cur = addr + radio.BLOCK_SIZE_UP
460
    ##        radio.status_fn(status)
461
    ##        _write_block(radio, addr, radio.BLOCK_SIZE_UP)
462

    
463
    _exit_programming_mode(radio)
464

    
465

    
466
def model_match(cls, data):
467
    """Match the opened/downloaded image to the correct version"""
468
    rid = data[0x01B8:0x01BE]
469

    
470
    return rid.startswith("P3207")
471

    
472

    
473
@directory.register
474
class RT21Radio(chirp_common.CloneModeRadio):
475
    """RETEVIS RT21"""
476
    VENDOR = "Retevis"
477
    MODEL = "RT21"
478
    BAUD_RATE = 9600
479
    BLOCK_SIZE = 0x10
480
    BLOCK_SIZE_UP = 0x10
481

    
482
    POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
483
                    chirp_common.PowerLevel("High", watts=2.50)]
484

    
485
    _magic = "PRMZUNE"
486
    _fingerprint = "P3207s\xF8\xFF"
487
    _upper = 16
488
    _skipflags = True
489
    _reserved = False
490
    _gmrs = False
491

    
492
    _ranges = [
493
               (0x0000, 0x0400),
494
              ]
495
    _memsize = 0x0400
496

    
497
    def get_features(self):
498
        rf = chirp_common.RadioFeatures()
499
        rf.has_settings = False ##True
500
        rf.has_bank = False
501
        rf.has_ctone = True
502
        rf.has_cross = True
503
        rf.has_rx_dtcs = True
504
        rf.has_tuning_step = False
505
        rf.can_odd_split = True
506
        rf.has_name = False
507
        rf.valid_skips = ["", "S"]
508
        rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
509
        rf.valid_cross_modes = ["Tone->Tone", "Tone->DTCS", "DTCS->Tone",
510
                                "->Tone", "->DTCS", "DTCS->", "DTCS->DTCS"]
511
        rf.valid_power_levels = self.POWER_LEVELS
512
        rf.valid_duplexes = ["", "-", "+", "split", "off"]
513
        rf.valid_modes = ["NFM", "FM"]  # 12.5 KHz, 25 kHz.
514
        rf.memory_bounds = (1, self._upper)
515
        rf.valid_tuning_steps = [2.5, 5., 6.25, 10., 12.5, 25.]
516
        ##rf.valid_bands = [(400000000, 480000000)]
517
        rf.valid_bands = [(136000000, 174000000)]
518

    
519
        return rf
520

    
521
    def process_mmap(self):
522
        self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
523

    
524
    def validate_memory(self, mem):
525
        msgs = ""
526
        msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
527

    
528
        _msg_freq = 'Memory location cannot change frequency'
529
        _msg_simplex = 'Memory location only supports Duplex:(None)'
530
        _msg_duplex = 'Memory location only supports Duplex: +'
531
        _msg_offset = 'Memory location only supports Offset: 5.000000'
532
        _msg_nfm = 'Memory location only supports Mode: NFM'
533
        _msg_txp = 'Memory location only supports Power: Low'
534

    
535
        # GMRS models
536
        if self._gmrs:
537
            # range of memories with values set by FCC rules
538
            if mem.freq != int(GMRS_FREQS[mem.number - 1] * 1000000):
539
                # warn user can't change frequency
540
                msgs.append(chirp_common.ValidationError(_msg_freq))
541

    
542
            # channels 1 - 22 are simplex only
543
            if mem.number <= 22:
544
                if str(mem.duplex) != "":
545
                    # warn user can't change duplex
546
                    msgs.append(chirp_common.ValidationError(_msg_simplex))
547

    
548
            # channels 23 - 30 are +5 MHz duplex only
549
            if mem.number >= 23:
550
                if str(mem.duplex) != "+":
551
                    # warn user can't change duplex
552
                    msgs.append(chirp_common.ValidationError(_msg_duplex))
553

    
554
                if str(mem.offset) != "5000000":
555
                    # warn user can't change offset
556
                    msgs.append(chirp_common.ValidationError(_msg_offset))
557

    
558
            # channels 8 - 14 are low power NFM only
559
            if mem.number >= 8 and mem.number <= 14:
560
                if mem.mode != "NFM":
561
                    # warn user can't change mode
562
                    msgs.append(chirp_common.ValidationError(_msg_nfm))
563

    
564
                if mem.power != "Low":
565
                    # warn user can't change power
566
                    msgs.append(chirp_common.ValidationError(_msg_txp))
567

    
568
        return msgs
569

    
570
    def sync_in(self):
571
        """Download from radio"""
572
        try:
573
            data = do_download(self)
574
        except errors.RadioError:
575
            # Pass through any real errors we raise
576
            raise
577
        except:
578
            # If anything unexpected happens, make sure we raise
579
            # a RadioError and log the problem
580
            LOG.exception('Unexpected error during download')
581
            raise errors.RadioError('Unexpected error communicating '
582
                                    'with the radio')
583
        self._mmap = data
584
        self.process_mmap()
585

    
586
    def sync_out(self):
587
        """Upload to radio"""
588
        try:
589
            do_upload(self)
590
        except:
591
            # If anything unexpected happens, make sure we raise
592
            # a RadioError and log the problem
593
            LOG.exception('Unexpected error during upload')
594
            raise errors.RadioError('Unexpected error communicating '
595
                                    'with the radio')
596

    
597
    def get_raw_memory(self, number):
598
        return repr(self._memobj.memory[number - 1])
599

    
600
    def _get_tone(self, _mem, mem):
601
        def _get_dcs(val):
602
            code = int("%03o" % (val & 0x07FF))
603
            pol = (val & 0x8000) and "R" or "N"
604
            return code, pol
605

    
606
        if _mem.tx_tone != 0xFFFF and _mem.tx_tone > 0x2000:
607
            tcode, tpol = _get_dcs(_mem.tx_tone)
608
            mem.dtcs = tcode
609
            txmode = "DTCS"
610
        elif _mem.tx_tone != 0xFFFF:
611
            mem.rtone = _mem.tx_tone / 10.0
612
            txmode = "Tone"
613
        else:
614
            txmode = ""
615

    
616
        if _mem.rx_tone != 0xFFFF and _mem.rx_tone > 0x2000:
617
            rcode, rpol = _get_dcs(_mem.rx_tone)
618
            mem.rx_dtcs = rcode
619
            rxmode = "DTCS"
620
        elif _mem.rx_tone != 0xFFFF:
621
            mem.ctone = _mem.rx_tone / 10.0
622
            rxmode = "Tone"
623
        else:
624
            rxmode = ""
625

    
626
        if txmode == "Tone" and not rxmode:
627
            mem.tmode = "Tone"
628
        elif txmode == rxmode and txmode == "Tone" and mem.rtone == mem.ctone:
629
            mem.tmode = "TSQL"
630
        elif txmode == rxmode and txmode == "DTCS" and mem.dtcs == mem.rx_dtcs:
631
            mem.tmode = "DTCS"
632
        elif rxmode or txmode:
633
            mem.tmode = "Cross"
634
            mem.cross_mode = "%s->%s" % (txmode, rxmode)
635

    
636
        if mem.tmode == "DTCS":
637
            mem.dtcs_polarity = "%s%s" % (tpol, rpol)
638

    
639
        LOG.debug("Got TX %s (%i) RX %s (%i)" %
640
                  (txmode, _mem.tx_tone, rxmode, _mem.rx_tone))
641

    
642
    def get_memory(self, number):
643
        if self._skipflags:
644
            bitpos = (1 << ((number - 1) % 8))
645
            bytepos = ((number - 1) / 8)
646
            LOG.debug("bitpos %s" % bitpos)
647
            LOG.debug("bytepos %s" % bytepos)
648
            _skp = self._memobj.skipflags[bytepos]
649

    
650
        mem = chirp_common.Memory()
651

    
652
        mem.number = number
653

    
654
        if self.MODEL == "RB17A":
655
            if mem.number < 17:
656
                _mem = self._memobj.lomems[number - 1]
657
            else:
658
                _mem = self._memobj.himems[number - 17]
659
        else:
660
            _mem = self._memobj.memory[number - 1]
661

    
662
        if self._reserved:
663
            _rsvd = _mem.reserved.get_raw()
664

    
665
        mem.freq = int(_mem.rxfreq) * 10
666

    
667
        # We'll consider any blank (i.e. 0MHz frequency) to be empty
668
        if mem.freq == 0:
669
            mem.empty = True
670
            return mem
671

    
672
        if _mem.rxfreq.get_raw() == "\xFF\xFF\xFF\xFF":
673
            mem.freq = 0
674
            mem.empty = True
675
            return mem
676

    
677
        if _mem.get_raw() == ("\xFF" * 16):
678
            LOG.debug("Initializing empty memory")
679
            if self.MODEL == "RB17A":
680
                _mem.set_raw("\x00" * 13 + "\x04\xFF\xFF")
681
            if self.MODEL == "RB26" or self.MODEL == "RT76":
682
                _mem.set_raw("\x00" * 13 + _rsvd)
683
            else:
684
                _mem.set_raw("\x00" * 13 + "\x30\x8F\xF8")
685

    
686
        if int(_mem.rxfreq) == int(_mem.txfreq):
687
            mem.duplex = ""
688
            mem.offset = 0
689
        else:
690
            mem.duplex = int(_mem.rxfreq) > int(_mem.txfreq) and "-" or "+"
691
            mem.offset = abs(int(_mem.rxfreq) - int(_mem.txfreq)) * 10
692

    
693
        mem.mode = _mem.wide and "FM" or "NFM"
694

    
695
        self._get_tone(_mem, mem)
696

    
697
        mem.power = self.POWER_LEVELS[_mem.highpower]
698

    
699
        if self.MODEL != "RT76":
700
            mem.skip = "" if (_skp & bitpos) else "S"
701
            LOG.debug("mem.skip %s" % mem.skip)
702

    
703
        mem.extra = RadioSettingGroup("Extra", "extra")
704

    
705
        if self.MODEL == "RT21" or self.MODEL == "RB17A":
706
            rs = RadioSettingValueList(BCL_LIST, BCL_LIST[_mem.bcl])
707
            rset = RadioSetting("bcl", "Busy Channel Lockout", rs)
708
            mem.extra.append(rset)
709

    
710
            rs = RadioSettingValueList(SCRAMBLE_LIST,
711
                                       SCRAMBLE_LIST[_mem.scramble_type - 8])
712
            rset = RadioSetting("scramble_type", "Scramble Type", rs)
713
            mem.extra.append(rset)
714

    
715
            if self.MODEL == "RB17A":
716
                rs = RadioSettingValueList(CDCSS_LIST, CDCSS_LIST[_mem.cdcss])
717
                rset = RadioSetting("cdcss", "Cdcss Mode", rs)
718
                mem.extra.append(rset)
719

    
720
        if self.MODEL == "RB26" or self.MODEL == "RT76":
721
            if self.MODEL == "RB26":
722
                rs = RadioSettingValueBoolean(_mem.bcl)
723
                rset = RadioSetting("bcl", "Busy Channel Lockout", rs)
724
                mem.extra.append(rset)
725

    
726
            rs = RadioSettingValueBoolean(_mem.compander)
727
            rset = RadioSetting("compander", "Compander", rs)
728
            mem.extra.append(rset)
729

    
730
        if self._gmrs:
731
            GMRS_IMMUTABLE = ["freq", "duplex", "offset"]
732
            if mem.number >= 8 and mem.number <= 14:
733
                mem.immutable = GMRS_IMMUTABLE + ["power", "mode"]
734
            else:
735
                mem.immutable = GMRS_IMMUTABLE
736

    
737
        return mem
738

    
739
    def _set_tone(self, mem, _mem):
740
        def _set_dcs(code, pol):
741
            val = int("%i" % code, 8) + 0x2800
742
            if pol == "R":
743
                val += 0x8000
744
            return val
745

    
746
        rx_mode = tx_mode = None
747
        rx_tone = tx_tone = 0xFFFF
748

    
749
        if mem.tmode == "Tone":
750
            tx_mode = "Tone"
751
            rx_mode = None
752
            tx_tone = int(mem.rtone * 10)
753
        elif mem.tmode == "TSQL":
754
            rx_mode = tx_mode = "Tone"
755
            rx_tone = tx_tone = int(mem.ctone * 10)
756
        elif mem.tmode == "DTCS":
757
            tx_mode = rx_mode = "DTCS"
758
            tx_tone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
759
            rx_tone = _set_dcs(mem.dtcs, mem.dtcs_polarity[1])
760
        elif mem.tmode == "Cross":
761
            tx_mode, rx_mode = mem.cross_mode.split("->")
762
            if tx_mode == "DTCS":
763
                tx_tone = _set_dcs(mem.dtcs, mem.dtcs_polarity[0])
764
            elif tx_mode == "Tone":
765
                tx_tone = int(mem.rtone * 10)
766
            if rx_mode == "DTCS":
767
                rx_tone = _set_dcs(mem.rx_dtcs, mem.dtcs_polarity[1])
768
            elif rx_mode == "Tone":
769
                rx_tone = int(mem.ctone * 10)
770

    
771
        _mem.rx_tone = rx_tone
772
        _mem.tx_tone = tx_tone
773

    
774
        LOG.debug("Set TX %s (%i) RX %s (%i)" %
775
                  (tx_mode, _mem.tx_tone, rx_mode, _mem.rx_tone))
776

    
777
    def set_memory(self, mem):
778
        if self._skipflags:
779
            bitpos = (1 << ((mem.number - 1) % 8))
780
            bytepos = ((mem.number - 1) / 8)
781
            LOG.debug("bitpos %s" % bitpos)
782
            LOG.debug("bytepos %s" % bytepos)
783
            _skp = self._memobj.skipflags[bytepos]
784

    
785
        if self.MODEL == "RB17A":
786
            if mem.number < 17:
787
                _mem = self._memobj.lomems[mem.number - 1]
788
            else:
789
                _mem = self._memobj.himems[mem.number - 17]
790
        else:
791
            _mem = self._memobj.memory[mem.number - 1]
792

    
793
        if self._reserved:
794
            _rsvd = _mem.reserved.get_raw()
795

    
796
        if mem.empty:
797
            if self.MODEL == "RB17A":
798
                _mem.set_raw("\xFF" * 12 + "\x00\x00\xFF\xFF")
799
            elif self.MODEL == "RB26" or self.MODEL == "RT76":
800
                _mem.set_raw("\xFF" * 13 + _rsvd)
801
            else:
802
                _mem.set_raw("\xFF" * (_mem.size() / 8))
803

    
804
            if self._gmrs:
805
                GMRS_FREQ = int(GMRS_FREQS[mem.number - 1] * 100000)
806
                if mem.number > 22:
807
                    _mem.rxfreq = GMRS_FREQ
808
                    _mem.txfreq = int(_mem.rxfreq) + 500000
809
                    _mem.wide = True
810
                else:
811
                    _mem.rxfreq = _mem.txfreq = GMRS_FREQ
812
                if mem.number >= 8 and mem.number <= 14:
813
                    _mem.wide = False
814
                    _mem.highpower = False
815
                else:
816
                    _mem.wide = True
817
                    _mem.highpower = True
818

    
819
            return
820

    
821
        if self.MODEL == "RB17A":
822
            _mem.set_raw("\x00" * 13 + "\x00\xFF\xFF")
823
        elif self.MODEL == "RB26" or self.MODEL == "RT76":
824
            _mem.set_raw("\x00" * 13 + _rsvd)
825
        else:
826
            _mem.set_raw("\x00" * 13 + "\x30\x8F\xF8")
827

    
828
        _mem.rxfreq = mem.freq / 10
829

    
830
        if mem.duplex == "off":
831
            for i in range(0, 4):
832
                _mem.txfreq[i].set_raw("\xFF")
833
        elif mem.duplex == "split":
834
            _mem.txfreq = mem.offset / 10
835
        elif mem.duplex == "+":
836
            _mem.txfreq = (mem.freq + mem.offset) / 10
837
        elif mem.duplex == "-":
838
            _mem.txfreq = (mem.freq - mem.offset) / 10
839
        else:
840
            _mem.txfreq = mem.freq / 10
841

    
842
        _mem.wide = mem.mode == "FM"
843

    
844
        self._set_tone(mem, _mem)
845

    
846
        _mem.highpower = mem.power == self.POWER_LEVELS[1]
847

    
848
        if self.MODEL != "RT76":
849
            if mem.skip != "S":
850
                _skp |= bitpos
851
            else:
852
                _skp &= ~bitpos
853
            LOG.debug("_skp %s" % _skp)
854

    
855
        for setting in mem.extra:
856
            if setting.get_name() == "scramble_type":
857
                setattr(_mem, setting.get_name(), int(setting.value) + 8)
858
                setattr(_mem, "scramble_type2", int(setting.value) + 8)
859
            else:
860
                setattr(_mem, setting.get_name(), setting.value)
861

    
862
    def get_settings(self):
863
        _settings = self._memobj.settings
864
        basic = RadioSettingGroup("basic", "Basic Settings")
865
        top = RadioSettings(basic)
866

    
867
        if self.MODEL == "RT21" or self.MODEL == "RB17A":
868
            _keys = self._memobj.keys
869

    
870
            rs = RadioSettingValueList(TIMEOUTTIMER_LIST,
871
                                       TIMEOUTTIMER_LIST[_settings.tot - 1])
872
            rset = RadioSetting("tot", "Time-out timer", rs)
873
            basic.append(rset)
874

    
875
            rs = RadioSettingValueList(TOTALERT_LIST,
876
                                       TOTALERT_LIST[_settings.totalert])
877
            rset = RadioSetting("totalert", "TOT Pre-alert", rs)
878
            basic.append(rset)
879

    
880
            rs = RadioSettingValueInteger(0, 9, _settings.squelch)
881
            rset = RadioSetting("squelch", "Squelch Level", rs)
882
            basic.append(rset)
883

    
884
            rs = RadioSettingValueList(VOICE_LIST, VOICE_LIST[_settings.voice])
885
            rset = RadioSetting("voice", "Voice Annumciation", rs)
886
            basic.append(rset)
887

    
888
            if self.MODEL == "RB17A":
889
                rs = RadioSettingValueList(ALARM_LIST,
890
                                           ALARM_LIST[_settings.alarm])
891
                rset = RadioSetting("alarm", "Alarm Type", rs)
892
                basic.append(rset)
893

    
894
            rs = RadioSettingValueBoolean(_settings.save)
895
            rset = RadioSetting("save", "Battery Saver", rs)
896
            basic.append(rset)
897

    
898
            rs = RadioSettingValueBoolean(_settings.use_scramble)
899
            rset = RadioSetting("use_scramble", "Scramble", rs)
900
            basic.append(rset)
901

    
902
            rs = RadioSettingValueBoolean(_settings.use_vox)
903
            rset = RadioSetting("use_vox", "VOX", rs)
904
            basic.append(rset)
905

    
906
            rs = RadioSettingValueList(VOX_LIST, VOX_LIST[_settings.vox])
907
            rset = RadioSetting("vox", "VOX Gain", rs)
908
            basic.append(rset)
909

    
910
            def apply_pf1_listvalue(setting, obj):
911
                LOG.debug("Setting value: " + str(
912
                          setting.value) + " from list")
913
                val = str(setting.value)
914
                index = PF1_CHOICES.index(val)
915
                val = PF1_VALUES[index]
916
                obj.set_value(val)
917

    
918
            if _keys.pf1 in PF1_VALUES:
919
                idx = PF1_VALUES.index(_keys.pf1)
920
            else:
921
                idx = LIST_DTMF_SPECIAL_VALUES.index(0x04)
922
            rs = RadioSettingValueList(PF1_CHOICES, PF1_CHOICES[idx])
923
            rset = RadioSetting("keys.pf1", "PF1 Key Function", rs)
924
            rset.set_apply_callback(apply_pf1_listvalue, _keys.pf1)
925
            basic.append(rset)
926

    
927
            def apply_topkey_listvalue(setting, obj):
928
                LOG.debug("Setting value: " + str(setting.value) +
929
                          " from list")
930
                val = str(setting.value)
931
                index = TOPKEY_CHOICES.index(val)
932
                val = TOPKEY_VALUES[index]
933
                obj.set_value(val)
934

    
935
            if self.MODEL == "RB17A":
936
                if _keys.topkey in TOPKEY_VALUES:
937
                    idx = TOPKEY_VALUES.index(_keys.topkey)
938
                else:
939
                    idx = TOPKEY_VALUES.index(0x0C)
940
                rs = RadioSettingValueList(TOPKEY_CHOICES, TOPKEY_CHOICES[idx])
941
                rset = RadioSetting("keys.topkey", "Top Key Function", rs)
942
                rset.set_apply_callback(apply_topkey_listvalue, _keys.topkey)
943
                basic.append(rset)
944

    
945
        if self.MODEL == "RB26" or self.MODEL == "RT76":
946
            if self.MODEL == "RB26":
947
                _settings2 = self._memobj.settings2
948
                _settings3 = self._memobj.settings3
949

    
950
            rs = RadioSettingValueInteger(0, 9, _settings.squelch)
951
            rset = RadioSetting("squelch", "Squelch Level", rs)
952
            basic.append(rset)
953

    
954
            rs = RadioSettingValueList(TIMEOUTTIMER_LIST,
955
                                       TIMEOUTTIMER_LIST[_settings.tot - 1])
956
            rset = RadioSetting("tot", "Time-out timer", rs)
957
            basic.append(rset)
958

    
959
            if self.MODEL == "RT76":
960
                rs = RadioSettingValueList(VOICE_LIST3,
961
                                           VOICE_LIST3[_settings.voice])
962
                rset = RadioSetting("voice", "Voice Annumciation", rs)
963
                basic.append(rset)
964

    
965
            if self.MODEL == "RB26":
966
                rs = RadioSettingValueList(VOICE_LIST2,
967
                                           VOICE_LIST2[_settings.voice])
968
                rset = RadioSetting("voice", "Voice Annumciation", rs)
969
                basic.append(rset)
970

    
971
                rs = RadioSettingValueBoolean(not _settings.chnumberd)
972
                rset = RadioSetting("chnumberd", "Channel Number Enable", rs)
973
                basic.append(rset)
974

    
975
            rs = RadioSettingValueBoolean(_settings.save)
976
            rset = RadioSetting("save", "Battery Save", rs)
977
            basic.append(rset)
978

    
979
            rs = RadioSettingValueBoolean(_settings.beep)
980
            rset = RadioSetting("beep", "Beep", rs)
981
            basic.append(rset)
982

    
983
            if self.MODEL == "RB26":
984
                rs = RadioSettingValueBoolean(not _settings.tail)
985
                rset = RadioSetting("tail", "QT/DQT Tail", rs)
986
                basic.append(rset)
987

    
988
            rs = RadioSettingValueList(SAVE_LIST, SAVE_LIST[_settings.savem])
989
            rset = RadioSetting("savem", "Battery Save Mode", rs)
990
            basic.append(rset)
991

    
992
            rs = RadioSettingValueList(GAIN_LIST, GAIN_LIST[_settings.gain])
993
            rset = RadioSetting("gain", "MIC Gain", rs)
994
            basic.append(rset)
995

    
996
            rs = RadioSettingValueList(WARN_LIST, WARN_LIST[_settings.warn])
997
            rset = RadioSetting("warn", "Warn Mode", rs)
998
            basic.append(rset)
999

    
1000
            if self.MODEL == "RB26":
1001
                rs = RadioSettingValueBoolean(_settings3.vox)
1002
                rset = RadioSetting("settings3.vox", "Vox Function", rs)
1003
                basic.append(rset)
1004

    
1005
                rs = RadioSettingValueList(VOXL_LIST,
1006
                                           VOXL_LIST[_settings3.voxl])
1007
                rset = RadioSetting("settings3.voxl", "Vox Level", rs)
1008
                basic.append(rset)
1009

    
1010
                rs = RadioSettingValueList(VOXD_LIST,
1011
                                           VOXD_LIST[_settings3.voxd])
1012
                rset = RadioSetting("settings3.voxd", "Vox Delay", rs)
1013
                basic.append(rset)
1014

    
1015
                rs = RadioSettingValueList(PFKEY_LIST,
1016
                                           PFKEY_LIST[_settings.pf1])
1017
                rset = RadioSetting("pf1", "PF1 Key Set", rs)
1018
                basic.append(rset)
1019

    
1020
                rs = RadioSettingValueList(PFKEY_LIST,
1021
                                           PFKEY_LIST[_settings.pf2])
1022
                rset = RadioSetting("pf2", "PF2 Key Set", rs)
1023
                basic.append(rset)
1024

    
1025
                rs = RadioSettingValueInteger(1, 30, _settings2.chnumber + 1)
1026
                rset = RadioSetting("settings2.chnumber", "Channel Number", rs)
1027
                basic.append(rset)
1028

    
1029
            if self.MODEL == "RT76":
1030
                rs = RadioSettingValueBoolean(_settings.vox)
1031
                rset = RadioSetting("vox", "Vox Function", rs)
1032
                basic.append(rset)
1033

    
1034
                rs = RadioSettingValueList(VOXL_LIST,
1035
                                           VOXL_LIST[_settings.voxl])
1036
                rset = RadioSetting("voxl", "Vox Level", rs)
1037
                basic.append(rset)
1038

    
1039
                rs = RadioSettingValueList(VOXD_LIST,
1040
                                           VOXD_LIST[_settings.voxd])
1041
                rset = RadioSetting("voxd", "Vox Delay", rs)
1042
                basic.append(rset)
1043

    
1044
                rs = RadioSettingValueInteger(1, 30, _settings.chnumber + 1)
1045
                rset = RadioSetting("chnumber", "Channel Number", rs)
1046
                basic.append(rset)
1047

    
1048
        return top
1049

    
1050
    def set_settings(self, settings):
1051
        for element in settings:
1052
            if not isinstance(element, RadioSetting):
1053
                self.set_settings(element)
1054
                continue
1055
            else:
1056
                try:
1057
                    if "." in element.get_name():
1058
                        bits = element.get_name().split(".")
1059
                        obj = self._memobj
1060
                        for bit in bits[:-1]:
1061
                            obj = getattr(obj, bit)
1062
                        setting = bits[-1]
1063
                    else:
1064
                        obj = self._memobj.settings
1065
                        setting = element.get_name()
1066

    
1067
                    if element.has_apply_callback():
1068
                        LOG.debug("Using apply callback")
1069
                        element.run_apply_callback()
1070
                    elif setting == "channel":
1071
                        setattr(obj, setting, int(element.value) - 1)
1072
                    elif setting == "chnumber":
1073
                        setattr(obj, setting, int(element.value) - 1)
1074
                    elif setting == "chnumberd":
1075
                        setattr(obj, setting, not int(element.value))
1076
                    elif setting == "tail":
1077
                        setattr(obj, setting, not int(element.value))
1078
                    elif setting == "tot":
1079
                        setattr(obj, setting, int(element.value) + 1)
1080
                    elif element.value.get_mutable():
1081
                        LOG.debug("Setting %s = %s" % (setting, element.value))
1082
                        setattr(obj, setting, element.value)
1083
                except Exception, e:
1084
                    LOG.debug(element.get_name())
1085
                    raise
1086

    
1087
    @classmethod
1088
    def match_model(cls, filedata, filename):
1089
        if cls.MODEL == "RT21":
1090
            # The RT21 is pre-metadata, so do old-school detection
1091
            match_size = False
1092
            match_model = False
1093

    
1094
            # testing the file data size
1095
            if len(filedata) in [0x0400, ]:
1096
                match_size = True
1097

    
1098
            # testing the model fingerprint
1099
            match_model = model_match(cls, filedata)
1100

    
1101
            if match_size and match_model:
1102
                return True
1103
            else:
1104
                return False
1105
        else:
1106
            # Radios that have always been post-metadata, so never do
1107
            # old-school detection
1108
            return False
1109

    
1110

    
1111
@directory.register
1112
class RB17ARadio(RT21Radio):
1113
    """RETEVIS RB17A"""
1114
    VENDOR = "Retevis"
1115
    MODEL = "RB17A"
1116
    BAUD_RATE = 9600
1117
    BLOCK_SIZE = 0x40
1118
    BLOCK_SIZE_UP = 0x10
1119

    
1120
    POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=0.50),
1121
                    chirp_common.PowerLevel("High", watts=5.00)]
1122

    
1123
    _magic = "PROA8US"
1124
    _fingerprint = "P3217s\xF8\xFF"
1125
    _upper = 30
1126
    _skipflags = True
1127
    _reserved = False
1128
    _gmrs = True
1129

    
1130
    _ranges = [
1131
               (0x0000, 0x0300),
1132
              ]
1133
    _memsize = 0x0300
1134

    
1135
    def process_mmap(self):
1136
        self._memobj = bitwise.parse(MEM_FORMAT_RB17A, self._mmap)
1137

    
1138

    
1139
@directory.register
1140
class RB26Radio(RT21Radio):
1141
    """RETEVIS RB26"""
1142
    VENDOR = "Retevis"
1143
    MODEL = "RB26"
1144
    BAUD_RATE = 9600
1145
    BLOCK_SIZE = 0x20
1146
    BLOCK_SIZE_UP = 0x10
1147

    
1148
    POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=0.50),
1149
                    chirp_common.PowerLevel("High", watts=3.00)]
1150

    
1151
    _magic = "PHOGR" + "\x01" + "0"
1152
    _fingerprint = "P32073" + "\x02\xFF"
1153
    _upper = 30
1154
    _skipflags = True
1155
    _reserved = True
1156
    _gmrs = True
1157

    
1158
    _ranges = [
1159
               (0x0000, 0x0320),
1160
              ]
1161
    _memsize = 0x0320
1162

    
1163
    def process_mmap(self):
1164
        self._memobj = bitwise.parse(MEM_FORMAT_RB26, self._mmap)
1165

    
1166

    
1167
@directory.register
1168
class RT76Radio(RT21Radio):
1169
    """RETEVIS RT76"""
1170
    VENDOR = "Retevis"
1171
    MODEL = "RT76"
1172
    BAUD_RATE = 9600
1173
    BLOCK_SIZE = 0x20
1174
    BLOCK_SIZE_UP = 0x10
1175

    
1176
    POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=0.50),
1177
                    chirp_common.PowerLevel("High", watts=5.00)]
1178

    
1179
    _magic = "PHOGR\x14\xD4"
1180
    _fingerprint = "P32073" + "\x02\xFF"
1181
    _upper = 30
1182
    _skipflags = False
1183
    _reserved = True
1184
    _gmrs = True
1185

    
1186
    _ranges = [
1187
               (0x0000, 0x01E0),
1188
              ]
1189
    _memsize = 0x01E0
1190

    
1191
    def process_mmap(self):
1192
        self._memobj = bitwise.parse(MEM_FORMAT_RT76, self._mmap)
1193

    
1194

    
1195
@directory.register
1196
class RT21VRadio(RT21Radio):
1197
    """RETEVIS RT21V"""
1198
    VENDOR = "Retevis"
1199
    MODEL = "RT21V"
1200
    ##BAUD_RATE = 9600
1201
    ##BLOCK_SIZE = 0x10
1202
    ##BLOCK_SIZE_UP = 0x10
1203

    
1204
    ##POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.00),
1205
    ##                chirp_common.PowerLevel("High", watts=2.50)]
1206

    
1207
    ##_magic = "PRMZUNE"
1208
    _fingerprint = "P2207\x01\xF8\xFF"
1209
    ##_upper = 16
1210
    ##_skipflags = True
1211
    ##_reserved = False
1212
    ##_gmrs = False
1213

    
1214
    ##_ranges = [
1215
    ##           (0x0000, 0x0400),
1216
    ##          ]
1217
    ##_memsize = 0x0400