[chirp_devel] [PATCH 00/24] more style fixes
This series of patches applies on top of the drivers/ui reorg patches, and it consists almost entirely of whitespace cleanups.
Zach Welch (24): Fix style issues in some drivers (#2355) Fix style issues in ap510.py (#2355) Fix style issues in baofeng_uv3r.py (#2355) Fix style issues in bjuv55.py (#2355) Fix style issues in yaesu_clone.py (#2355) Fix style issues in wouxum_common.py (#2355) Fix style issues in wouxum.py (#2355) Fix style issues in vxa700.py (#2355) Fix style issues in uv5r.py (#2355) Fix style issues in uvb5.py (#2355) Fix style issues in rfinder.py (#2355) Fix style issues in idrp.py (#2355) Fix style issues in puxing.py (#2355) Fix style issues in leixen.py (#2355) Fix style issues in kyd.py (#2355) Fix style issues in h777.py (#2355) Fix style issues in kenwood_hmk.py (#2355) Fix style issues in kguv8d.py (#2355) Fix style issues in id31.py (#2355) Fix style issues in id800.py (#2355) Fix style issues in icomciv.py (#2355) Fix style issues in tk8102.py (#2355) Fix style issues in thuv1f.py (#2355) Fix style issues in thd72.py (#2355)
chirp/drivers/alinco.py | 22 +- chirp/drivers/anytone.py | 25 +- chirp/drivers/ap510.py | 197 ++++++------ chirp/drivers/baofeng_uv3r.py | 106 ++++--- chirp/drivers/bjuv55.py | 181 +++++------ chirp/drivers/h777.py | 38 ++- chirp/drivers/icomciv.py | 44 +-- chirp/drivers/id31.py | 20 +- chirp/drivers/id800.py | 37 +-- chirp/drivers/id880.py | 46 +-- chirp/drivers/idrp.py | 22 +- chirp/drivers/kenwood_hmk.py | 36 +-- chirp/drivers/kenwood_itm.py | 20 +- chirp/drivers/kenwood_live.py | 251 ++++++++------- chirp/drivers/kguv8d.py | 184 ++++++----- chirp/drivers/kyd.py | 61 ++-- chirp/drivers/leixen.py | 146 +++++---- chirp/drivers/puxing.py | 44 +-- chirp/drivers/rfinder.py | 54 ++-- chirp/drivers/thd72.py | 88 +++--- chirp/drivers/thuv1f.py | 18 +- chirp/drivers/tk8102.py | 21 +- chirp/drivers/uv5r.py | 354 +++++++++++----------- chirp/drivers/uvb5.py | 109 ++++--- chirp/drivers/vxa700.py | 38 ++- chirp/drivers/wouxun.py | 672 +++++++++++++++++++++-------------------- chirp/drivers/wouxun_common.py | 20 +- chirp/drivers/yaesu_clone.py | 38 ++- tools/cpep8.blacklist | 28 -- 29 files changed, 1611 insertions(+), 1309 deletions(-)
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 9859baf4234e7136fcafc090adcfc88d3340b285
Fix style issues in some drivers (#2355)
diff --git a/chirp/drivers/alinco.py b/chirp/drivers/alinco.py index 9c70125..31bbbea 100644 --- a/chirp/drivers/alinco.py +++ b/chirp/drivers/alinco.py @@ -19,6 +19,7 @@ from chirp.settings import RadioSettingValueBoolean, RadioSettings
import time
+ DRX35_MEM_FORMAT = """ #seekto 0x0120; u8 used_flags[25]; @@ -67,6 +68,7 @@ RLENGTH = 2 + 5 + 32 + 2
STEPS = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0]
+ def isascii(data): for byte in data: if (ord(byte) < ord(" ") or ord(byte) > ord("~")) and \ @@ -74,6 +76,7 @@ def isascii(data): return False return True
+ def tohex(data): if isascii(data): return repr(data) @@ -82,6 +85,7 @@ def tohex(data): string += "%02X" % ord(byte) return string
+ class AlincoStyleRadio(chirp_common.CloneModeRadio): """Base class for all known Alinco radios""" _memsize = 0 @@ -204,12 +208,13 @@ class AlincoStyleRadio(chirp_common.CloneModeRadio): def get_raw_memory(self, number): return repr(self._memobj.memory[number])
+ DUPLEX = ["", "-", "+"] TMODES = ["", "Tone", "", "TSQL"] + [""] * 12 TMODES[12] = "DTCS" DCS_CODES = { - "Alinco" : chirp_common.DTCS_CODES, - "Jetstream" : [17] + chirp_common.DTCS_CODES, + "Alinco": chirp_common.DTCS_CODES, + "Jetstream": [17] + chirp_common.DTCS_CODES, }
CHARSET = (["\x00"] * 0x30) + \ @@ -217,6 +222,7 @@ CHARSET = (["\x00"] * 0x30) + \ [chr(x + ord("A")) for x in range(0, 26)] + [" "] + \ list("\x00" * 128)
+ def _get_name(_mem): name = "" for i in _mem.name: @@ -225,6 +231,7 @@ def _get_name(_mem): name += CHARSET[i] return name
+ def _set_name(mem, _mem): name = [0x00] * 7 j = 0 @@ -251,6 +258,7 @@ ALINCO_TONES.remove(206.5) ALINCO_TONES.remove(229.1) ALINCO_TONES.remove(254.1)
+ class DRx35Radio(AlincoStyleRadio): """Base class for the DR-x35 radios""" _range = [(118000000, 155000000)] @@ -385,6 +393,7 @@ class DRx35Radio(AlincoStyleRadio):
self._set_extra(_mem, mem)
+ @directory.register class DR03Radio(DRx35Radio): """Alinco DR03""" @@ -400,6 +409,7 @@ class DR03Radio(DRx35Radio): return len(filedata) == cls._memsize and \ filedata[0x64] == chr(0x00) and filedata[0x65] == chr(0x28)
+ @directory.register class DR06Radio(DRx35Radio): """Alinco DR06""" @@ -414,7 +424,8 @@ class DR06Radio(DRx35Radio): def match_model(cls, filedata, filename): return len(filedata) == cls._memsize and \ filedata[0x64] == chr(0x00) and filedata[0x65] == chr(0x50) - + + @directory.register class DR135Radio(DRx35Radio): """Alinco DR135""" @@ -430,6 +441,7 @@ class DR135Radio(DRx35Radio): return len(filedata) == cls._memsize and \ filedata[0x64] == chr(0x01) and filedata[0x65] == chr(0x44)
+ @directory.register class DR235Radio(DRx35Radio): """Alinco DR235""" @@ -445,6 +457,7 @@ class DR235Radio(DRx35Radio): return len(filedata) == cls._memsize and \ filedata[0x64] == chr(0x02) and filedata[0x65] == chr(0x22)
+ @directory.register class DR435Radio(DRx35Radio): """Alinco DR435""" @@ -460,6 +473,7 @@ class DR435Radio(DRx35Radio): return len(filedata) == cls._memsize and \ filedata[0x64] == chr(0x04) and filedata[0x65] == chr(0x00)
+ @directory.register class DJ596Radio(DRx35Radio): """Alinco DJ596""" @@ -477,6 +491,7 @@ class DJ596Radio(DRx35Radio): return len(filedata) == cls._memsize and \ filedata[0x64] == chr(0x45) and filedata[0x65] == chr(0x01)
+ @directory.register class JT220MRadio(DRx35Radio): """Jetstream JT220""" @@ -492,6 +507,7 @@ class JT220MRadio(DRx35Radio): return len(filedata) == cls._memsize and \ filedata[0x60:0x64] == "2009"
+ @directory.register class DJ175Radio(DRx35Radio): """Alinco DJ175""" diff --git a/chirp/drivers/anytone.py b/chirp/drivers/anytone.py index b7d722b..8755708 100644 --- a/chirp/drivers/anytone.py +++ b/chirp/drivers/anytone.py @@ -27,6 +27,7 @@ from chirp import util from chirp.settings import RadioSettingGroup, RadioSetting, RadioSettings, \ RadioSettingValueList, RadioSettingValueString, RadioSettingValueBoolean
+ LOG = logging.getLogger(__name__)
_mem_format = """ @@ -74,12 +75,12 @@ struct memory {
#seekto 0x0030; struct { - char serial[16]; + char serial[16]; } serial_no;
#seekto 0x0050; struct { - char date[16]; + char date[16]; } version;
#seekto 0x0280; @@ -110,6 +111,7 @@ struct memory memory[758]; struct memory memblk2[10]; """
+ class FlagObj(object): def __init__(self, flagobj, which): self._flagobj = flagobj @@ -155,18 +157,22 @@ class FlagObj(object): def __repr__(self): return repr(self._flagobj)
+ def _is_loc_used(memobj, loc): return memobj.flags[loc / 2].get_raw() != "\xFF"
+ def _addr_to_loc(addr): return (addr - 0x2000) / 32
+ def _should_send_addr(memobj, addr): if addr < 0x2000 or addr >= 0x7EC0: return True else: return _is_loc_used(memobj, _addr_to_loc(addr))
+ def _echo_write(radio, data): try: radio.pipe.write(data) @@ -175,6 +181,7 @@ def _echo_write(radio, data): print "Error writing to radio: %s" % e raise errors.RadioError("Unable to write to radio")
+ def _read(radio, length): try: data = radio.pipe.read(length) @@ -191,6 +198,7 @@ def _read(radio, length):
valid_model = ['QX588UV', 'HR-2040', 'DB-50M\x00', 'DB-750X']
+ def _ident(radio): radio.pipe.setTimeout(1) _echo_write(radio, "PROGRAM") @@ -205,6 +213,7 @@ def _ident(radio): print "Response was:\n%s" % util.hexprint(response) raise errors.RadioError("Unsupported model")
+ def _finish(radio): endframe = "\x45\x4E\x44" _echo_write(radio, endframe) @@ -213,12 +222,14 @@ def _finish(radio): print "Got:\n%s" % util.hexprint(result) raise errors.RadioError("Radio did not finish cleanly")
+ def _checksum(data): cs = 0 for byte in data: cs += ord(byte) return cs % 256
+ def _send(radio, cmd, addr, length, data=None): frame = struct.pack(">cHb", cmd, addr, length) if data: @@ -231,8 +242,8 @@ def _send(radio, cmd, addr, length, data=None): result = radio.pipe.read(1) if result != "\x06": print "Ack was: %s" % repr(result) - raise errors.RadioError("Radio did not accept block at %04x" % \ - addr) + raise errors.RadioError( + "Radio did not accept block at %04x" % addr) return result = _read(radio, length + 6) LOG.debug("Got:\n%s" % util.hexprint(result)) @@ -255,6 +266,7 @@ def _send(radio, cmd, addr, length, data=None): raise errors.RadioError("Block at 0x%04x failed checksum" % addr) return data
+ def _download(radio): _ident(radio)
@@ -282,6 +294,7 @@ def _download(radio):
return memmap.MemoryMap(data)
+ def _upload(radio): _ident(radio)
@@ -302,6 +315,7 @@ def _upload(radio):
_finish(radio)
+ TONES = [62.5] + list(chirp_common.TONES) TMODES = ['', 'Tone', 'DTCS', ''] DUPLEXES = ['', '-', '+', ''] @@ -527,6 +541,7 @@ class AnyTone5888UVRadio(chirp_common.CloneModeRadio, def match_model(cls, filedata, filename): return cls._file_ident in filedata[0x20:0x40]
+ @directory.register class IntekHR2040Radio(AnyTone5888UVRadio): """Intek HR-2040""" @@ -534,6 +549,7 @@ class IntekHR2040Radio(AnyTone5888UVRadio): MODEL = "HR-2040" _file_ident = "HR-2040"
+ @directory.register class PolmarDB50MRadio(AnyTone5888UVRadio): """Polmar DB-50M""" @@ -541,6 +557,7 @@ class PolmarDB50MRadio(AnyTone5888UVRadio): MODEL = "DB-50M" _file_ident = "DB-50M"
+ @directory.register class PowerwerxDB750XRadio(AnyTone5888UVRadio): """Powerwerx DB-750X""" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index d877a24..b90eb3f 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,8 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/alinco.py -./chirp/drivers/anytone.py ./chirp/drivers/ap510.py ./chirp/drivers/baofeng_uv3r.py ./chirp/drivers/bjuv55.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID a09163a1d3aa404c1069ef6e5ca58177c9c33e72
Fix style issues in ap510.py (#2355)
diff --git a/chirp/drivers/ap510.py b/chirp/drivers/ap510.py index 4597781..ae2ffe6 100644 --- a/chirp/drivers/ap510.py +++ b/chirp/drivers/ap510.py @@ -225,15 +225,16 @@ class AP510Memory(object): ))
def set_smartbeacon(self, d): - self._memobj[self.ATTR_MAP['smartbeacon']] = struct.pack(">7H", - encode_base100(d['lowspeed']), - encode_base100(d['slowrate']), - encode_base100(d['highspeed']), - encode_base100(d['fastrate']), - encode_base100(d['turnslope']), - encode_base100(d['turnangle']), - encode_base100(d['turntime']), - ) + self._memobj[self.ATTR_MAP['smartbeacon']] = \ + struct.pack(">7H", + encode_base100(d['lowspeed']), + encode_base100(d['slowrate']), + encode_base100(d['highspeed']), + encode_base100(d['fastrate']), + encode_base100(d['turnslope']), + encode_base100(d['turnangle']), + encode_base100(d['turntime']), + )
class AP510Memory20141215(AP510Memory): @@ -251,24 +252,24 @@ class AP510Memory20141215(AP510Memory): }.items())
def get_multiple(self): - return dict(zip(( - 'mice_message', # conveniently matches APRS spec Mic-E messages - 'voltage', # voltage in comment - 'temperature', # temperature in comment - 'tfx', # not sure what the TF/X toggle does - 'squelch', # squelch level 0-8 (0 = disabled) - 'blueled', # 0: squelch LED on GPS lock - # 1: light LED on GPS lock - 'telemetry', # 1: enable + return dict(zip( + ( + 'mice_message', # conveniently matches APRS spec Mic-E messages + 'voltage', # voltage in comment + 'temperature', # temperature in comment + 'tfx', # not sure what the TF/X toggle does + 'squelch', # squelch level 0-8 (0 = disabled) + 'blueled', # 0: squelch LED on GPS lock + # 1: light LED on GPS lock + 'telemetry', # 1: enable 'telemetry_every', # two-digit int 'timeslot_enable', # 1: enable Is this implemented in firmware? - 'timeslot', # int 00-59 - 'dcd', # 0: Blue LED displays squelch, - # 1: Blue LED displays software DCD - 'tf_card' # 0: KML, 1: WPL - ), map(int, chunks( - self._memobj[self.ATTR_MAP['multiple']], - (1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1))) + 'timeslot', # int 00-59 + 'dcd', # 0: Blue LED displays squelch, + # 1: Blue LED displays software DCD + 'tf_card' # 0: KML, 1: WPL + ), map(int, chunks(self._memobj[self.ATTR_MAP['multiple']], + (1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 1))) ))
def set_multiple(self, d): @@ -329,7 +330,7 @@ BEACON = ['manual', 'auto', 'auto + manual', 'smart', 'smart + manual'] ALIAS = ['WIDE1-N', 'WIDE2-N', 'WIDE1-N + WIDE2-N'] CHARSET = "".join(map(chr, range(0, 256))) MICE_MESSAGE = ['Emergency', 'Priority', 'Special', 'Committed', 'Returning', - 'In Service', 'En Route', 'Off Duty'] + 'In Service', 'En Route', 'Off Duty'] TF_CARD = ['WPL', 'KML'] POWER_LEVELS = [chirp_common.PowerLevel("0.5 watt", watts=0.50), chirp_common.PowerLevel("1 watt", watts=1.00)] @@ -440,7 +441,6 @@ class AP510Radio(chirp_common.CloneModeRadio): except NotImplementedError: pass
- def get_settings(self): china = RadioSettingGroup("china", "China Map Fix") smartbeacon = RadioSettingGroup("smartbeacon", "Smartbeacon") @@ -451,77 +451,85 @@ class AP510Radio(chirp_common.CloneModeRadio): settings = RadioSettings(aprs, digipeat, system)
aprs.append(RadioSetting("callsign", "Callsign", - RadioSettingValueString(0, 6, self._mmap.callsign[:6]))) + RadioSettingValueString(0, 6, self._mmap.callsign[:6]))) aprs.append(RadioSetting("ssid", "SSID", RadioSettingValueInteger( - 0, 15, ord(self._mmap.callsign[6]) - 0x30))) + 0, 15, ord(self._mmap.callsign[6]) - 0x30))) + pttdelay = PTT_DELAY[int(self._mmap.pttdelay) - 1] aprs.append(RadioSetting("pttdelay", "PTT Delay", - RadioSettingValueList( - PTT_DELAY, PTT_DELAY[int(self._mmap.pttdelay) - 1]))) + RadioSettingValueList(PTT_DELAY, pttdelay))) + output = OUTPUT[int(self._mmap.output) - 1] aprs.append(RadioSetting("output", "Output", - RadioSettingValueList( - OUTPUT, OUTPUT[int(self._mmap.output) - 1]))) + RadioSettingValueList(OUTPUT, output))) aprs.append(RadioSetting("mice", "Mic-E", - RadioSettingValueBoolean(strbool(self._mmap.mice)))) + RadioSettingValueBoolean(strbool(self._mmap.mice)))) try: + mice_msg = MICE_MESSAGE[int(self._mmap.multiple['mice_message'])] aprs.append(RadioSetting("mice_message", "Mic-E Message", - RadioSettingValueList( - MICE_MESSAGE, - MICE_MESSAGE[int(self._mmap.multiple['mice_message'])]))) + RadioSettingValueList(MICE_MESSAGE, mice_msg))) except NotImplementedError: pass try: aprs.append(RadioSetting("path1", "Path 1", - RadioSettingValueString(0, 6, self._mmap.path1[:6], - autopad=True, charset=CHARSET))) + RadioSettingValueString(0, 6, self._mmap.path1[:6], + autopad=True, + charset=CHARSET))) + ssid1 = ord(self._mmap.path1[6]) - 0x30 aprs.append(RadioSetting("ssid1", "SSID 1", - RadioSettingValueInteger( - 0, 7, ord(self._mmap.path1[6]) - 0x30))) + RadioSettingValueInteger(0, 7, ssid1))) aprs.append(RadioSetting("path2", "Path 2", - RadioSettingValueString(0, 6, self._mmap.path2[:6], - autopad=True, charset=CHARSET))) + RadioSettingValueString(0, 6, self._mmap.path2[:6], + autopad=True, + charset=CHARSET))) + ssid2 = ord(self._mmap.path2[6]) - 0x30 aprs.append(RadioSetting("ssid2", "SSID 2", - RadioSettingValueInteger( - 0, 7, ord(self._mmap.path2[6]) - 0x30))) + RadioSettingValueInteger(0, 7, ssid2))) aprs.append(RadioSetting("path3", "Path 3", - RadioSettingValueString(0, 6, self._mmap.path3[:6], - autopad=True, charset=CHARSET))) + RadioSettingValueString(0, 6, self._mmap.path3[:6], + autopad=True, + charset=CHARSET))) + ssid3 = ord(self._mmap.path3[6]) - 0x30 aprs.append(RadioSetting("ssid3", "SSID 3", - RadioSettingValueInteger( - 0, 7, ord(self._mmap.path3[6]) - 0x30))) + RadioSettingValueInteger(0, 7, ssid3))) except NotImplementedError: aprs.append(RadioSetting("path", "Path", - RadioSettingValueList(PATH, PATH[int(self._mmap.path)]))) + RadioSettingValueList(PATH, + PATH[int(self._mmap.path)]))) aprs.append(RadioSetting("table", "Table or Overlay", - RadioSettingValueList(TABLE, self._mmap.symbol[1]))) + RadioSettingValueList(TABLE, self._mmap.symbol[1]))) aprs.append(RadioSetting("symbol", "Symbol", - RadioSettingValueList(SYMBOL, self._mmap.symbol[0]))) + RadioSettingValueList(SYMBOL, self._mmap.symbol[0]))) aprs.append(RadioSetting("beacon", "Beacon Mode", - RadioSettingValueList( - BEACON, BEACON[int(self._mmap.beacon) - 1]))) + RadioSettingValueList(BEACON, + BEACON[int(self._mmap.beacon) - 1]))) aprs.append(RadioSetting("rate", "Beacon Rate (seconds)", - RadioSettingValueInteger(10, 9999, self._mmap.rate))) - aprs.append(RadioSetting("comment", "Comment", RadioSettingValueString( - 0, 34, self._mmap.comment, autopad=False, charset=CHARSET))) + RadioSettingValueInteger(10, 9999, self._mmap.rate))) + aprs.append(RadioSetting("comment", "Comment", + RadioSettingValueString(0, 34, self._mmap.comment, + autopad=False, charset=CHARSET))) try: + voltage = self._mmap.multiple['voltage'] aprs.append(RadioSetting("voltage", "Voltage in comment", - RadioSettingValueBoolean(self._mmap.multiple['voltage']))) + RadioSettingValueBoolean(voltage))) + temperature = self._mmap.multiple['temperature'] aprs.append(RadioSetting("temperature", "Temperature in comment", - RadioSettingValueBoolean(self._mmap.multiple['temperature']))) + RadioSettingValueBoolean(temperature))) except NotImplementedError: pass aprs.append(RadioSetting("status", "Status", RadioSettingValueString( 0, 34, self._mmap.status, autopad=False, charset=CHARSET))) try: + telemetry = self._mmap.multiple['telemetry'] aprs.append(RadioSetting("telemetry", "Telemetry", - RadioSettingValueBoolean(self._mmap.multiple['telemetry']))) + RadioSettingValueBoolean(telemetry))) + telemetry_every = self._mmap.multiple['telemetry_every'] aprs.append(RadioSetting("telemetry_every", "Telemetry every", - RadioSettingValueInteger( - 1, 99, self._mmap.multiple['telemetry_every']))) + RadioSettingValueInteger(1, 99, telemetry_every))) + timeslot_enable = self._mmap.multiple['telemetry'] aprs.append(RadioSetting("timeslot_enable", "Timeslot", - RadioSettingValueBoolean(self._mmap.multiple['telemetry']))) + RadioSettingValueBoolean(timeslot_enable))) + timeslot = self._mmap.multiple['timeslot'] aprs.append(RadioSetting("timeslot", "Timeslot (second of minute)", - RadioSettingValueInteger( - 0, 59, self._mmap.multiple['timeslot']))) + RadioSettingValueInteger(0, 59, timeslot))) except NotImplementedError: pass
@@ -575,44 +583,54 @@ class AP510Radio(chirp_common.CloneModeRadio): ))
system.append(RadioSetting("version", "Version (read-only)", - RadioSettingValueString(0, 14, self._mmap.version))) + RadioSettingValueString(0, 14, self._mmap.version))) system.append(RadioSetting("autooff", "Auto off (after 90 minutes)", - RadioSettingValueBoolean(strbool(self._mmap.autooff)))) + RadioSettingValueBoolean(strbool(self._mmap.autooff)))) system.append(RadioSetting("beep", "Beep on transmit", - RadioSettingValueBoolean(strbool(self._mmap.beep)))) + RadioSettingValueBoolean(strbool(self._mmap.beep)))) system.append(RadioSetting("highaltitude", "High Altitude", - RadioSettingValueBoolean(strbool(self._mmap.highaltitude)))) + RadioSettingValueBoolean( + strbool(self._mmap.highaltitude)))) system.append(RadioSetting("busywait", - "Wait for clear channel before transmit", - RadioSettingValueBoolean(strbool(self._mmap.busywait)))) + "Wait for clear channel before transmit", + RadioSettingValueBoolean( + strbool(self._mmap.busywait)))) try: system.append(RadioSetting("tx_volume", "Transmit volume", - RadioSettingValueList( - map(str, range(1, 7)), self._mmap.tx_volume))) + RadioSettingValueList( + map(str, range(1, 7)), self._mmap.tx_volume))) system.append(RadioSetting("rx_volume", "Receive volume", - RadioSettingValueList( - map(str, range(1, 10)), self._mmap.rx_volume))) + RadioSettingValueList( + map(str, range(1, 10)), self._mmap.rx_volume))) system.append(RadioSetting("squelch", "Squelch", - RadioSettingValueList(map(str, range(0, 9)), - str(self._mmap.multiple['squelch'])))) + RadioSettingValueList( + map(str, range(0, 9)), + str(self._mmap.multiple['squelch'])))) system.append(RadioSetting("tx_serial_ui_out", "Tx serial UI out", - RadioSettingValueBoolean( - strbool(self._mmap.tx_serial_ui_out)))) + RadioSettingValueBoolean( + strbool(self._mmap.tx_serial_ui_out)))) system.append(RadioSetting("auto_on", "Auto-on with 5V input", - RadioSettingValueBoolean(strbool(self._mmap.auto_on[0])))) - system.append(RadioSetting("auto_on_delay", - "Auto-off delay after 5V lost (seconds)", - RadioSettingValueInteger(0, 9999, int(self._mmap.auto_on[1:])) + RadioSettingValueBoolean( + strbool(self._mmap.auto_on[0])))) + system.append(RadioSetting( + "auto_on_delay", + "Auto-off delay after 5V lost (seconds)", + RadioSettingValueInteger( + 0, 9999, int(self._mmap.auto_on[1:])) )) system.append(RadioSetting("tfx", "TF/X", - RadioSettingValueBoolean(self._mmap.multiple['tfx']))) + RadioSettingValueBoolean( + self._mmap.multiple['tfx']))) system.append(RadioSetting("blueled", "Light blue LED on GPS lock", - RadioSettingValueBoolean(self._mmap.multiple['blueled']))) + RadioSettingValueBoolean( + self._mmap.multiple['blueled']))) system.append(RadioSetting("dcd", "Blue LED shows software DCD", - RadioSettingValueBoolean(self._mmap.multiple['dcd']))) + RadioSettingValueBoolean( + self._mmap.multiple['dcd']))) system.append(RadioSetting("tf_card", "TF card format", - RadioSettingValueList( - TF_CARD, TF_CARD[int(self._mmap.multiple['tf_card'])]))) + RadioSettingValueList( + TF_CARD, + TF_CARD[int(self._mmap.multiple['tf_card'])]))) except NotImplementedError: pass
@@ -685,7 +703,8 @@ class AP510Radio(chirp_common.CloneModeRadio): elif name == "status": self._mmap.status = str(setting.value) elif name in ("telemetry", "telemetry_every", - "timeslot_enable", "timeslot", "tfx", "blueled", "dcd"): + "timeslot_enable", "timeslot", + "tfx", "blueled", "dcd"): multiple = self._mmap.multiple multiple[name] = int(setting.value) self._mmap.multiple = multiple diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index b90eb3f..63b46cc 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/ap510.py ./chirp/drivers/baofeng_uv3r.py ./chirp/drivers/bjuv55.py ./chirp/drivers/ft1802.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 31a8fe92d77abb5ced11e7f79a964eefba9de694
Fix style issues in baofeng_uv3r.py (#2355)
diff --git a/chirp/drivers/baofeng_uv3r.py b/chirp/drivers/baofeng_uv3r.py index c98ab37..7b5ac60 100644 --- a/chirp/drivers/baofeng_uv3r.py +++ b/chirp/drivers/baofeng_uv3r.py @@ -24,6 +24,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueString, \ RadioSettingValueFloat, RadioSettings
+ def _uv3r_prep(radio): radio.pipe.write("\x05PROGRAM") ack = radio.pipe.read(1) @@ -40,6 +41,7 @@ def _uv3r_prep(radio): if radio.pipe.read(1) != "\x06": raise errors.RadioError("Radio did not ACK ident")
+ def uv3r_prep(radio): """Do the UV3R identification dance""" for _i in range(0, 10): @@ -50,6 +52,7 @@ def uv3r_prep(radio):
raise e
+ def uv3r_download(radio): """Talk to a UV3R and do a download""" try: @@ -60,6 +63,7 @@ def uv3r_download(radio): except Exception, e: raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ def uv3r_upload(radio): """Talk to a UV3R and do an upload""" try: @@ -70,6 +74,7 @@ def uv3r_upload(radio): except Exception, e: raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ UV3R_MEM_FORMAT = """ #seekto 0x0010; struct { @@ -183,6 +188,7 @@ UV3R_POWER_LEVELS = [chirp_common.PowerLevel("High", watts=2.00), chirp_common.PowerLevel("Low", watts=0.50)] UV3R_DTCS_POL = ["NN", "NR", "RN", "RR"]
+ @directory.register class UV3RRadio(chirp_common.CloneModeRadio): """Baofeng UV-3R""" @@ -359,8 +365,9 @@ class UV3RRadio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("backlight", "LCD Back Light", - RadioSettingValueList(BACKLIGHT_LIST, - BACKLIGHT_LIST[_settings.backlight])) + RadioSettingValueList( + BACKLIGHT_LIST, + BACKLIGHT_LIST[_settings.backlight])) basic.append(rs)
rs = RadioSetting("beep", "Keypad Beep", @@ -376,8 +383,8 @@ class UV3RRadio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("ste", "Squelch Tail Eliminate", - RadioSettingValueList(STE_LIST, - STE_LIST[_settings.ste])) + RadioSettingValueList( + STE_LIST, STE_LIST[_settings.ste])) basic.append(rs)
rs = RadioSetting("save", "Battery Saver", @@ -385,13 +392,13 @@ class UV3RRadio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("timeout", "Time Out Timer", - RadioSettingValueList(TIMEOUT_LIST, - TIMEOUT_LIST[_settings.timeout])) + RadioSettingValueList( + TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout])) basic.append(rs)
rs = RadioSetting("scanm", "Scan Mode", - RadioSettingValueList(SCANM_LIST, - SCANM_LIST[_settings.scanm])) + RadioSettingValueList( + SCANM_LIST, SCANM_LIST[_settings.scanm])) basic.append(rs)
rs = RadioSetting("relaym", "Repeater Sound Response", @@ -407,13 +414,13 @@ class UV3RRadio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("pri_ch", "Priority Channel", - RadioSettingValueList(PRI_CH_LIST, - PRI_CH_LIST[_settings.pri_ch])) + RadioSettingValueList( + PRI_CH_LIST, PRI_CH_LIST[_settings.pri_ch])) basic.append(rs)
rs = RadioSetting("ch_flag", "Display Mode", - RadioSettingValueList(CH_FLAG_LIST, - CH_FLAG_LIST[_settings.ch_flag])) + RadioSettingValueList( + CH_FLAG_LIST, CH_FLAG_LIST[_settings.ch_flag])) basic.append(rs)
_limit = int(self._memobj.limits.lower_vhf) / 10 @@ -421,6 +428,7 @@ class UV3RRadio(chirp_common.CloneModeRadio): _limit = 144 rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (115-239 MHz)", RadioSettingValueInteger(115, 235, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.lower_vhf = value @@ -432,6 +440,7 @@ class UV3RRadio(chirp_common.CloneModeRadio): _limit = 146 rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (115-239 MHz)", RadioSettingValueInteger(115, 235, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.upper_vhf = value @@ -443,6 +452,7 @@ class UV3RRadio(chirp_common.CloneModeRadio): _limit = 420 rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (200-529 MHz)", RadioSettingValueInteger(200, 529, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.lower_uhf = value @@ -454,6 +464,7 @@ class UV3RRadio(chirp_common.CloneModeRadio): _limit = 450 rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (200-529 MHz)", RadioSettingValueInteger(200, 529, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.upper_uhf = value @@ -464,95 +475,97 @@ class UV3RRadio(chirp_common.CloneModeRadio): group.append(vfo_preset)
def convert_bytes_to_freq(bytes): - real_freq = 0 - real_freq = bytes - return chirp_common.format_freq(real_freq * 10) + real_freq = 0 + real_freq = bytes + return chirp_common.format_freq(real_freq * 10)
def apply_vhf_freq(setting, obj): value = chirp_common.parse_freq(str(setting.value)) / 10 obj.vhf.freq = value
- val = RadioSettingValueString(0, 10, - convert_bytes_to_freq(int(_vfo.vhf.freq))) + val = RadioSettingValueString( + 0, 10, convert_bytes_to_freq(int(_vfo.vhf.freq))) rs = RadioSetting("vfo.vhf.freq", "VHF RX Frequency (115.00000-236.00000)", val) rs.set_apply_callback(apply_vhf_freq, _vfo) vfo_preset.append(rs)
rs = RadioSetting("vfo.vhf.duplex", "Shift Direction", - RadioSettingValueList(DUPLEX_LIST, - DUPLEX_LIST[_vfo.vhf.duplex])) + RadioSettingValueList( + DUPLEX_LIST, DUPLEX_LIST[_vfo.vhf.duplex])) vfo_preset.append(rs)
def convert_bytes_to_offset(bytes): - real_offset = 0 - real_offset = bytes - return chirp_common.format_freq(real_offset * 10000) + real_offset = 0 + real_offset = bytes + return chirp_common.format_freq(real_offset * 10000)
def apply_vhf_offset(setting, obj): value = chirp_common.parse_freq(str(setting.value)) / 10000 obj.vhf.offset = value
- val = RadioSettingValueString(0, 10, - convert_bytes_to_offset(int(_vfo.vhf.offset))) + val = RadioSettingValueString( + 0, 10, convert_bytes_to_offset(int(_vfo.vhf.offset))) rs = RadioSetting("vfo.vhf.offset", "Offset (0.00-37.995)", val) rs.set_apply_callback(apply_vhf_offset, _vfo) vfo_preset.append(rs)
rs = RadioSetting("vfo.vhf.power", "Power Level", - RadioSettingValueList(POWER_LIST, - POWER_LIST[_vfo.vhf.power])) + RadioSettingValueList( + POWER_LIST, POWER_LIST[_vfo.vhf.power])) vfo_preset.append(rs)
rs = RadioSetting("vfo.vhf.bandwidth", "Bandwidth", - RadioSettingValueList(BANDWIDTH_LIST, - BANDWIDTH_LIST[_vfo.vhf.bandwidth])) + RadioSettingValueList( + BANDWIDTH_LIST, + BANDWIDTH_LIST[_vfo.vhf.bandwidth])) vfo_preset.append(rs)
rs = RadioSetting("vfo.vhf.step", "Step", - RadioSettingValueList(STEP_LIST, - STEP_LIST[_vfo.vhf.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[_vfo.vhf.step])) vfo_preset.append(rs)
def apply_uhf_freq(setting, obj): value = chirp_common.parse_freq(str(setting.value)) / 10 obj.uhf.freq = value
- val = RadioSettingValueString(0, 10, - convert_bytes_to_freq(int(_vfo.uhf.freq))) + val = RadioSettingValueString( + 0, 10, convert_bytes_to_freq(int(_vfo.uhf.freq))) rs = RadioSetting("vfo.uhf.freq", - "UHF RX Frequency (200.00000-529.00000)", val) + "UHF RX Frequency (200.00000-529.00000)", val) rs.set_apply_callback(apply_uhf_freq, _vfo) vfo_preset.append(rs)
rs = RadioSetting("vfo.uhf.duplex", "Shift Direction", - RadioSettingValueList(DUPLEX_LIST, - DUPLEX_LIST[_vfo.uhf.duplex])) + RadioSettingValueList( + DUPLEX_LIST, DUPLEX_LIST[_vfo.uhf.duplex])) vfo_preset.append(rs)
def apply_uhf_offset(setting, obj): value = chirp_common.parse_freq(str(setting.value)) / 10000 obj.uhf.offset = value
- val = RadioSettingValueString(0, 10, - convert_bytes_to_offset(int(_vfo.uhf.offset))) + val = RadioSettingValueString( + 0, 10, convert_bytes_to_offset(int(_vfo.uhf.offset))) rs = RadioSetting("vfo.uhf.offset", "Offset (0.00-69.995)", val) rs.set_apply_callback(apply_uhf_offset, _vfo) vfo_preset.append(rs)
rs = RadioSetting("vfo.uhf.power", "Power Level", - RadioSettingValueList(POWER_LIST, - POWER_LIST[_vfo.uhf.power])) + RadioSettingValueList( + POWER_LIST, POWER_LIST[_vfo.uhf.power])) vfo_preset.append(rs)
rs = RadioSetting("vfo.uhf.bandwidth", "Bandwidth", - RadioSettingValueList(BANDWIDTH_LIST, - BANDWIDTH_LIST[_vfo.uhf.bandwidth])) + RadioSettingValueList( + BANDWIDTH_LIST, + BANDWIDTH_LIST[_vfo.uhf.bandwidth])) vfo_preset.append(rs)
rs = RadioSetting("vfo.uhf.step", "Step", - RadioSettingValueList(STEP_LIST, - STEP_LIST[_vfo.uhf.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[_vfo.uhf.step])) vfo_preset.append(rs)
fm_preset = RadioSettingGroup("fm_preset", "FM Radio Presets") @@ -566,8 +579,8 @@ class UV3RRadio(chirp_common.CloneModeRadio): used = False preset = 65 rs = RadioSetting("fm_presets_%1i" % i, "FM Preset %i" % (i + 1), - RadioSettingValueBoolean(used), - RadioSettingValueFloat(65, 108, preset, 0.1, 1)) + RadioSettingValueBoolean(used), + RadioSettingValueFloat(65, 108, preset, 0.1, 1)) fm_preset.append(rs)
return group @@ -576,7 +589,7 @@ class UV3RRadio(chirp_common.CloneModeRadio): _settings = self._memobj.settings for element in settings: if not isinstance(element, RadioSetting): - if element.get_name() == "fm_preset" : + if element.get_name() == "fm_preset": self._set_fm_preset(element) else: self.set_settings(element) @@ -625,7 +638,6 @@ class UV3RRadio(chirp_common.CloneModeRadio): print element.get_name() raise
- @classmethod def match_model(cls, filedata, filename): return len(filedata) == 3648 diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 63b46cc..255e3b0 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/baofeng_uv3r.py ./chirp/drivers/bjuv55.py ./chirp/drivers/ft1802.py ./chirp/drivers/ft2800.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID c14054b31a7be6e8e29504005cc74a4164e63d59
Fix style issues in bjuv55.py (#2355)
diff --git a/chirp/drivers/bjuv55.py b/chirp/drivers/bjuv55.py index 81bc2ed..e5c2377 100644 --- a/chirp/drivers/bjuv55.py +++ b/chirp/drivers/bjuv55.py @@ -28,7 +28,8 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueFloat, InvalidValueError, RadioSettings from textwrap import dedent
-BJUV55_MODEL = "\x50\xBB\xDD\x55\x63\x98\x4D" + +BJUV55_MODEL = "\x50\xBB\xDD\x55\x63\x98\x4D"
COLOR_LIST = ["Off", "Blue", "Red", "Pink"]
@@ -91,11 +92,11 @@ struct { u8 step; u8 tdrab; u8 tdr; - u8 vox; + u8 vox; u8 timeout; u8 unk2[6]; u8 abr; - u8 beep; + u8 beep; u8 ani; u8 unknown3[2]; u8 voice; @@ -228,23 +229,23 @@ struct {
"""
+ @directory.register class BaojieBJUV55Radio(uv5r.BaofengUV5R): VENDOR = "Baojie" MODEL = "BJ-UV55" - #_basetype = "BJ55" _basetype = ["BJ55"] - _idents = [ BJUV55_MODEL ] - _mem_params = ( 0x1928 # poweron_msg offset - ) + _idents = [BJUV55_MODEL] + _mem_params = (0x1928 # poweron_msg offset + ) _fw_ver_file_start = 0x1938 _fw_ver_file_stop = 0x193E - + def get_features(self): rf = super(BaojieBJUV55Radio, self).get_features() rf.valid_name_length = 6 return rf - + def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT % self._mem_params, self._mmap)
@@ -260,7 +261,6 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): else: _mem.txtoneicon = False
- def _get_settings(self): _settings = self._memobj.settings basic = RadioSettingGroup("basic", "Basic Settings") @@ -284,8 +284,9 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): advanced.append(rs)
rs = RadioSetting("tdrab", "Dual Watch TX Priority", - RadioSettingValueList(uv5r.TDRAB_LIST, - uv5r.TDRAB_LIST[_settings.tdrab])) + RadioSettingValueList( + uv5r.TDRAB_LIST, + uv5r.TDRAB_LIST[_settings.tdrab])) advanced.append(rs)
rs = RadioSetting("alarm", "Alarm", @@ -297,23 +298,25 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): basic.append(rs)
rs = RadioSetting("timeout", "Timeout Timer", - RadioSettingValueList(uv5r.TIMEOUT_LIST, - uv5r.TIMEOUT_LIST[_settings.timeout])) + RadioSettingValueList( + uv5r.TIMEOUT_LIST, + uv5r.TIMEOUT_LIST[_settings.timeout])) basic.append(rs)
rs = RadioSetting("screv", "Scan Resume", - RadioSettingValueList(uv5r.RESUME_LIST, - uv5r.RESUME_LIST[_settings.screv])) + RadioSettingValueList( + uv5r.RESUME_LIST, + uv5r.RESUME_LIST[_settings.screv])) advanced.append(rs)
rs = RadioSetting("mdfa", "Display Mode (A)", - RadioSettingValueList(uv5r.MODE_LIST, - uv5r.MODE_LIST[_settings.mdfa])) + RadioSettingValueList( + uv5r.MODE_LIST, uv5r.MODE_LIST[_settings.mdfa])) basic.append(rs)
rs = RadioSetting("mdfb", "Display Mode (B)", - RadioSettingValueList(uv5r.MODE_LIST, - uv5r.MODE_LIST[_settings.mdfb])) + RadioSettingValueList( + uv5r.MODE_LIST, uv5r.MODE_LIST[_settings.mdfb])) basic.append(rs)
rs = RadioSetting("bcl", "Busy Channel Lockout", @@ -329,18 +332,18 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): advanced.append(rs)
rs = RadioSetting("wtled", "Standby LED Color", - RadioSettingValueList(COLOR_LIST, - COLOR_LIST[_settings.wtled])) + RadioSettingValueList( + COLOR_LIST, COLOR_LIST[_settings.wtled])) basic.append(rs)
rs = RadioSetting("rxled", "RX LED Color", - RadioSettingValueList(COLOR_LIST, - COLOR_LIST[_settings.rxled])) + RadioSettingValueList( + COLOR_LIST, COLOR_LIST[_settings.rxled])) basic.append(rs)
rs = RadioSetting("txled", "TX LED Color", - RadioSettingValueList(COLOR_LIST, - COLOR_LIST[_settings.txled])) + RadioSettingValueList( + COLOR_LIST, COLOR_LIST[_settings.txled])) basic.append(rs)
rs = RadioSetting("reset", "RESET Menu", @@ -351,7 +354,6 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): RadioSettingValueBoolean(_settings.menu)) advanced.append(rs)
- if len(self._mmap.get_packed()) == 0x1808: # Old image, without aux block return group @@ -379,13 +381,13 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): limit = "limits" vhf_limit = getattr(self._memobj, limit).vhf rs = RadioSetting("%s.vhf.lower" % limit, "VHF Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - vhf_limit.lower)) + RadioSettingValueInteger( + 1, 1000, vhf_limit.lower)) other.append(rs)
rs = RadioSetting("%s.vhf.upper" % limit, "VHF Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - vhf_limit.upper)) + RadioSettingValueInteger( + 1, 1000, vhf_limit.upper)) other.append(rs)
rs = RadioSetting("%s.vhf.enable" % limit, "VHF TX Enabled", @@ -394,12 +396,12 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
uhf_limit = getattr(self._memobj, limit).uhf rs = RadioSetting("%s.uhf.lower" % limit, "UHF Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - uhf_limit.lower)) + RadioSettingValueInteger( + 1, 1000, uhf_limit.lower)) other.append(rs) rs = RadioSetting("%s.uhf.upper" % limit, "UHF Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - uhf_limit.upper)) + RadioSettingValueInteger( + 1, 1000, uhf_limit.upper)) other.append(rs) rs = RadioSetting("%s.uhf.enable" % limit, "UHF TX Enabled", RadioSettingValueBoolean(uhf_limit.enable)) @@ -410,14 +412,14 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
options = ["A", "B"] rs = RadioSetting("displayab", "Display Selected", - RadioSettingValueList(options, - options[_settings.displayab])) + RadioSettingValueList( + options, options[_settings.displayab])) workmode.append(rs)
options = ["Frequency", "Channel"] rs = RadioSetting("workmode", "VFO/MR Mode", - RadioSettingValueList(options, - options[_settings.workmode])) + RadioSettingValueList( + options, options[_settings.workmode])) workmode.append(rs)
rs = RadioSetting("keylock", "Keypad Lock", @@ -435,10 +437,10 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): workmode.append(rs)
def convert_bytes_to_freq(bytes): - real_freq = 0 - for byte in bytes: - real_freq = (real_freq * 10) + byte - return chirp_common.format_freq(real_freq * 10) + real_freq = 0 + for byte in bytes: + real_freq = (real_freq * 10) + byte + return chirp_common.format_freq(real_freq * 10)
def my_validate(value): value = chirp_common.parse_freq(value) @@ -453,15 +455,15 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): obj.freq[i] = value % 10 value /= 10
- val1a = RadioSettingValueString(0, 10, - convert_bytes_to_freq(self._memobj.vfoa.freq)) + val1a = RadioSettingValueString( + 0, 10, convert_bytes_to_freq(self._memobj.vfoa.freq)) val1a.set_validate_callback(my_validate) rs = RadioSetting("vfoa.freq", "VFO A Frequency", val1a) rs.set_apply_callback(apply_freq, self._memobj.vfoa) workmode.append(rs)
- val1b = RadioSettingValueString(0, 10, - convert_bytes_to_freq(self._memobj.vfob.freq)) + val1b = RadioSettingValueString( + 0, 10, convert_bytes_to_freq(self._memobj.vfob.freq)) val1b.set_validate_callback(my_validate) rs = RadioSetting("vfob.freq", "VFO B Frequency", val1b) rs.set_apply_callback(apply_freq, self._memobj.vfob) @@ -469,20 +471,20 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
options = ["Off", "+", "-"] rs = RadioSetting("vfoa.sftd", "VFO A Shift", - RadioSettingValueList(options, - options[self._memobj.vfoa.sftd])) + RadioSettingValueList( + options, options[self._memobj.vfoa.sftd])) workmode.append(rs)
rs = RadioSetting("vfob.sftd", "VFO B Shift", - RadioSettingValueList(options, - options[self._memobj.vfob.sftd])) + RadioSettingValueList( + options, options[self._memobj.vfob.sftd])) workmode.append(rs)
def convert_bytes_to_offset(bytes): - real_offset = 0 - for byte in bytes: - real_offset = (real_offset * 10) + byte - return chirp_common.format_freq(real_offset * 10000) + real_offset = 0 + for byte in bytes: + real_offset = (real_offset * 10) + byte + return chirp_common.format_freq(real_offset * 10000)
def apply_offset(setting, obj): value = chirp_common.parse_freq(str(setting.value)) / 10000 @@ -490,68 +492,66 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): obj.offset[i] = value % 10 value /= 10
- val1a = RadioSettingValueString(0, 10, - convert_bytes_to_offset(self._memobj.vfoa.offset)) + val1a = RadioSettingValueString( + 0, 10, convert_bytes_to_offset(self._memobj.vfoa.offset)) rs = RadioSetting("vfoa.offset", "VFO A Offset (0.00-69.95)", val1a) rs.set_apply_callback(apply_offset, self._memobj.vfoa) workmode.append(rs)
- val1b = RadioSettingValueString(0, 10, - convert_bytes_to_offset(self._memobj.vfob.offset)) + val1b = RadioSettingValueString( + 0, 10, convert_bytes_to_offset(self._memobj.vfob.offset)) rs = RadioSetting("vfob.offset", "VFO B Offset (0.00-69.95)", val1b) rs.set_apply_callback(apply_offset, self._memobj.vfob) workmode.append(rs)
options = ["High", "Low"] rs = RadioSetting("vfoa.txpower", "VFO A Power", - RadioSettingValueList(options, - options[self._memobj.vfoa.txpower])) + RadioSettingValueList( + options, options[self._memobj.vfoa.txpower])) workmode.append(rs)
rs = RadioSetting("vfob.txpower", "VFO B Power", - RadioSettingValueList(options, - options[self._memobj.vfob.txpower])) + RadioSettingValueList( + options, options[self._memobj.vfob.txpower])) workmode.append(rs)
options = ["Wide", "Narrow"] rs = RadioSetting("vfoa.widenarr", "VFO A Bandwidth", - RadioSettingValueList(options, - options[self._memobj.vfoa.widenarr])) + RadioSettingValueList( + options, options[self._memobj.vfoa.widenarr])) workmode.append(rs)
rs = RadioSetting("vfob.widenarr", "VFO B Bandwidth", - RadioSettingValueList(options, - options[self._memobj.vfob.widenarr])) + RadioSettingValueList( + options, options[self._memobj.vfob.widenarr])) workmode.append(rs)
options = ["%s" % x for x in range(1, 16)] rs = RadioSetting("vfoa.scode", "VFO A PTT-ID", - RadioSettingValueList(options, - options[self._memobj.vfoa.scode])) + RadioSettingValueList( + options, options[self._memobj.vfoa.scode])) workmode.append(rs)
rs = RadioSetting("vfob.scode", "VFO B PTT-ID", - RadioSettingValueList(options, - options[self._memobj.vfob.scode])) + RadioSettingValueList( + options, options[self._memobj.vfob.scode])) workmode.append(rs)
- rs = RadioSetting("vfoa.step", "VFO A Tuning Step", - RadioSettingValueList(STEP_LIST, - STEP_LIST[self._memobj.vfoa.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[self._memobj.vfoa.step])) workmode.append(rs) rs = RadioSetting("vfob.step", "VFO B Tuning Step", - RadioSettingValueList(STEP_LIST, - STEP_LIST[self._memobj.vfob.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[self._memobj.vfob.step])) workmode.append(rs)
- fm_preset = RadioSettingGroup("fm_preset", "FM Radio Preset") group.append(fm_preset)
preset = self._memobj.fm_preset / 10.0 + 87 rs = RadioSetting("fm_preset", "FM Preset(MHz)", - RadioSettingValueFloat(87, 107.5, preset, 0.1, 1)) + RadioSettingValueFloat(87, 107.5, preset, 0.1, 1)) fm_preset.append(rs)
dtmf = RadioSettingGroup("dtmf", "DTMF Settings") @@ -563,7 +563,9 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): _code = "".join([dtmfchars[x] for x in _codeobj if int(x) < 0x1F]) val = RadioSettingValueString(0, 5, _code, False) val.set_charset(dtmfchars) - rs = RadioSetting("pttid/%i.code" % i, "PTT ID Code %i" % (i + 1), val) + rs = RadioSetting("pttid/%i.code" % i, + "PTT ID Code %i" % (i + 1), val) + def apply_code(setting, obj): code = [] for j in range(0, 5): @@ -580,6 +582,7 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): val = RadioSettingValueString(0, 5, _code, False) val.set_charset(dtmfchars) rs = RadioSetting("ani.code", "ANI Code", val) + def apply_code(setting, obj): code = [] for j in range(0, 5): @@ -593,8 +596,8 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R):
options = ["Off", "BOT", "EOT", "Both"] rs = RadioSetting("ani.aniid", "ANI ID", - RadioSettingValueList(options, - options[self._memobj.ani.aniid])) + RadioSettingValueList( + options, options[self._memobj.ani.aniid])) dtmf.append(rs)
_codeobj = self._memobj.ani.alarmcode @@ -602,6 +605,7 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): val = RadioSettingValueString(0, 5, _code, False) val.set_charset(dtmfchars) rs = RadioSetting("ani.alarmcode", "Alarm Code", val) + def apply_code(setting, obj): alarmcode = [] for j in range(5): @@ -614,18 +618,21 @@ class BaojieBJUV55Radio(uv5r.BaofengUV5R): dtmf.append(rs)
rs = RadioSetting("dtmfst", "DTMF Sidetone", - RadioSettingValueList(uv5r.DTMFST_LIST, - uv5r.DTMFST_LIST[_settings.dtmfst])) + RadioSettingValueList( + uv5r.DTMFST_LIST, + uv5r.DTMFST_LIST[_settings.dtmfst])) dtmf.append(rs)
rs = RadioSetting("ani.dtmfon", "DTMF Speed (on)", - RadioSettingValueList(uv5r.DTMFSPEED_LIST, - uv5r.DTMFSPEED_LIST[self._memobj.ani.dtmfon])) + RadioSettingValueList( + uv5r.DTMFSPEED_LIST, + uv5r.DTMFSPEED_LIST[self._memobj.ani.dtmfon])) dtmf.append(rs)
rs = RadioSetting("ani.dtmfoff", "DTMF Speed (off)", - RadioSettingValueList(uv5r.DTMFSPEED_LIST, - uv5r.DTMFSPEED_LIST[self._memobj.ani.dtmfoff])) + RadioSettingValueList( + uv5r.DTMFSPEED_LIST, + uv5r.DTMFSPEED_LIST[self._memobj.ani.dtmfoff])) dtmf.append(rs)
return group diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 255e3b0..029afc5 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -1,7 +1,6 @@ # cpep8.blacklist: The list of files that do not meet PEP8 standards. # DO NOT ADD NEW FILES!! Instead, fix the code to be compliant. # Over time, this list should shrink and (eventually) be eliminated. -./chirp/drivers/bjuv55.py ./chirp/drivers/ft1802.py ./chirp/drivers/ft2800.py ./chirp/drivers/ft50.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 8caf00e2d67395f50defcb95fa1b8197131f1595
Fix style issues in yaesu_clone.py (#2355)
diff --git a/chirp/drivers/yaesu_clone.py b/chirp/drivers/yaesu_clone.py index e8ec732..ddaa1d2 100644 --- a/chirp/drivers/yaesu_clone.py +++ b/chirp/drivers/yaesu_clone.py @@ -13,30 +13,35 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-CMD_ACK = 0x06 +import time +import os +import logging +from textwrap import dedent
from chirp import chirp_common, util, memmap, errors -import time, os, logging -from textwrap import dedent
LOG = logging.getLogger(__name__)
+CMD_ACK = 0x06 + + def _safe_read(pipe, count): buf = "" first = True for _i in range(0, 60): buf += pipe.read(count - len(buf)) - #print "safe_read: %i/%i\n" % (len(buf), count) + # print "safe_read: %i/%i\n" % (len(buf), count) if buf: if first and buf[0] == chr(CMD_ACK): - #print "Chewed an ack" - buf = buf[1:] # Chew an echo'd ack if using a 2-pin cable + # print "Chewed an ack" + buf = buf[1:] # Chew an echo'd ack if using a 2-pin cable first = False if len(buf) == count: break print util.hexprint(buf) return buf
+ def _chunk_read(pipe, count, status_fn): block = 32 data = "" @@ -44,15 +49,16 @@ def _chunk_read(pipe, count, status_fn): data += pipe.read(block) if data: if data[0] == chr(CMD_ACK): - data = data[1:] # Chew an echo'd ack if using a 2-pin cable - #print "Chewed an ack" + data = data[1:] # Chew an echo'd ack if using a 2-pin cable + # print "Chewed an ack" status = chirp_common.Status() status.msg = "Cloning from radio" status.max = count status.cur = len(data) status_fn(status) LOG.debug("Read %i/%i" % (len(data), count)) - return data + return data +
def __clone_in(radio): pipe = radio.pipe @@ -79,12 +85,14 @@ def __clone_in(radio):
return memmap.MemoryMap(data)
+ def _clone_in(radio): try: return __clone_in(radio) except Exception, e: raise errors.RadioError("Failed to communicate with the radio: %s" % e)
+ def _chunk_write(pipe, data, status_fn, block): delay = 0.03 count = 0 @@ -92,7 +100,7 @@ def _chunk_write(pipe, data, status_fn, block): chunk = data[i:i+block] pipe.write(chunk) count += len(chunk) - LOG.debug("@_chunk_write, count: %i, blocksize: %i" % (count,block)) + LOG.debug("@_chunk_write, count: %i, blocksize: %i" % (count, block)) time.sleep(delay)
status = chirp_common.Status() @@ -100,7 +108,8 @@ def _chunk_write(pipe, data, status_fn, block): status.max = len(data) status.cur = count status_fn(status) - + + def __clone_out(radio): pipe = radio.pipe block_lengths = radio._block_lengths @@ -132,16 +141,18 @@ def __clone_out(radio): radio.status_fn, radio._block_size) pos += block
- pipe.read(pos) # Chew the echo if using a 2-pin cable + pipe.read(pos) # Chew the echo if using a 2-pin cable
print "Clone completed in %i seconds" % (time.time() - start)
+ def _clone_out(radio): try: return __clone_out(radio) except Exception, e: raise errors.RadioError("Failed to communicate with the radio: %s" % e)
+ class YaesuChecksum: """A Yaesu Checksum Object""" def __init__(self, start, stop, address=None): @@ -172,6 +183,7 @@ class YaesuChecksum: self._stop, self._address)
+ class YaesuCloneModeRadio(chirp_common.CloneModeRadio): """Base class for all Yaesu clone-mode radios""" _block_lengths = [8, 65536] @@ -194,7 +206,7 @@ class YaesuCloneModeRadio(chirp_common.CloneModeRadio): 3. Prepare radio for clone. 4. Press the key to receive the image.""")) return rp - + def _checksums(self): """Return a list of checksum objects that need to be calculated""" return [] diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 029afc5..d957f1c 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -61,4 +61,3 @@ ./chirp/drivers/vxa700.py ./chirp/drivers/wouxun.py ./chirp/drivers/wouxun_common.py -./chirp/drivers/yaesu_clone.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 54cc338a03f37073501060e354610dfc306c4b98
Fix style issues in wouxum_common.py (#2355)
diff --git a/chirp/drivers/wouxun_common.py b/chirp/drivers/wouxun_common.py index 5b51e93..9399eae 100644 --- a/chirp/drivers/wouxun_common.py +++ b/chirp/drivers/wouxun_common.py @@ -23,10 +23,12 @@ from chirp import util, chirp_common, memmap
LOG = logging.getLogger(__name__)
+ def wipe_memory(_mem, byte): """Cleanup a memory""" _mem.set_raw(byte * (_mem.size() / 8)) - + + def do_download(radio, start, end, blocksize): """Initiate a download of @radio between @start and @end""" image = "" @@ -38,23 +40,23 @@ def do_download(radio, start, end, blocksize): resp = radio.pipe.read(length) if len(resp) != (len(cmd) + blocksize): print util.hexprint(resp) - raise Exception("Failed to read full block (%i!=%i)" % \ - (len(resp), - len(cmd) + blocksize)) - + raise Exception("Failed to read full block (%i!=%i)" % + (len(resp), len(cmd) + blocksize)) + radio.pipe.write("\x06") radio.pipe.read(1) image += resp[4:]
if radio.status_fn: - status = chirp_common.Status() + status = chirp_common.Status() status.cur = i status.max = end status.msg = "Cloning from radio" radio.status_fn(status) - + return memmap.MemoryMap(image)
+ def do_upload(radio, start, end, blocksize): """Initiate an upload of @radio between @start and @end""" ptr = start @@ -68,7 +70,7 @@ def do_upload(radio, start, end, blocksize): ack = radio.pipe.read(1) if not ack == "\x06": raise Exception("Radio did not ack block %i" % ptr) - #radio.pipe.write(ack) + # radio.pipe.write(ack)
if radio.status_fn: status = chirp_common.Status() @@ -76,5 +78,3 @@ def do_upload(radio, start, end, blocksize): status.max = end status.msg = "Cloning to radio" radio.status_fn(status) - - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index d957f1c..84b4135 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -60,4 +60,3 @@ ./chirp/drivers/vx8.py ./chirp/drivers/vxa700.py ./chirp/drivers/wouxun.py -./chirp/drivers/wouxun_common.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 09ea08bd2891750679e12d7df4cc689ed12f19c6
Fix style issues in wouxum.py (#2355)
diff --git a/chirp/drivers/wouxun.py b/chirp/drivers/wouxun.py index 2a73f0a..dc03314 100644 --- a/chirp/drivers/wouxun.py +++ b/chirp/drivers/wouxun.py @@ -28,47 +28,49 @@ from textwrap import dedent
LOG = logging.getLogger(__name__)
-FREQ_ENCODE_TABLE = [ 0x7, 0xa, 0x0, 0x9, 0xb, 0x2, 0xe, 0x1, 0x3, 0xf ] - +FREQ_ENCODE_TABLE = [0x7, 0xa, 0x0, 0x9, 0xb, 0x2, 0xe, 0x1, 0x3, 0xf] + + def encode_freq(freq): """Convert frequency (4 decimal digits) to wouxun format (2 bytes)""" enc = 0 div = 1000 for i in range(0, 4): enc <<= 4 - enc |= FREQ_ENCODE_TABLE[ (freq/div) % 10 ] + enc |= FREQ_ENCODE_TABLE[(freq/div) % 10] div /= 10 return enc
+ def decode_freq(data): """Convert from wouxun format (2 bytes) to frequency (4 decimal digits)""" freq = 0 shift = 12 for i in range(0, 4): freq *= 10 - freq += FREQ_ENCODE_TABLE.index( (data>>shift) & 0xf ) + freq += FREQ_ENCODE_TABLE.index((data >> shift) & 0xf) shift -= 4 # print "data %04x freq %d shift %d" % (data, freq, shift) return freq
+ @directory.register class KGUVD1PRadio(chirp_common.CloneModeRadio, - chirp_common.ExperimentalRadio): + chirp_common.ExperimentalRadio): """Wouxun KG-UVD1P,UV2,UV3""" VENDOR = "Wouxun" MODEL = "KG-UVD1P" _model = "KG669V" - + _querymodel = ("HiWOUXUN\x02", "PROGUV6X\x02") - - CHARSET = list("0123456789") + [chr(x + ord("A")) \ - for x in range(0, 26)] + list("?+-") + + CHARSET = list("0123456789") + \ + [chr(x + ord("A")) for x in range(0, 26)] + list("?+-")
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00), chirp_common.PowerLevel("Low", watts=1.00)] - - valid_freq = [(136000000, 175000000), (216000000, 520000000)]
+ valid_freq = [(136000000, 175000000), (216000000, 520000000)]
_MEM_FORMAT = """ #seekto 0x0010; @@ -90,7 +92,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, iswidex:1, _0_unknown_2:4; } memory[199]; - + #seekto 0x0842; u16 fm_presets_0[9];
@@ -203,12 +205,12 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, def get_prompts(cls): rp = chirp_common.RadioPrompts() rp.experimental = \ - ('This version of the Wouxun driver allows you to modify the ' - 'frequency range settings of your radio. This has been tested ' - 'and reports from other users indicate that it is a safe ' - 'thing to do. However, modifications to this value may have ' - 'unintended consequences, including damage to your device. ' - 'You have been warned. Proceed at your own risk!') + ('This version of the Wouxun driver allows you to modify the ' + 'frequency range settings of your radio. This has been tested ' + 'and reports from other users indicate that it is a safe ' + 'thing to do. However, modifications to this value may have ' + 'unintended consequences, including damage to your device. ' + 'You have been warned. Proceed at your own risk!') rp.pre_download = _(dedent("""\ 1. Turn radio off. 2. Connect cable to mic/spkr connector. @@ -224,7 +226,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, 5. Ensure that the radio is tuned to channel with no activity. 6. Click OK to upload image to device.""")) return rp - + @classmethod def _get_querymodel(cls): if isinstance(cls._querymodel, str): @@ -248,8 +250,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, time.sleep(1) continue if resp[2:8] != self._model: - raise Exception("I can't talk to this model (%s)" % - util.hexprint(resp)) + raise Exception("I can't talk to this model (%s)" % + util.hexprint(resp)) return if len(resp) == 0: raise Exception("Radio not responding") @@ -262,7 +264,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, time.sleep(0.05) ack = self.pipe.read(1) if ack != "\x06": - raise Exception("Radio refused transfer mode") + raise Exception("Radio refused transfer mode") + def _download(self): """Talk to an original wouxun and do a download""" try: @@ -285,7 +288,6 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, except Exception, e: raise errors.RadioError("Failed to communicate with radio: %s" % e)
- def sync_in(self): self._mmap = self._download() self.process_mmap() @@ -303,8 +305,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, # offset 0x0010, like the radio actually stores it. So, # if we find one of those old ones, convert it to the new # format, padding 16 bytes of 0xFF in front. - self._mmap = memmap.MemoryMap(("\xFF" * 16) + \ - self._mmap.get_packed()[8:8184]) + self._mmap = memmap.MemoryMap( + ("\xFF" * 16) + self._mmap.get_packed()[8:8184]) self._memobj = bitwise.parse(self._MEM_FORMAT, self._mmap)
def get_features(self): @@ -342,57 +344,58 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, group = RadioSettings(cfg_s, freq_ranges, fm_preset)
rs = RadioSetting("menu_available", "Menu Available", - RadioSettingValueBoolean( - self._memobj.settings.menu_available)) + RadioSettingValueBoolean( + self._memobj.settings.menu_available)) cfg_s.append(rs)
rs = RadioSetting("vhf_rx_start", "1st band RX Lower Limit (MHz)", - RadioSettingValueInteger(50, 174, - decode_freq( - self._memobj.freq_ranges.vhf_rx_start))) + RadioSettingValueInteger( + 50, 174, decode_freq( + self._memobj.freq_ranges.vhf_rx_start))) freq_ranges.append(rs) rs = RadioSetting("vhf_rx_stop", "1st band RX Upper Limit (MHz)", - RadioSettingValueInteger(50, 174, - decode_freq( - self._memobj.freq_ranges.vhf_rx_stop))) + RadioSettingValueInteger( + 50, 174, decode_freq( + self._memobj.freq_ranges.vhf_rx_stop))) freq_ranges.append(rs) rs = RadioSetting("uhf_rx_start", "2nd band RX Lower Limit (MHz)", - RadioSettingValueInteger(136, 520, - decode_freq( - self._memobj.freq_ranges.uhf_rx_start))) + RadioSettingValueInteger( + 136, 520, decode_freq( + self._memobj.freq_ranges.uhf_rx_start))) freq_ranges.append(rs) rs = RadioSetting("uhf_rx_stop", "2nd band RX Upper Limit (MHz)", - RadioSettingValueInteger(136, 520, - decode_freq( - self._memobj.freq_ranges.uhf_rx_stop))) + RadioSettingValueInteger( + 136, 520, decode_freq( + self._memobj.freq_ranges.uhf_rx_stop))) freq_ranges.append(rs) rs = RadioSetting("vhf_tx_start", "1st band TX Lower Limit (MHz)", - RadioSettingValueInteger(50, 174, - decode_freq( - self._memobj.freq_ranges.vhf_tx_start))) + RadioSettingValueInteger( + 50, 174, decode_freq( + self._memobj.freq_ranges.vhf_tx_start))) freq_ranges.append(rs) rs = RadioSetting("vhf_tx_stop", "1st TX Upper Limit (MHz)", - RadioSettingValueInteger(50, 174, - decode_freq( - self._memobj.freq_ranges.vhf_tx_stop))) + RadioSettingValueInteger( + 50, 174, decode_freq( + self._memobj.freq_ranges.vhf_tx_stop))) freq_ranges.append(rs) rs = RadioSetting("uhf_tx_start", "2st band TX Lower Limit (MHz)", - RadioSettingValueInteger(136, 520, - decode_freq( - self._memobj.freq_ranges.uhf_tx_start))) + RadioSettingValueInteger( + 136, 520, decode_freq( + self._memobj.freq_ranges.uhf_tx_start))) freq_ranges.append(rs) rs = RadioSetting("uhf_tx_stop", "2st band TX Upper Limit (MHz)", - RadioSettingValueInteger(136, 520, - decode_freq( - self._memobj.freq_ranges.uhf_tx_stop))) + RadioSettingValueInteger( + 136, 520, decode_freq( + self._memobj.freq_ranges.uhf_tx_stop))) freq_ranges.append(rs) - + # tell the decoded ranges to UI - self.valid_freq = [ - (decode_freq(self._memobj.freq_ranges.vhf_rx_start) * 1000000, - (decode_freq(self._memobj.freq_ranges.vhf_rx_stop)+1) * 1000000), - (decode_freq(self._memobj.freq_ranges.uhf_rx_start) * 1000000, - (decode_freq(self._memobj.freq_ranges.uhf_rx_stop)+1) * 1000000)] + freq_ranges = self._memobj.freq_ranges + self.valid_freq = \ + [(decode_freq(freq_ranges.vhf_rx_start) * 1000000, + (decode_freq(freq_ranges.vhf_rx_stop) + 1) * 1000000), + (decode_freq(freq_ranges.uhf_rx_start) * 1000000, + (decode_freq(freq_ranges.uhf_rx_stop) + 1) * 1000000)]
def _filter(name): filtered = "" @@ -406,167 +409,179 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, # add some radio specific settings options = ["Off", "Welcome", "V bat"] rs = RadioSetting("ponmsg", "Poweron message", - RadioSettingValueList(options, - options[self._memobj.settings.ponmsg])) + RadioSettingValueList( + options, options[self._memobj.settings.ponmsg])) cfg_s.append(rs) rs = RadioSetting("strings.welcome1", "Power-On Message 1", - RadioSettingValueString(0, 6, - _filter(self._memobj.strings.welcome1))) + RadioSettingValueString( + 0, 6, _filter(self._memobj.strings.welcome1))) cfg_s.append(rs) rs = RadioSetting("strings.welcome2", "Power-On Message 2", - RadioSettingValueString(0, 6, - _filter(self._memobj.strings.welcome2))) + RadioSettingValueString( + 0, 6, _filter(self._memobj.strings.welcome2))) cfg_s.append(rs) rs = RadioSetting("strings.single_band", "Single Band Message", - RadioSettingValueString(0, 6, - _filter(self._memobj.strings.single_band))) + RadioSettingValueString( + 0, 6, _filter(self._memobj.strings.single_band))) cfg_s.append(rs) - options = ["Channel", "ch/freq","Name", "VFO"] + options = ["Channel", "ch/freq", "Name", "VFO"] rs = RadioSetting("vfo_a_ch_disp", "VFO A Channel disp mode", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_a_ch_disp])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_a_ch_disp])) cfg_s.append(rs) rs = RadioSetting("vfo_b_ch_disp", "VFO B Channel disp mode", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_b_ch_disp])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_b_ch_disp])) cfg_s.append(rs) options = ["5.0", "6.25", "10.0", "12.5", "25.0", "50.0", "100.0"] rs = RadioSetting("vfo_a_fr_step", "VFO A Frequency Step", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_a_fr_step])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_a_fr_step])) cfg_s.append(rs) rs = RadioSetting("vfo_b_fr_step", "VFO B Frequency Step", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_b_fr_step])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_b_fr_step])) cfg_s.append(rs) rs = RadioSetting("vfo_a_squelch", "VFO A Squelch", - RadioSettingValueInteger(0, 9, - self._memobj.settings.vfo_a_squelch)) + RadioSettingValueInteger( + 0, 9, self._memobj.settings.vfo_a_squelch)) cfg_s.append(rs) rs = RadioSetting("vfo_b_squelch", "VFO B Squelch", - RadioSettingValueInteger(0, 9, - self._memobj.settings.vfo_b_squelch)) + RadioSettingValueInteger( + 0, 9, self._memobj.settings.vfo_b_squelch)) cfg_s.append(rs) rs = RadioSetting("vfo_a_cur_chan", "VFO A current channel", - RadioSettingValueInteger(1, 128, - self._memobj.settings.vfo_a_cur_chan)) + RadioSettingValueInteger( + 1, 128, self._memobj.settings.vfo_a_cur_chan)) cfg_s.append(rs) rs = RadioSetting("vfo_b_cur_chan", "VFO B current channel", - RadioSettingValueInteger(1, 128, - self._memobj.settings.vfo_b_cur_chan)) + RadioSettingValueInteger( + 1, 128, self._memobj.settings.vfo_b_cur_chan)) cfg_s.append(rs) rs = RadioSetting("priority_chan", "Priority channel", - RadioSettingValueInteger(0, 199, - self._memobj.settings.priority_chan)) + RadioSettingValueInteger( + 0, 199, self._memobj.settings.priority_chan)) cfg_s.append(rs) rs = RadioSetting("power_save", "Power save", - RadioSettingValueBoolean( - self._memobj.settings.power_save)) + RadioSettingValueBoolean( + self._memobj.settings.power_save)) cfg_s.append(rs) options = ["Off", "Scan", "Lamp", "SOS", "Radio"] rs = RadioSetting("pf1_function", "PF1 Function select", - RadioSettingValueList(options, - options[self._memobj.settings.pf1_function])) + RadioSettingValueList( + options, + options[self._memobj.settings.pf1_function])) cfg_s.append(rs) options = ["Off", "Begin", "End", "Both"] rs = RadioSetting("roger_beep", "Roger beep select", - RadioSettingValueList(options, - options[self._memobj.settings.roger_beep])) + RadioSettingValueList( + options, + options[self._memobj.settings.roger_beep])) cfg_s.append(rs) options = ["%s" % x for x in range(15, 615, 15)] + transmit_time_out = options[self._memobj.settings.transmit_time_out] rs = RadioSetting("transmit_time_out", "TX Time-out Timer", - RadioSettingValueList(options, - options[self._memobj.settings.transmit_time_out])) + RadioSettingValueList( + options, transmit_time_out)) cfg_s.append(rs) rs = RadioSetting("tx_time_out_alert", "TX Time-out Alert", - RadioSettingValueInteger(0, 10, - self._memobj.settings.tx_time_out_alert)) + RadioSettingValueInteger( + 0, 10, self._memobj.settings.tx_time_out_alert)) cfg_s.append(rs) rs = RadioSetting("vox", "Vox", - RadioSettingValueInteger(0, 10, - self._memobj.settings.vox)) + RadioSettingValueInteger( + 0, 10, self._memobj.settings.vox)) cfg_s.append(rs) options = ["Off", "Chinese", "English"] rs = RadioSetting("voice", "Voice", - RadioSettingValueList(options, - options[self._memobj.settings.voice])) + RadioSettingValueList( + options, options[self._memobj.settings.voice])) cfg_s.append(rs) rs = RadioSetting("beep", "Beep", - RadioSettingValueBoolean( - self._memobj.settings.beep)) + RadioSettingValueBoolean( + self._memobj.settings.beep)) cfg_s.append(rs) rs = RadioSetting("ani_id_enable", "ANI id enable", - RadioSettingValueBoolean( - self._memobj.settings.ani_id_enable)) + RadioSettingValueBoolean( + self._memobj.settings.ani_id_enable)) cfg_s.append(rs) rs = RadioSetting("ani_id_tx_delay", "ANI id tx delay", - RadioSettingValueInteger(0, 30, - self._memobj.settings.ani_id_tx_delay)) + RadioSettingValueInteger( + 0, 30, self._memobj.settings.ani_id_tx_delay)) cfg_s.append(rs) options = ["Off", "Key", "ANI", "Key+ANI"] rs = RadioSetting("ani_id_sidetone", "ANI id sidetone", - RadioSettingValueList(options, - options[self._memobj.settings.ani_id_sidetone])) + RadioSettingValueList( + options, + options[self._memobj.settings.ani_id_sidetone])) cfg_s.append(rs) options = ["Time", "Carrier", "Search"] rs = RadioSetting("scan_mode", "Scan mode", - RadioSettingValueList(options, - options[self._memobj.settings.scan_mode])) + RadioSettingValueList( + options, + options[self._memobj.settings.scan_mode])) cfg_s.append(rs) rs = RadioSetting("kbd_lock", "Keyboard lock", - RadioSettingValueBoolean( - self._memobj.settings.kbd_lock)) + RadioSettingValueBoolean( + self._memobj.settings.kbd_lock)) cfg_s.append(rs) rs = RadioSetting("auto_lock_kbd", "Auto lock keyboard", - RadioSettingValueBoolean( - self._memobj.settings.auto_lock_kbd)) + RadioSettingValueBoolean( + self._memobj.settings.auto_lock_kbd)) cfg_s.append(rs) rs = RadioSetting("auto_backlight", "Auto backlight", - RadioSettingValueBoolean( - self._memobj.settings.auto_backlight)) + RadioSettingValueBoolean( + self._memobj.settings.auto_backlight)) cfg_s.append(rs) options = ["CH A", "CH B"] rs = RadioSetting("sos_ch", "SOS CH", - RadioSettingValueList(options, - options[self._memobj.settings.sos_ch])) + RadioSettingValueList( + options, + options[self._memobj.settings.sos_ch])) cfg_s.append(rs) rs = RadioSetting("stopwatch", "Stopwatch", - RadioSettingValueBoolean( - self._memobj.settings.stopwatch)) + RadioSettingValueBoolean( + self._memobj.settings.stopwatch)) cfg_s.append(rs) rs = RadioSetting("dual_band_receive", "Dual band receive", - RadioSettingValueBoolean( - self._memobj.settings.dual_band_receive)) + RadioSettingValueBoolean( + self._memobj.settings.dual_band_receive)) cfg_s.append(rs) options = ["VFO A", "VFO B"] rs = RadioSetting("current_vfo", "Current VFO", - RadioSettingValueList(options, - options[self._memobj.settings.current_vfo])) + RadioSettingValueList( + options, + options[self._memobj.settings.current_vfo])) cfg_s.append(rs)
options = ["Dual", "Single"] rs = RadioSetting("sd_available", "Single/Dual Band", - RadioSettingValueList(options, - options[self._memobj.settings.sd_available])) + RadioSettingValueList( + options, + options[self._memobj.settings.sd_available])) cfg_s.append(rs)
_pwd = self._memobj.settings.mode_password rs = RadioSetting("mode_password", "Mode password (000000 disabled)", - RadioSettingValueInteger(0, 9, _pwd[0]), - RadioSettingValueInteger(0, 9, _pwd[1]), - RadioSettingValueInteger(0, 9, _pwd[2]), - RadioSettingValueInteger(0, 9, _pwd[3]), - RadioSettingValueInteger(0, 9, _pwd[4]), - RadioSettingValueInteger(0, 9, _pwd[5])) + RadioSettingValueInteger(0, 9, _pwd[0]), + RadioSettingValueInteger(0, 9, _pwd[1]), + RadioSettingValueInteger(0, 9, _pwd[2]), + RadioSettingValueInteger(0, 9, _pwd[3]), + RadioSettingValueInteger(0, 9, _pwd[4]), + RadioSettingValueInteger(0, 9, _pwd[5])) cfg_s.append(rs) _pwd = self._memobj.settings.reset_password rs = RadioSetting("reset_password", "Reset password (000000 disabled)", - RadioSettingValueInteger(0, 9, _pwd[0]), - RadioSettingValueInteger(0, 9, _pwd[1]), - RadioSettingValueInteger(0, 9, _pwd[2]), - RadioSettingValueInteger(0, 9, _pwd[3]), - RadioSettingValueInteger(0, 9, _pwd[4]), - RadioSettingValueInteger(0, 9, _pwd[5])) + RadioSettingValueInteger(0, 9, _pwd[0]), + RadioSettingValueInteger(0, 9, _pwd[1]), + RadioSettingValueInteger(0, 9, _pwd[2]), + RadioSettingValueInteger(0, 9, _pwd[3]), + RadioSettingValueInteger(0, 9, _pwd[4]), + RadioSettingValueInteger(0, 9, _pwd[5])) cfg_s.append(rs)
dtmfchars = "0123456789 *#ABCD" @@ -575,6 +590,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, val = RadioSettingValueString(0, 6, _code, False) val.set_charset(dtmfchars) rs = RadioSetting("settings.ani_id_content", "PTT-ID Code", val) + def apply_ani_id(setting, obj): value = [] for j in range(0, 6): @@ -589,26 +605,26 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, for i in range(0, 9): if self._memobj.fm_presets_0[i] != 0xFFFF: used = True - preset = self._memobj.fm_presets_0[i]/10.0+76 + preset = self._memobj.fm_presets_0[i] / 10.0 + 76 else: used = False preset = 76 - rs = RadioSetting("fm_presets_0_%1i" % i, - "Team 1 Location %i" % (i+1), - RadioSettingValueBoolean(used), - RadioSettingValueFloat(76, 108, preset, 0.1, 1)) + rs = RadioSetting("fm_presets_0_%1i" % i, + "Team 1 Location %i" % (i + 1), + RadioSettingValueBoolean(used), + RadioSettingValueFloat(76, 108, preset, 0.1, 1)) fm_preset.append(rs) for i in range(0, 9): if self._memobj.fm_presets_1[i] != 0xFFFF: used = True - preset = self._memobj.fm_presets_1[i]/10.0+76 + preset = self._memobj.fm_presets_1[i] / 10.0 + 76 else: used = False preset = 76 - rs = RadioSetting("fm_presets_1_%1i" % i, - "Team 2 Location %i" % (i+1), - RadioSettingValueBoolean(used), - RadioSettingValueFloat(76, 108, preset, 0.1, 1)) + rs = RadioSetting("fm_presets_1_%1i" % i, + "Team 2 Location %i" % (i + 1), + RadioSettingValueBoolean(used), + RadioSettingValueFloat(76, 108, preset, 0.1, 1)) fm_preset.append(rs)
return group @@ -616,9 +632,9 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, def set_settings(self, settings): for element in settings: if not isinstance(element, RadioSetting): - if element.get_name() == "freq_ranges" : + if element.get_name() == "freq_ranges": self._set_freq_settings(element) - elif element.get_name() == "fm_preset" : + elif element.get_name() == "fm_preset": self._set_fm_preset(element) else: self.set_settings(element) @@ -720,8 +736,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, # always set it even if no dtcs is used mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
- LOG.debug("Got TX %s (%i) RX %s (%i)" % (txmode, _mem.tx_tone, - rxmode, _mem.rx_tone)) + LOG.debug("Got TX %s (%i) RX %s (%i)" % + (txmode, _mem.tx_tone, rxmode, _mem.rx_tone))
def _is_txinh(self, _mem): raw_tx = "" @@ -779,8 +795,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio,
options = ["NFM", "FM"] iswidex = RadioSetting("iswidex", "Mode TX(KG-UV6X)", - RadioSettingValueList(options, - options[_mem.iswidex])) + RadioSettingValueList( + options, options[_mem.iswidex])) iswidex.set_doc("Mode TX") mem.extra.append(iswidex)
@@ -801,7 +817,6 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, else: tx_mode = rx_mode = mem.tmode
- if tx_mode == "DTCS": _mem.tx_tone = mem.tmode != "DTCS" and \ _set_dcs(mem.dtcs, mem.dtcs_polarity[0]) or \ @@ -819,8 +834,8 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, else: _mem.rx_tone = 0xFFFF
- LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, - rx_mode, _mem.rx_tone)) + LOG.debug("Set TX %s (%i) RX %s (%i)" % + (tx_mode, _mem.tx_tone, rx_mode, _mem.rx_tone))
def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1] @@ -873,7 +888,7 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, filedata[0x60:0x64] != "2009" and \ filedata[0x1f77:0x1f7d] == "\xff\xff\xff\xff\xff\xff" and \ filedata[0x0d70:0x0d80] == "\xff\xff\xff\xff\xff\xff\xff\xff" \ - "\xff\xff\xff\xff\xff\xff\xff\xff": + "\xff\xff\xff\xff\xff\xff\xff\xff": # those areas are (seems to be) unused return True # Old-style image (CHIRP 0.1.11) @@ -882,13 +897,14 @@ class KGUVD1PRadio(chirp_common.CloneModeRadio, return True return False
+ @directory.register class KGUV6DRadio(KGUVD1PRadio): """Wouxun KG-UV6 (D and X variants)""" MODEL = "KG-UV6" - + _querymodel = ("HiWXUVD1\x02", "HiKGUVD1\x02") - + _MEM_FORMAT = """ #seekto 0x0010; struct { @@ -1009,7 +1025,7 @@ class KGUV6DRadio(KGUVD1PRadio): _2_unknown_4:4; u8 pad[2]; } vfo_settings[2]; - + #seekto 0x0f82; u16 fm_presets_0[9];
@@ -1043,7 +1059,6 @@ class KGUV6DRadio(KGUVD1PRadio): u16 fm_presets_1[9]; """
- def get_features(self): rf = KGUVD1PRadio.get_features(self) rf.memory_bounds = (1, 199) @@ -1056,57 +1071,58 @@ class KGUV6DRadio(KGUVD1PRadio): group = RadioSettings(cfg_s, freq_ranges, fm_preset)
rs = RadioSetting("menu_available", "Menu Available", - RadioSettingValueBoolean( - self._memobj.settings.menu_available)) + RadioSettingValueBoolean( + self._memobj.settings.menu_available)) cfg_s.append(rs)
rs = RadioSetting("vhf_rx_start", "VHF RX Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.vhf_rx_start))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.vhf_rx_start))) freq_ranges.append(rs) rs = RadioSetting("vhf_rx_stop", "VHF RX Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.vhf_rx_stop))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.vhf_rx_stop))) freq_ranges.append(rs) rs = RadioSetting("uhf_rx_start", "UHF RX Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.uhf_rx_start))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.uhf_rx_start))) freq_ranges.append(rs) rs = RadioSetting("uhf_rx_stop", "UHF RX Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.uhf_rx_stop))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.uhf_rx_stop))) freq_ranges.append(rs) rs = RadioSetting("vhf_tx_start", "VHF TX Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.vhf_tx_start))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.vhf_tx_start))) freq_ranges.append(rs) rs = RadioSetting("vhf_tx_stop", "VHF TX Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.vhf_tx_stop))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.vhf_tx_stop))) freq_ranges.append(rs) rs = RadioSetting("uhf_tx_start", "UHF TX Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.uhf_tx_start))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.uhf_tx_start))) freq_ranges.append(rs) rs = RadioSetting("uhf_tx_stop", "UHF TX Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - decode_freq( - self._memobj.freq_ranges.uhf_tx_stop))) + RadioSettingValueInteger( + 1, 1000, decode_freq( + self._memobj.freq_ranges.uhf_tx_stop))) freq_ranges.append(rs) - + # tell the decoded ranges to UI - self.valid_freq = [ - (decode_freq(self._memobj.freq_ranges.vhf_rx_start) * 1000000, - (decode_freq(self._memobj.freq_ranges.vhf_rx_stop)+1) * 1000000), - (decode_freq(self._memobj.freq_ranges.uhf_rx_start) * 1000000, - (decode_freq(self._memobj.freq_ranges.uhf_rx_stop)+1) * 1000000)] + freq_ranges = self._memobj.freq_ranges + self.valid_freq = \ + [(decode_freq(freq_ranges.vhf_rx_start) * 1000000, + (decode_freq(freq_ranges.vhf_rx_stop) + 1) * 1000000), + (decode_freq(freq_ranges.uhf_rx_start) * 1000000, + (decode_freq(freq_ranges.uhf_rx_stop) + 1) * 1000000)]
def _filter(name): filtered = "" @@ -1120,173 +1136,185 @@ class KGUV6DRadio(KGUVD1PRadio): # add some radio specific settings options = ["Off", "Welcome", "V bat", "N/A(KG-UV6X)"] rs = RadioSetting("ponmsg", "Poweron message", - RadioSettingValueList(options, - options[self._memobj.settings.ponmsg])) + RadioSettingValueList( + options, options[self._memobj.settings.ponmsg])) cfg_s.append(rs) rs = RadioSetting("strings.welcome1", "Power-On Message 1", - RadioSettingValueString(0, 6, - _filter(self._memobj.strings.welcome1))) + RadioSettingValueString( + 0, 6, _filter(self._memobj.strings.welcome1))) cfg_s.append(rs) rs = RadioSetting("strings.welcome2", "Power-On Message 2", - RadioSettingValueString(0, 6, - _filter(self._memobj.strings.welcome2))) + RadioSettingValueString( + 0, 6, _filter(self._memobj.strings.welcome2))) cfg_s.append(rs) rs = RadioSetting("strings.single_band", "Single Band Message", - RadioSettingValueString(0, 6, - _filter(self._memobj.strings.single_band))) + RadioSettingValueString( + 0, 6, _filter(self._memobj.strings.single_band))) cfg_s.append(rs) - options = ["Channel", "ch/freq","Name", "VFO"] + options = ["Channel", "ch/freq", "Name", "VFO"] rs = RadioSetting("vfo_a_ch_disp", "VFO A Channel disp mode", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_a_ch_disp])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_a_ch_disp])) cfg_s.append(rs) rs = RadioSetting("vfo_b_ch_disp", "VFO B Channel disp mode", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_b_ch_disp])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_b_ch_disp])) cfg_s.append(rs) options = \ ["2.5", "5.0", "6.25", "10.0", "12.5", "25.0", "50.0", "100.0"] rs = RadioSetting("vfo_a_fr_step", "VFO A Frequency Step", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_a_fr_step])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_a_fr_step])) cfg_s.append(rs) rs = RadioSetting("vfo_b_fr_step", "VFO B Frequency Step", - RadioSettingValueList(options, - options[self._memobj.settings.vfo_b_fr_step])) + RadioSettingValueList( + options, + options[self._memobj.settings.vfo_b_fr_step])) cfg_s.append(rs) rs = RadioSetting("vfo_a_squelch", "VFO A Squelch", - RadioSettingValueInteger(0, 9, - self._memobj.settings.vfo_a_squelch)) + RadioSettingValueInteger( + 0, 9, self._memobj.settings.vfo_a_squelch)) cfg_s.append(rs) rs = RadioSetting("vfo_b_squelch", "VFO B Squelch", - RadioSettingValueInteger(0, 9, - self._memobj.settings.vfo_b_squelch)) + RadioSettingValueInteger( + 0, 9, self._memobj.settings.vfo_b_squelch)) cfg_s.append(rs) rs = RadioSetting("vfo_a_cur_chan", "VFO A current channel", - RadioSettingValueInteger(1, 199, - self._memobj.settings.vfo_a_cur_chan)) + RadioSettingValueInteger( + 1, 199, self._memobj.settings.vfo_a_cur_chan)) cfg_s.append(rs) rs = RadioSetting("vfo_b_cur_chan", "VFO B current channel", - RadioSettingValueInteger(1, 199, - self._memobj.settings.vfo_b_cur_chan)) + RadioSettingValueInteger( + 1, 199, self._memobj.settings.vfo_b_cur_chan)) cfg_s.append(rs) rs = RadioSetting("priority_chan", "Priority channel", - RadioSettingValueInteger(0, 199, - self._memobj.settings.priority_chan)) + RadioSettingValueInteger( + 0, 199, self._memobj.settings.priority_chan)) cfg_s.append(rs) rs = RadioSetting("power_save", "Power save", - RadioSettingValueBoolean( - self._memobj.settings.power_save)) + RadioSettingValueBoolean( + self._memobj.settings.power_save)) cfg_s.append(rs) options = ["Off", "Scan", "Lamp", "SOS", "Radio"] rs = RadioSetting("pf1_function", "PF1 Function select", - RadioSettingValueList(options, - options[self._memobj.settings.pf1_function])) + RadioSettingValueList( + options, + options[self._memobj.settings.pf1_function])) cfg_s.append(rs) options = ["Off", "Radio", "fr/ch", "Rpt", "Stopwatch", "Lamp", "SOS"] rs = RadioSetting("pf2_function", "PF2 Function select", - RadioSettingValueList(options, - options[self._memobj.settings.pf2_function])) + RadioSettingValueList( + options, + options[self._memobj.settings.pf2_function])) cfg_s.append(rs) options = ["Off", "Begin", "End", "Both"] rs = RadioSetting("roger_beep", "Roger beep select", - RadioSettingValueList(options, - options[self._memobj.settings.roger_beep])) + RadioSettingValueList( + options, + options[self._memobj.settings.roger_beep])) cfg_s.append(rs) options = ["%s" % x for x in range(15, 615, 15)] + transmit_time_out = options[self._memobj.settings.transmit_time_out] rs = RadioSetting("transmit_time_out", "TX Time-out Timer", - RadioSettingValueList(options, - options[self._memobj.settings.transmit_time_out])) + RadioSettingValueList( + options, transmit_time_out)) cfg_s.append(rs) rs = RadioSetting("tx_time_out_alert", "TX Time-out Alert", - RadioSettingValueInteger(0, 10, - self._memobj.settings.tx_time_out_alert)) + RadioSettingValueInteger( + 0, 10, self._memobj.settings.tx_time_out_alert)) cfg_s.append(rs) rs = RadioSetting("vox", "Vox", - RadioSettingValueInteger(0, 10, - self._memobj.settings.vox)) + RadioSettingValueInteger( + 0, 10, self._memobj.settings.vox)) cfg_s.append(rs) options = ["Off", "Chinese", "English"] rs = RadioSetting("voice", "Voice", - RadioSettingValueList(options, - options[self._memobj.settings.voice])) + RadioSettingValueList( + options, options[self._memobj.settings.voice])) cfg_s.append(rs) rs = RadioSetting("beep", "Beep", - RadioSettingValueBoolean( - self._memobj.settings.beep)) + RadioSettingValueBoolean( + self._memobj.settings.beep)) cfg_s.append(rs) rs = RadioSetting("ani_id_enable", "ANI id enable", - RadioSettingValueBoolean( - self._memobj.settings.ani_id_enable)) + RadioSettingValueBoolean( + self._memobj.settings.ani_id_enable)) cfg_s.append(rs) rs = RadioSetting("ani_id_tx_delay", "ANI id tx delay", - RadioSettingValueInteger(0, 30, - self._memobj.settings.ani_id_tx_delay)) + RadioSettingValueInteger( + 0, 30, self._memobj.settings.ani_id_tx_delay)) cfg_s.append(rs) options = ["Off", "Key", "ANI", "Key+ANI"] rs = RadioSetting("ani_id_sidetone", "ANI id sidetone", - RadioSettingValueList(options, - options[self._memobj.settings.ani_id_sidetone])) + RadioSettingValueList( + options, + options[self._memobj.settings.ani_id_sidetone])) cfg_s.append(rs) options = ["Time", "Carrier", "Search"] rs = RadioSetting("scan_mode", "Scan mode", - RadioSettingValueList(options, - options[self._memobj.settings.scan_mode])) + RadioSettingValueList( + options, + options[self._memobj.settings.scan_mode])) cfg_s.append(rs) rs = RadioSetting("kbd_lock", "Keyboard lock", - RadioSettingValueBoolean( - self._memobj.settings.kbd_lock)) + RadioSettingValueBoolean( + self._memobj.settings.kbd_lock)) cfg_s.append(rs) rs = RadioSetting("auto_lock_kbd", "Auto lock keyboard", - RadioSettingValueBoolean( - self._memobj.settings.auto_lock_kbd)) + RadioSettingValueBoolean( + self._memobj.settings.auto_lock_kbd)) cfg_s.append(rs) rs = RadioSetting("auto_backlight", "Auto backlight", - RadioSettingValueBoolean( - self._memobj.settings.auto_backlight)) + RadioSettingValueBoolean( + self._memobj.settings.auto_backlight)) cfg_s.append(rs) options = ["CH A", "CH B"] rs = RadioSetting("sos_ch", "SOS CH", - RadioSettingValueList(options, - options[self._memobj.settings.sos_ch])) + RadioSettingValueList( + options, options[self._memobj.settings.sos_ch])) cfg_s.append(rs) rs = RadioSetting("stopwatch", "Stopwatch", - RadioSettingValueBoolean( - self._memobj.settings.stopwatch)) + RadioSettingValueBoolean( + self._memobj.settings.stopwatch)) cfg_s.append(rs) rs = RadioSetting("dual_band_receive", "Dual band receive", - RadioSettingValueBoolean( - self._memobj.settings.dual_band_receive)) + RadioSettingValueBoolean( + self._memobj.settings.dual_band_receive)) cfg_s.append(rs) options = ["VFO A", "VFO B"] rs = RadioSetting("current_vfo", "Current VFO", - RadioSettingValueList(options, - options[self._memobj.settings.current_vfo])) + RadioSettingValueList( + options, + options[self._memobj.settings.current_vfo])) cfg_s.append(rs)
options = ["Dual", "Single"] rs = RadioSetting("sd_available", "Single/Dual Band", - RadioSettingValueList(options, - options[self._memobj.settings.sd_available])) + RadioSettingValueList( + options, + options[self._memobj.settings.sd_available])) cfg_s.append(rs)
_pwd = self._memobj.settings.mode_password rs = RadioSetting("mode_password", "Mode password (000000 disabled)", - RadioSettingValueInteger(0, 9, _pwd[0]), - RadioSettingValueInteger(0, 9, _pwd[1]), - RadioSettingValueInteger(0, 9, _pwd[2]), - RadioSettingValueInteger(0, 9, _pwd[3]), - RadioSettingValueInteger(0, 9, _pwd[4]), - RadioSettingValueInteger(0, 9, _pwd[5])) + RadioSettingValueInteger(0, 9, _pwd[0]), + RadioSettingValueInteger(0, 9, _pwd[1]), + RadioSettingValueInteger(0, 9, _pwd[2]), + RadioSettingValueInteger(0, 9, _pwd[3]), + RadioSettingValueInteger(0, 9, _pwd[4]), + RadioSettingValueInteger(0, 9, _pwd[5])) cfg_s.append(rs) _pwd = self._memobj.settings.reset_password rs = RadioSetting("reset_password", "Reset password (000000 disabled)", - RadioSettingValueInteger(0, 9, _pwd[0]), - RadioSettingValueInteger(0, 9, _pwd[1]), - RadioSettingValueInteger(0, 9, _pwd[2]), - RadioSettingValueInteger(0, 9, _pwd[3]), - RadioSettingValueInteger(0, 9, _pwd[4]), - RadioSettingValueInteger(0, 9, _pwd[5])) + RadioSettingValueInteger(0, 9, _pwd[0]), + RadioSettingValueInteger(0, 9, _pwd[1]), + RadioSettingValueInteger(0, 9, _pwd[2]), + RadioSettingValueInteger(0, 9, _pwd[3]), + RadioSettingValueInteger(0, 9, _pwd[4]), + RadioSettingValueInteger(0, 9, _pwd[5])) cfg_s.append(rs)
dtmfchars = "0123456789 *#ABCD" @@ -1295,6 +1323,7 @@ class KGUV6DRadio(KGUVD1PRadio): val = RadioSettingValueString(0, 6, _code, False) val.set_charset(dtmfchars) rs = RadioSetting("settings.ani_id_content", "ANI Code", val) + def apply_ani_id(setting, obj): value = [] for j in range(0, 6): @@ -1313,10 +1342,10 @@ class KGUV6DRadio(KGUVD1PRadio): else: used = False preset = 76 - rs = RadioSetting("fm_presets_0_%1i" % i, - "Team 1 Location %i" % (i+1), - RadioSettingValueBoolean(used), - RadioSettingValueFloat(76, 108, preset, 0.1, 1)) + rs = RadioSetting("fm_presets_0_%1i" % i, + "Team 1 Location %i" % (i+1), + RadioSettingValueBoolean(used), + RadioSettingValueFloat(76, 108, preset, 0.1, 1)) fm_preset.append(rs) for i in range(0, 9): if self._memobj.fm_presets_1[i] != 0xFFFF: @@ -1325,10 +1354,10 @@ class KGUV6DRadio(KGUVD1PRadio): else: used = False preset = 76 - rs = RadioSetting("fm_presets_1_%1i" % i, - "Team 2 Location %i" % (i+1), - RadioSettingValueBoolean(used), - RadioSettingValueFloat(76, 108, preset, 0.1, 1)) + rs = RadioSetting("fm_presets_1_%1i" % i, + "Team 2 Location %i" % (i+1), + RadioSettingValueBoolean(used), + RadioSettingValueFloat(76, 108, preset, 0.1, 1)) fm_preset.append(rs)
return group @@ -1336,9 +1365,9 @@ class KGUV6DRadio(KGUVD1PRadio): def set_settings(self, settings): for element in settings: if not isinstance(element, RadioSetting): - if element.get_name() == "freq_ranges" : + if element.get_name() == "freq_ranges": self._set_freq_settings(element) - elif element.get_name() == "fm_preset" : + elif element.get_name() == "fm_preset": self._set_fm_preset(element) else: self.set_settings(element) @@ -1392,14 +1421,14 @@ class KGUV6DRadio(KGUVD1PRadio): return True return False
+ @directory.register -class KG816Radio(KGUVD1PRadio, - chirp_common.ExperimentalRadio): +class KG816Radio(KGUVD1PRadio, chirp_common.ExperimentalRadio): """Wouxun KG-816""" MODEL = "KG-816"
_querymodel = "HiWOUXUN\x02" - + _MEM_FORMAT = """ #seekto 0x0010; struct { @@ -1420,7 +1449,7 @@ class KG816Radio(KGUVD1PRadio, iswidex:1, _0_unknown_2:4; } memory[199]; - + #seekto 0x0d70; struct { u16 vhf_rx_start; @@ -1435,10 +1464,9 @@ class KG816Radio(KGUVD1PRadio,
#seekto 0x1010; struct { - u8 name[6]; - u8 pad[10]; + u8 name[6]; + u8 pad[10]; } names[199]; - """
@classmethod @@ -1448,62 +1476,62 @@ class KG816Radio(KGUVD1PRadio, 'organization of KGUVD1 but uses 199 memories. ' 'it has been reported to work but ' 'proceed at your own risk!') - + def get_features(self): rf = KGUVD1PRadio.get_features(self) - rf.memory_bounds = (1, 199) # this is the only known difference + rf.memory_bounds = (1, 199) # this is the only known difference return rf
def get_settings(self): - freq_ranges = RadioSettingGroup("freq_ranges", + freq_ranges = RadioSettingGroup("freq_ranges", "Freq Ranges (read only)") group = RadioSettings(freq_ranges)
rs = RadioSetting("vhf_rx_start", "vhf rx start", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.vhf_rx_start))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.vhf_rx_start))) freq_ranges.append(rs) rs = RadioSetting("vhf_rx_stop", "vhf rx stop", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.vhf_rx_stop))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.vhf_rx_stop))) freq_ranges.append(rs) rs = RadioSetting("uhf_rx_start", "uhf rx start", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.uhf_rx_start))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.uhf_rx_start))) freq_ranges.append(rs) rs = RadioSetting("uhf_rx_stop", "uhf rx stop", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.uhf_rx_stop))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.uhf_rx_stop))) freq_ranges.append(rs) rs = RadioSetting("vhf_tx_start", "vhf tx start", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.vhf_tx_start))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.vhf_tx_start))) freq_ranges.append(rs) rs = RadioSetting("vhf_tx_stop", "vhf tx stop", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.vhf_tx_stop))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.vhf_tx_stop))) freq_ranges.append(rs) rs = RadioSetting("uhf_tx_start", "uhf tx start", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.uhf_tx_start))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.uhf_tx_start))) freq_ranges.append(rs) rs = RadioSetting("uhf_tx_stop", "uhf tx stop", - RadioSettingValueInteger(66, 520, - decode_freq( - self._memobj.freq_ranges.uhf_tx_stop))) + RadioSettingValueInteger( + 66, 520, decode_freq( + self._memobj.freq_ranges.uhf_tx_stop))) freq_ranges.append(rs) - + # tell the decoded ranges to UI - self.valid_freq = [ - (decode_freq(self._memobj.freq_ranges.vhf_rx_start) * 1000000, - (decode_freq(self._memobj.freq_ranges.vhf_rx_stop)+1) * 1000000)] + self.valid_freq = \ + [(decode_freq(self._memobj.freq_ranges.vhf_rx_start) * 1000000, + (decode_freq(self._memobj.freq_ranges.vhf_rx_stop)+1) * 1000000)]
return group
@@ -1513,7 +1541,7 @@ class KG816Radio(KGUVD1PRadio, filedata[0x60:0x64] != "2009" and \ filedata[0x1f77:0x1f7d] == "\xff\xff\xff\xff\xff\xff" and \ filedata[0x0d70:0x0d80] != "\xff\xff\xff\xff\xff\xff\xff\xff" \ - "\xff\xff\xff\xff\xff\xff\xff\xff": + "\xff\xff\xff\xff\xff\xff\xff\xff": return True return False
diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 84b4135..3d41ee2 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -59,4 +59,3 @@ ./chirp/drivers/vx7.py ./chirp/drivers/vx8.py ./chirp/drivers/vxa700.py -./chirp/drivers/wouxun.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID c8b532fb0ba7f19d1471b557be2f006d759b3c7a
Fix style issues in vxa700.py (#2355)
diff --git a/chirp/drivers/vxa700.py b/chirp/drivers/vxa700.py index bfccfbd..a484754 100644 --- a/chirp/drivers/vxa700.py +++ b/chirp/drivers/vxa700.py @@ -19,10 +19,12 @@ from chirp import bitwise import time import struct
+ def _debug(string): pass print string
+ def _send(radio, data): _debug("Sending %s" % repr(data)) radio.pipe.write(data) @@ -31,8 +33,9 @@ def _send(radio, data): if len(echo) != len(data): raise errors.RadioError("Invalid echo")
+ def _spoonfeed(radio, data): - #count = 0 + # count = 0 _debug("Writing %i:\n%s" % (len(data), util.hexprint(data))) for byte in data: radio.pipe.write(byte) @@ -45,7 +48,8 @@ def _spoonfeed(radio, data): if echo != byte: print "%02x != %02x" % (ord(echo), ord(byte)) raise errors.RadioError("No echo?") - #count += 1 + # count += 1 +
def _download(radio): count = 0 @@ -80,6 +84,7 @@ def _download(radio):
return memmap.MemoryMap(data)
+ def _upload(radio): for i in range(0, radio.get_memsize(), 128): chunk = radio.get_mmap()[i:i+128] @@ -102,7 +107,7 @@ def _upload(radio): if ack != "\x06": print repr(ack) raise errors.RadioError("Radio did not ack block %i" % (i / 132)) - #radio.pipe.read(1) + # radio.pipe.read(1) if radio.status_fn: status = chirp_common.Status() status.msg = "Cloning to radio" @@ -146,9 +151,9 @@ struct memory_struct memory[100];
CHARSET = "".join(["%i" % i for i in range(0, 10)]) + \ "".join([chr(ord("A") + i) for i in range(0, 26)]) + \ - "".join([chr(ord("a") + i) for i in range(0,26)]) + \ + "".join([chr(ord("a") + i) for i in range(0, 26)]) + \ "., :;!"#$%&'()*+-/=<>?@[?]^_`{|}????~??????????????????????????" - + TMODES = ["", "Tone", "TSQL", "DTCS"] DUPLEX = ["", "-", "+", ""] POWER = [chirp_common.PowerLevel("Low1", watts=0.050), @@ -156,9 +161,11 @@ POWER = [chirp_common.PowerLevel("Low1", watts=0.050), chirp_common.PowerLevel("Low3", watts=2.500), chirp_common.PowerLevel("High", watts=5.000)]
+ def _wipe_memory(_mem): _mem.set_raw("\x00" * (_mem.size() / 8))
+ @directory.register class VXA700Radio(chirp_common.CloneModeRadio): """Vertex Standard VXA-700""" @@ -178,10 +185,10 @@ class VXA700Radio(chirp_common.CloneModeRadio): self.process_mmap()
def sync_out(self): - #header[4] = 0x00 <- default - # 0xFF <- air band only - # 0x01 <- air band only - # 0x02 <- air band only + # header[4] = 0x00 <- default + # 0xFF <- air band only + # 0x01 <- air band only + # 0x02 <- air band only try: self.pipe.setTimeout(2) _upload(self) @@ -205,7 +212,8 @@ class VXA700Radio(chirp_common.CloneModeRadio): rf.valid_characters = CHARSET rf.valid_skips = ["", "S"] rf.valid_bands = [(88000000, 165000000)] - rf.valid_tuning_steps = [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] + rf.valid_tuning_steps = \ + [5.0, 10.0, 12.5, 15.0, 20.0, 25.0, 50.0, 100.0] rf.valid_modes = ["AM", "FM"] rf.valid_power_levels = POWER rf.memory_bounds = (1, 100) @@ -232,7 +240,7 @@ class VXA700Radio(chirp_common.CloneModeRadio): mem.empty = True return mem
- if _mem.step & 0x05: # Not sure this is right, but it seems to be + if _mem.step & 0x05: # Not sure this is right, but it seems to be mult = 6250 else: mult = 5000 @@ -274,9 +282,9 @@ class VXA700Radio(chirp_common.CloneModeRadio): self._memobj.invisible_bits[byte] &= ~bit self._memobj.invalid_bits[byte] &= ~bit
- _mem.unknown2 = 0x02 # Channels don't display without this - _mem.unknown7 = 0x01 # some bit in this field is related to - _mem.unknown8 = 0xFF # being able to transmit + _mem.unknown2 = 0x02 # Channels don't display without this + _mem.unknown7 = 0x01 # some bit in this field is related to + _mem.unknown8 = 0xFF # being able to transmit
if chirp_common.required_step(mem.freq) == 12.5: mult = 6250 @@ -296,7 +304,7 @@ class VXA700Radio(chirp_common.CloneModeRadio): try: _mem.power = POWER.index(mem.power) except ValueError: - _mem.power = 3 # High + _mem.power = 3 # High
for i in range(0, 8): try: diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 3d41ee2..0e9f07d 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -58,4 +58,3 @@ ./chirp/drivers/vx6.py ./chirp/drivers/vx7.py ./chirp/drivers/vx8.py -./chirp/drivers/vxa700.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 05e9272663483d41cd79d133f7b165e7955c4ff5
Fix style issues in uv5r.py (#2355)
diff --git a/chirp/drivers/uv5r.py b/chirp/drivers/uv5r.py index 646d6e2..2f6ddad 100644 --- a/chirp/drivers/uv5r.py +++ b/chirp/drivers/uv5r.py @@ -107,9 +107,9 @@ struct { u8 mdfa; u8 mdfb; u8 bcl; - u8 autolk; // NOTE: The UV-6 calls this byte voxenable, but the UV-5R calls - // it autolk. Since this is a minor difference, it will be referred - // to by the wrong name for the UV-6. + u8 autolk; // NOTE: The UV-6 calls this byte voxenable, but the UV-5R + // calls it autolk. Since this is a minor difference, it will + // be referred to by the wrong name for the UV-6. u8 sftd; u8 unknown6[3]; u8 wtled; @@ -279,10 +279,10 @@ struct { vhf_220_radio = "\x02"
BASETYPE_UV5R = ["BFS", "BFB", "N5R-2", "BTS"] -BASETYPE_F11 = ["USA"] +BASETYPE_F11 = ["USA"] BASETYPE_UV82 = ["US2S", "B82S", "BF82"] -BASETYPE_BJ55 = ["BJ55"] # needed for for the Baojie UV-55 in bjuv55.py -BASETYPE_UV6 = ["BF1"] +BASETYPE_BJ55 = ["BJ55"] # needed for for the Baojie UV-55 in bjuv55.py +BASETYPE_UV6 = ["BF1"] BASETYPE_KT980HP = ["BFP3V3 B"] BASETYPE_F8HP = ["BFP3V3 F", "N5R-3", "N5R3"] BASETYPE_LIST = BASETYPE_UV5R + BASETYPE_F11 + BASETYPE_UV82 + \ @@ -320,38 +320,39 @@ VOX_LIST = ["OFF"] + ["%s" % x for x in range(1, 11)] WORKMODE_LIST = ["Frequency", "Channel"]
SETTING_LISTS = { - "almod" : ALMOD_LIST, - "aniid" : PTTID_LIST, - "displayab" : AB_LIST, - "dtmfst" : DTMFST_LIST, - "dtmfspeed" : DTMFSPEED_LIST, - "mdfa" : MODE_LIST, - "mdfb" : MODE_LIST, - "ponmsg" : PONMSG_LIST, - "pttid" : PTTID_LIST, - "rogerrx" : ROGERRX_LIST, - "rpste" : RPSTE_LIST, - "rxled" : COLOR_LIST, - "save" : SAVE_LIST, - "scode" : PTTIDCODE_LIST, - "screv" : RESUME_LIST, - "sftd" : SHIFTD_LIST, - "stedelay" : STEDELAY_LIST, - "step" : STEP_LIST, - "step291" : STEP291_LIST, - "tdrab" : TDRAB_LIST, - "tdrch" : TDRCH_LIST, - "timeout" : TIMEOUT_LIST, - "txled" : COLOR_LIST, - "txpower" : TXPOWER_LIST, - "txpower3" : TXPOWER3_LIST, - "voice" : VOICE_LIST, - "vox" : VOX_LIST, - "widenarr" : BANDWIDTH_LIST, - "workmode" : WORKMODE_LIST, - "wtled" : COLOR_LIST + "almod": ALMOD_LIST, + "aniid": PTTID_LIST, + "displayab": AB_LIST, + "dtmfst": DTMFST_LIST, + "dtmfspeed": DTMFSPEED_LIST, + "mdfa": MODE_LIST, + "mdfb": MODE_LIST, + "ponmsg": PONMSG_LIST, + "pttid": PTTID_LIST, + "rogerrx": ROGERRX_LIST, + "rpste": RPSTE_LIST, + "rxled": COLOR_LIST, + "save": SAVE_LIST, + "scode": PTTIDCODE_LIST, + "screv": RESUME_LIST, + "sftd": SHIFTD_LIST, + "stedelay": STEDELAY_LIST, + "step": STEP_LIST, + "step291": STEP291_LIST, + "tdrab": TDRAB_LIST, + "tdrch": TDRCH_LIST, + "timeout": TIMEOUT_LIST, + "txled": COLOR_LIST, + "txpower": TXPOWER_LIST, + "txpower3": TXPOWER3_LIST, + "voice": VOICE_LIST, + "vox": VOX_LIST, + "widenarr": BANDWIDTH_LIST, + "workmode": WORKMODE_LIST, + "wtled": COLOR_LIST }
+ def _do_status(radio, block): status = chirp_common.Status() status.msg = "Cloning" @@ -359,6 +360,7 @@ def _do_status(radio, block): status.max = radio.get_memsize() radio.status_fn(status)
+ def validate_orig(ident): try: ver = int(ident[4:7]) @@ -367,27 +369,32 @@ def validate_orig(ident): except ValueError: raise errors.RadioError("Radio reported invalid version string")
+ def validate_291(ident): if ident[4:7] != "\x30\x04\x50": raise errors.RadioError("Radio version not supported")
UV5R_MODEL_ORIG = "\x50\xBB\xFF\x01\x25\x98\x4D" -UV5R_MODEL_291 = "\x50\xBB\xFF\x20\x12\x07\x25" -UV5R_MODEL_F11 = "\x50\xBB\xFF\x13\xA1\x11\xDD" +UV5R_MODEL_291 = "\x50\xBB\xFF\x20\x12\x07\x25" +UV5R_MODEL_F11 = "\x50\xBB\xFF\x13\xA1\x11\xDD" UV5R_MODEL_UV82 = "\x50\xBB\xFF\x20\x13\x01\x05" -UV5R_MODEL_UV6 = "\x50\xBB\xFF\x20\x12\x08\x23" -UV5R_MODEL_UV6_ORIG = "\x50\xBB\xFF\x12\x03\x98\x4D" +UV5R_MODEL_UV6 = "\x50\xBB\xFF\x20\x12\x08\x23" +UV5R_MODEL_UV6_ORIG = "\x50\xBB\xFF\x12\x03\x98\x4D" +
def _upper_band_from_data(data): return data[0x03:0x04]
+ def _upper_band_from_image(radio): return _upper_band_from_data(radio.get_mmap())
+ def _firmware_version_from_data(data, version_start, version_stop): version_tag = data[version_start:version_stop] return version_tag
+ def _firmware_version_from_image(radio): version = _firmware_version_from_data(radio.get_mmap(), radio._fw_ver_file_start, @@ -395,15 +402,18 @@ def _firmware_version_from_image(radio): LOG.debug("_firmware_version_from_image: " + util.hexprint(version)) return version
+ def _special_block_from_data(data, special_block_start, special_block_stop): special_block_tag = data[special_block_start:special_block_stop] return special_block_tag
+ def _special_block_from_image(radio): special_block = _special_block_from_data(radio.get_mmap(), 0x0CFA, 0x0D01) LOG.debug("_special_block_from_image: " + util.hexprint(special_block)) return special_block
+ def _do_ident(radio, magic): serial = radio.pipe serial.setTimeout(1) @@ -431,6 +441,7 @@ def _do_ident(radio, magic):
return ident
+ def _read_block(radio, start, size): msg = struct.pack(">BHB", ord("S"), start, size) radio.pipe.write(msg) @@ -460,6 +471,7 @@ def _read_block(radio, start, size):
return chunk
+ def _get_radio_firmware_version(radio): if radio.MODEL == "BJ-UV55": block = _read_block(radio, 0x1FF0, 0x40) @@ -471,11 +483,13 @@ def _get_radio_firmware_version(radio): version = block[48:62] return version
+ def _get_radio_special_block(radio): block = _read_block(radio, 0xCF0, 0x40) special_block = block[2:9] return special_block
+ def _ident_radio(radio): for magic in radio._idents: error = None @@ -490,6 +504,7 @@ def _ident_radio(radio): raise error raise errors.RadioError("Radio did not respond")
+ def _do_download(radio): data = _ident_radio(radio)
@@ -512,6 +527,7 @@ def _do_download(radio): LOG.debug("done.") return memmap.MemoryMap(data)
+ def _send_block(radio, addr, data): msg = struct.pack(">BHB", ord("X"), addr, len(data)) radio.pipe.write(msg + data) @@ -520,6 +536,7 @@ def _send_block(radio, addr, data): if ack != "\x06": raise errors.RadioError("Radio refused to accept block 0x%04x" % addr)
+ def _do_upload(radio): ident = _ident_radio(radio) radio_upper_band = ident[3:4] @@ -554,7 +571,7 @@ def _do_upload(radio):
if len(radio.get_mmap().get_packed()) == 0x1808: print "Old image, not writing aux block" - return # Old image, no aux block + return # Old image, no aux block
if image_version != radio_version: msg = ("Upload finished, but the 'Other Settings' " @@ -580,6 +597,7 @@ UV5R_DTCS = sorted(chirp_common.DTCS_CODES + [645]) UV5R_CHARSET = chirp_common.CHARSET_UPPER_NUMERIC + \ "!@#$%^&*()+-=[]:";'<>?,./"
+ # Uncomment this to actually register this radio in CHIRP @directory.register class BaofengUV5R(chirp_common.CloneModeRadio, @@ -597,8 +615,8 @@ class BaofengUV5R(chirp_common.CloneModeRadio, _vhf_range = (136000000, 174000000) _220_range = (220000000, 260000000) _uhf_range = (400000000, 520000000) - _mem_params = ( 0x1828 # poweron_msg offset - ) + _mem_params = (0x1828 # poweron_msg offset + ) # offset of fw version in image file _fw_ver_file_start = 0x1838 _fw_ver_file_stop = 0x1846 @@ -606,12 +624,13 @@ class BaofengUV5R(chirp_common.CloneModeRadio, @classmethod def get_prompts(cls): rp = chirp_common.RadioPrompts() - rp.experimental = ('Due to the fact that the manufacturer continues to ' - 'release new versions of the firmware with obscure and ' - 'hard-to-track changes, this driver may not work with ' - 'your device. Thus far and to the best knowledge of the ' - 'author, no UV-5R radios have been harmed by using CHIRP. ' - 'However, proceed at your own risk!') + rp.experimental = \ + ('Due to the fact that the manufacturer continues to ' + 'release new versions of the firmware with obscure and ' + 'hard-to-track changes, this driver may not work with ' + 'your device. Thus far and to the best knowledge of the ' + 'author, no UV-5R radios have been harmed by using CHIRP. ' + 'However, proceed at your own risk!') rp.pre_download = _(dedent("""\ 1. Turn radio off. 2. Connect cable to mic/spkr connector. @@ -737,7 +756,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
for char in _nam.name: if str(char) == "\xFF": - char = " " # The UV-5R software may have 0xFF mid-name + char = " " # The UV-5R software may have 0xFF mid-name mem.name += str(char) mem.name = mem.name.rstrip()
@@ -790,15 +809,15 @@ class BaofengUV5R(chirp_common.CloneModeRadio, if not _mem.scan: mem.skip = "S"
- if self.MODEL == "KT-980HP" or self.MODEL == "BF-F8HP": + if self.MODEL == "KT-980HP" or self.MODEL == "BF-F8HP": levels = UV5R_POWER_LEVELS3 else: levels = UV5R_POWER_LEVELS try: mem.power = levels[_mem.lowpower] except IndexError: - print "Radio reported invalid power level %s (in %s)" % ( - _mem.power, levels) + print "Radio reported invalid power level %s (in %s)" % \ + (_mem.power, levels) mem.power = levels[0]
mem.mode = _mem.wide and "FM" or "NFM" @@ -986,13 +1005,13 @@ class BaofengUV5R(chirp_common.CloneModeRadio, basic.append(rs)
rs = RadioSetting("save", "Battery Saver", - RadioSettingValueList(SAVE_LIST, - SAVE_LIST[_settings.save])) + RadioSettingValueList( + SAVE_LIST, SAVE_LIST[_settings.save])) basic.append(rs)
rs = RadioSetting("vox", "VOX Sensitivity", - RadioSettingValueList(VOX_LIST, - VOX_LIST[_settings.vox])) + RadioSettingValueList( + VOX_LIST, VOX_LIST[_settings.vox])) advanced.append(rs)
if self.MODEL == "UV-6": @@ -1014,9 +1033,8 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
if self.MODEL == "UV-6": rs = RadioSetting("tdrch", "Dual Watch Channel", - RadioSettingValueList(TDRCH_LIST, - TDRCH_LIST[ - _settings.tdrch])) + RadioSettingValueList( + TDRCH_LIST, TDRCH_LIST[_settings.tdrch])) advanced.append(rs)
rs = RadioSetting("tdrab", "Dual Watch TX Priority", @@ -1024,9 +1042,8 @@ class BaofengUV5R(chirp_common.CloneModeRadio, advanced.append(rs) else: rs = RadioSetting("tdrab", "Dual Watch TX Priority", - RadioSettingValueList(TDRAB_LIST, - TDRAB_LIST[ - _settings.tdrab])) + RadioSettingValueList( + TDRAB_LIST, TDRAB_LIST[_settings.tdrab])) advanced.append(rs)
if self.MODEL == "UV-6": @@ -1039,8 +1056,8 @@ class BaofengUV5R(chirp_common.CloneModeRadio, else: val = _settings.almod rs = RadioSetting("almod", "Alarm Mode", - RadioSettingValueList(ALMOD_LIST, - ALMOD_LIST[val])) + RadioSettingValueList( + ALMOD_LIST, ALMOD_LIST[val])) advanced.append(rs)
rs = RadioSetting("beep", "Beep", @@ -1048,9 +1065,8 @@ class BaofengUV5R(chirp_common.CloneModeRadio, basic.append(rs)
rs = RadioSetting("timeout", "Timeout Timer", - RadioSettingValueList(TIMEOUT_LIST, - TIMEOUT_LIST[ - _settings.timeout])) + RadioSettingValueList( + TIMEOUT_LIST, TIMEOUT_LIST[_settings.timeout])) basic.append(rs)
if self._is_orig() and self._my_version() < 251: @@ -1059,25 +1075,24 @@ class BaofengUV5R(chirp_common.CloneModeRadio, advanced.append(rs) else: rs = RadioSetting("voice", "Voice", - RadioSettingValueList(VOICE_LIST, - VOICE_LIST[ - _settings.voice])) + RadioSettingValueList( + VOICE_LIST, VOICE_LIST[_settings.voice])) advanced.append(rs)
rs = RadioSetting("screv", "Scan Resume", - RadioSettingValueList(RESUME_LIST, - RESUME_LIST[_settings.screv])) + RadioSettingValueList( + RESUME_LIST, RESUME_LIST[_settings.screv])) advanced.append(rs)
if self.MODEL != "UV-6": rs = RadioSetting("mdfa", "Display Mode (A)", - RadioSettingValueList(MODE_LIST, - MODE_LIST[_settings.mdfa])) + RadioSettingValueList( + MODE_LIST, MODE_LIST[_settings.mdfa])) basic.append(rs)
rs = RadioSetting("mdfb", "Display Mode (B)", - RadioSettingValueList(MODE_LIST, - MODE_LIST[_settings.mdfb])) + RadioSettingValueList( + MODE_LIST, MODE_LIST[_settings.mdfb])) basic.append(rs)
rs = RadioSetting("bcl", "Busy Channel Lockout", @@ -1095,21 +1110,18 @@ class BaofengUV5R(chirp_common.CloneModeRadio,
if self.MODEL != "UV-6": rs = RadioSetting("wtled", "Standby LED Color", - RadioSettingValueList(COLOR_LIST, - COLOR_LIST[ - _settings.wtled])) + RadioSettingValueList( + COLOR_LIST, COLOR_LIST[_settings.wtled])) basic.append(rs)
rs = RadioSetting("rxled", "RX LED Color", - RadioSettingValueList(COLOR_LIST, - COLOR_LIST[ - _settings.rxled])) + RadioSettingValueList( + COLOR_LIST, COLOR_LIST[_settings.rxled])) basic.append(rs)
rs = RadioSetting("txled", "TX LED Color", - RadioSettingValueList(COLOR_LIST, - COLOR_LIST[ - _settings.txled])) + RadioSettingValueList( + COLOR_LIST, COLOR_LIST[_settings.txled])) basic.append(rs)
if self.MODEL == "UV-82": @@ -1117,9 +1129,9 @@ class BaofengUV5R(chirp_common.CloneModeRadio, RadioSettingValueBoolean(_settings.roger)) basic.append(rs) rs = RadioSetting("rogerrx", "Roger Beep (RX)", - RadioSettingValueList(ROGERRX_LIST, - ROGERRX_LIST[ - _settings.rogerrx])) + RadioSettingValueList( + ROGERRX_LIST, + ROGERRX_LIST[_settings.rogerrx])) basic.append(rs) else: rs = RadioSetting("roger", "Roger Beep", @@ -1131,13 +1143,13 @@ class BaofengUV5R(chirp_common.CloneModeRadio, advanced.append(rs)
rs = RadioSetting("rpste", "Squelch Tail Eliminate (repeater)", - RadioSettingValueList(RPSTE_LIST, - RPSTE_LIST[_settings.rpste])) + RadioSettingValueList( + RPSTE_LIST, RPSTE_LIST[_settings.rpste])) advanced.append(rs)
rs = RadioSetting("rptrl", "STE Repeater Delay", - RadioSettingValueList(STEDELAY_LIST, - STEDELAY_LIST[_settings.rptrl])) + RadioSettingValueList( + STEDELAY_LIST, STEDELAY_LIST[_settings.rptrl])) advanced.append(rs)
if self.MODEL != "UV-6": @@ -1197,28 +1209,27 @@ class BaofengUV5R(chirp_common.CloneModeRadio, if self.MODEL != "UV-6": _msg = self._memobj.sixpoweron_msg rs = RadioSetting("sixpoweron_msg.line1", "6+Power-On Message 1", - RadioSettingValueString(0, 7, _filter( - _msg.line1))) + RadioSettingValueString( + 0, 7, _filter(_msg.line1))) other.append(rs) rs = RadioSetting("sixpoweron_msg.line2", "6+Power-On Message 2", - RadioSettingValueString(0, 7, _filter( - _msg.line2))) + RadioSettingValueString( + 0, 7, _filter(_msg.line2))) other.append(rs)
_msg = self._memobj.poweron_msg rs = RadioSetting("poweron_msg.line1", "Power-On Message 1", - RadioSettingValueString(0, 7, _filter( - _msg.line1))) + RadioSettingValueString( + 0, 7, _filter(_msg.line1))) other.append(rs) rs = RadioSetting("poweron_msg.line2", "Power-On Message 2", - RadioSettingValueString(0, 7, _filter( - _msg.line2))) + RadioSettingValueString( + 0, 7, _filter(_msg.line2))) other.append(rs)
rs = RadioSetting("ponmsg", "Power-On Message", - RadioSettingValueList(PONMSG_LIST, - PONMSG_LIST[ - _settings.ponmsg])) + RadioSettingValueList( + PONMSG_LIST, PONMSG_LIST[_settings.ponmsg])) other.append(rs)
if self._is_orig(): @@ -1259,15 +1270,14 @@ class BaofengUV5R(chirp_common.CloneModeRadio, group.append(workmode)
rs = RadioSetting("displayab", "Display", - RadioSettingValueList(AB_LIST, - AB_LIST[ - _settings.displayab])) + RadioSettingValueList( + AB_LIST, AB_LIST[_settings.displayab])) workmode.append(rs)
rs = RadioSetting("workmode", "VFO/MR Mode", - RadioSettingValueList(WORKMODE_LIST, - WORKMODE_LIST[ - _settings.workmode])) + RadioSettingValueList( + WORKMODE_LIST, + WORKMODE_LIST[_settings.workmode])) workmode.append(rs)
rs = RadioSetting("keylock", "Keypad Lock", @@ -1285,10 +1295,10 @@ class BaofengUV5R(chirp_common.CloneModeRadio, workmode.append(rs)
def convert_bytes_to_freq(bytes): - real_freq = 0 - for byte in bytes: - real_freq = (real_freq * 10) + byte - return chirp_common.format_freq(real_freq * 10) + real_freq = 0 + for byte in bytes: + real_freq = (real_freq * 10) + byte + return chirp_common.format_freq(real_freq * 10)
def my_validate(value): value = chirp_common.parse_freq(value) @@ -1319,20 +1329,20 @@ class BaofengUV5R(chirp_common.CloneModeRadio, workmode.append(rs)
rs = RadioSetting("vfoa.sftd", "VFO A Shift", - RadioSettingValueList(SHIFTD_LIST, - SHIFTD_LIST[_vfoa.sftd])) + RadioSettingValueList( + SHIFTD_LIST, SHIFTD_LIST[_vfoa.sftd])) workmode.append(rs)
rs = RadioSetting("vfob.sftd", "VFO B Shift", - RadioSettingValueList(SHIFTD_LIST, - SHIFTD_LIST[_vfob.sftd])) + RadioSettingValueList( + SHIFTD_LIST, SHIFTD_LIST[_vfob.sftd])) workmode.append(rs)
def convert_bytes_to_offset(bytes): - real_offset = 0 - for byte in bytes: - real_offset = (real_offset * 10) + byte - return chirp_common.format_freq(real_offset * 10000) + real_offset = 0 + for byte in bytes: + real_offset = (real_offset * 10) + byte + return chirp_common.format_freq(real_offset * 10000)
def apply_offset(setting, obj): value = chirp_common.parse_freq(str(setting.value)) / 10000 @@ -1340,89 +1350,84 @@ class BaofengUV5R(chirp_common.CloneModeRadio, obj.offset[i] = value % 10 value /= 10
- val1a = RadioSettingValueString(0, 10, - convert_bytes_to_offset( - _vfoa.offset)) - rs = RadioSetting("vfoa.offset", "VFO A Offset (0.00-69.95)", val1a) + val1a = RadioSettingValueString( + 0, 10, convert_bytes_to_offset(_vfoa.offset)) + rs = RadioSetting("vfoa.offset", + "VFO A Offset (0.00-69.95)", val1a) rs.set_apply_callback(apply_offset, _vfoa) workmode.append(rs)
- val1b = RadioSettingValueString(0, 10, - convert_bytes_to_offset( - _vfob.offset)) - rs = RadioSetting("vfob.offset", "VFO B Offset (0.00-69.95)", val1b) + val1b = RadioSettingValueString( + 0, 10, convert_bytes_to_offset(_vfob.offset)) + rs = RadioSetting("vfob.offset", + "VFO B Offset (0.00-69.95)", val1b) rs.set_apply_callback(apply_offset, _vfob) workmode.append(rs)
if self.MODEL == "KT-980HP" or self.MODEL == "BF-F8HP": rs = RadioSetting("vfoa.txpower3", "VFO A Power", - RadioSettingValueList(TXPOWER3_LIST, - TXPOWER3_LIST[ - _vfoa.txpower3])) + RadioSettingValueList( + TXPOWER3_LIST, + TXPOWER3_LIST[_vfoa.txpower3])) workmode.append(rs)
rs = RadioSetting("vfob.txpower3", "VFO B Power", - RadioSettingValueList(TXPOWER3_LIST, - TXPOWER3_LIST[ - _vfob.txpower3])) + RadioSettingValueList( + TXPOWER3_LIST, + TXPOWER3_LIST[_vfob.txpower3])) workmode.append(rs) else: rs = RadioSetting("vfoa.txpower", "VFO A Power", - RadioSettingValueList(TXPOWER_LIST, - TXPOWER_LIST[ - _vfoa.txpower])) + RadioSettingValueList( + TXPOWER_LIST, + TXPOWER_LIST[_vfoa.txpower])) workmode.append(rs)
rs = RadioSetting("vfob.txpower", "VFO B Power", - RadioSettingValueList(TXPOWER_LIST, - TXPOWER_LIST[ - _vfob.txpower])) + RadioSettingValueList( + TXPOWER_LIST, + TXPOWER_LIST[_vfob.txpower])) workmode.append(rs)
- rs = RadioSetting("vfoa.widenarr", "VFO A Bandwidth", - RadioSettingValueList(BANDWIDTH_LIST, - BANDWIDTH_LIST[ - _vfoa.widenarr])) + RadioSettingValueList( + BANDWIDTH_LIST, + BANDWIDTH_LIST[_vfoa.widenarr])) workmode.append(rs)
rs = RadioSetting("vfob.widenarr", "VFO B Bandwidth", - RadioSettingValueList(BANDWIDTH_LIST, - BANDWIDTH_LIST[ - _vfob.widenarr])) + RadioSettingValueList( + BANDWIDTH_LIST, + BANDWIDTH_LIST[_vfob.widenarr])) workmode.append(rs)
rs = RadioSetting("vfoa.scode", "VFO A PTT-ID", - RadioSettingValueList(PTTIDCODE_LIST, - PTTIDCODE_LIST[ - _vfoa.scode])) + RadioSettingValueList( + PTTIDCODE_LIST, PTTIDCODE_LIST[_vfoa.scode])) workmode.append(rs)
rs = RadioSetting("vfob.scode", "VFO B PTT-ID", - RadioSettingValueList(PTTIDCODE_LIST, - PTTIDCODE_LIST[ - _vfob.scode])) + RadioSettingValueList( + PTTIDCODE_LIST, PTTIDCODE_LIST[_vfob.scode])) workmode.append(rs)
if not self._is_orig(): rs = RadioSetting("vfoa.step", "VFO A Tuning Step", - RadioSettingValueList(STEP291_LIST, - STEP291_LIST[ - _vfoa.step])) + RadioSettingValueList( + STEP291_LIST, STEP291_LIST[_vfoa.step])) workmode.append(rs) rs = RadioSetting("vfob.step", "VFO B Tuning Step", - RadioSettingValueList(STEP291_LIST, - STEP291_LIST[ - _vfob.step])) + RadioSettingValueList( + STEP291_LIST, STEP291_LIST[_vfob.step])) workmode.append(rs) else: rs = RadioSetting("vfoa.step", "VFO A Tuning Step", - RadioSettingValueList(STEP_LIST, - STEP_LIST[_vfoa.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[_vfoa.step])) workmode.append(rs) rs = RadioSetting("vfob.step", "VFO B Tuning Step", - RadioSettingValueList(STEP_LIST, - STEP_LIST[_vfob.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[_vfob.step])) workmode.append(rs)
fm_preset = RadioSettingGroup("fm_preset", "FM Radio Preset") @@ -1433,7 +1438,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio, else: preset = 76.0 rs = RadioSetting("fm_presets", "FM Preset(MHz)", - RadioSettingValueFloat(65, 116.1, preset, 0.1, 1)) + RadioSettingValueFloat(65, 116.1, preset, 0.1, 1)) fm_preset.append(rs)
dtmf = RadioSettingGroup("dtmf", "DTMF Settings") @@ -1447,6 +1452,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio, val.set_charset(dtmfchars) rs = RadioSetting("pttid/%i.code" % i, "PTT ID Code %i" % (i + 1), val) + def apply_code(setting, obj): code = [] for j in range(0, 5): @@ -1463,6 +1469,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio, val = RadioSettingValueString(0, 5, _code, False) val.set_charset(dtmfchars) rs = RadioSetting("ani.code", "ANI Code", val) + def apply_code(setting, obj): code = [] for j in range(0, 5): @@ -1484,6 +1491,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio, val = RadioSettingValueString(0, 3, _code, False) val.set_charset(dtmfchars) rs = RadioSetting("ani.alarmcode", "Alarm Code", val) + def apply_code(setting, obj): alarmcode = [] for j in range(0, 3): @@ -1518,7 +1526,6 @@ class BaofengUV5R(chirp_common.CloneModeRadio, DTMFSPEED_LIST[val])) dtmf.append(rs)
- #if not self._is_orig(): if not self._my_version() < 291: service = RadioSettingGroup("service", "Service Settings") group.append(service) @@ -1531,8 +1538,10 @@ class BaofengUV5R(chirp_common.CloneModeRadio, elif band == "uhf": _obj = self._memobj.squelch_new.uhf name = "%s Squelch %i" % (band.upper(), index) - rs = RadioSetting(key, name, RadioSettingValueInteger( - 0, 123, getattr(_obj, "sql%i" % (index)))) + rs = RadioSetting(key, name, + RadioSettingValueInteger( + 0, 123, + getattr(_obj, "sql%i" % (index)))) service.append(rs)
return group @@ -1550,7 +1559,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio, _settings = self._memobj.settings for element in settings: if not isinstance(element, RadioSetting): - if element.get_name() == "fm_preset" : + if element.get_name() == "fm_preset": self._set_fm_preset(element) else: self.set_settings(element) @@ -1594,6 +1603,7 @@ class BaofengUV5R(chirp_common.CloneModeRadio, print element.get_name() raise
+ @directory.register class BaofengF11Radio(BaofengUV5R): VENDOR = "Baofeng" @@ -1605,6 +1615,7 @@ class BaofengF11Radio(BaofengUV5R): # Override this for F11 to always return False return False
+ @directory.register class BaofengUV82Radio(BaofengUV5R): MODEL = "UV-82" @@ -1617,6 +1628,7 @@ class BaofengUV82Radio(BaofengUV5R): # Override this for UV82 to always return False return False
+ @directory.register class BaofengUV6Radio(BaofengUV5R): """Baofeng UV-6/UV-7""" @@ -1648,6 +1660,7 @@ class BaofengUV6Radio(BaofengUV5R): # Override this for UV6 to always return False return False
+ @directory.register class IntekKT980Radio(BaofengUV5R): VENDOR = "Intek" @@ -1666,6 +1679,7 @@ class IntekKT980Radio(BaofengUV5R): # Override this for KT980HP to always return False return False
+ @directory.register class BaofengBFF8HPRadio(BaofengUV5R): VENDOR = "Baofeng" diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 0e9f07d..cb22466 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -48,7 +48,6 @@ ./chirp/drivers/tk8102.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/uv5r.py ./chirp/drivers/uvb5.py ./chirp/drivers/vx170.py ./chirp/drivers/vx2.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 80f947919eb7989f6b5db1c5037b2714394258d6
Fix style issues in uvb5.py (#2355)
diff --git a/chirp/drivers/uvb5.py b/chirp/drivers/uvb5.py index 2a9f5b8..d336a06 100644 --- a/chirp/drivers/uvb5.py +++ b/chirp/drivers/uvb5.py @@ -169,6 +169,7 @@ struct { } test; """
+ def do_ident(radio): radio.pipe.setTimeout(3) radio.pipe.write("PROGRAM") @@ -185,6 +186,7 @@ def do_ident(radio): if ack != "\x06": raise errors.RadioError("Radio did not ack ident")
+ def do_status(radio, direction, addr): status = chirp_common.Status() status.msg = "Cloning %s radio" % direction @@ -192,6 +194,7 @@ def do_status(radio, direction, addr): status.max = 0x1000 radio.status_fn(status)
+ def do_download(radio): do_ident(radio) data = "KT511 Radio Program data v1.08\x00\x00" @@ -218,6 +221,7 @@ def do_download(radio):
return memmap.MemoryMap(data)
+ def do_upload(radio): do_ident(radio) data = radio._mmap[0x0030:] @@ -241,9 +245,10 @@ SPECIALS = { POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1), chirp_common.PowerLevel("High", watts=5)]
+ @directory.register class BaofengUVB5(chirp_common.CloneModeRadio, - chirp_common.ExperimentalRadio): + chirp_common.ExperimentalRadio): """Baofeng UV-B5""" VENDOR = "Baofeng" MODEL = "UV-B5" @@ -254,12 +259,13 @@ class BaofengUVB5(chirp_common.CloneModeRadio, @classmethod def get_prompts(cls): rp = chirp_common.RadioPrompts() - rp.experimental = ('This version of the UV-B5 driver allows you to ' - 'modify the Test Mode settings of your radio. This has been ' - 'tested and reports from other users indicate that it is a ' - 'safe thing to do. However, modifications to these values may ' - 'have unintended consequences, including damage to your ' - 'device. You have been warned. Proceed at your own risk!') + rp.experimental = \ + ('This version of the UV-B5 driver allows you to ' + 'modify the Test Mode settings of your radio. This has been ' + 'tested and reports from other users indicate that it is a ' + 'safe thing to do. However, modifications to these values may ' + 'have unintended consequences, including damage to your ' + 'device. You have been warned. Proceed at your own risk!') rp.pre_download = _(dedent("""\ 1. Turn radio off. 2. Connect cable to mic/spkr connector. @@ -393,8 +399,8 @@ class BaofengUVB5(chirp_common.CloneModeRadio, mem.power = POWER_LEVELS[_mem.highpower]
if mem.freq == mem.offset and mem.duplex == "-": - mem.duplex = "off" - mem.offset = 0 + mem.duplex = "off" + mem.offset = 0
if _nam: for char in _nam: @@ -471,16 +477,15 @@ class BaofengUVB5(chirp_common.CloneModeRadio, msgs = chirp_common.CloneModeRadio.validate_memory(self, mem)
if (mem.duplex == "split" and abs(mem.freq - mem.offset) > 69995000) \ - or (mem.duplex in ["+", "-"] and mem.offset > 69995000) : + or (mem.duplex in ["+", "-"] and mem.offset > 69995000): msgs.append(chirp_common.ValidationError( "Max split is 69.995MHz")) return msgs
- def get_settings(self): _settings = self._memobj.settings basic = RadioSettingGroup("basic", "Basic Settings") - + group = RadioSettings(basic)
options = ["Time", "Carrier", "Search"] @@ -491,50 +496,52 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
options = ["Off"] + ["%s min" % x for x in range(1, 8)] rs = RadioSetting("timeout", "Time Out Timer", - RadioSettingValueList(options, - options[_settings.timeout])) + RadioSettingValueList( + options, options[_settings.timeout])) basic.append(rs)
options = ["A", "B"] rs = RadioSetting("freqmode_ab", "Frequency Mode", - RadioSettingValueList(options, - options[_settings.freqmode_ab])) + RadioSettingValueList( + options, options[_settings.freqmode_ab])) basic.append(rs)
options = ["Frequency Mode", "Channel Mode"] rs = RadioSetting("workmode_a", "Radio Work Mode(A)", - RadioSettingValueList(options, - options[_settings.workmode_a])) + RadioSettingValueList( + options, options[_settings.workmode_a])) basic.append(rs)
rs = RadioSetting("workmode_b", "Radio Work Mode(B)", - RadioSettingValueList(options, - options[_settings.workmode_b])) + RadioSettingValueList( + options, options[_settings.workmode_b])) basic.append(rs)
options = ["Frequency", "Name", "Channel"] rs = RadioSetting("mdf_a", "Display Format(F1)", - RadioSettingValueList(options, - options[_settings.mdf_a])) + RadioSettingValueList( + options, options[_settings.mdf_a])) basic.append(rs)
rs = RadioSetting("mdf_b", "Display Format(F2)", - RadioSettingValueList(options, - options[_settings.mdf_b])) + RadioSettingValueList( + options, options[_settings.mdf_b])) basic.append(rs)
rs = RadioSetting("mem_chan_a", "Mem Channel (A)", - RadioSettingValueInteger(1, 99, _settings.mem_chan_a)) + RadioSettingValueInteger( + 1, 99, _settings.mem_chan_a)) basic.append(rs)
rs = RadioSetting("mem_chan_b", "Mem Channel (B)", - RadioSettingValueInteger(1, 99, _settings.mem_chan_b)) + RadioSettingValueInteger( + 1, 99, _settings.mem_chan_b)) basic.append(rs)
options = ["Off", "BOT", "EOT", "Both"] rs = RadioSetting("pttid", "PTT-ID", - RadioSettingValueList(options, - options[_settings.pttid])) + RadioSettingValueList( + options, options[_settings.pttid])) basic.append(rs)
dtmfchars = "0123456789ABCD*#" @@ -543,6 +550,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio, val = RadioSettingValueString(0, 6, _code, False) val.set_charset(dtmfchars) rs = RadioSetting("pttid.code", "PTT-ID Code", val) + def apply_code(setting, obj): code = [] for j in range(0, 6): @@ -564,8 +572,8 @@ class BaofengUVB5(chirp_common.CloneModeRadio,
options = ["Frequency Mode", "Channel Mode"] rs = RadioSetting("workmode_fm", "FM Work Mode", - RadioSettingValueList(options, - options[_settings.workmode_fm])) + RadioSettingValueList( + options, options[_settings.workmode_fm])) basic.append(rs)
options = ["Current Frequency", "F1 Frequency", "F2 Frequency"] @@ -593,7 +601,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio, basic.append(rs)
rs = RadioSetting("save_funct", "Save Mode", - RadioSettingValueBoolean( _settings.save_funct)) + RadioSettingValueBoolean(_settings.save_funct)) basic.append(rs)
rs = RadioSetting("fm", "FM Function", @@ -620,6 +628,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio, _limit = int(self._memobj.limits.lower_vhf) / 10 rs = RadioSetting("limits.lower_vhf", "VHF Lower Limit (MHz)", RadioSettingValueInteger(128, 270, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.lower_vhf = value @@ -629,6 +638,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio, _limit = int(self._memobj.limits.upper_vhf) / 10 rs = RadioSetting("limits.upper_vhf", "VHF Upper Limit (MHz)", RadioSettingValueInteger(128, 270, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.upper_vhf = value @@ -638,6 +648,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio, _limit = int(self._memobj.limits.lower_uhf) / 10 rs = RadioSetting("limits.lower_uhf", "UHF Lower Limit (MHz)", RadioSettingValueInteger(400, 520, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.lower_uhf = value @@ -647,6 +658,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio, _limit = int(self._memobj.limits.upper_uhf) / 10 rs = RadioSetting("limits.upper_uhf", "UHF Upper Limit (MHz)", RadioSettingValueInteger(400, 520, _limit)) + def apply_limit(setting, obj): value = int(setting.value) * 10 obj.upper_uhf = value @@ -664,8 +676,8 @@ class BaofengUVB5(chirp_common.CloneModeRadio, used = False preset = 65 rs = RadioSetting("fm_presets_%1i" % i, "FM Preset %i" % (i + 1), - RadioSettingValueBoolean(used), - RadioSettingValueFloat(65, 108, preset, 0.1, 1)) + RadioSettingValueBoolean(used), + RadioSettingValueFloat(65, 108, preset, 0.1, 1)) fm_preset.append(rs)
testmode = RadioSettingGroup("testmode", "Test Mode Settings") @@ -678,33 +690,39 @@ class BaofengUVB5(chirp_common.CloneModeRadio, powernamedata = ["Hi", "Lo"] powerkeydata = ["hipwr", "lopwr"]
- for power in range (0, 2): + for power in range(0, 2): for index in range(0, 8): key = "test.vhf%s%i" % (powerkeydata[power], index) name = "%s Mhz %s Power" % (vhfdata[index], powernamedata[power]) - rs = RadioSetting(key, name, RadioSettingValueInteger(0, 255, - getattr(self._memobj.test, "vhf%s%i" - % (powerkeydata[power], index)))) + rs = RadioSetting( + key, name, RadioSettingValueInteger( + 0, 255, getattr( + self._memobj.test, + "vhf%s%i" % (powerkeydata[power], index)))) testmode.append(rs)
- for power in range (0, 2): + for power in range(0, 2): for index in range(0, 8): key = "test.uhf%s%i" % (powerkeydata[power], index) name = "%s Mhz %s Power" % (uhfdata[index], powernamedata[power]) - rs = RadioSetting(key, name, RadioSettingValueInteger(0, 255, - getattr(self._memobj.test, "uhf%s%i" - % (powerkeydata[power], index)))) + rs = RadioSetting( + key, name, RadioSettingValueInteger( + 0, 255, getattr( + self._memobj.test, + "uhf%s%i" % (powerkeydata[power], index)))) testmode.append(rs)
for band in ["vhf", "uhf"]: for index in range(0, 10): key = "test.%ssquelch%i" % (band, index) name = "%s Squelch %i" % (band.upper(), index) - rs = RadioSetting(key, name, RadioSettingValueInteger(0, 255, - getattr(self._memobj.test, "%ssquelch%i" - % (band, index)))) + rs = RadioSetting( + key, name, RadioSettingValueInteger( + 0, 255, getattr( + self._memobj.test, + "%ssquelch%i" % (band, index)))) testmode.append(rs)
return group @@ -713,7 +731,7 @@ class BaofengUVB5(chirp_common.CloneModeRadio, _settings = self._memobj.settings for element in settings: if not isinstance(element, RadioSetting): - if element.get_name() == "fm_preset" : + if element.get_name() == "fm_preset": self._set_fm_preset(element) else: self.set_settings(element) @@ -766,7 +784,6 @@ class BaofengUVB5(chirp_common.CloneModeRadio, print element.get_name() raise
- @classmethod def match_model(cls, filedata, filename): return (filedata.startswith("KT511 Radio Program data") and diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index cb22466..0669c24 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -48,7 +48,6 @@ ./chirp/drivers/tk8102.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py -./chirp/drivers/uvb5.py ./chirp/drivers/vx170.py ./chirp/drivers/vx2.py ./chirp/drivers/vx3.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 65001f06deb9ab778e50659a30ca3f804f53ea25
Fix style issues in rfinder.py (#2355)
diff --git a/chirp/drivers/rfinder.py b/chirp/drivers/rfinder.py index a82bc21..ee0bc79 100644 --- a/chirp/drivers/rfinder.py +++ b/chirp/drivers/rfinder.py @@ -18,7 +18,6 @@ import hashlib import re
from math import pi, cos, acos, sin, atan2 - from chirp import chirp_common, CHIRP_VERSION
EARTH_RADIUS = 3963.1 @@ -47,18 +46,22 @@ SCHEMA = [ "DOC_ID", ]
+ def deg2rad(deg): """Convert degrees to radians""" return deg * (pi / 180)
+ def rad2deg(rad): """Convert radians to degrees""" return rad / (pi / 180)
+ def dm2deg(degrees, minutes): """Convert degrees and minutes to decimal degrees""" return degrees + (minutes / 60.0)
+ def deg2dm(decdeg): """Convert decimal degrees to degrees and minutes""" degrees = int(decdeg) @@ -66,6 +69,7 @@ def deg2dm(decdeg):
return degrees, minutes
+ def nmea2deg(nmea, direction="N"): """Convert NMEA-encoded value to float""" deg = int(nmea) / 100 @@ -81,35 +85,37 @@ def nmea2deg(nmea, direction="N"):
return dm2deg(deg, minutes) * sign
+ def deg2nmea(deg): """Convert degrees to a NMEA-encoded value""" degrees, minutes = deg2dm(deg)
return (degrees * 100) + minutes
+ def meters2feet(meters): """Convert meters to feet""" return meters * 3.2808399
+ def feet2meters(feet): """Convert feet to meters""" return feet * 0.3048
+ def distance(lat_a, lon_a, lat_b, lon_b): """Calculate the distance between two points""" lat_a = deg2rad(lat_a) lon_a = deg2rad(lon_a) - + lat_b = deg2rad(lat_b) lon_b = deg2rad(lon_b) - + earth_radius = EARTH_RADIUS - - tmp = (cos(lat_a) * cos(lon_a) * \ - cos(lat_b) * cos(lon_b)) + \ - (cos(lat_a) * sin(lon_a) * \ - cos(lat_b) * sin(lon_b)) + \ - (sin(lat_a) * sin(lat_b)) + + tmp = (cos(lat_a) * cos(lon_a) * cos(lat_b) * cos(lon_b)) + \ + (cos(lat_a) * sin(lon_a) * cos(lat_b) * sin(lon_b)) + \ + (sin(lat_a) * sin(lat_b))
# Correct round-off error (which is just *silly*) if tmp > 1: @@ -121,6 +127,7 @@ def distance(lat_a, lon_a, lat_b, lon_b):
return dist * earth_radius
+ def bearing(lat_a, lon_a, lat_b, lon_b): """Calculate the bearing between two points""" lat_me = deg2rad(lat_a) @@ -135,6 +142,7 @@ def bearing(lat_a, lon_a, lat_b, lon_b):
return (bear + 360) % 360
+ def fuzzy_to(lat_a, lon_a, lat_b, lon_b): """Calculate a fuzzy distance to a point""" bear = bearing(lat_a, lon_a, lat_b, lon_b) @@ -155,6 +163,7 @@ def fuzzy_to(lat_a, lon_a, lat_b, lon_b):
return direction
+ class RFinderParser: """Parser for RFinder's data format""" def __init__(self, lat, lon): @@ -168,18 +177,18 @@ class RFinderParser: print user print pw args = { - "email" : urllib.quote_plus(user), - "pass" : hashlib.new("md5", pw).hexdigest(), - "lat" : "%7.5f" % coords[0], - "lon" : "%7.5f" % coords[1], + "email": urllib.quote_plus(user), + "pass": hashlib.new("md5", pw).hexdigest(), + "lat": "%7.5f" % coords[0], + "lon": "%7.5f" % coords[1], "radius": "%i" % radius, - "vers" : "CH%s" % CHIRP_VERSION, + "vers": "CH%s" % CHIRP_VERSION, }
- _url = "https://www.rfinder.net/query.php?%s" % (\ - "&".join(["%s=%s" % (k,v) for k,v in args.items()])) + _url = "https://www.rfinder.net/query.php?%s" % \ + ("&".join(["%s=%s" % (k, v) for k, v in args.items()]))
- print "Query URL: %s" % _url + print "Query URL: %s" % _url
f = urllib.urlopen(_url) data = f.read() @@ -247,7 +256,8 @@ class RFinderParser: number += 1 self.__memories.append(mem) except Exception, e: - import traceback, sys + import traceback + import sys traceback.print_exc(file=sys.stdout) print "Error in received data, cannot continue" print e @@ -259,6 +269,7 @@ class RFinderParser: """Return the Memory objects associated with the fetched data""" return self.__memories
+ class RFinderRadio(chirp_common.NetworkSourceRadio): """A network source radio that supports the RFinder repeater directory""" VENDOR = "ITWeRKS" @@ -266,13 +277,13 @@ class RFinderRadio(chirp_common.NetworkSourceRadio):
def __init__(self, *args, **kwargs): chirp_common.NetworkSourceRadio.__init__(self, *args, **kwargs) - + self._lat = 0 self._lon = 0 self._user = "" self._pass = "" self._miles = 25 - + self._rfp = None
def set_params(self, (lat, lon), miles, email, password): @@ -290,7 +301,7 @@ class RFinderRadio(chirp_common.NetworkSourceRadio): self._pass, (self._lat, self._lon), self._miles)) - + def get_features(self): if not self._rfp: self.do_fetch() @@ -309,6 +320,7 @@ class RFinderRadio(chirp_common.NetworkSourceRadio):
return self._rfp.get_memories()[number-1]
+ def _test(): rfp = RFinderParser() data = rfp.fetch_data("KK7DS", "dsmith@danplanet.com", diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 0669c24..2fbf1ce 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -38,7 +38,6 @@ ./chirp/drivers/kyd.py ./chirp/drivers/leixen.py ./chirp/drivers/puxing.py -./chirp/drivers/rfinder.py ./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID e4d862d94343c27b80b8c94fc49bc8faf558f473
Fix style issues in idrp.py (#2355)
diff --git a/chirp/drivers/idrp.py b/chirp/drivers/idrp.py index 012bb46..3ba3f9b 100644 --- a/chirp/drivers/idrp.py +++ b/chirp/drivers/idrp.py @@ -13,12 +13,14 @@ # You should have received a copy of the GNU General Public License # along with this program. If not, see http://www.gnu.org/licenses/.
-import serial, logging +import serial +import logging
from chirp import chirp_common, errors, util
LOG = logging.getLogger(__name__)
+ def parse_frames(buf): """Parse frames from the radio""" frames = [] @@ -36,6 +38,7 @@ def parse_frames(buf):
return frames
+ def send(pipe, buf): """Send data in @buf to @pipe""" pipe.write("\xfe\xfe%s\xfd" % buf) @@ -52,10 +55,12 @@ def send(pipe, buf):
return parse_frames(data)
+ def send_magic(pipe): """Send the magic wakeup call to @pipe""" send(pipe, ("\xfe" * 15) + "\x01\x7f\x19")
+ def drain(pipe): """Chew up any data waiting on @pipe""" while True: @@ -63,6 +68,7 @@ def drain(pipe): if not buf: break
+ def set_freq(pipe, freq): """Set the frequency of the radio on @pipe to @freq""" freqbcd = util.bcd_encode(freq, bigendian=False, width=9) @@ -77,7 +83,8 @@ def set_freq(pipe, freq): return True
raise errors.InvalidDataError("Repeater reported error") - + + def get_freq(pipe): """Get the frequency of the radio attached to @pipe""" buf = "\x01\x7f\x1a\x09" @@ -104,15 +111,16 @@ RP_IMMUTABLE = ["number", "skip", "bank", "extd_number", "name", "rtone", "ctone", "dtcs", "tmode", "dtcs_polarity", "skip", "duplex", "offset", "mode", "tuning_step", "bank_index"]
+ class IDRPx000V(chirp_common.LiveRadio): """Icom IDRP-*""" BAUD_RATE = 19200 VENDOR = "Icom" MODEL = "ID-2000V/4000V/2D/2V"
- _model = "0000" # Unknown + _model = "0000" # Unknown mem_upper_limit = 0 - + def get_features(self): rf = chirp_common.RadioFeatures() rf.valid_modes = ["DV"] @@ -129,7 +137,7 @@ class IDRPx000V(chirp_common.LiveRadio): rf.has_mode = False rf.has_name = False rf.has_offset = False - rf.has_tuning_step = False + rf.has_tuning_step = False rf.memory_bounds = (0, 0) return rf
@@ -153,11 +161,13 @@ class IDRPx000V(chirp_common.LiveRadio):
set_freq(self.pipe, mem.freq)
+ def do_test(): """Get the frequency of /dev/icom""" ser = serial.Serial(port="/dev/icom", baudrate=19200, timeout=0.5) - #set_freq(pipe, 439.920) + # set_freq(pipe, 439.920) get_freq(ser)
+ if __name__ == "__main__": do_test() diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 2fbf1ce..6fec7bd 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -30,7 +30,6 @@ ./chirp/drivers/id31.py ./chirp/drivers/id800.py ./chirp/drivers/id880.py -./chirp/drivers/idrp.py ./chirp/drivers/kenwood_hmk.py ./chirp/drivers/kenwood_itm.py ./chirp/drivers/kenwood_live.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 82ef06f999fe0ce91ce2fa6d389e6c40edefcb17
Fix style issues in puxing.py (#2355)
diff --git a/chirp/drivers/puxing.py b/chirp/drivers/puxing.py index ddfee1a..1295123 100644 --- a/chirp/drivers/puxing.py +++ b/chirp/drivers/puxing.py @@ -20,6 +20,7 @@ import os from chirp import util, chirp_common, bitwise, errors, directory from chirp.drivers.wouxun import wipe_memory, do_download, do_upload
+ def _puxing_prep(radio): radio.pipe.write("\x02PROGRA") ack = radio.pipe.read(1) @@ -36,6 +37,7 @@ def _puxing_prep(radio): if radio.pipe.read(1) != "\x06": raise Exception("Radio did not ACK ident")
+ def puxing_prep(radio): """Do the Puxing PX-777 identification dance""" for _i in range(0, 10): @@ -46,6 +48,7 @@ def puxing_prep(radio):
raise e
+ def puxing_download(radio): """Talk to a Puxing PX-777 and do a download""" try: @@ -56,6 +59,7 @@ def puxing_download(radio): except Exception, e: raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ def puxing_upload(radio): """Talk to a Puxing PX-777 and do an upload""" try: @@ -68,7 +72,7 @@ def puxing_upload(radio):
POWER_LEVELS = [chirp_common.PowerLevel("High", watts=5.00), chirp_common.PowerLevel("Low", watts=1.00)] - + PUXING_CHARSET = list("0123456789") + \ [chr(x + ord("A")) for x in range(0, 26)] + \ list("- ") @@ -118,13 +122,13 @@ struct { # 460-520: 0xF7
PUXING_MODELS = { - 328 : 0x38, - 338 : 0x39, - 777 : 0x3A, + 328: 0x38, + 338: 0x39, + 777: 0x3A, }
PUXING_777_BANDS = [ - ( 67000000, 72000000), + (67000000, 72000000), (136000000, 174000000), (240000000, 260000000), (350000000, 390000000), @@ -136,6 +140,7 @@ PUXING_777_BANDS = [ (460000000, 520000000), ]
+ @directory.register class Puxing777Radio(chirp_common.CloneModeRadio): """Puxing PX-777""" @@ -177,9 +182,9 @@ class Puxing777Radio(chirp_common.CloneModeRadio): if self._memobj.model.limits == 0xEE: rf.valid_bands = [PUXING_777_BANDS[1]] else: - raise Exception("Unsupported band limits 0x%02x for PX-777" % \ - (self._memobj.model.limits) + - " submodel 328 - PLEASE REPORT THIS ERROR TO DEVELOPERS!!") + raise Exception("Unsupported band limits 0x%02x for PX-777" % + (self._memobj.model.limits) + " submodel 328" + " - PLEASE REPORT THIS ERROR TO DEVELOPERS!!")
return rf
@@ -193,12 +198,10 @@ class Puxing777Radio(chirp_common.CloneModeRadio): @classmethod def match_model(cls, filedata, filename): # There are PX-777 that says to be model 328 ... - return len(filedata) == 3168 and ( - ord(filedata[0x080B]) == PUXING_MODELS[777] or ( - ord(filedata[0x080B]) == PUXING_MODELS[328] and - ord(filedata[0x080A]) == 0xEE - ) - ) + return (len(filedata) == 3168 and + (ord(filedata[0x080B]) == PUXING_MODELS[777] or + (ord(filedata[0x080B]) == PUXING_MODELS[328] and + ord(filedata[0x080A]) == 0xEE)))
def get_memory(self, number): _mem = self._memobj.memory[number - 1] @@ -230,7 +233,7 @@ class Puxing777Radio(chirp_common.CloneModeRadio): tp, tx = "N", None else: tp, tx = _get_dtcs(int(txfield)) - + if rxfield[0].get_raw() == "\xFF": rp, rx = "N", None else: @@ -267,7 +270,7 @@ class Puxing777Radio(chirp_common.CloneModeRadio): mem.mode = "NFM"
if _is_no_tone(_mem.tx_tone): - pass # No tone + pass # No tone elif int(_mem.tx_tone) > 8000 or \ (not _is_no_tone(_mem.rx_tone) and int(_mem.rx_tone) > 8000): mem.tmode = "DTCS" @@ -304,13 +307,11 @@ class Puxing777Radio(chirp_common.CloneModeRadio): _mem.skip = mem.skip != "S" _mem.iswide = mem.mode != "NFM"
- _mem.rx_tone[0].set_raw("\xFF") _mem.rx_tone[1].set_raw("\xFF") _mem.tx_tone[0].set_raw("\xFF") _mem.tx_tone[1].set_raw("\xFF")
- if mem.tmode == "DTCS": _mem.tx_tone = int("%x" % int("%i" % (mem.dtcs), 16)) _mem.rx_tone = int("%x" % int("%i" % (mem.dtcs), 16)) @@ -344,6 +345,7 @@ class Puxing777Radio(chirp_common.CloneModeRadio): except IndexError: raise Exception("Character `%s' not supported")
+ def puxing_2r_prep(radio): """Do the Puxing 2R identification dance""" radio.pipe.setTimeout(0.2) @@ -356,6 +358,7 @@ def puxing_2r_prep(radio): ident = radio.pipe.read(16) print "Radio ident: %s (%i)" % (repr(ident), len(ident))
+ def puxing_2r_download(radio): """Talk to a Puxing 2R and do a download""" try: @@ -366,6 +369,7 @@ def puxing_2r_download(radio): except Exception, e: raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ def puxing_2r_upload(radio): """Talk to a Puxing 2R and do an upload""" try: @@ -399,6 +403,7 @@ PX2R_POWER_LEVELS = [chirp_common.PowerLevel("Low", watts=1.0), chirp_common.PowerLevel("High", watts=2.0)] PX2R_CHARSET = "0123456789- ABCDEFGHIJKLMNOPQRSTUVWXYZ +"
+ @directory.register class Puxing2RRadio(chirp_common.CloneModeRadio): """Puxing PX-2R""" @@ -494,7 +499,7 @@ class Puxing2RRadio(chirp_common.CloneModeRadio): if mem.tmode == "DTCS": _mem.tx_tone = chirp_common.DTCS_CODES.index(mem.dtcs) + 0x33 _mem.rx_tone = chirp_common.DTCS_CODES.index(mem.dtcs) + 0x33 - _mem.txdtcsinv = mem.dtcs_polarity[0] == "R" + _mem.txdtcsinv = mem.dtcs_polarity[0] == "R" _mem.rxdtcsinv = mem.dtcs_polarity[1] == "R" elif mem.tmode in ["Tone", "TSQL"]: _mem.tx_tone = chirp_common.TONES.index(mem.rtone) + 1 @@ -511,4 +516,3 @@ class Puxing2RRadio(chirp_common.CloneModeRadio):
def get_raw_memory(self, number): return repr(self._memobj.memory[number-1]) - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 6fec7bd..81de4c1 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -36,7 +36,6 @@ ./chirp/drivers/kguv8d.py ./chirp/drivers/kyd.py ./chirp/drivers/leixen.py -./chirp/drivers/puxing.py ./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID fd075facb1ef097848e6af0fc8eed81094a6acca
Fix style issues in leixen.py (#2355)
diff --git a/chirp/drivers/leixen.py b/chirp/drivers/leixen.py index 285fe84..97ab555 100644 --- a/chirp/drivers/leixen.py +++ b/chirp/drivers/leixen.py @@ -232,38 +232,46 @@ TMODES = ["", "Tone", "DTCS", "DTCS"] def _image_ident_from_data(data): return data[0x168:0x178]
+ def _image_ident_from_image(radio): return _image_ident_from_data(radio.get_mmap())
+ def checksum(frame): x = 0 for b in frame: x ^= ord(b) return chr(x)
+ def make_frame(cmd, addr, data=""): payload = struct.pack(">H", addr) + data header = struct.pack(">BB", ord(cmd), len(payload)) frame = header + payload return frame + checksum(frame)
+ def send(radio, frame): - # print "%04i P>R: %s" % (len(frame), util.hexprint(frame).replace("\n", "\n ")) + # print "%04i P>R: %s" % \ + # (len(frame), util.hexprint(frame).replace("\n", "\n ")) try: radio.pipe.write(frame) except Exception, e: raise errors.RadioError("Failed to communicate with radio: %s" % e)
+ def recv(radio, readdata=True): hdr = radio.pipe.read(4) - # print "%04i P<R: %s" % (len(hdr), util.hexprint(hdr).replace("\n", "\n ")) + # print "%04i P<R: %s" % \ + # (len(hdr), util.hexprint(hdr).replace("\n", "\n ")) if hdr == "\x09\x00\x09": raise errors.RadioError("Radio rejected command.") cmd, length, addr = struct.unpack(">BBH", hdr) length -= 2 if readdata: data = radio.pipe.read(length) - # print " P<R: %s" % util.hexprint(hdr + data).replace("\n", "\n ") + # print " P<R: %s" % \ + # util.hexprint(hdr + data).replace("\n", "\n ") if len(data) != length: raise errors.RadioError("Radio sent %i bytes (expected %i)" % ( len(data), length)) @@ -272,6 +280,7 @@ def recv(radio, readdata=True): data = "" return addr, data
+ def do_ident(radio): send(radio, "\x02\x06LEIXEN\x17") ident = radio.pipe.read(9) @@ -283,6 +292,7 @@ def do_ident(radio): if ack != "\x06\x00\x06": raise errors.RadioError("Radio did not ack.")
+ def do_download(radio): do_ident(radio)
@@ -305,6 +315,7 @@ def do_download(radio):
return memmap.MemoryMap(data)
+ def do_upload(radio): _ranges = [(0x0d00, 0x2000)]
@@ -313,12 +324,13 @@ def do_upload(radio): _ranges = radio._ranges
do_ident(radio) - + for start, end in _ranges: for addr in range(start, end, 0x10): frame = make_frame("W", addr, radio._mmap[addr:addr + 0x10]) send(radio, frame) - # print " P<R: %s" % util.hexprint(frame).replace("\n", "\n ") + # print " P<R: %s" % \ + # util.hexprint(frame).replace("\n", "\n ") radio.pipe.write("\x06\x00\x06") ack = radio.pipe.read(3) if ack != "\x06\x00\x06": @@ -332,6 +344,7 @@ def do_upload(radio):
finish(radio)
+ def finish(radio): send(radio, "\x64\x01\x6F\x0A") ack = radio.pipe.read(8) @@ -413,7 +426,7 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio):
tx_tmode = TMODES[_mem.tx_tmode] rx_tmode = TMODES[_mem.rx_tmode] - + if tx_tmode == "Tone": tx_tone = TONES[_mem.tx_tone - 1] elif tx_tmode == "DTCS": @@ -532,44 +545,44 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio): # Basic Settings # rs = RadioSetting("apo", "Auto Power Off", - RadioSettingValueList(APO_LIST, - APO_LIST[_settings.apo])) + RadioSettingValueList( + APO_LIST, APO_LIST[_settings.apo])) cfg_grp.append(rs) rs = RadioSetting("sql", "Squelch Level", - RadioSettingValueList(SQL_LIST, - SQL_LIST[_settings.sql])) + RadioSettingValueList( + SQL_LIST, SQL_LIST[_settings.sql])) cfg_grp.append(rs) rs = RadioSetting("scanm", "Scan Mode", - RadioSettingValueList(SCANM_LIST, - SCANM_LIST[_settings.scanm])) + RadioSettingValueList( + SCANM_LIST, SCANM_LIST[_settings.scanm])) cfg_grp.append(rs) rs = RadioSetting("tot", "Time Out Timer", - RadioSettingValueList(TOT_LIST, - TOT_LIST[_settings.tot])) + RadioSettingValueList( + TOT_LIST, TOT_LIST[_settings.tot])) cfg_grp.append(rs) rs = RadioSetting("step", "Step", - RadioSettingValueList(STEP_LIST, - STEP_LIST[_settings.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[_settings.step])) cfg_grp.append(rs) rs = RadioSetting("monitor", "Monitor", - RadioSettingValueList(MONITOR_LIST, - MONITOR_LIST[_settings.monitor])) + RadioSettingValueList( + MONITOR_LIST, MONITOR_LIST[_settings.monitor])) cfg_grp.append(rs) rs = RadioSetting("vfomr", "VFO/MR", - RadioSettingValueList(VFOMR_LIST, - VFOMR_LIST[_settings.vfomr])) + RadioSettingValueList( + VFOMR_LIST, VFOMR_LIST[_settings.vfomr])) cfg_grp.append(rs) rs = RadioSetting("mrcha", "MR/CHA", - RadioSettingValueList(MRCHA_LIST, - MRCHA_LIST[_settings.mrcha])) + RadioSettingValueList( + MRCHA_LIST, MRCHA_LIST[_settings.mrcha])) cfg_grp.append(rs) rs = RadioSetting("vol", "Volume", - RadioSettingValueList(VOL_LIST, - VOL_LIST[_settings.vol])) + RadioSettingValueList( + VOL_LIST, VOL_LIST[_settings.vol])) cfg_grp.append(rs) rs = RadioSetting("opendis", "Open Display", - RadioSettingValueList(OPENDIS_LIST, - OPENDIS_LIST[_settings.opendis])) + RadioSettingValueList( + OPENDIS_LIST, OPENDIS_LIST[_settings.opendis])) cfg_grp.append(rs)
def _filter(name): @@ -595,12 +608,13 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio): cfg_grp.append(rs)
rs = RadioSetting("lamp", "Backlight", - RadioSettingValueList(LAMP_LIST, - LAMP_LIST[_settings.lamp])) + RadioSettingValueList( + LAMP_LIST, LAMP_LIST[_settings.lamp])) cfg_grp.append(rs) rs = RadioSetting("keylockm", "Key Lock Mode", - RadioSettingValueList(KEYLOCKM_LIST, - KEYLOCKM_LIST[_settings.keylockm])) + RadioSettingValueList( + KEYLOCKM_LIST, + KEYLOCKM_LIST[_settings.keylockm])) cfg_grp.append(rs) rs = RadioSetting("absel", "A/B Select", RadioSettingValueList(ABSEL_LIST, @@ -650,18 +664,20 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio): RadioSettingValueBoolean(_settings.fmdw)) cfg_grp.append(rs) rs = RadioSetting("fmscan_off", "FM Scan", - RadioSettingValueBoolean(not _settings.fmscan_off)) + RadioSettingValueBoolean( + not _settings.fmscan_off)) cfg_grp.append(rs) rs = RadioSetting("keypadmic_off", "Keypad MIC", - RadioSettingValueBoolean(not _settings.keypadmic_off)) + RadioSettingValueBoolean( + not _settings.keypadmic_off)) cfg_grp.append(rs) rs = RadioSetting("voxgain", "VOX Gain", - RadioSettingValueList(VOXGAIN_LIST, - VOXGAIN_LIST[_settings.voxgain])) + RadioSettingValueList( + VOXGAIN_LIST, VOXGAIN_LIST[_settings.voxgain])) cfg_grp.append(rs) rs = RadioSetting("voxdt", "VOX Delay Time", - RadioSettingValueList(VOXDT_LIST, - VOXDT_LIST[_settings.voxdt])) + RadioSettingValueList( + VOXDT_LIST, VOXDT_LIST[_settings.voxdt])) cfg_grp.append(rs) rs = RadioSetting("vir", "VOX Inhibit on Receive", RadioSettingValueBoolean(_settings.vir)) @@ -672,28 +688,28 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio): # val = (_settings.dtmftime) - 5 rs = RadioSetting("dtmftime", "DTMF Digit Time", - RadioSettingValueList(DTMFTIME_LIST, - DTMFTIME_LIST[val])) + RadioSettingValueList( + DTMFTIME_LIST, DTMFTIME_LIST[val])) adv_grp.append(rs) val = (_settings.dtmfspace) - 5 rs = RadioSetting("dtmfspace", "DTMF Digit Space Time", - RadioSettingValueList(DTMFTIME_LIST, - DTMFTIME_LIST[val])) + RadioSettingValueList( + DTMFTIME_LIST, DTMFTIME_LIST[val])) adv_grp.append(rs) val = (_settings.dtmfdelay) / 5 rs = RadioSetting("dtmfdelay", "DTMF 1st Digit Delay", - RadioSettingValueList(DTMFDELAY_LIST, - DTMFDELAY_LIST[val])) + RadioSettingValueList( + DTMFDELAY_LIST, DTMFDELAY_LIST[val])) adv_grp.append(rs) val = (_settings.dtmfpretime) / 10 - 1 rs = RadioSetting("dtmfpretime", "DTMF Pretime", - RadioSettingValueList(DTMFPRETIME_LIST, - DTMFPRETIME_LIST[val])) + RadioSettingValueList( + DTMFPRETIME_LIST, DTMFPRETIME_LIST[val])) adv_grp.append(rs) val = (_settings.dtmfdelay2) / 5 rs = RadioSetting("dtmfdelay2", "DTMF * and # Digit Delay", - RadioSettingValueList(DTMFDELAY2_LIST, - DTMFDELAY2_LIST[val])) + RadioSettingValueList( + DTMFDELAY2_LIST, DTMFDELAY2_LIST[val])) adv_grp.append(rs) rs = RadioSetting("ackdecode", "ACK Decode", RadioSettingValueBoolean(_settings.ackdecode)) @@ -703,10 +719,10 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio): adv_grp.append(rs)
rs = RadioSetting("service.rssi400", "Squelch Base Level (UHF)", - RadioSettingValueInteger(0, 255,_service.rssi400)) + RadioSettingValueInteger(0, 255, _service.rssi400)) adv_grp.append(rs) rs = RadioSetting("service.rssi136", "Squelch Base Level (VHF)", - RadioSettingValueInteger(0, 255,_service.rssi136)) + RadioSettingValueInteger(0, 255, _service.rssi136)) adv_grp.append(rs)
# @@ -714,32 +730,38 @@ class LeixenVV898Radio(chirp_common.CloneModeRadio): # val = (_settings.lptime) - 5 rs = RadioSetting("lptime", "Long Press Time", - RadioSettingValueList(LPTIME_LIST, - LPTIME_LIST[val])) + RadioSettingValueList( + LPTIME_LIST, LPTIME_LIST[val])) key_grp.append(rs) rs = RadioSetting("keyp1long", "P1 Long Key", - RadioSettingValueList(PFKEYLONG_LIST, - PFKEYLONG_LIST[_settings.keyp1long])) + RadioSettingValueList( + PFKEYLONG_LIST, + PFKEYLONG_LIST[_settings.keyp1long])) key_grp.append(rs) rs = RadioSetting("keyp1short", "P1 Short Key", - RadioSettingValueList(PFKEYSHORT_LIST, - PFKEYSHORT_LIST[_settings.keyp1short])) + RadioSettingValueList( + PFKEYSHORT_LIST, + PFKEYSHORT_LIST[_settings.keyp1short])) key_grp.append(rs) rs = RadioSetting("keyp2long", "P2 Long Key", - RadioSettingValueList(PFKEYLONG_LIST, - PFKEYLONG_LIST[_settings.keyp2long])) + RadioSettingValueList( + PFKEYLONG_LIST, + PFKEYLONG_LIST[_settings.keyp2long])) key_grp.append(rs) rs = RadioSetting("keyp2short", "P2 Short Key", - RadioSettingValueList(PFKEYSHORT_LIST, - PFKEYSHORT_LIST[_settings.keyp2short])) + RadioSettingValueList( + PFKEYSHORT_LIST, + PFKEYSHORT_LIST[_settings.keyp2short])) key_grp.append(rs) rs = RadioSetting("keyp3long", "P3 Long Key", - RadioSettingValueList(PFKEYLONG_LIST, - PFKEYLONG_LIST[_settings.keyp3long])) + RadioSettingValueList( + PFKEYLONG_LIST, + PFKEYLONG_LIST[_settings.keyp3long])) key_grp.append(rs) rs = RadioSetting("keyp3short", "P3 Short Key", - RadioSettingValueList(PFKEYSHORT_LIST, - PFKEYSHORT_LIST[_settings.keyp3short])) + RadioSettingValueList( + PFKEYSHORT_LIST, + PFKEYSHORT_LIST[_settings.keyp3short])) key_grp.append(rs)
val = RadioSettingValueList(PFKEYSHORT_LIST, diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 81de4c1..743448c 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -35,7 +35,6 @@ ./chirp/drivers/kenwood_live.py ./chirp/drivers/kguv8d.py ./chirp/drivers/kyd.py -./chirp/drivers/leixen.py ./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 445fc1c6509b16e97d78be88493a2ca2f3f787c5
Fix style issues in kyd.py (#2355)
diff --git a/chirp/drivers/kyd.py b/chirp/drivers/kyd.py index e188df9..a6db68a 100644 --- a/chirp/drivers/kyd.py +++ b/chirp/drivers/kyd.py @@ -49,7 +49,7 @@ struct { u8 voice; // Voice Annunciation u8 tot; // Time-out Timer u8 totalert; // Time-out Timer Pre-alert - u8 unknown1[2]; + u8 unknown1[2]; u8 squelch; // Squelch Level u8 save; // Battery Saver u8 beep; // Beep @@ -78,14 +78,15 @@ VOX_LIST = ["OFF"] + ["%s" % x for x in range(1, 17)] VOXDELAY_LIST = ["0.3", "0.5", "1.0", "1.5", "2.0", "3.0"]
SETTING_LISTS = { - "bcl" : BCL_LIST, - "tot" : TIMEOUTTIMER_LIST, - "totalert" : TOTALERT_LIST, - "voice" : VOICE_LIST, - "vox" : VOX_LIST, - "voxdelay" : VOXDELAY_LIST, + "bcl": BCL_LIST, + "tot": TIMEOUTTIMER_LIST, + "totalert": TOTALERT_LIST, + "voice": VOICE_LIST, + "vox": VOX_LIST, + "voxdelay": VOXDELAY_LIST, }
+ def _nc630a_enter_programming_mode(radio): serial = radio.pipe
@@ -121,6 +122,7 @@ def _nc630a_enter_programming_mode(radio): if ack != CMD_ACK: raise errors.RadioError("Radio refused to enter programming mode")
+ def _nc630a_exit_programming_mode(radio): serial = radio.pipe try: @@ -128,6 +130,7 @@ def _nc630a_exit_programming_mode(radio): except: raise errors.RadioError("Radio refused to exit programming mode")
+ def _nc630a_read_block(radio, block_addr, block_size): serial = radio.pipe
@@ -153,6 +156,7 @@ def _nc630a_read_block(radio, block_addr, block_size):
return block_data
+ def _nc630a_write_block(radio, block_addr, block_size): serial = radio.pipe
@@ -170,6 +174,7 @@ def _nc630a_write_block(radio, block_addr, block_size): raise errors.RadioError("Failed to send block " "to radio at %04x" % block_addr)
+ def do_download(radio): print "download" _nc630a_enter_programming_mode(radio) @@ -196,6 +201,7 @@ def do_download(radio):
return memmap.MemoryMap(data)
+ def do_upload(radio): status = chirp_common.Status() status.msg = "Uploading to radio" @@ -213,6 +219,7 @@ def do_upload(radio):
_nc630a_exit_programming_mode(radio)
+ @directory.register class NC630aRadio(chirp_common.CloneModeRadio): """KYD NC-630A""" @@ -299,8 +306,8 @@ class NC630aRadio(chirp_common.CloneModeRadio): if mem.tmode == "DTCS": mem.dtcs_polarity = "%s%s" % (tpol, rpol)
- LOG.debug("Got TX %s (%i) RX %s (%i)" % (txmode, _mem.tx_tone, - rxmode, _mem.rx_tone)) + LOG.debug("Got TX %s (%i) RX %s (%i)" % + (txmode, _mem.tx_tone, rxmode, _mem.rx_tone))
def get_memory(self, number): bitpos = (1 << ((number - 1) % 8)) @@ -345,8 +352,8 @@ class NC630aRadio(chirp_common.CloneModeRadio): mem.extra = RadioSettingGroup("Extra", "extra")
rs = RadioSetting("bcl", "Busy Channel Lockout", - RadioSettingValueList(BCL_LIST, - BCL_LIST[_mem.bcl])) + RadioSettingValueList( + BCL_LIST, BCL_LIST[_mem.bcl])) mem.extra.append(rs)
return mem @@ -366,11 +373,10 @@ class NC630aRadio(chirp_common.CloneModeRadio): else: tx_mode = rx_mode = mem.tmode
- if tx_mode == "DTCS": _mem.tx_tone = mem.tmode != "DTCS" and \ - _set_dcs(mem.dtcs, mem.dtcs_polarity[0]) or \ - _set_dcs(mem.rx_dtcs, mem.dtcs_polarity[0]) + _set_dcs(mem.dtcs, mem.dtcs_polarity[0]) or \ + _set_dcs(mem.rx_dtcs, mem.dtcs_polarity[0]) elif tx_mode: _mem.tx_tone = tx_mode == "Tone" and \ int(mem.rtone * 10) or int(mem.ctone * 10) @@ -384,8 +390,8 @@ class NC630aRadio(chirp_common.CloneModeRadio): else: _mem.rx_tone = 0xFFFF
- LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, - rx_mode, _mem.rx_tone)) + LOG.debug("Set TX %s (%i) RX %s (%i)" % + (tx_mode, _mem.tx_tone, rx_mode, _mem.rx_tone))
def set_memory(self, mem): bitpos = (1 << ((mem.number - 1) % 8)) @@ -435,23 +441,25 @@ class NC630aRadio(chirp_common.CloneModeRadio): top = RadioSettings(basic)
rs = RadioSetting("tot", "Time-out timer", - RadioSettingValueList(TIMEOUTTIMER_LIST, - TIMEOUTTIMER_LIST[_settings.tot])) + RadioSettingValueList( + TIMEOUTTIMER_LIST, + TIMEOUTTIMER_LIST[_settings.tot])) basic.append(rs)
rs = RadioSetting("totalert", "TOT Pre-alert", - RadioSettingValueList(TOTALERT_LIST, - TOTALERT_LIST[_settings.totalert])) + RadioSettingValueList( + TOTALERT_LIST, + TOTALERT_LIST[_settings.totalert])) basic.append(rs)
rs = RadioSetting("vox", "VOX Gain", - RadioSettingValueList(VOX_LIST, - VOX_LIST[_settings.vox])) + RadioSettingValueList( + VOX_LIST, VOX_LIST[_settings.vox])) basic.append(rs)
rs = RadioSetting("voice", "Voice Annumciation", - RadioSettingValueList(VOICE_LIST, - VOICE_LIST[_settings.voice])) + RadioSettingValueList( + VOICE_LIST, VOICE_LIST[_settings.voice])) basic.append(rs)
rs = RadioSetting("squelch", "Squelch Level", @@ -459,8 +467,9 @@ class NC630aRadio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("voxdelay", "VOX Delay", - RadioSettingValueList(VOXDELAY_LIST, - VOXDELAY_LIST[_settings.voxdelay])) + RadioSettingValueList( + VOXDELAY_LIST, + VOXDELAY_LIST[_settings.voxdelay])) basic.append(rs)
rs = RadioSetting("beep", "Beep", diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 743448c..a2fe563 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -34,7 +34,6 @@ ./chirp/drivers/kenwood_itm.py ./chirp/drivers/kenwood_live.py ./chirp/drivers/kguv8d.py -./chirp/drivers/kyd.py ./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID fe77b9c2f987ee9653587bb155e29590397ae1f2
Fix style issues in h777.py (#2355)
diff --git a/chirp/drivers/h777.py b/chirp/drivers/h777.py index 5ac0351..236c2a9 100644 --- a/chirp/drivers/h777.py +++ b/chirp/drivers/h777.py @@ -90,9 +90,10 @@ TIMEOUTTIMER_LIST = ["Off", "30 seconds", "60 seconds", "90 seconds", SCANMODE_LIST = ["Carrier", "Time"]
SETTING_LISTS = { - "voice" : VOICE_LIST, + "voice": VOICE_LIST, }
+ def _h777_enter_programming_mode(radio): serial = radio.pipe
@@ -128,6 +129,7 @@ def _h777_enter_programming_mode(radio): if ack != CMD_ACK: raise errors.RadioError("Radio refused to enter programming mode")
+ def _h777_exit_programming_mode(radio): serial = radio.pipe try: @@ -135,6 +137,7 @@ def _h777_exit_programming_mode(radio): except: raise errors.RadioError("Radio refused to exit programming mode")
+ def _h777_read_block(radio, block_addr, block_size): serial = radio.pipe
@@ -160,6 +163,7 @@ def _h777_read_block(radio, block_addr, block_size):
return block_data
+ def _h777_write_block(radio, block_addr, block_size): serial = radio.pipe
@@ -177,6 +181,7 @@ def _h777_write_block(radio, block_addr, block_size): raise errors.RadioError("Failed to send block " "to radio at %04x" % block_addr)
+ def do_download(radio): print "download" _h777_enter_programming_mode(radio) @@ -203,6 +208,7 @@ def do_download(radio):
return memmap.MemoryMap(data)
+ def do_upload(radio): status = chirp_common.Status() status.msg = "Uploading to radio" @@ -220,6 +226,7 @@ def do_upload(radio):
_h777_exit_programming_mode(radio)
+ @directory.register class H777Radio(chirp_common.CloneModeRadio): """HST H-777""" @@ -232,7 +239,7 @@ class H777Radio(chirp_common.CloneModeRadio): # This code currently requires that ranges start at 0x0000 # and are continious. In the original program 0x0388 and 0x03C8 # are only written (all bytes 0xFF), not read. - #_ranges = [ + # _ranges = [ # (0x0000, 0x0110), # (0x02B0, 0x02C0), # (0x0380, 0x03E0) @@ -400,7 +407,8 @@ class H777Radio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("voicelanguage", "Voice language", - RadioSettingValueList(VOICE_LIST, + RadioSettingValueList( + VOICE_LIST, VOICE_LIST[_settings.voicelanguage])) basic.append(rs)
@@ -409,8 +417,9 @@ class H777Radio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("settings2.scanmode", "Scan mode", - RadioSettingValueList(SCANMODE_LIST, - SCANMODE_LIST[self._memobj.settings2.scanmode])) + RadioSettingValueList( + SCANMODE_LIST, + SCANMODE_LIST[self._memobj.settings2.scanmode])) basic.append(rs)
rs = RadioSetting("vox", "VOX", @@ -455,20 +464,22 @@ class H777Radio(chirp_common.CloneModeRadio): basic.append(rs)
rs = RadioSetting("settings2.squelchlevel", "Squelch level", - RadioSettingValueInteger(0, 9, - self._memobj.settings2.squelchlevel)) + RadioSettingValueInteger( + 0, 9, self._memobj.settings2.squelchlevel)) basic.append(rs)
rs = RadioSetting("settings2.sidekeyfunction", "Side key function", - RadioSettingValueList(SIDEKEYFUNCTION_LIST, - SIDEKEYFUNCTION_LIST[ - self._memobj.settings2.sidekeyfunction])) + RadioSettingValueList( + SIDEKEYFUNCTION_LIST, + SIDEKEYFUNCTION_LIST[ + self._memobj.settings2.sidekeyfunction])) basic.append(rs)
rs = RadioSetting("settings2.timeouttimer", "Timeout timer", - RadioSettingValueList(TIMEOUTTIMER_LIST, - TIMEOUTTIMER_LIST[ - self._memobj.settings2.timeouttimer])) + RadioSettingValueList( + TIMEOUTTIMER_LIST, + TIMEOUTTIMER_LIST[ + self._memobj.settings2.timeouttimer])) basic.append(rs)
return top @@ -502,6 +513,7 @@ class H777Radio(chirp_common.CloneModeRadio): print element.get_name() raise
+ class H777TestCase(unittest.TestCase): def setUp(self): self.driver = H777Radio(None) diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index a2fe563..0b9c455 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -9,7 +9,6 @@ ./chirp/drivers/ft7800.py ./chirp/drivers/ft90.py ./chirp/drivers/ftm350.py -./chirp/drivers/h777.py ./chirp/drivers/ic208.py ./chirp/drivers/ic2100.py ./chirp/drivers/ic2200.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 552614e54a36cd930ee142fa1221c832b96720cb
Fix style issues in kenwood_hmk.py (#2355)
diff --git a/chirp/drivers/kenwood_hmk.py b/chirp/drivers/kenwood_hmk.py index cff0162..7e76f33 100644 --- a/chirp/drivers/kenwood_hmk.py +++ b/chirp/drivers/kenwood_hmk.py @@ -19,10 +19,12 @@ import csv from chirp import chirp_common, errors, directory from chirp.drivers import generic_csv
+ class OmittedHeaderError(Exception): """An internal exception to indicate that a header was omitted""" pass
+ @directory.register class HMKRadio(generic_csv.CSVRadio): """Kenwood HMK format""" @@ -51,18 +53,18 @@ class HMKRadio(generic_csv.CSVRadio): }
ATTR_MAP = { - "!!Ch" : (int, "number"), - "M.Name" : (str, "name"), - "Rx Freq." : (chirp_common.parse_freq, "freq"), - "Shift/Split" : (lambda v: HMKRadio.DUPLEX_MAP[v], "duplex"), - "Offset" : (chirp_common.parse_freq, "offset"), - "T/CT/DCS" : (lambda v: HMKRadio.TMODE_MAP[v], "tmode"), - "TO Freq." : (float, "rtone"), - "CT Freq." : (float, "ctone"), - "DCS Code" : (int, "dtcs"), - "Mode" : (str, "mode"), - "Rx Step" : (float, "tuning_step"), - "L.Out" : (lambda v: HMKRadio.SKIP_MAP[v], "skip"), + "!!Ch": (int, "number"), + "M.Name": (str, "name"), + "Rx Freq.": (chirp_common.parse_freq, "freq"), + "Shift/Split": (lambda v: HMKRadio.DUPLEX_MAP[v], "duplex"), + "Offset": (chirp_common.parse_freq, "offset"), + "T/CT/DCS": (lambda v: HMKRadio.TMODE_MAP[v], "tmode"), + "TO Freq.": (float, "rtone"), + "CT Freq.": (float, "ctone"), + "DCS Code": (int, "dtcs"), + "Mode": (str, "mode"), + "Rx Step": (float, "tuning_step"), + "L.Out": (lambda v: HMKRadio.SKIP_MAP[v], "skip"), }
def load(self, filename=None): @@ -90,10 +92,10 @@ class HMKRadio(generic_csv.CSVRadio): continue
if len(header) > len(line): - print "Line %i has %i columns, expected %i" % (lineno, - len(line), - len(header)) - self.errors.append("Column number mismatch on line %i" % lineno) + print "Line %i has %i columns, expected %i" % \ + (lineno, len(line), len(header)) + self.errors.append("Column number mismatch on line %i" % + lineno) continue
# hmk stores Tx Freq. in its own field, but Chirp expects the Tx @@ -103,7 +105,7 @@ class HMKRadio(generic_csv.CSVRadio): line[header.index('Offset')] = line[header.index('Tx Freq.')]
# fix EU decimal - line = [i.replace(',','.') for i in line] + line = [i.replace(',', '.') for i in line]
try: mem = self._parse_csv_data_line(header, line) diff --git a/chirp/drivers/kenwood_itm.py b/chirp/drivers/kenwood_itm.py index a5fc8c2..a0fec83 100644 --- a/chirp/drivers/kenwood_itm.py +++ b/chirp/drivers/kenwood_itm.py @@ -19,10 +19,12 @@ import csv from chirp import chirp_common, errors, directory from chirp.drivers import generic_csv
+ class OmittedHeaderError(Exception): """An internal exception to indicate that a header was omitted""" pass
+ @directory.register class ITMRadio(generic_csv.CSVRadio): """Kenwood ITM format""" @@ -31,9 +33,9 @@ class ITMRadio(generic_csv.CSVRadio): FILE_EXTENSION = "itm"
ATTR_MAP = { - "CH" : (int, "number"), - "RXF" : (chirp_common.parse_freq, "freq"), - "NAME" : (str, "name"), + "CH": (int, "number"), + "RXF": (chirp_common.parse_freq, "freq"), + "NAME": (str, "name"), }
def _clean_duplex(self, headers, line, mem): @@ -51,7 +53,7 @@ class ITMRadio(generic_csv.CSVRadio): mem.offset = txfreq
return mem - + def _clean_number(self, headers, line, mem): zone = int(generic_csv.get_datum_by_header(headers, line, "ZN")) mem.number = zone * 100 + mem.number @@ -100,14 +102,14 @@ class ITMRadio(generic_csv.CSVRadio): break
if len(header) > len(line): - print "Line %i has %i columns, expected %i" % (lineno, - len(line), - len(header)) - self.errors.append("Column number mismatch on line %i" % lineno) + print "Line %i has %i columns, expected %i" % \ + (lineno, len(line), len(header)) + self.errors.append("Column number mismatch on line %i" % + lineno) continue
# fix EU decimal - line = [i.replace(',','.') for i in line] + line = [i.replace(',', '.') for i in line]
try: mem = self._parse_csv_data_line(header, line) diff --git a/chirp/drivers/kenwood_live.py b/chirp/drivers/kenwood_live.py index 6cac1c9..f440b17 100644 --- a/chirp/drivers/kenwood_live.py +++ b/chirp/drivers/kenwood_live.py @@ -19,21 +19,17 @@ import sys import time import logging
-LOG = logging.getLogger(__name__) - -NOCACHE = os.environ.has_key("CHIRP_NOCACHE") - -if __name__ == "__main__": - import sys - sys.path.insert(0, "..") - from chirp import chirp_common, errors, directory, util from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueInteger, RadioSettingValueBoolean, \ RadioSettingValueString, RadioSettingValueList, RadioSettings
-DUPLEX = { 0 : "", 1 : "+", 2 : "-" } -MODES = { 0 : "FM", 1 : "AM" } +LOG = logging.getLogger(__name__) + +NOCACHE = "CHIRP_NOCACHE" in os.environ + +DUPLEX = {0: "", 1: "+", 2: "-"} +MODES = {0: "FM", 1: "AM"} STEPS = list(chirp_common.TUNING_STEPS) STEPS.append(100.0)
@@ -41,6 +37,7 @@ THF6_MODES = ["FM", "WFM", "AM", "LSB", "USB", "CW"]
LOCK = threading.Lock()
+ def command(ser, cmd, *args): """Send @cmd to radio via @ser""" global LOCK @@ -67,6 +64,8 @@ def command(ser, cmd, *args): return result.strip()
LAST_BAUD = 9600 + + def get_id(ser): """Get the ID of the radio attached to @ser""" global LAST_BAUD @@ -86,6 +85,7 @@ def get_id(ser):
raise errors.RadioError("No response from radio")
+ def get_tmode(tone, ctcss, dcs): """Get the tone mode based on the values of the tone, ctcss, dcs""" if dcs and int(dcs) == 1: @@ -97,10 +97,12 @@ def get_tmode(tone, ctcss, dcs): else: return ""
+ def iserr(result): """Returns True if the @result from a radio is an error""" return result in ["N", "?"]
+ class KenwoodLiveRadio(chirp_common.LiveRadio): """Base class for all live-mode kenwood radios""" BAUD_RATE = 9600 @@ -151,9 +153,9 @@ class KenwoodLiveRadio(chirp_common.LiveRadio):
def get_memory(self, number): if number < 0 or number > self._upper: - raise errors.InvalidMemoryLocation( \ + raise errors.InvalidMemoryLocation( "Number must be between 0 and %i" % self._upper) - if self.__memcache.has_key(number) and not NOCACHE: + if number in self.__memcache and not NOCACHE: return self.__memcache[number]
result = command(self.pipe, *self._cmd_get_memory(number)) @@ -180,7 +182,7 @@ class KenwoodLiveRadio(chirp_common.LiveRadio): _zero, _loc, mem.name = value.split(",") else: _loc, mem.name = value.split(",") - + if mem.duplex == "" and self._kenwood_split: result = command(self.pipe, *self._cmd_get_split(number)) if " " in result: @@ -204,7 +206,7 @@ class KenwoodLiveRadio(chirp_common.LiveRadio):
def set_memory(self, memory): if memory.number < 0 or memory.number > self._upper: - raise errors.InvalidMemoryLocation( \ + raise errors.InvalidMemoryLocation( "Number must be between 0 and %i" % self._upper)
spec = self._make_mem_spec(memory) @@ -218,22 +220,22 @@ class KenwoodLiveRadio(chirp_common.LiveRadio): memory.name = memory.name.rstrip() self.__memcache[memory.number] = memory else: - raise errors.InvalidDataError("Radio refused name %i: %s" %\ - (memory.number, - repr(memory.name))) + raise errors.InvalidDataError("Radio refused name %i: %s" % + (memory.number, + repr(memory.name))) else: raise errors.InvalidDataError("Radio refused %i" % memory.number)
- if memory.duplex == "split" and self._kenwood_split: + if memory.duplex == "split" and self._kenwood_split: spec = ",".join(self._make_split_spec(memory)) result = command(self.pipe, *self._cmd_set_split(memory.number, spec)) if iserr(result): - raise errors.InvalidDataError("Radio refused %i" % \ - memory.number) + raise errors.InvalidDataError("Radio refused %i" % + memory.number)
def erase_memory(self, number): - if not self.__memcache.has_key(number): + if number not in self.__memcache: return
resp = command(self.pipe, *self._cmd_set_memory(number, "")) @@ -242,31 +244,33 @@ class KenwoodLiveRadio(chirp_common.LiveRadio): del self.__memcache[number]
TH_D7_SETTINGS = { - "BAL" : ["4:0", "3:1", "2:2", "1:3", "0:4"], - "BEP" : ["Off", "Key", "Key+Data", "All"], - "BEPT" : ["Off", "Mine", "All New"], # D700 has fourth "All" - "DS" : ["Data Band", "Both Bands"], - "DTB" : ["A", "B"], - "DTBA" : ["A", "B", "A:TX/B:RX"], # D700 has fourth A:RX/B:TX - "DTX" : ["Manual", "PTT", "Auto"], - "ICO" : ["Kenwood", "Runner", "House", "Tent", "Boat", "SSTV", + "BAL": ["4:0", "3:1", "2:2", "1:3", "0:4"], + "BEP": ["Off", "Key", "Key+Data", "All"], + "BEPT": ["Off", "Mine", "All New"], # D700 has fourth "All" + "DS": ["Data Band", "Both Bands"], + "DTB": ["A", "B"], + "DTBA": ["A", "B", "A:TX/B:RX"], # D700 has fourth A:RX/B:TX + "DTX": ["Manual", "PTT", "Auto"], + "ICO": ["Kenwood", "Runner", "House", "Tent", "Boat", "SSTV", "Plane", "Speedboat", "Car", "Bicycle"], - "MNF" : ["Name", "Frequency"], - "PKSA" : ["1200", "9600"], - "POSC" : ["Off Duty", "Enroute", "In Service", "Returning", + "MNF": ["Name", "Frequency"], + "PKSA": ["1200", "9600"], + "POSC": ["Off Duty", "Enroute", "In Service", "Returning", "Committed", "Special", "Priority", "Emergency"], - "PT" : ["100ms", "200ms", "500ms", "750ms", "1000ms", "1500ms", "2000ms"], - "SCR" : ["Time", "Carrier", "Seek"], - "SV" : ["Off", "0.2s", "0.4s", "0.6s", "0.8s", "1.0s", + "PT": ["100ms", "200ms", "500ms", "750ms", + "1000ms", "1500ms", "2000ms"], + "SCR": ["Time", "Carrier", "Seek"], + "SV": ["Off", "0.2s", "0.4s", "0.6s", "0.8s", "1.0s", "2s", "3s", "4s", "5s"], - "TEMP" : ["F", "C"], - "TXI" : ["30sec", "1min", "2min", "3min", "4min", "5min", + "TEMP": ["F", "C"], + "TXI": ["30sec", "1min", "2min", "3min", "4min", "5min", "10min", "20min", "30min"], - "UNIT" : ["English", "Metric"], - "WAY" : ["Off", "6 digit NMEA", "7 digit NMEA", "8 digit NMEA", + "UNIT": ["English", "Metric"], + "WAY": ["Off", "6 digit NMEA", "7 digit NMEA", "8 digit NMEA", "9 digit NMEA", "6 digit Magellan", "DGPS"], }
+ class KenwoodOldLiveRadio(KenwoodLiveRadio): _kenwood_valid_tones = list(chirp_common.OLD_TONES)
@@ -282,6 +286,7 @@ class KenwoodOldLiveRadio(KenwoodLiveRadio):
return KenwoodLiveRadio.set_memory(self, memory)
+ @directory.register class THD7Radio(KenwoodOldLiveRadio): """Kenwood TH-D7""" @@ -301,7 +306,8 @@ class THD7Radio(KenwoodOldLiveRadio): rf.valid_duplexes = ["", "-", "+", "split"] rf.valid_modes = MODES.values() rf.valid_tmodes = ["", "Tone", "TSQL"] - rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC + "/.-+*)('&%$#! ~}|{" + rf.valid_characters = \ + chirp_common.CHARSET_ALPHANUMERIC + "/.-+*)('&%$#! ~}|{" rf.valid_name_length = 7 rf.memory_bounds = (1, self._upper) return rf @@ -313,17 +319,17 @@ class THD7Radio(KenwoodOldLiveRadio): else: duplex = 0 offset = 0 - - spec = ( \ + + spec = ( "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % duplex, "0", "%i" % (mem.tmode == "Tone"), "%i" % (mem.tmode == "TSQL"), - "", # DCS Flag + "", # DCS Flag "%02i" % (self._kenwood_valid_tones.index(mem.rtone) + 1), - "", # DCS Code + "", # DCS Code "%02i" % (self._kenwood_valid_tones.index(mem.ctone) + 1), "%09i" % offset, "%i" % util.get_dict_rev(MODES, mem.mode), @@ -380,7 +386,7 @@ class THD7Radio(KenwoodOldLiveRadio):
def _kenwood_set_int(self, cmd, value, digits=1): return self._kenwood_set(cmd, ("%%0%ii" % digits) % value) - + def get_settings(self): aux = RadioSettingGroup("aux", "Aux") tnc = RadioSettingGroup("tnc", "TNC") @@ -391,7 +397,7 @@ class THD7Radio(KenwoodOldLiveRadio): aux, tnc, save, display, dtmf) sky = RadioSettingGroup("sky", "SkyCommand") aprs = RadioSettingGroup("aprs", "APRS") - + top = RadioSettings(radio, aprs, sky)
bools = [("AMR", aprs, "APRS Message Auto-Reply"), @@ -399,7 +405,7 @@ class THD7Radio(KenwoodOldLiveRadio): ("ARO", aux, "Automatic Repeater Offset"), ("BCN", aprs, "Beacon"), ("CH", radio, "Channel Mode Display"), - #("DIG", aprs, "APRS Digipeater"), + # ("DIG", aprs, "APRS Digipeater"), ("DL", all, "Dual"), ("LK", all, "Lock"), ("LMP", all, "Lamp"), @@ -420,7 +426,7 @@ class THD7Radio(KenwoodOldLiveRadio): ("DTB", tnc, "Data Band"), ("DTBA", aprs, "APRS Data Band"), ("DTX", aprs, "APRS Data TX"), - #("ICO", aprs, "APRS Icon"), + # ("ICO", aprs, "APRS Icon"), ("MNF", all, "Memory Display Mode"), ("PKSA", aprs, "APRS Packet Speed"), ("POSC", aprs, "APRS Position Comment"), @@ -428,7 +434,7 @@ class THD7Radio(KenwoodOldLiveRadio): ("SV", save, "Battery Save"), ("TEMP", aprs, "APRS Temperature Units"), ("TXI", aprs, "APRS Transmit Interval"), - #("UNIT", aprs, "APRS Display Units"), + # ("UNIT", aprs, "APRS Display Units"), ("WAY", aprs, "Waypoint Mode"), ]
@@ -453,7 +459,7 @@ class THD7Radio(KenwoodOldLiveRadio): ("PP", aprs, "APRS Path", 32), ("SCC", sky, "SkyCommand Callsign", 8), ("SCT", sky, "SkyCommand To Callsign", 8), - #("STAT", aprs, "APRS Status Text", 32), + # ("STAT", aprs, "APRS Status Text", 32), ] for setting, group, name, length in strings: _cmd, value = self._kenwood_get(setting) @@ -478,19 +484,21 @@ class THD7Radio(KenwoodOldLiveRadio): digits = 2 else: digits = 1 - self._kenwood_set_int(element.get_name(), element.value, digits) + self._kenwood_set_int(element.get_name(), + element.value, digits) elif isinstance(element.value, RadioSettingValueString): self._kenwood_set(element.get_name(), str(element.value)) else: print "Unknown type %s" % element.value
+ @directory.register class THD7GRadio(THD7Radio): """Kenwood TH-D7G""" MODEL = "TH-D7G"
def get_features(self): - rf = super(THD7GRadio,self).get_features() + rf = super(THD7GRadio, self).get_features() rf.valid_name_length = 8 return rf
@@ -523,7 +531,7 @@ class TMD700Radio(KenwoodOldLiveRadio): duplex = util.get_dict_rev(DUPLEX, mem.duplex) else: duplex = 0 - spec = ( \ + spec = ( "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % duplex, @@ -563,12 +571,13 @@ class TMD700Radio(KenwoodOldLiveRadio):
return mem
+ @directory.register class TMV7Radio(KenwoodOldLiveRadio): """Kenwood TM-V7""" MODEL = "TM-V7"
- mem_upper_limit = 200 # Will be updated + mem_upper_limit = 200 # Will be updated
def get_features(self): rf = chirp_common.RadioFeatures() @@ -586,7 +595,7 @@ class TMV7Radio(KenwoodOldLiveRadio): return rf
def _make_mem_spec(self, mem): - spec = ( \ + spec = ( "%011i" % mem.freq, "%X" % STEPS.index(mem.tuning_step), "%i" % util.get_dict_rev(DUPLEX, mem.duplex), @@ -642,34 +651,38 @@ class TMV7Radio(KenwoodOldLiveRadio): try: self.erase_memory(loc) except Exception: - pass # V7A Can't delete just yet + pass # V7A Can't delete just yet
return True
def _detect_split(self): return 50
+ class TMV7RadioSub(TMV7Radio): """Base class for the TM-V7 sub devices""" def __init__(self, pipe): TMV7Radio.__init__(self, pipe) self._detect_split()
+ class TMV7RadioVHF(TMV7RadioSub): """TM-V7 VHF subdevice""" VARIANT = "VHF" _vfo = 0
+ class TMV7RadioUHF(TMV7RadioSub): """TM-V7 UHF subdevice""" VARIANT = "UHF" _vfo = 1
+ @directory.register class TMG707Radio(TMV7Radio): """Kenwood TM-G707""" MODEL = "TM-G707" - + def get_features(self): rf = TMV7Radio.get_features(self) rf.has_sub_devices = False @@ -679,7 +692,10 @@ class TMG707Radio(TMV7Radio): (800000000, 999000000)] return rf
-THG71_STEPS = [ 5, 6.25, 10, 12.5, 15, 20, 25, 30, 50, 100 ] + +THG71_STEPS = [5, 6.25, 10, 12.5, 15, 20, 25, 30, 50, 100] + + @directory.register class THG71Radio(TMV7Radio): """Kenwood TH-G71""" @@ -693,11 +709,11 @@ class THG71Radio(TMV7Radio): rf.has_sub_devices = False rf.valid_bands = [(118000000, 174000000), (320000000, 470000000), - (800000000, 945000000)] + (800000000, 945000000)] return rf
def _make_mem_spec(self, mem): - spec = ( \ + spec = ( "%011i" % mem.freq, "%X" % THG71_STEPS.index(mem.tuning_step), "%i" % util.get_dict_rev(DUPLEX, mem.duplex), @@ -730,13 +746,14 @@ class THG71Radio(TMV7Radio): mem.offset = 0 return mem
- + THF6A_STEPS = [5.0, 6.25, 8.33, 9.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, 100.0]
THF6A_DUPLEX = dict(DUPLEX) THF6A_DUPLEX[3] = "split"
+ @directory.register class THF6ARadio(KenwoodLiveRadio): """Kenwood TH-F6""" @@ -814,7 +831,7 @@ class THF6ARadio(KenwoodLiveRadio): offset = 0 else: print "Bug: unsupported duplex `%s'" % mem.duplex - spec = ( \ + spec = ( "%011i" % mem.freq, "%X" % THF6A_STEPS.index(mem.tuning_step), "%i" % duplex, @@ -831,6 +848,7 @@ class THF6ARadio(KenwoodLiveRadio):
return spec
+ @directory.register class THF7ERadio(THF6ARadio): """Kenwood TH-F7""" @@ -850,11 +868,12 @@ D710_TONES.remove(189.9) D710_TONES.remove(196.6) D710_TONES.remove(199.5)
+ @directory.register class TMD710Radio(KenwoodLiveRadio): """Kenwood TM-D710""" MODEL = "TM-D710" - + _upper = 999 _kenwood_valid_tones = list(D710_TONES)
@@ -867,7 +886,7 @@ class TMD710Radio(KenwoodLiveRadio): rf.valid_modes = D710_MODES rf.valid_duplexes = D710_DUPLEX rf.valid_tuning_steps = D710_STEPS - rf.valid_characters = chirp_common.CHARSET_ASCII.replace(',','') + rf.valid_characters = chirp_common.CHARSET_ASCII.replace(',', '') rf.valid_name_length = 8 rf.valid_skips = D710_SKIP rf.memory_bounds = (0, 999) @@ -909,37 +928,38 @@ class TMD710Radio(KenwoodLiveRadio): mem.duplex = "split" mem.offset = int(spec[13]) # Unknown - mem.skip = D710_SKIP[int(spec[15])] # Memory Lockout + mem.skip = D710_SKIP[int(spec[15])] # Memory Lockout
return mem
def _make_mem_spec(self, mem): - spec = ( \ + spec = ( "%010i" % mem.freq, "%X" % D710_STEPS.index(mem.tuning_step), - "%i" % (0 if mem.duplex == "split" else \ - D710_DUPLEX.index(mem.duplex)), - "0", # Reverse + "%i" % (0 if mem.duplex == "split" + else D710_DUPLEX.index(mem.duplex)), + "0", # Reverse "%i" % (mem.tmode == "Tone" and 1 or 0), "%i" % (mem.tmode == "TSQL" and 1 or 0), "%i" % (mem.tmode == "DTCS" and 1 or 0), "%02i" % (self._kenwood_valid_tones.index(mem.rtone)), "%02i" % (self._kenwood_valid_tones.index(mem.ctone)), "%03i" % (chirp_common.DTCS_CODES.index(mem.dtcs)), - "%08i" % (0 if mem.duplex == "split" else mem.offset), # Offset + "%08i" % (0 if mem.duplex == "split" else mem.offset), # Offset "%i" % D710_MODES.index(mem.mode), - "%010i" % (mem.offset if mem.duplex == "split" else 0), # TX Freq - "0", # Unknown - "%i" % D710_SKIP.index(mem.skip), # Memory Lockout + "%010i" % (mem.offset if mem.duplex == "split" else 0), # TX Freq + "0", # Unknown + "%i" % D710_SKIP.index(mem.skip), # Memory Lockout )
return spec
+ @directory.register class THD72Radio(TMD710Radio): """Kenwood TH-D72""" MODEL = "TH-D72 (live mode)" - HARDWARE_FLOW = sys.platform == "darwin" # only OS X driver needs hw flow + HARDWARE_FLOW = sys.platform == "darwin" # only OS X driver needs hw flow
def _parse_mem_spec(self, spec): mem = chirp_common.Memory() @@ -965,17 +985,17 @@ class THD72Radio(TMD710Radio): mem.duplex = "split" mem.offset = int(spec[15]) # Lockout - mem.skip = D710_SKIP[int(spec[17])] # Memory Lockout + mem.skip = D710_SKIP[int(spec[17])] # Memory Lockout
return mem
def _make_mem_spec(self, mem): - spec = ( \ + spec = ( "%010i" % mem.freq, "%X" % D710_STEPS.index(mem.tuning_step), - "%i" % (0 if mem.duplex == "split" else \ - D710_DUPLEX.index(mem.duplex)), - "0", # Reverse + "%i" % (0 if mem.duplex == "split" + else D710_DUPLEX.index(mem.duplex)), + "0", # Reverse "%i" % (mem.tmode == "Tone" and 1 or 0), "%i" % (mem.tmode == "TSQL" and 1 or 0), "%i" % (mem.tmode == "DTCS" and 1 or 0), @@ -984,20 +1004,22 @@ class THD72Radio(TMD710Radio): "%02i" % (self._kenwood_valid_tones.index(mem.ctone)), "%03i" % (chirp_common.DTCS_CODES.index(mem.dtcs)), "0", - "%08i" % (0 if mem.duplex == "split" else mem.offset), # Offset + "%08i" % (0 if mem.duplex == "split" else mem.offset), # Offset "%i" % D710_MODES.index(mem.mode), - "%010i" % (mem.offset if mem.duplex == "split" else 0), # TX Freq - "0", # Unknown - "%i" % D710_SKIP.index(mem.skip), # Memory Lockout + "%010i" % (mem.offset if mem.duplex == "split" else 0), # TX Freq + "0", # Unknown + "%i" % D710_SKIP.index(mem.skip), # Memory Lockout )
return spec
+ @directory.register class TMV71Radio(TMD710Radio): """Kenwood TM-V71""" MODEL = "TM-V71"
+ @directory.register class TMD710GRadio(TMD710Radio): """Kenwood TM-D710G""" @@ -1016,17 +1038,18 @@ class TMD710GRadio(TMD710Radio): THK2_DUPLEX = ["", "+", "-"] THK2_MODES = ["FM", "NFM"] THK2_TONES = list(chirp_common.TONES) -THK2_TONES.remove(159.8) # ?? -THK2_TONES.remove(165.5) # ?? -THK2_TONES.remove(171.3) # ?? -THK2_TONES.remove(177.3) # ?? -THK2_TONES.remove(183.5) # ?? -THK2_TONES.remove(189.9) # ?? -THK2_TONES.remove(196.6) # ?? -THK2_TONES.remove(199.5) # ?? +THK2_TONES.remove(159.8) # ?? +THK2_TONES.remove(165.5) # ?? +THK2_TONES.remove(171.3) # ?? +THK2_TONES.remove(177.3) # ?? +THK2_TONES.remove(183.5) # ?? +THK2_TONES.remove(189.9) # ?? +THK2_TONES.remove(196.6) # ?? +THK2_TONES.remove(199.5) # ??
THK2_CHARS = chirp_common.CHARSET_UPPER_NUMERIC + "-/"
+ @directory.register class THK2Radio(KenwoodLiveRadio): """Kenwood TH-K2""" @@ -1068,7 +1091,7 @@ class THK2Radio(KenwoodLiveRadio):
mem.number = int(spec[0]) mem.freq = int(spec[1]) - #mem.tuning_step = + # mem.tuning_step = mem.duplex = THK2_DUPLEX[int(spec[3])] if int(spec[5]): mem.tmode = "Tone" @@ -1091,32 +1114,32 @@ class THK2Radio(KenwoodLiveRadio): except ValueError: raise errors.UnsupportedToneError()
- spec = ( \ + spec = ( "%010i" % mem.freq, "0", - "%i" % THK2_DUPLEX.index(mem.duplex), + "%i" % THK2_DUPLEX.index(mem.duplex), "0", - "%i" % int(mem.tmode == "Tone"), - "%i" % int(mem.tmode == "TSQL"), - "%i" % int(mem.tmode == "DTCS"), - "%02i" % rti, - "%02i" % cti, - "%03i" % chirp_common.DTCS_CODES.index(mem.dtcs), - "%08i" % mem.offset, - "%i" % THK2_MODES.index(mem.mode), + "%i" % int(mem.tmode == "Tone"), + "%i" % int(mem.tmode == "TSQL"), + "%i" % int(mem.tmode == "DTCS"), + "%02i" % rti, + "%02i" % cti, + "%03i" % chirp_common.DTCS_CODES.index(mem.dtcs), + "%08i" % mem.offset, + "%i" % THK2_MODES.index(mem.mode), "0", "%010i" % 0, "0", - "%i" % int(mem.skip == "S") + "%i" % int(mem.skip == "S") ) return spec - +
@directory.register class TM271Radio(THK2Radio): """Kenwood TM-271""" MODEL = "TM-271" - + def get_features(self): rf = chirp_common.RadioFeatures() rf.can_odd_split = False @@ -1146,12 +1169,14 @@ class TM271Radio(THK2Radio): def _cmd_set_memory_name(self, number, name): return "MN", "%03i,%s" % (number, name)
+ @directory.register class TM281Radio(TM271Radio): """Kenwood TM-281""" MODEL = "TM-281" # seems that this is a perfect clone of TM271 with just a different model
+ def do_test(): """Dev test""" mem = chirp_common.Memory() @@ -1161,20 +1186,25 @@ def do_test(): mem.offset = 146000000
tc = THF6ARadio + class FakeSerial: """Faked serial line""" buf = "" + def write(self, buf): """Write""" self.buf = buf + def read(self, count): """Read""" if self.buf[:2] == "ID": return "ID %s\r" % tc.MODEL return self.buf + def setTimeout(self, foo): """Set Timeout""" pass + def setBaudrate(self, foo): """Set Baudrate""" pass @@ -1182,11 +1212,12 @@ def do_test(): radio = tc(FakeSerial()) radio.set_memory(mem)
+ @directory.register class TM471Radio(THK2Radio): """Kenwood TM-471""" MODEL = "TM-471" - + def get_features(self): rf = chirp_common.RadioFeatures() rf.can_odd_split = False @@ -1216,6 +1247,7 @@ class TM471Radio(THK2Radio): def _cmd_set_memory_name(self, number, name): return "MN", "%03i,%s" % (number, name)
+ def do_test(): """Dev test""" mem = chirp_common.Memory() @@ -1225,20 +1257,25 @@ def do_test(): mem.offset = 442000000
tc = THF6ARadio + class FakeSerial: """Faked serial line""" buf = "" + def write(self, buf): """Write""" self.buf = buf + def read(self, count): """Read""" if self.buf[:2] == "ID": return "ID %s\r" % tc.MODEL return self.buf + def setTimeout(self, foo): """Set Timeout""" pass + def setBaudrate(self, foo): """Set Baudrate""" pass @@ -1246,6 +1283,6 @@ def do_test(): radio = tc(FakeSerial()) radio.set_memory(mem)
+ if __name__ == "__main__": do_test() - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 0b9c455..96facb4 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -29,9 +29,6 @@ ./chirp/drivers/id31.py ./chirp/drivers/id800.py ./chirp/drivers/id880.py -./chirp/drivers/kenwood_hmk.py -./chirp/drivers/kenwood_itm.py -./chirp/drivers/kenwood_live.py ./chirp/drivers/kguv8d.py ./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 0540247c7fa41542ff4aa8fcf698ae535b4074b4
Fix style issues in kguv8d.py (#2355)
diff --git a/chirp/drivers/kguv8d.py b/chirp/drivers/kguv8d.py index d0f779f..165fc27 100644 --- a/chirp/drivers/kguv8d.py +++ b/chirp/drivers/kguv8d.py @@ -272,7 +272,7 @@ _MEM_FORMAT = """
@directory.register class KGUV8DRadio(chirp_common.CloneModeRadio, - chirp_common.ExperimentalRadio): + chirp_common.ExperimentalRadio): """Wouxun KG-UV8D""" VENDOR = "Wouxun" MODEL = "KG-UV8D" @@ -280,7 +280,7 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, _file_ident = "KGUV8D" BAUD_RATE = 19200 POWER_LEVELS = [chirp_common.PowerLevel("L", watts=1), - chirp_common.PowerLevel("H", watts=5)] + chirp_common.PowerLevel("H", watts=5)] _mmap = ""
def _checksum(self, data): @@ -528,8 +528,8 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, # always set it even if no dtcs is used mem.dtcs_polarity = "%s%s" % (tpol or "N", rpol or "N")
- LOG.debug("Got TX %s (%i) RX %s (%i)" % (txmode, _mem.txtone, - rxmode, _mem.rxtone)) + LOG.debug("Got TX %s (%i) RX %s (%i)" % + (txmode, _mem.txtone, rxmode, _mem.rxtone))
def get_memory(self, number): _mem = self._memobj.memory[number] @@ -607,8 +607,8 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, else: _mem.rxtone = 0
- LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.txtone, - rx_mode, _mem.rxtone)) + LOG.debug("Set TX %s (%i) RX %s (%i)" % + (tx_mode, _mem.txtone, rx_mode, _mem.rxtone))
def set_memory(self, mem): number = mem.number @@ -664,121 +664,138 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, key_grp = RadioSettingGroup("key_grp", "Key Settings") lmt_grp = RadioSettingGroup("lmt_grp", "Frequency Limits") oem_grp = RadioSettingGroup("oem_grp", "OEM Info") - - group = RadioSettings(cfg_grp, vfoa_grp, vfob_grp, key_grp, - lmt_grp, oem_grp) + + group = RadioSettings(cfg_grp, vfoa_grp, vfob_grp, + key_grp, lmt_grp, oem_grp)
# # Configuration Settings # - rs = RadioSetting("ponmsg", "Poweron message", RadioSettingValueList( - PONMSG_LIST, PONMSG_LIST[_settings.ponmsg])) + rs = RadioSetting("ponmsg", "Poweron message", + RadioSettingValueList( + PONMSG_LIST, PONMSG_LIST[_settings.ponmsg])) cfg_grp.append(rs) - rs = RadioSetting("voice", "Voice Guide", RadioSettingValueBoolean( - _settings.voice)) + rs = RadioSetting("voice", "Voice Guide", + RadioSettingValueBoolean(_settings.voice)) cfg_grp.append(rs) - rs = RadioSetting("language", "Language", RadioSettingValueList( - LANGUAGE_LIST, LANGUAGE_LIST[_settings.language])) + rs = RadioSetting("language", "Language", + RadioSettingValueList( + LANGUAGE_LIST, + LANGUAGE_LIST[_settings.language])) cfg_grp.append(rs) - rs = RadioSetting("timeout", "Timeout Timer", RadioSettingValueInteger( - 15, 900, _settings.timeout * 15, 15)) + rs = RadioSetting("timeout", "Timeout Timer", + RadioSettingValueInteger( + 15, 900, _settings.timeout * 15, 15)) cfg_grp.append(rs) rs = RadioSetting("toalarm", "Timeout Alarm", - RadioSettingValueInteger(0, 10, _settings.toalarm)) + RadioSettingValueInteger(0, 10, _settings.toalarm)) cfg_grp.append(rs) rs = RadioSetting("channel_menu", "Menu available in channel mode", - RadioSettingValueBoolean(_settings.channel_menu)) + RadioSettingValueBoolean(_settings.channel_menu)) cfg_grp.append(rs) - rs = RadioSetting("power_save", "Power save", RadioSettingValueBoolean( - _settings.power_save)) + rs = RadioSetting("power_save", "Power save", + RadioSettingValueBoolean(_settings.power_save)) cfg_grp.append(rs) - rs = RadioSetting("autolock", "Autolock", RadioSettingValueBoolean( - _settings.autolock)) + rs = RadioSetting("autolock", "Autolock", + RadioSettingValueBoolean(_settings.autolock)) cfg_grp.append(rs) - rs = RadioSetting("keylock", "Keypad Lock", RadioSettingValueBoolean( - _settings.keylock)) + rs = RadioSetting("keylock", "Keypad Lock", + RadioSettingValueBoolean(_settings.keylock)) cfg_grp.append(rs) - rs = RadioSetting("beep", "Keypad Beep", RadioSettingValueBoolean( - _settings.keylock)) + rs = RadioSetting("beep", "Keypad Beep", + RadioSettingValueBoolean(_settings.keylock)) cfg_grp.append(rs) - rs = RadioSetting("stopwatch", "Stopwatch", RadioSettingValueBoolean( - _settings.keylock)) + rs = RadioSetting("stopwatch", "Stopwatch", + RadioSettingValueBoolean(_settings.keylock)) cfg_grp.append(rs)
# # VFO A Settings # - rs = RadioSetting("vfoa_mode", "VFO A Workmode", RadioSettingValueList( - WORKMODE_LIST, WORKMODE_LIST[_settings.workmode_a])) + rs = RadioSetting("vfoa_mode", "VFO A Workmode", + RadioSettingValueList( + WORKMODE_LIST, + WORKMODE_LIST[_settings.workmode_a])) vfoa_grp.append(rs) rs = RadioSetting("vfoa_chan", "VFO A Channel", - RadioSettingValueInteger(1, 999, _settings.work_cha)) + RadioSettingValueInteger(1, 999, _settings.work_cha)) vfoa_grp.append(rs) rs = RadioSetting("rxfreqa", "VFO A Rx Frequency", - RadioSettingValueInteger(134000000, 520000000, - _vfoa.rxfreq * 10, 5000)) + RadioSettingValueInteger( + 134000000, 520000000, _vfoa.rxfreq * 10, 5000)) vfoa_grp.append(rs) # u32 txoffset; # u16 rxtone; # u16 txtone; # u8 unknown1:6, - rs = RadioSetting("vfoa_power", "VFO A Power", RadioSettingValueList( - POWER_LIST, POWER_LIST[_vfoa.power])) + rs = RadioSetting("vfoa_power", "VFO A Power", + RadioSettingValueList( + POWER_LIST, POWER_LIST[_vfoa.power])) vfoa_grp.append(rs) # unknown2:1; # u8 unknown3:1, # shift_dir:2 # unknown4:2, - rs = RadioSetting("vfoa_mute_mode", "VFO A Mute", RadioSettingValueList( - SPMUTE_LIST, SPMUTE_LIST[_vfoa.mute_mode])) + rs = RadioSetting("vfoa_mute_mode", "VFO A Mute", + RadioSettingValueList( + SPMUTE_LIST, SPMUTE_LIST[_vfoa.mute_mode])) vfoa_grp.append(rs) - rs = RadioSetting("vfoa_iswide", "VFO A NBFM", RadioSettingValueList( - BANDWIDTH_LIST, BANDWIDTH_LIST[_vfoa.iswide])) + rs = RadioSetting("vfoa_iswide", "VFO A NBFM", + RadioSettingValueList( + BANDWIDTH_LIST, BANDWIDTH_LIST[_vfoa.iswide])) vfoa_grp.append(rs) rs = RadioSetting("vfoa_step", "VFO A Step (kHz)", - RadioSettingValueList(STEP_LIST, STEP_LIST[_vfoa.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[_vfoa.step])) vfoa_grp.append(rs) rs = RadioSetting("vfoa_squelch", "VFO A Squelch", - RadioSettingValueList(LIST_10, LIST_10[_vfoa.squelch])) + RadioSettingValueList( + LIST_10, LIST_10[_vfoa.squelch])) vfoa_grp.append(rs) # # VFO B Settings # - rs = RadioSetting("vfob_mode", "VFO B Workmode", RadioSettingValueList( - WORKMODE_LIST, WORKMODE_LIST[_settings.workmode_b])) + rs = RadioSetting("vfob_mode", "VFO B Workmode", + RadioSettingValueList( + WORKMODE_LIST, + WORKMODE_LIST[_settings.workmode_b])) vfob_grp.append(rs) rs = RadioSetting("vfob_chan", "VFO B Channel", - RadioSettingValueInteger(1, 999, _settings.work_chb)) + RadioSettingValueInteger(1, 999, _settings.work_chb)) vfob_grp.append(rs) rs = RadioSetting("rxfreqb", "VFO B Rx Frequency", - RadioSettingValueInteger(134000000, 520000000, - _vfob.rxfreq * 10, 5000)) + RadioSettingValueInteger( + 134000000, 520000000, _vfob.rxfreq * 10, 5000)) vfob_grp.append(rs) # u32 txoffset; # u16 rxtone; # u16 txtone; # u8 unknown1:6, - rs = RadioSetting("vfob_power", "VFO B Power", RadioSettingValueList( - POWER_LIST, POWER_LIST[_vfob.power])) + rs = RadioSetting("vfob_power", "VFO B Power", + RadioSettingValueList( + POWER_LIST, POWER_LIST[_vfob.power])) vfob_grp.append(rs) # unknown2:1; # u8 unknown3:1, # shift_dir:2 # unknown4:2, - rs = RadioSetting("vfob_mute_mode", "VFO B Mute", RadioSettingValueList( - SPMUTE_LIST, SPMUTE_LIST[_vfob.mute_mode])) + rs = RadioSetting("vfob_mute_mode", "VFO B Mute", + RadioSettingValueList( + SPMUTE_LIST, SPMUTE_LIST[_vfob.mute_mode])) vfob_grp.append(rs) - rs = RadioSetting("vfob_iswide", "VFO B NBFM", RadioSettingValueList( - BANDWIDTH_LIST, BANDWIDTH_LIST[_vfob.iswide])) + rs = RadioSetting("vfob_iswide", "VFO B NBFM", + RadioSettingValueList( + BANDWIDTH_LIST, BANDWIDTH_LIST[_vfob.iswide])) vfob_grp.append(rs) rs = RadioSetting("vfob_step", "VFO B Step (kHz)", - RadioSettingValueList(STEP_LIST, STEP_LIST[_vfob.step])) + RadioSettingValueList( + STEP_LIST, STEP_LIST[_vfob.step])) vfob_grp.append(rs) rs = RadioSetting("vfob_squelch", "VFO B Squelch", - RadioSettingValueList(LIST_10, LIST_10[_vfob.squelch])) + RadioSettingValueList( + LIST_10, LIST_10[_vfob.squelch])) vfob_grp.append(rs)
- # # Key Settings # @@ -797,13 +814,15 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, val.set_mutable(True) rs = RadioSetting("ani", "ANI code", val) key_grp.append(rs) - rs = RadioSetting("pf1_func", "PF1 Key function", RadioSettingValueList( - PF1KEY_LIST, - PF1KEY_LIST[self._memobj.settings.pf1_func])) + rs = RadioSetting("pf1_func", "PF1 Key function", + RadioSettingValueList( + PF1KEY_LIST, + PF1KEY_LIST[self._memobj.settings.pf1_func])) key_grp.append(rs) - rs = RadioSetting("pf3_func", "PF3 Key function", RadioSettingValueList( - PF3KEY_LIST, - PF3KEY_LIST[self._memobj.settings.pf3_func])) + rs = RadioSetting("pf3_func", "PF3 Key function", + RadioSettingValueList( + PF3KEY_LIST, + PF3KEY_LIST[self._memobj.settings.pf3_func])) key_grp.append(rs)
# @@ -818,7 +837,6 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, # u16 upper; # } scan_groups[10];
- # # Call group settings # @@ -827,36 +845,44 @@ class KGUV8DRadio(chirp_common.CloneModeRadio, # Limits settings # rs = RadioSetting("urx_start", "UHF RX Lower Limit", - RadioSettingValueInteger(400000000, 520000000, - self._memobj.uhf_limits.rx_start * 10, 5000)) + RadioSettingValueInteger( + 400000000, 520000000, + self._memobj.uhf_limits.rx_start * 10, 5000)) lmt_grp.append(rs) rs = RadioSetting("urx_stop", "UHF RX Upper Limit", - RadioSettingValueInteger(400000000, 520000000, - self._memobj.uhf_limits.rx_stop * 10, 5000)) + RadioSettingValueInteger( + 400000000, 520000000, + self._memobj.uhf_limits.rx_stop * 10, 5000)) lmt_grp.append(rs) rs = RadioSetting("utx_start", "UHF TX Lower Limit", - RadioSettingValueInteger(400000000, 520000000, - self._memobj.uhf_limits.tx_start * 10, 5000)) + RadioSettingValueInteger( + 400000000, 520000000, + self._memobj.uhf_limits.tx_start * 10, 5000)) lmt_grp.append(rs) rs = RadioSetting("utx_stop", "UHF TX Upper Limit", - RadioSettingValueInteger(400000000, 520000000, - self._memobj.uhf_limits.tx_stop * 10, 5000)) + RadioSettingValueInteger( + 400000000, 520000000, + self._memobj.uhf_limits.tx_stop * 10, 5000)) lmt_grp.append(rs) rs = RadioSetting("vrx_start", "VHF RX Lower Limit", - RadioSettingValueInteger(134000000, 174997500, - self._memobj.vhf_limits.rx_start * 10, 5000)) + RadioSettingValueInteger( + 134000000, 174997500, + self._memobj.vhf_limits.rx_start * 10, 5000)) lmt_grp.append(rs) rs = RadioSetting("vrx_stop", "VHF RX Upper Limit", - RadioSettingValueInteger(134000000, 174997500, - self._memobj.vhf_limits.rx_stop * 10, 5000)) + RadioSettingValueInteger( + 134000000, 174997500, + self._memobj.vhf_limits.rx_stop * 10, 5000)) lmt_grp.append(rs) rs = RadioSetting("vtx_start", "VHF TX Lower Limit", - RadioSettingValueInteger(134000000, 174997500, - self._memobj.vhf_limits.tx_start * 10, 5000)) + RadioSettingValueInteger( + 134000000, 174997500, + self._memobj.vhf_limits.tx_start * 10, 5000)) lmt_grp.append(rs) rs = RadioSetting("vtx_stop", "VHF TX Upper Limit", - RadioSettingValueInteger(134000000, 174997500, - self._memobj.vhf_limits.tx_stop * 10, 5000)) + RadioSettingValueInteger( + 134000000, 174997500, + self._memobj.vhf_limits.tx_stop * 10, 5000)) lmt_grp.append(rs)
# diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 96facb4..42c4364 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -29,7 +29,6 @@ ./chirp/drivers/id31.py ./chirp/drivers/id800.py ./chirp/drivers/id880.py -./chirp/drivers/kguv8d.py ./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 7d34ed196547bcae7332f25b6c38518a497c6c55
Fix style issues in id31.py (#2355)
diff --git a/chirp/drivers/id31.py b/chirp/drivers/id31.py index 7c91b02..66325d7 100644 --- a/chirp/drivers/id31.py +++ b/chirp/drivers/id31.py @@ -94,6 +94,7 @@ DTCS_POLARITY = ["NN", "NR", "RN", "RR"] TUNING_STEPS = [5.0, 6.25, 0, 0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, 100.0, 125.0, 200.0]
+ def _decode_call(_call): # Why Icom, why? call = "" @@ -107,6 +108,7 @@ def _decode_call(_call): call += chr(acc) return call
+ def _encode_call(call): _call = [0x00] * 7 for i in range(0, 7): @@ -115,9 +117,10 @@ def _encode_call(call): _call[i-1] |= (val & 0xFF00) >> 8 _call[i] = val _call[6] |= (ord(call[7]) & 0x7F) - + return _call
+ def _get_freq(_mem): freq = int(_mem.freq) offs = int(_mem.offset) @@ -131,6 +134,7 @@ def _get_freq(_mem):
return (freq * mult), (offs * mult)
+ def _set_freq(_mem, freq, offset): if chirp_common.is_fractional_step(freq): mult = 6250 @@ -142,6 +146,7 @@ def _set_freq(_mem, freq, offset): _mem.freq = (freq / mult) | flag _mem.offset = (offset / mult)
+ class ID31Bank(icf.IcomBank): """A ID-31 Bank""" def get_name(self): @@ -152,6 +157,7 @@ class ID31Bank(icf.IcomBank): _banks = self._model._radio._memobj.bank_names _banks[self.index].name = str(name).ljust(16)[:16]
+ @directory.register class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): """Icom ID-31""" @@ -250,7 +256,7 @@ class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): mem.skip = "P" if _skp & bit: mem.skip = "S" - + return mem
def set_memory(self, memory): @@ -277,8 +283,8 @@ class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): _mem.dtcs = chirp_common.DTCS_CODES.index(memory.dtcs) _mem.dtcs_polarity = DTCS_POLARITY.index(memory.dtcs_polarity) _mem.tune_step = TUNING_STEPS.index(memory.tuning_step) - _mem.mode = next(i for i, mode in self.MODES.items() \ - if mode == memory.mode) + _mem.mode = next(i for i, mode in self.MODES.items() + if mode == memory.mode)
if isinstance(memory, chirp_common.DVMemory): _mem.urcall = _encode_call(memory.dv_urcall.ljust(8)) @@ -288,15 +294,15 @@ class ID31Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): raise Exception("BUG")
if memory.skip == "S": - _skp |= bit + _skp |= bit _psk &= ~bit elif memory.skip == "P": _skp &= ~bit - _psk |= bit + _psk |= bit else: _skp &= ~bit _psk &= ~bit - + def get_urcall_list(self): calls = [] for i in range(0, 200): diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 42c4364..63ab2ed 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -26,7 +26,6 @@ ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py -./chirp/drivers/id31.py ./chirp/drivers/id800.py ./chirp/drivers/id880.py ./chirp/drivers/th9800.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 7d218b87d19ae78eab699d991159e812e990bd0e
Fix style issues in id800.py (#2355)
diff --git a/chirp/drivers/id800.py b/chirp/drivers/id800.py index c0d233a..f71ec3b 100644 --- a/chirp/drivers/id800.py +++ b/chirp/drivers/id800.py @@ -20,7 +20,7 @@ MEM_FORMAT = """ #seekto 0x0020; struct { u24 freq; - u16 offset; + u16 offset; u8 unknown0:2, rtone:6; u8 duplex:2, @@ -46,7 +46,7 @@ struct { digital_code:7; u8 urcall; u8 rpt1call; - u8 rpt2call; + u8 rpt2call; u8 unknown7:1, mode:3, unknown8:4; @@ -84,12 +84,12 @@ DTCS_POL = ["NN", "NR", "RN", "RR"] STEPS = [5.0, 10.0, 12.5, 15, 20.0, 25.0, 30.0, 50.0, 100.0, 200.0, 6.25]
ID800_SPECIAL = { - "C2" : 510, - "C1" : 511, + "C2": 510, + "C1": 511, } ID800_SPECIAL_REV = { - 510 : "C2", - 511 : "C1", + 510: "C2", + 511: "C1", }
for i in range(0, 5): @@ -104,6 +104,7 @@ for i in range(0, 5): ALPHA_CHARSET = " ABCDEFGHIJKLMNOPQRSTUVWXYZ" NUMERIC_CHARSET = "0123456789+-=*/()|"
+ def get_name(_mem): """Decode the name from @_mem""" def _get_char(val): @@ -122,6 +123,7 @@ def get_name(_mem):
return name.rstrip()
+ def set_name(_mem, name): """Encode @name in @_mem""" def _get_index(char): @@ -145,6 +147,7 @@ def set_name(_mem, name): _mem.name5 = _get_index(name[4]) _mem.name6 = _get_index(name[5])
+ @directory.register class ID800v2Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): """Icom ID800""" @@ -192,10 +195,10 @@ class ID800v2Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): (0x37E0, 0x3898, 32), (0x3898, 0x389A, 2),
- (0x38A8, 0x38C0, 16),] + (0x38A8, 0x38C0, 16), ]
- MYCALL_LIMIT = (1, 7) - URCALL_LIMIT = (1, 99) + MYCALL_LIMIT = (1, 7) + URCALL_LIMIT = (1, 99) RPTCALL_LIMIT = (1, 59)
def _get_bank(self, loc): @@ -235,10 +238,10 @@ class ID800v2Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): def get_memory(self, number): if isinstance(number, str): try: - number = ID800_SPECIAL[number] + 1 # Because we subtract below + number = ID800_SPECIAL[number] + 1 # Because we subtract below except KeyError: - raise errors.InvalidMemoryLocation("Unknown channel %s" % \ - number) + raise errors.InvalidMemoryLocation("Unknown channel %s" % + number)
_mem = self._memobj.memory[number-1] _flg = self._memobj.flags[number-1] @@ -351,25 +354,25 @@ class ID800v2Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): calls.append(str(self._memobj.mycalls[i-1].call).rstrip())
return calls - + def set_urcall_list(self, calls): for i in range(*self.URCALL_LIMIT): try: - call = calls[i].upper() # Skip the implicit CQCQCQ + call = calls[i].upper() # Skip the implicit CQCQCQ except IndexError: call = " " * 8 - + self._memobj.urcalls[i-1].call = call.ljust(8)[:8]
def set_repeater_call_list(self, calls): for i in range(*self.RPTCALL_LIMIT): try: - call = calls[i].upper() # Skip the implicit blank + call = calls[i].upper() # Skip the implicit blank except IndexError: call = " " * 8
self._memobj.rptcalls[i-1].call = call.ljust(8)[:8] - + def set_mycall_list(self, calls): for i in range(*self.MYCALL_LIMIT): try: diff --git a/chirp/drivers/id880.py b/chirp/drivers/id880.py index 3639b30..713258d 100644 --- a/chirp/drivers/id880.py +++ b/chirp/drivers/id880.py @@ -80,10 +80,11 @@ u8 name_flags[132];
TMODES = ["", "Tone", "?2", "TSQL", "DTCS", "TSQL-R", "DTCS-R", ""] DUPLEX = ["", "-", "+", "?3"] -DTCSP = ["NN", "NR", "RN", "RR"] -MODES = ["FM", "NFM", "?2", "AM", "NAM", "DV"] -STEPS = [5.0, 6.25, 8.33, 9.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, - 100.0, 125.0, 200.0] +DTCSP = ["NN", "NR", "RN", "RR"] +MODES = ["FM", "NFM", "?2", "AM", "NAM", "DV"] +STEPS = [5.0, 6.25, 8.33, 9.0, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, + 100.0, 125.0, 200.0] +
def decode_call(sevenbytes): """Decode a callsign from a packed region @sevenbytes""" @@ -96,16 +97,17 @@ def decode_call(sevenbytes): for byte in [ord(x) for x in sevenbytes]: i += 1
- mask = (1 << i) - 1 # Mask is 0x01, 0x03, 0x07, etc + # Mask is 0x01, 0x03, 0x07, etc + mask = (1 << i) - 1
- code = (byte >> i) | rem # Code gets the upper bits of remainder - # plus all but the i lower bits of this - # byte + # Code gets the upper bits of remainder plus all but the i lower + # bits of this byte + code = (byte >> i) | rem call += chr(code)
- rem = (byte & mask) << 7 - i # Remainder for next time are the masked - # bits, moved to the high places for the - # next round + # Remainder for next time are the masked bits, moved to the high + # places for the next round + rem = (byte & mask) << 7 - i
# After seven trips gathering overflow bits, we chould have seven # left, which is the final character @@ -113,11 +115,12 @@ def decode_call(sevenbytes):
return call.rstrip()
+ def encode_call(call): """Encode @call into a 7-byte region""" call = call.ljust(8) buf = [] - + for i in range(0, 8): byte = ord(call[i]) if i > 0: @@ -132,6 +135,7 @@ def encode_call(call):
return "".join([chr(x) for x in buf[:7]])
+ def _get_freq(_mem): val = int(_mem.freq)
@@ -144,6 +148,7 @@ def _get_freq(_mem):
return (val * mult)
+ def _set_freq(_mem, freq): if chirp_common.is_fractional_step(freq): mult = 6250 @@ -154,9 +159,11 @@ def _set_freq(_mem, freq):
_mem.freq = (freq / mult) | flag
+ def _wipe_memory(mem, char): mem.set_raw(char * (mem.size() / 8))
+ class ID880Bank(icf.IcomNamedBank): """ID880 Bank""" def get_name(self): @@ -167,6 +174,7 @@ class ID880Bank(icf.IcomNamedBank): _bank = self._model._radio._memobj.bank_names[self.index] _bank.name = name.ljust(6)[:6]
+ @directory.register class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): """Icom ID880""" @@ -206,7 +214,7 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): def _get_bank_index(self, loc): _bank = self._memobj.bank_info[loc] return _bank.index - + def _set_bank_index(self, loc, index): _bank = self._memobj.bank_info[loc] _bank.index = index @@ -231,7 +239,7 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): rf.valid_skips = ["", "S", "P"] rf.valid_name_length = 8 rf.valid_characters = chirp_common.CHARSET_UPPER_NUMERIC + \ - "!"#$%&'()*+,-./:;<=>?@[]^" + "!"#$%&'()*+,-./:;<=>?@[]^" rf.memory_bounds = (0, 999) return rf
@@ -265,7 +273,7 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): elif _pskip & bitpos: mem.skip = "P" else: - pass # FIXME: Special memories + pass # FIXME: Special memories
if not is_used: mem.empty = True @@ -329,7 +337,7 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): _mem.urcall = encode_call(mem.dv_urcall) _mem.r1call = encode_call(mem.dv_rpt1call) _mem.r2call = encode_call(mem.dv_rpt2call) - + if mem.number < 1000: skip = self._memobj.skip_flags[bytepos] pskip = self._memobj.pskip_flags[bytepos] @@ -377,7 +385,8 @@ class ID880Radio(icf.IcomCloneModeRadio, chirp_common.IcomDstarSupport): # destination, but it should suffice in most cases until we get # a rich container file format return len(filedata) == cls._memsize and "API880," in filedata - + + # This radio isn't really supported yet and detects as a conflict with # the ID-880. So, don't register right now @directory.register @@ -386,11 +395,10 @@ class ID80Radio(ID880Radio): MODEL = "ID-80H"
_model = "\x31\x55\x00\x01" - + @classmethod def match_model(cls, filedata, filename): # This is a horrid hack, given that people can change the GPS-A # destination, but it should suffice in most cases until we get # a rich container file format return len(filedata) == cls._memsize and "API80," in filedata - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 63ab2ed..bc99216 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -26,8 +26,6 @@ ./chirp/drivers/icw32.py ./chirp/drivers/icx8x.py ./chirp/drivers/icx8x_ll.py -./chirp/drivers/id800.py -./chirp/drivers/id880.py ./chirp/drivers/th9800.py ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID eadd858b79e8a8bf9f3620114a9298f2a00ed284
Fix style issues in icomciv.py (#2355)
diff --git a/chirp/drivers/icomciv.py b/chirp/drivers/icomciv.py index fd9090f..04ff53e 100644 --- a/chirp/drivers/icomciv.py +++ b/chirp/drivers/icomciv.py @@ -1,5 +1,6 @@
-import struct, logging +import struct +import logging from chirp.drivers import icf from chirp import chirp_common, util, errors, bitwise, directory from chirp.memmap import MemoryMap @@ -55,6 +56,7 @@ u8 unknown[11]; char name[9]; """
+ class Frame: """Base class for an ICF frame""" _cmd = 0x00 @@ -81,8 +83,8 @@ class Frame: raw = struct.pack("BBBBBB", 0xFE, 0xFE, src, dst, self._cmd, self._sub) raw += str(self._data) + chr(0xFD)
- LOG.debug("%02x -> %02x (%i):\n%s" % (src, dst, - len(raw), util.hexprint(raw))) + LOG.debug("%02x -> %02x (%i):\n%s" % + (src, dst, len(raw), util.hexprint(raw)))
serial.write(raw) if willecho: @@ -117,6 +119,7 @@ class Frame: def get_obj(self): raise errors.RadioError("Generic frame has no structure")
+ class MemFrame(Frame): """A memory frame""" _cmd = 0x1A @@ -138,13 +141,14 @@ class MemFrame(Frame):
def get_obj(self): """Return a bitwise parsed object""" - self._data = MemoryMap(str(self._data)) # Make sure we're assignable + self._data = MemoryMap(str(self._data)) # Make sure we're assignable return bitwise.parse(MEM_FORMAT, self._data)
def initialize(self): """Initialize to sane values""" self._data = MemoryMap("".join(["\x00"] * (self.get_obj().size() / 8)))
+ class MultiVFOMemFrame(MemFrame): """A memory frame for radios with multiple VFOs""" def set_location(self, loc, vfo=1): @@ -152,14 +156,16 @@ class MultiVFOMemFrame(MemFrame): self._data = struct.pack(">BH", vfo, int("%04i" % loc, 16))
def get_obj(self): - self._data = MemoryMap(str(self._data)) # Make sure we're assignable + self._data = MemoryMap(str(self._data)) # Make sure we're assignable return bitwise.parse(MEM_VFO_FORMAT, self._data)
+ class DupToneMemFrame(MemFrame): def get_obj(self): self._data = MemoryMap(str(self._data)) return bitwise.parse(mem_duptone_format, self._data)
+ class IcomCIVRadio(icf.IcomLiveRadio): """Base class for ICOM CIV-based radios""" BAUD_RATE = 19200 @@ -191,7 +197,7 @@ class IcomCIVRadio(icf.IcomLiveRadio): icf.IcomLiveRadio.__init__(self, *args, **kwargs)
self._classes = { - "mem" : MemFrame, + "mem": MemFrame, }
if self.pipe: @@ -199,16 +205,16 @@ class IcomCIVRadio(icf.IcomLiveRadio): print "Interface echo: %s" % self._willecho self.pipe.setTimeout(1)
- #f = Frame() - #f.set_command(0x19, 0x00) - #self._send_frame(f) + # f = Frame() + # f.set_command(0x19, 0x00) + # self._send_frame(f) # - #res = f.read(self.pipe) - #if res: + # res = f.read(self.pipe) + # if res: # print "Result: %x->%x (%i)" % (res[0], res[1], len(f.get_data())) # print util.hexprint(f.get_data()) # - #self._id = f.get_data()[0] + # self._id = f.get_data()[0] self._rf = chirp_common.RadioFeatures()
self._initialize() @@ -281,8 +287,8 @@ class IcomCIVRadio(icf.IcomLiveRadio): self._send_frame(f) return
- #f.set_data(MemoryMap(self.get_raw_memory(mem.number))) - #f.initialize() + # f.set_data(MemoryMap(self.get_raw_memory(mem.number))) + # f.initialize()
memobj = f.get_obj() memobj.number = mem.number @@ -307,6 +313,7 @@ class IcomCIVRadio(icf.IcomLiveRadio): f = self._recv_frame() print "Result:\n%s" % util.hexprint(f.get_data())
+ @directory.register class Icom7200Radio(IcomCIVRadio): """Icom IC-7200""" @@ -329,6 +336,7 @@ class Icom7200Radio(IcomCIVRadio): self._rf.valid_skips = [] self._rf.memory_bounds = (1, 200)
+ @directory.register class Icom7000Radio(IcomCIVRadio): """Icom IC-7000""" @@ -355,6 +363,7 @@ class Icom7000Radio(IcomCIVRadio): self._rf.valid_characters = chirp_common.CHARSET_ASCII self._rf.memory_bounds = (1, 99)
+ @directory.register class Icom746Radio(IcomCIVRadio): """Icom IC-746""" @@ -383,11 +392,12 @@ class Icom746Radio(IcomCIVRadio): self._rf.memory_bounds = (1, 99)
CIV_MODELS = { - (0x76, 0xE0) : Icom7200Radio, - (0x70, 0xE0) : Icom7000Radio, - (0x46, 0xE0) : Icom746Radio, + (0x76, 0xE0): Icom7200Radio, + (0x70, 0xE0): Icom7000Radio, + (0x46, 0xE0): Icom746Radio, }
+ def probe_model(ser): """Probe the radio attatched to @ser for its model""" f = Frame() diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index bc99216..3b7a604 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -19,7 +19,6 @@ ./chirp/drivers/ic9x_icf_ll.py ./chirp/drivers/ic9x_ll.py ./chirp/drivers/icf.py -./chirp/drivers/icomciv.py ./chirp/drivers/icq7.py ./chirp/drivers/ict70.py ./chirp/drivers/ict8.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 2976a057cf0af4155293d00a4d7f8f65fa217ebf
Fix style issues in tk8102.py (#2355)
diff --git a/chirp/drivers/tk8102.py b/chirp/drivers/tk8102.py index 4cf291e..50ea12b 100644 --- a/chirp/drivers/tk8102.py +++ b/chirp/drivers/tk8102.py @@ -58,19 +58,22 @@ MODES = ["NFM", "FM"] PTTID = ["", "BOT", "EOT", "Both"] SIGNAL = ["", "DTMF"]
+ def make_frame(cmd, addr, length, data=""): return struct.pack(">BHB", ord(cmd), addr, length) + data
+ def send(radio, frame): - #print "%04i P>R: %s" % (len(frame), util.hexprint(frame)) + # print "%04i P>R: %s" % (len(frame), util.hexprint(frame)) radio.pipe.write(frame)
+ def recv(radio, readdata=True): hdr = radio.pipe.read(4) cmd, addr, length = struct.unpack(">BHB", hdr) if readdata: data = radio.pipe.read(length) - #print " P<R: %s" % util.hexprint(hdr + data) + # print " P<R: %s" % util.hexprint(hdr + data) if len(data) != length: raise errors.RadioError("Radio sent %i bytes (expected %i)" % ( len(data), length)) @@ -79,6 +82,7 @@ def recv(radio, readdata=True): radio.pipe.write("\x06") return addr, data
+ def do_ident(radio): send(radio, "PROGRAM") ack = radio.pipe.read(1) @@ -93,6 +97,7 @@ def do_ident(radio): radio.pipe.write("\x06") ack = radio.pipe.read(1)
+ def do_download(radio): radio.pipe.setParity("E") radio.pipe.setTimeout(1) @@ -122,6 +127,7 @@ def do_download(radio): data) return memmap.MemoryMap(data)
+ def do_upload(radio): radio.pipe.setParity("E") radio.pipe.setTimeout(1) @@ -143,6 +149,7 @@ def do_upload(radio):
radio.pipe.write("\x45")
+ class KenwoodTKx102Radio(chirp_common.CloneModeRadio): """Kenwood TK-x102""" VENDOR = "Kenwood" @@ -320,8 +327,9 @@ class KenwoodTKx102Radio(chirp_common.CloneModeRadio): else: _mem.rx_tone = 0xFFFF
- LOG.debug("Set TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, - rx_mode, _mem.rx_tone)) + LOG.debug("Set TX %s (%i) RX %s (%i)" % + (tx_mode, _mem.tx_tone, rx_mode, _mem.rx_tone)) + def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1]
@@ -341,7 +349,6 @@ class KenwoodTKx102Radio(chirp_common.CloneModeRadio):
self._set_tone(mem, _mem)
- _mem.highpower = mem.power == POWER_LEVELS[1] _mem.wide = mem.mode == "FM" _mem.scan = mem.skip != "S" @@ -416,21 +423,23 @@ class KenwoodTK7102Radio(KenwoodTKx102Radio): _range = (136000000, 174000000) _upper = 4
+ @directory.register class KenwoodTK8102Radio(KenwoodTKx102Radio): MODEL = "TK-8102" _range = (400000000, 500000000) _upper = 4
+ @directory.register class KenwoodTK7108Radio(KenwoodTKx102Radio): MODEL = "TK-7108" _range = (136000000, 174000000) _upper = 8
+ @directory.register class KenwoodTK8108Radio(KenwoodTKx102Radio): MODEL = "TK-8108" _range = (400000000, 500000000) _upper = 8 - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 3b7a604..16d6347 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -31,7 +31,6 @@ ./chirp/drivers/th_uvf8d.py ./chirp/drivers/thd72.py ./chirp/drivers/thuv1f.py -./chirp/drivers/tk8102.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py ./chirp/drivers/vx170.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID f3550aa0750a46d1deb15f3a58d6c540d391318d
Fix style issues in thuv1f.py (#2355)
diff --git a/chirp/drivers/thuv1f.py b/chirp/drivers/thuv1f.py index c5ac91f..73ec10c 100644 --- a/chirp/drivers/thuv1f.py +++ b/chirp/drivers/thuv1f.py @@ -22,6 +22,7 @@ from chirp.settings import RadioSetting, RadioSettingGroup, \ RadioSettingValueBoolean, RadioSettingValueString, \ RadioSettings
+ def uvf1_identify(radio): """Do identify handshake with TYT TH-UVF1""" radio.pipe.write("PROG333") @@ -37,6 +38,7 @@ def uvf1_identify(radio): raise errors.RadioError("Radio did not ack identification") return ident
+ def uvf1_download(radio): """Download from TYT TH-UVF1""" data = uvf1_identify(radio) @@ -63,6 +65,7 @@ def uvf1_download(radio):
return memmap.MemoryMap(data)
+ def uvf1_upload(radio): """Upload to TYT TH-UVF1""" data = uvf1_identify(radio) @@ -91,6 +94,7 @@ def uvf1_upload(radio): # End of clone? radio.pipe.write("\x45")
+ THUV1F_MEM_FORMAT = """ struct mem { bbcd rx_freq[4]; @@ -170,6 +174,7 @@ PTTID_LIST = ["Off", "BOT", "EOT", "Both"] BCL_LIST = ["Off", "CSQ", "QT/DQT"] CODES_LIST = [x for x in range(1, 9)]
+ @directory.register class TYTTHUVF1Radio(chirp_common.CloneModeRadio): """TYT TH-UVF1""" @@ -307,9 +312,8 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio): txmode, txval, txpol = self._decode_tone(_mem.tx_tone) rxmode, rxval, rxpol = self._decode_tone(_mem.rx_tone)
- chirp_common.split_tone_decode(mem, - (txmode, txval, txpol), - (rxmode, rxval, rxpol)) + chirp_common.split_tone_decode( + mem, (txmode, txval, txpol), (rxmode, rxval, rxpol))
mem.name = str(self._memobj.names[number - 1].name) mem.name = mem.name.replace("\xFF", " ").rstrip() @@ -335,8 +339,8 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio): mem.extra.append(rs)
rs = RadioSetting("scramble_code", "Scramble Code", - RadioSettingValueList(CODES_LIST, - CODES_LIST[_mem.scramble_code])) + RadioSettingValueList( + CODES_LIST, CODES_LIST[_mem.scramble_code])) mem.extra.append(rs)
return mem @@ -382,7 +386,7 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio): def get_settings(self): _settings = self._memobj.settings
- group = RadioSettingGroup("basic", "Basic"); + group = RadioSettingGroup("basic", "Basic") top = RadioSettings(group)
group.append( @@ -396,7 +400,7 @@ class TYTTHUVF1Radio(chirp_common.CloneModeRadio):
group.append( RadioSetting("squelch", "Squelch Level", - RadioSettingValueInteger(0, 9, _settings.squelch))) + RadioSettingValueInteger(0, 9, _settings.squelch)))
group.append( RadioSetting("vox_level", "VOX Level", diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 16d6347..26dab82 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -30,7 +30,6 @@ ./chirp/drivers/th_uv3r25.py ./chirp/drivers/th_uvf8d.py ./chirp/drivers/thd72.py -./chirp/drivers/thuv1f.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py ./chirp/drivers/vx170.py
# HG changeset patch # User Zach Welch zach@mandolincreekfarm.com # Fake Node ID 2d4427ed3888ecc9a83ddc05212190fc5fe881b4
Fix style issues in thd72.py (#2355)
diff --git a/chirp/drivers/thd72.py b/chirp/drivers/thd72.py index aa414de..d503740 100644 --- a/chirp/drivers/thd72.py +++ b/chirp/drivers/thd72.py @@ -15,7 +15,10 @@
from chirp import chirp_common, errors, util, directory from chirp import bitwise, memmap -import time, struct, sys, logging +import time +import struct +import sys +import logging
LOG = logging.getLogger(__name__)
@@ -41,7 +44,7 @@ LOG = logging.getLogger(__name__) # 0xe500..0xe7d0: startup bitmap # 0xe7d0..0xe800: startup bitmap filename # 0xe800..0xead0: gps-logger bitmap -# 0xe8d0..0xeb00: gps-logger bipmap filename +# 0xe8d0..0xeb00: gps-logger bipmap filename # 0xeb00..0xff00: ? # 0xff00..0xffff: stuff?
@@ -111,47 +114,47 @@ THD72_SPECIAL["C VHF"] = 1030 THD72_SPECIAL["C UHF"] = 1031
THD72_SPECIAL_REV = {} -for k,v in THD72_SPECIAL.items(): +for k, v in THD72_SPECIAL.items(): THD72_SPECIAL_REV[v] = k
TMODES = { - 0x08 : "Tone", - 0x04 : "TSQL", - 0x02 : "DTCS", - 0x01 : "Cross", - 0x00 : "", + 0x08: "Tone", + 0x04: "TSQL", + 0x02: "DTCS", + 0x01: "Cross", + 0x00: "", } TMODES_REV = { - "" : 0x00, - "Cross" : 0x01, - "DTCS" : 0x02, - "TSQL" : 0x04, - "Tone" : 0x08, + "": 0x00, + "Cross": 0x01, + "DTCS": 0x02, + "TSQL": 0x04, + "Tone": 0x08, }
MODES = { - 0x00 : "FM", - 0x01 : "NFM", - 0x02 : "AM", + 0x00: "FM", + 0x01: "NFM", + 0x02: "AM", }
MODES_REV = { - "FM" : 0x00, + "FM": 0x00, "NFM": 0x01, - "AM" : 0x2, + "AM": 0x2, }
DUPLEX = { - 0x00 : "", - 0x01 : "+", - 0x02 : "-", - 0x04 : "split", + 0x00: "", + 0x01: "+", + 0x02: "-", + 0x04: "split", } DUPLEX_REV = { - "" : 0x00, - "+" : 0x01, - "-" : 0x02, - "split" : 0x04, + "": 0x00, + "+": 0x01, + "-": 0x02, + "split": 0x04, }
@@ -170,7 +173,7 @@ class THD72Radio(chirp_common.CloneModeRadio):
mem_upper_limit = 1022 _memsize = 65536 - _model = "" # FIXME: REMOVE + _model = "" # FIXME: REMOVE _dirty_blocks = []
def get_features(self): @@ -252,11 +255,12 @@ class THD72Radio(chirp_common.CloneModeRadio): try: number = THD72_SPECIAL[number] except KeyError: - raise errors.InvalidMemoryLocation("Unknown channel %s" % \ - number) + raise errors.InvalidMemoryLocation("Unknown channel %s" % + number)
if number < 0 or number > (max(THD72_SPECIAL.values()) + 1): - raise errors.InvalidMemoryLocation("Number must be between 0 and 999") + raise errors.InvalidMemoryLocation( + "Number must be between 0 and 999")
_mem = self._memobj.memory[number] flag = self._memobj.flag[number] @@ -287,17 +291,18 @@ class THD72Radio(chirp_common.CloneModeRadio): mem.cross_mode = chirp_common.CROSS_MODES[0] mem.immutable = ["number", "bank", "extd_number", "cross_mode"] if number >= 1020 and number < 1030: - mem.immutable += ["freq", "offset", "tone", "mode", "tmode", "ctone", "skip"] # FIXME: ALL + mem.immutable += ["freq", "offset", "tone", "mode", + "tmode", "ctone", "skip"] # FIXME: ALL else: mem.immutable += ["name"]
return mem
- def set_memory(self, mem): - print "set_memory(%d)"%mem.number + print "set_memory(%d)" % mem.number if mem.number < 0 or mem.number > (max(THD72_SPECIAL.values()) + 1): - raise errors.InvalidMemoryLocation("Number must be between 0 and 999") + raise errors.InvalidMemoryLocation( + "Number must be between 0 and 999")
# weather channels can only change name, nothing else if mem.number >= 1020 and mem.number < 1030: @@ -336,7 +341,6 @@ class THD72Radio(chirp_common.CloneModeRadio): if mem.number < 999: flag.skip = chirp_common.SKIP_VALUES.index(mem.skip)
- def sync_in(self): self._detect_baud() self._mmap = self.download() @@ -447,7 +451,6 @@ class THD72Radio(chirp_common.CloneModeRadio): # clear out blocks we uploaded from the dirty blocks list self._dirty_blocks = [b for b in self._dirty_blocks if b not in blocks]
- def command(self, cmd, timeout=0.5): start = time.time()
@@ -466,7 +469,6 @@ class THD72Radio(chirp_common.CloneModeRadio): else: raise errors.RadioError("No response to ID command")
- def initialize(self, mmap): mmap[0] = \ "\x80\xc8\xb3\x08\x00\x01\x00\x08" + \ @@ -478,15 +480,18 @@ if __name__ == "__main__": import serial import detect import getopt + def fixopts(opts): r = {} for opt in opts: - k,v = opt + k, v = opt r[k] = v return r
def usage(): - print "Usage: %s <-i input.img>|<-o output.img> -p port [[-f first-addr] [-l last-addr] | [-b list,of,blocks]]" % sys.argv[0] + print "Usage: %s <-i input.img>|<-o output.img> -p port " \ + "[[-f first-addr] [-l last-addr] | [-b list,of,blocks]]" % \ + sys.argv[0] sys.exit(1)
opts, args = getopt.getopt(sys.argv[1:], "i:o:p:f:l:b:") @@ -507,9 +512,9 @@ if __name__ == "__main__": usage()
if '-f' in opts: - first = int(opts['-f'],0) + first = int(opts['-f'], 0) if '-l' in opts: - last = int(opts['-l'],0) + last = int(opts['-l'], 0) if '-b' in opts: blocks = [int(b, 0) for b in opts['-b'].split(',')] blocks.sort() @@ -540,4 +545,3 @@ if __name__ == "__main__": r._mmap = file(fname, "rb").read(r._memsize) r.upload(blocks) print "\nDone" - diff --git a/tools/cpep8.blacklist b/tools/cpep8.blacklist index 26dab82..fa6ebdb 100644 --- a/tools/cpep8.blacklist +++ b/tools/cpep8.blacklist @@ -29,7 +29,6 @@ ./chirp/drivers/th_uv3r.py ./chirp/drivers/th_uv3r25.py ./chirp/drivers/th_uvf8d.py -./chirp/drivers/thd72.py ./chirp/drivers/tmv71.py ./chirp/drivers/tmv71_ll.py ./chirp/drivers/vx170.py
participants (1)
-
Zach Welch