# 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