577 |
577 |
ul16 special_bank[7];
|
578 |
578 |
#seekto 0x1200;
|
579 |
579 |
struct {
|
580 |
|
u8 unknown;
|
|
580 |
u8 empty;
|
581 |
581 |
ul32 freq;
|
582 |
582 |
u8 mode;
|
583 |
583 |
u8 step;
|
... | ... | |
587 |
587 |
u8 tx_tone;
|
588 |
588 |
u8 rx_tone;
|
589 |
589 |
u8 dcs;
|
590 |
|
#seek 3;
|
|
590 |
ul24 unknown1;
|
591 |
591 |
u8 skip;
|
592 |
|
#seek 12;
|
|
592 |
ul32 unknown2;
|
|
593 |
ul32 unknown3;
|
|
594 |
ul32 unknown4;
|
593 |
595 |
char name[32];
|
594 |
596 |
} memory[1000];
|
595 |
597 |
"""
|
... | ... | |
740 |
742 |
status.msg = "Uploading to radio"
|
741 |
743 |
self.status_fn(status)
|
742 |
744 |
|
|
745 |
def _get_empty_flag(self, freq, mode):
|
|
746 |
# Returns flag used to hide a channel from the main band. This occurs
|
|
747 |
# when the mode is anything but NFM or FM (main band can only do those)
|
|
748 |
# or when the frequency is outside of the range supported by the main
|
|
749 |
# band.
|
|
750 |
if mode not in ("NFM", "FM"):
|
|
751 |
return 0x01
|
|
752 |
if (freq >= 136000000 and freq < 174000000) or \
|
|
753 |
(freq >= 400000000 and freq < 470000000) or \
|
|
754 |
(freq >= 1240000000 and freq < 1300000000):
|
|
755 |
return 0x02
|
|
756 |
else:
|
|
757 |
return 0x01
|
|
758 |
|
|
759 |
def _check_channel_consistency(self, number):
|
|
760 |
_mem = self._memobj.memory[number]
|
|
761 |
if _mem.empty != 0x00:
|
|
762 |
if _mem.unknown1 == 0xffffff:
|
|
763 |
# Previous versions of this code have skipped the unknown
|
|
764 |
# fields. They contain bytes of value if the channel is empty and
|
|
765 |
# thus those bytes remain 0xff when the channel is put to use.
|
|
766 |
# The radio is totally fine with this but the Alinco programming
|
|
767 |
# software is not (see #5275). Here, we check for this and
|
|
768 |
# report if it is encountered.
|
|
769 |
LOG.warning("Channel %d is inconsistent: Found 0xff in non-empty channel. Touch channel to fix." % number)
|
|
770 |
|
|
771 |
if _mem.empty != self._get_empty_flag(_mem.freq, self.MODES[_mem.mode]):
|
|
772 |
LOG.warning("Channel %d is inconsistent: Found out of band frequency. Touch channel to fix." % number)
|
|
773 |
|
743 |
774 |
def process_mmap(self):
|
744 |
775 |
self._memobj = bitwise.parse(DJG7EG_MEM_FORMAT, self._mmap)
|
|
776 |
# We check all channels for corruption (see bug #5275) but we don't fix
|
|
777 |
# it automatically because it would be unpolite to modify something on a
|
|
778 |
# read operation. A log message is emitted though for the user to take
|
|
779 |
# actions.
|
|
780 |
for number in range(len(self._memobj.memory)):
|
|
781 |
self._check_channel_consistency(number)
|
745 |
782 |
|
746 |
783 |
def get_memory(self, number):
|
747 |
784 |
_mem = self._memobj.memory[number]
|
748 |
785 |
mem = chirp_common.Memory()
|
749 |
786 |
mem.number = number
|
750 |
|
if _mem.unknown == 0:
|
|
787 |
if _mem.empty == 0:
|
751 |
788 |
mem.empty = True
|
752 |
789 |
else:
|
753 |
790 |
mem.freq = int(_mem.freq)
|
... | ... | |
774 |
811 |
# Get a low-level memory object mapped to the image
|
775 |
812 |
_mem = self._memobj.memory[mem.number]
|
776 |
813 |
if mem.empty:
|
777 |
|
_mem.unknown = 0x00 # Maybe 0 is empty, 2 is used?
|
|
814 |
_mem.set_raw("\xff" * (_mem.size()/8))
|
|
815 |
_mem.empty = 0x00
|
778 |
816 |
else:
|
779 |
|
_mem.unknown = 0x02
|
|
817 |
_mem.empty = self._get_empty_flag(mem.freq, mem.mode)
|
780 |
818 |
_mem.freq = mem.freq
|
781 |
819 |
_mem.mode = self.MODES.index(mem.mode)
|
782 |
820 |
_mem.step = self.STEPS.index(mem.tuning_step)
|
... | ... | |
819 |
857 |
_mem.dcs = DCS_CODES[self.VENDOR].index(mem.dtcs)
|
820 |
858 |
_mem.skip = (mem.skip == "S")
|
821 |
859 |
_mem.name = "\x00".join(mem.name).ljust(32, "\x00")
|
|
860 |
_mem.unknown1 = 0x3e001c
|
|
861 |
_mem.unknown2 = 0x0000000a
|
|
862 |
_mem.unknown3 = 0x00000000
|
|
863 |
_mem.unknown4 = 0x00000000
|