[chirp_devel] [PATCH 0 of 2] changes to support vx170 #1183
changes to support subclassing from ft7800 initial support of vx170
# HG changeset patch # User Jens Jensen kd4tjx@yahoo.com # Date 1396636573 18000 # Fri Apr 04 13:36:13 2014 -0500 # Node ID c99645fbc263661c809e0935e357cecd8a6f532d # Parent c0d50dd2b786d768448cba0d9be6c9e2d48b665d [ft7800] updating ft7800 class to support subclassing #1183
prequisite changes to support subclassing for vx170 move power levels to class member use _block_size class member for chunk size in transfers
diff -r c0d50dd2b786 -r c99645fbc263 chirp/ft7800.py --- a/chirp/ft7800.py Thu Apr 03 14:07:20 2014 -0700 +++ b/chirp/ft7800.py Fri Apr 04 13:36:13 2014 -0500 @@ -161,16 +161,6 @@
DTMFCHARSET = list("0123456789ABCD*#")
-POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=50), - chirp_common.PowerLevel("Mid1", watts=20), - chirp_common.PowerLevel("Mid2", watts=10), - chirp_common.PowerLevel("Low", watts=5)] - -POWER_LEVELS_UHF = [chirp_common.PowerLevel("Hi", watts=35), - chirp_common.PowerLevel("Mid1", watts=20), - chirp_common.PowerLevel("Mid2", watts=10), - chirp_common.PowerLevel("Low", watts=5)] - def _send(ser, data): for i in data: ser.write(i) @@ -194,10 +184,10 @@
_send(radio.pipe, ACK)
- for i in range(0, radio._block_lengths[1], 64): - chunk = radio.pipe.read(64) + for i in range(0, radio._block_lengths[1], radio._block_size): + chunk = radio.pipe.read(radio._block_size) data += chunk - if len(chunk) != 64: + if len(chunk) != radio._block_size: break time.sleep(0.01) _send(radio.pipe, ACK) @@ -216,8 +206,8 @@ def _upload(radio): cur = 0 for block in radio._block_lengths: - for _i in range(0, block, 64): - length = min(64, block) + for _i in range(0, block, radio._block_size): + length = min(radio._block_size, block) #print "i=%i length=%i range: %i-%i" % (i, length, # cur, cur+length) _send(radio.pipe, radio.get_mmap()[cur:cur+length]) @@ -261,6 +251,17 @@ BAUD_RATE = 9600 VENDOR = "Yaesu" MODES = list(MODES) + _block_size = 64 + + POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=50), + chirp_common.PowerLevel("Mid1", watts=20), + chirp_common.PowerLevel("Mid2", watts=10), + chirp_common.PowerLevel("Low", watts=5)] + + POWER_LEVELS_UHF = [chirp_common.PowerLevel("Hi", watts=35), + chirp_common.PowerLevel("Mid1", watts=20), + chirp_common.PowerLevel("Mid2", watts=10), + chirp_common.PowerLevel("Low", watts=5)]
@classmethod def get_prompts(cls): @@ -299,7 +300,7 @@ rf.valid_tuning_steps = STEPS rf.valid_bands = [(108000000, 520000000), (700000000, 990000000)] rf.valid_skips = ["", "S", "P"] - rf.valid_power_levels = POWER_LEVELS_VHF + rf.valid_power_levels = self.POWER_LEVELS_VHF rf.valid_characters = "".join(CHARSET) rf.valid_name_length = 6 rf.can_odd_split = True @@ -402,9 +403,9 @@ mem.name = self._get_mem_name(mem, _mem)
if int(mem.freq / 100) == 4: - mem.power = POWER_LEVELS_UHF[_mem.power] + mem.power = self.POWER_LEVELS_UHF[_mem.power] else: - mem.power = POWER_LEVELS_VHF[_mem.power] + mem.power = self.POWER_LEVELS_VHF[_mem.power]
mem.skip = self._get_mem_skip(mem, _mem)
@@ -427,7 +428,7 @@ _mem.duplex = DUPLEX.index(mem.duplex) _mem.split = mem.duplex == "split" and int (mem.offset / 10000) or 0 if mem.power: - _mem.power = POWER_LEVELS_VHF.index(mem.power) + _mem.power = self.POWER_LEVELS_VHF.index(mem.power) else: _mem.power = 0 _mem.unknown5 = 0 # Make sure we don't leave garbage here @@ -792,7 +793,6 @@ _memsize = 22217
_block_lengths = [8, 22208, 1] - _block_size = 64
_memstart = 0x0000
# HG changeset patch # User Jens Jensen kd4tjx@yahoo.com # Date 1396636893 18000 # Fri Apr 04 13:41:33 2014 -0500 # Node ID 3916788fff75f73d78dff12e334be09489c452d4 # Parent c99645fbc263661c809e0935e357cecd8a6f532d [vx170] initial vx170 support #1183
diff -r c99645fbc263 -r 3916788fff75 chirp/vx170.py --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/chirp/vx170.py Fri Apr 04 13:41:33 2014 -0500 @@ -0,0 +1,135 @@ +# Copyright 2014 Jens Jensen af5mi@yahoo.com +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see http://www.gnu.org/licenses/. + +from chirp import chirp_common, yaesu_clone, directory, memmap +from chirp import bitwise, errors +from textwrap import dedent +import time, os +from chirp import ft7800 + +if os.getenv("CHIRP_DEBUG"): + CHIRP_DEBUG = True +else: + CHIRP_DEBUG = False + +MEM_FORMAT = """ +#seekto 0x018A; +struct { + u16 in_use; +} bank_used[24]; + +#seekto 0x0214; +u16 banksoff1; +#seekto 0x0294; +u16 banksoff2; + +#seekto 0x097A; +struct { + u8 name[6]; +} bank_names[24]; + +#seekto 0x0C0A; +struct { + u16 channels[100]; +} banks[24]; + +#seekto 0x0168; +struct { + u8 used:1, + unknown1:1, + mode:1, + unknown2:2, + duplex:3; + bbcd freq[3]; + u8 clockshift:1, + tune_step:3, + unknown5:1, + tmode:3; + bbcd split[3]; + u8 power:2, + tone:6; + u8 unknown6:1, + dtcs:7; + u8 unknown7[2]; + u8 offset; + u8 unknown9[3]; +} memory [200]; + +#seekto 0x0F28; +struct { + char name[6]; + u8 enabled:1, + unknown1:7; + u8 used:1, + unknown2:7; +} names[200]; + +#seekto 0x1768; +struct { + u8 skip3:2, + skip2:2, + skip1:2, + skip0:2; +} flags[50]; +""" + +@directory.register +class VX170Radio(ft7800.FTx800Radio): + """Yaesu VX-170""" + MODEL = "VX-170" + _model = "AH022" + _memsize = 6057 + _block_lengths = [8, 6048, 1] + _block_size = 32 + + POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=5.00), + chirp_common.PowerLevel("Med", watts=2.00), + chirp_common.PowerLevel("Lo", watts=0.50)] + + MODES = ["FM", "NFM"] + + @classmethod + def get_prompts(cls): + rp = chirp_common.RadioPrompts() + rp.pre_download = _(dedent("""\ + 1. Turn radio off. + 2. Connect cable to MIC/SP jack. + 3. Press and hold in the [moni] key while turning the radio on. + 4. Select CLONE in menu, then press F. Radio restarts in clone mode. + ("CLONE" will appear on the display). + 5. <b>After clicking OK</b>, breifly hold [PTT] key to send image. + ("-TX-" will appear on the LCD). """)) + rp.pre_upload = _(dedent("""\ + 1. Turn radio off. + 3. Press and hold in the [moni] key while turning the radio on. + 4. Select CLONE in menu, then press F. Radio restarts in clone mode. + ("CLONE" will appear on the display). + 5. Press the [moni] key ("-RX-" will appear on the LCD).""")) + return rp + + def _checksums(self): + return [ yaesu_clone.YaesuChecksum(0x0000, self._memsize - 2) ] + + def process_mmap(self): + self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) + + def get_features(self): + rf = super(VX170Radio, self).get_features() + rf.has_bank = False + rf.has_bank_names = False + rf.valid_modes = self.MODES + rf.memory_bounds = (1, 200) + rf.valid_bands = [(137000000, 174000000)] + return rf
participants (1)
-
Jens Jensen