mirror of
https://github.com/kk7ds/chirp.git
synced 2024-09-21 10:37:15 +00:00
Fix up 2200 memory location initialization. Also properly detect used
memory locations.
This commit is contained in:
parent
ec31cf5d16
commit
6fa5a2a4e2
@ -75,7 +75,10 @@ class IC2200Radio(chirp_common.IcomMmapRadio):
|
||||
if not self._mmap:
|
||||
self.sync_in()
|
||||
|
||||
return self._memories[number]
|
||||
try:
|
||||
return self._memories[number]
|
||||
except IndexError:
|
||||
raise errors.InvalidMemoryLocation("Location is empty")
|
||||
|
||||
def get_memories(self, vfo=None):
|
||||
if not self._mmap:
|
||||
|
@ -9,12 +9,14 @@ def get_memory(map, number):
|
||||
_freq = (struct.unpack("<H", chunk[0:2])[0] * 5) / 1000.0
|
||||
_name = chunk[4:10]
|
||||
|
||||
if _name[0] == "\x00" or _name[0] == "\xFF":
|
||||
if map[0x1370 + number] == "\x7A":
|
||||
# Location is not used
|
||||
return None
|
||||
|
||||
m = chirp_common.Memory()
|
||||
m.freq = _freq
|
||||
m.name = _name.replace("\x0e", "").strip()
|
||||
m.number = number
|
||||
|
||||
return m
|
||||
|
||||
@ -22,12 +24,25 @@ def set_memory(map, memory):
|
||||
_fa = (memory.number * 24)
|
||||
_na = (memory.number * 24) + 4
|
||||
|
||||
if map[_fa + 2] == "\xFF":
|
||||
# Assume this is empty now, so initialize bits
|
||||
map = util.write_in_place(map, _fa + 2, "\x78\x00")
|
||||
map = util.write_in_place(map, _fa + 10, "\x08\x08" + ("\x00" * 12))
|
||||
|
||||
freq = struct.pack("<H", int(memory.freq * 1000) / 5)
|
||||
name = memory.name.ljust(8)[:8]
|
||||
name = memory.name.ljust(6)[:6]
|
||||
|
||||
map = util.write_in_place(map, _fa, freq)
|
||||
map = util.write_in_place(map, _na, name)
|
||||
|
||||
# Mark as used
|
||||
map = util.write_in_place(map, 0x1370 + memory.number, "\x4A")
|
||||
|
||||
if name == (" " * 6):
|
||||
map = util.write_in_place(map, _fa+22, "\x00")
|
||||
else:
|
||||
map = util.write_in_place(map, _fa+22, "\x10")
|
||||
|
||||
return map
|
||||
|
||||
def parse_map_for_memory(map):
|
||||
|
Loading…
Reference in New Issue
Block a user