1
|
# Copyright 2010 Dan Smith <dsmith@danplanet.com>
|
2
|
#
|
3
|
# This program is free software: you can redistribute it and/or modify
|
4
|
# it under the terms of the GNU General Public License as published by
|
5
|
# the Free Software Foundation, either version 3 of the License, or
|
6
|
# (at your option) any later version.
|
7
|
#
|
8
|
# This program is distributed in the hope that it will be useful,
|
9
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
10
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
11
|
# GNU General Public License for more details.
|
12
|
#
|
13
|
# You should have received a copy of the GNU General Public License
|
14
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
15
|
|
16
|
from chirp import chirp_common, icf, ic9x_icf_ll, util, directory, errors
|
17
|
|
18
|
# Don't register as this module is used to load icf file from File-Open menu
|
19
|
# see do_open in mainapp.py
|
20
|
class IC9xICFRadio(chirp_common.CloneModeRadio):
|
21
|
VENDOR = "Icom"
|
22
|
MODEL = "IC-91/92AD"
|
23
|
VARIANT = "ICF File"
|
24
|
_model = None
|
25
|
|
26
|
_upper = 1200
|
27
|
|
28
|
def get_features(self):
|
29
|
rf = chirp_common.RadioFeatures()
|
30
|
rf.has_bank = False
|
31
|
rf.memory_bounds = (0, self._upper)
|
32
|
rf.has_sub_devices = True
|
33
|
rf.valid_modes = ["FM", "AM"]
|
34
|
if "A" in self.VARIANT:
|
35
|
rf.valid_modes.append("WFM")
|
36
|
else:
|
37
|
rf.valid_modes.append("DV")
|
38
|
rf.valid_modes.append("NFM")
|
39
|
return rf
|
40
|
|
41
|
def get_raw_memory(self, number):
|
42
|
raw = ic9x_icf_ll.get_raw_memory(self._mmap, number).get_packed()
|
43
|
return util.hexprint(raw)
|
44
|
|
45
|
def get_memory(self, number):
|
46
|
return ic9x_icf_ll.get_memory(self._mmap, number)
|
47
|
|
48
|
def load_mmap(self, filename):
|
49
|
_mdata, self._mmap = icf.read_file(filename)
|
50
|
|
51
|
def get_sub_devices(self):
|
52
|
return [IC9xICFRadioA(self._mmap),
|
53
|
IC9xICFRadioB(self._mmap)]
|
54
|
|
55
|
class IC9xICFRadioA(IC9xICFRadio):
|
56
|
VARIANT = "ICF File Band A"
|
57
|
|
58
|
_upper = 800
|
59
|
|
60
|
def get_memory(self, number):
|
61
|
if number > self._upper:
|
62
|
raise errors.InvalidMemoryLocation("Number must be <800")
|
63
|
|
64
|
return ic9x_icf_ll.get_memory(self._mmap, number)
|
65
|
|
66
|
class IC9xICFRadioB(IC9xICFRadio):
|
67
|
VARIANT = "ICF File Band B"
|
68
|
|
69
|
_upper = 400
|
70
|
|
71
|
def get_memory(self, number):
|
72
|
if number > self._upper:
|
73
|
raise errors.InvalidMemoryLocation("Number must be <400")
|
74
|
|
75
|
mem = ic9x_icf_ll.get_memory(self._mmap, 850 + number)
|
76
|
mem.number = number
|
77
|
return mem
|