# Copyright 2011 Dan Smith # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation, either version 3 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program. If not, see . from chirp import chirp_common, icf, directory from chirp import bitwise MEM_FORMAT = """ struct { ul32 freq; ul32 offset; u8 ts; u16 unknown1; u8 dtcs1; u8 dtcs2; u8 tsql; char name[8]; } memory[1000]; """ TMODES = ["", "TSQL", "DTCS", "VSC"] DUPLEX = ["", "-", "+"] DTCS_POLARITY = ["Normal", "Reverse"] TUNING_STEPS = [0.01, 0.1, 1.0, 5.0, 6.25, 8.33, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, 100.0] @directory.register class icr20Radio(icf.IcomCloneModeRadio): """Icom IC-R20""" VENDOR = "Icom" MODEL = "IC-R20" _model = "\x26\x99\x00\x01" _memsize = 0x15500 _endframe = "Icom Inc\x2eCF" _can_hispeed = False _ranges = [(0x0000, 0x15500, 32)] # _num_banks = 26 # _bank_class = ICT70Bank def get_features(self): rf = chirp_common.RadioFeatures() rf.memory_bounds = (0, 999) rf.valid_tmodes = TMODES rf.valid_duplexes = DUPLEX rf.valid_modes = ["FM", "WFM", "AM", "LSB", "USB", "CW"] # rf.valid_bands = [(136000000, 174000000), (400000000, 479000000)] rf.valid_skips = ["", "S", "P"] rf.valid_tuning_steps = TUNING_STEPS rf.valid_name_length = 8 rf.has_ctone = False rf.has_bank = False rf.has_bank_index = False rf.has_bank_names = False return rf def process_mmap(self): self._memobj = bitwise.parse(MEM_FORMAT, self._mmap) def get_raw_memory(self, number): return repr(self._memobj.memory[number]) def get_memory(self, number): bit = 1 << (number % 8) byte = int(number / 8) _mem = self._memobj.memory[number] mem = chirp_common.Memory() mem.number = number if _mem.freq == 0x0: mem.empty = True return mem else: mem.freq = int(_mem.freq) mem.offset = int(_mem.offset) mem.name = str(_mem.name).rstrip() mem.rtone = chirp_common.TONES[0] mem.ctone = chirp_common.TONES[0] mem.dtcs = chirp_common.DTCS_CODES[0] mem.tuning_step = TUNING_STEPS[_mem.ts & 0x0F] mem.mode = "FM" mem.duplex = DUPLEX[0] # mem.dtcs_polarity = DTCS_POLARITY[_mem.dtcs_polarity] # mem.tmode = TMODES[_mem.tmode] # mem.skip = (_psk & bit and "P") or (_skp & bit and "S") or "" return mem