[chirp_devel] [PATCH] [ 1 of 2 ] Prepare for new Leixen model
Brian Dickman
Sat Sep 3 13:55:27 PDT 2016
# HG changeset patch
# User Brian Dickman <brian.maybe at gmail.com>
# Date 1472935944 25200
# Sat Sep 03 13:52:24 2016 -0700
# Node ID d9eda786d470f7845f96d3ada98e3de65f5213a6
# Parent 3d8359621d43d5713869497d17182d6a43aebd67
[leixen] [ 1 of 2 ] Migrate radio paramters into class to prepare for
multiple models
Parameterize the mmap to account for changes between the 898 and 898S
models. Move power levels into the class out of the global module
level. Extend model matching to additional bytes to tell apart
additional models. Related to #3889, #3327, #3065.
diff -r 3d8359621d43 -r d9eda786d470 chirp/drivers/leixen.py
--- a/chirp/drivers/leixen.py Sat Sep 03 08:37:00 2016 -0700
+++ b/chirp/drivers/leixen.py Sat Sep 03 13:52:24 2016 -0700
@@ -135,14 +135,13 @@
u8 unknown5;
u8 pttidoff:1,
dtmfoff:1,
- unknown6:1,
+ %(unknownormode)s,
tailcut:1,
aliasop:1,
talkaroundoff:1,
voxoff:1,
skip:1;
- u8 power:1,
- mode:1
+ u8 %(modeorpower)s,
reverseoff:1,
blckoff:1,
unknown7:1,
@@ -223,8 +222,6 @@
"Reverse"
]
-POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=4),
- chirp_common.PowerLevel("High", watts=10)]
MODES = ["NFM", "FM"]
WTFTONES = map(float, xrange(56, 64))
TONES = WTFTONES + chirp_common.TONES
@@ -326,7 +323,8 @@
_ranges = [(0x0d00, 0x2000)]
image_ident = _image_ident_from_image(radio)
- if image_ident.startswith(radio._file_ident) and "LX-" in image_ident:
+ if image_ident.startswith(radio._file_ident) and \
+ radio._model_ident in image_ident:
_ranges = radio._ranges
do_ident(radio)
@@ -371,6 +369,8 @@
BAUD_RATE = 9600
_file_ident = "Leixen"
+ _model_ident = 'LX-\x89\x85\x63'
+
_memsize = 0x2000
_ranges = [
(0x0000, 0x013f),
@@ -382,6 +382,11 @@
(0x0d00, 0x2000),
]
+ _mem_formatter = {'unknownormode': 'unknown6:1',
+ 'modeorpower': 'mode:1, power:1'}
+ _power_levels = [chirp_common.PowerLevel("Low", watts=4),
+ chirp_common.PowerLevel("High", watts=10)]
+
def get_features(self):
rf = chirp_common.RadioFeatures()
rf.has_settings = True
@@ -402,7 +407,7 @@
"DTCS->DTCS"]
rf.valid_characters = chirp_common.CHARSET_ASCII
rf.valid_name_length = 7
- rf.valid_power_levels = POWER_LEVELS
+ rf.valid_power_levels = self._power_levels
rf.valid_duplexes = ["", "-", "+", "split", "off"]
rf.valid_skips = ["", "S"]
rf.valid_bands = [(136000000, 174000000),
@@ -419,7 +424,7 @@
self.process_mmap()
def process_mmap(self):
- self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
+ self._memobj = bitwise.parse(MEM_FORMAT %
self._mem_formatter, self._mmap)
def sync_out(self):
try:
@@ -492,12 +497,8 @@
self._get_tone(mem, _mem)
mem.mode = MODES[_mem.mode]
- mem.power = POWER_LEVELS[_mem.power]
- mem.skip = _mem.skip and "S" or ""
-
- self._get_tone(mem, _mem)
- mem.mode = MODES[_mem.mode]
- mem.power = POWER_LEVELS[_mem.power]
+ powerindex = _mem.power if _mem.power < len(self._power_levels) else -1
+ mem.power = self._power_levels[powerindex]
mem.skip = _mem.skip and "S" or ""
mem.extra = RadioSettingGroup("Extra", "extra")
@@ -595,7 +596,7 @@
self._set_tone(mem, _mem)
- _mem.power = mem.power and POWER_LEVELS.index(mem.power) or 0
+ _mem.power = mem.power and self._power_levels.index(mem.power) or 0
_mem.mode = MODES.index(mem.mode)
_mem.skip = mem.skip == "S"
_name.name = mem.name.ljust(7)
@@ -934,9 +935,7 @@
@classmethod
def match_model(cls, filedata, filename):
if filedata[0x168:0x170].startswith(cls._file_ident) and \
- filedata[0x170:0x178].startswith("LX-\x89\x85"):
- return True
- elif filedata[0x900:0x906] == cls.MODEL:
+
filedata[0x170:0x178].startswith(cls._model_ident):
return True
else:
return False
@@ -949,3 +948,4 @@
MODEL = "JT270M"
_file_ident = "JET"
+ _model_ident = 'LX-\x89\x85\x53'
More information about the chirp_devel
mailing list