Project

General

Profile

Bug #10477 » vx170.py

7a2d836a - Dan Smith, 03/26/2023 08:39 AM

 
1
# Copyright 2014 Jens Jensen <af5mi@yahoo.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.drivers import yaesu_clone, ft7800
17
from chirp import chirp_common, directory, bitwise
18

    
19
MEM_FORMAT = """
20
#seekto 0x018A;
21
struct {
22
    u16 in_use;
23
} bank_used[24];
24

    
25
#seekto 0x0214;
26
u16  banksoff1;
27
#seekto 0x0294;
28
u16  banksoff2;
29

    
30
#seekto 0x097A;
31
struct {
32
  u8 name[6];
33
} bank_names[24];
34

    
35
#seekto 0x0C0A;
36
struct {
37
  u16 channels[100];
38
} banks[24];
39

    
40
#seekto 0x0168;
41
struct {
42
  u8 used:1,
43
     unknown1:1,
44
     mode:1,
45
     unknown2:2,
46
     duplex:3;
47
  bbcd freq[3];
48
  u8 clockshift:1,
49
     tune_step:3,
50
     unknown5:1,
51
     tmode:3;
52
  bbcd split[3];
53
  u8 power:2,
54
     tone:6;
55
  u8 unknown6:1,
56
     dtcs:7;
57
  u8 unknown7[2];
58
  u8 offset;
59
  u8 unknown9[3];
60
} memory [200];
61

    
62
#seekto 0x0F28;
63
struct {
64
  char name[6];
65
  u8 enabled:1,
66
     unknown1:7;
67
  u8 used:1,
68
     unknown2:7;
69
} names[200];
70

    
71
#seekto 0x1768;
72
struct {
73
  u8 skip3:2,
74
     skip2:2,
75
     skip1:2,
76
     skip0:2;
77
} flags[50];
78
"""
79

    
80

    
81
@directory.register
82
class VX170Radio(ft7800.FTx800Radio):
83
    """Yaesu VX-170"""
84
    MODEL = "VX-170"
85
    _model = "AH022"
86
    _memsize = 6057
87
    _block_lengths = [8, 6048, 1]
88
    _block_size = 32
89

    
90
    POWER_LEVELS_VHF = [chirp_common.PowerLevel("Hi", watts=5.00),
91
                        chirp_common.PowerLevel("Med", watts=2.00),
92
                        chirp_common.PowerLevel("Lo", watts=0.50)]
93

    
94
    MODES = ["FM", "NFM"]
95
    # Note that mode index 4 is actually EPCS (dual-toone paging), which
96
    # we do not support, so map that to TSQL, which is most similar
97
    TMODES = ["", "Tone", "TSQL", "DTCS", "TSQL"]
98

    
99
    @classmethod
100
    def get_prompts(cls):
101
        rp = chirp_common.RadioPrompts()
102
        rp.pre_download = _(
103
            "1. Turn radio off.\n"
104
            "2. Connect cable to MIC/SP jack.\n"
105
            "3. Press and hold in the [moni] key while turning the radio"
106
            " on.\n"
107
            "4. Select CLONE in menu, then press F. Radio restarts in clone"
108
            " mode.\n"
109
            "     (\"CLONE\" will appear on the display).\n"
110
            "5. <b>After clicking OK</b>, briefly hold [PTT] key to send"
111
            " image.\n"
112
            "    (\"-TX-\" will appear on the LCD). \n")
113
        rp.pre_upload = _(
114
            "1. Turn radio off.\n"
115
            "3. Press and hold in the [moni] key while turning the radio"
116
            " on.\n"
117
            "4. Select CLONE in menu, then press F. Radio restarts in clone"
118
            " mode.\n"
119
            "     (\"CLONE\" will appear on the display).\n"
120
            "5. Press the [moni] key (\"-RX-\" will appear on the LCD).\n")
121
        return rp
122

    
123
    def _checksums(self):
124
        return [yaesu_clone.YaesuChecksum(0x0000, self._memsize - 2)]
125

    
126
    def process_mmap(self):
127
        self._memobj = bitwise.parse(MEM_FORMAT, self._mmap)
128

    
129
    def get_features(self):
130
        rf = super(VX170Radio, self).get_features()
131
        rf.has_bank = False
132
        rf.has_bank_names = False
133
        rf.valid_modes = self.MODES
134
        rf.memory_bounds = (1, 200)
135
        rf.valid_bands = [(137000000, 174000000)]
136
        return rf
(3-3/3)