Skip to content

Commit

Permalink
Merge branch 'kk7ds:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
jbradsha authored Aug 21, 2024
2 parents 1fc2fc6 + 02f2d72 commit 8fb525c
Show file tree
Hide file tree
Showing 34 changed files with 1,722 additions and 1,181 deletions.
7 changes: 5 additions & 2 deletions chirp/chirp_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1572,8 +1572,11 @@ def get_memory_extra(self, memory):
rf = self.get_features()
if not rf.has_comment and isinstance(memory.number, int):
self._metadata.setdefault('mem_extra', {})
memory.comment = self._metadata['mem_extra'].get(
'%04i_comment' % memory.number, '')
try:
memory.comment = self._metadata['mem_extra'].get(
'%04i_comment' % memory.number, '')
except ImmutableValueError:
pass
return memory

def set_memory_extra(self, memory):
Expand Down
6 changes: 4 additions & 2 deletions chirp/drivers/baofeng_uv17.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ class UV17(baofeng_uv17Pro.UV17Pro):
LIST_MODE = ["Name", "Frequency"]
CHANNELS = 999

MEM_DEFS = """
CHANNEL_DEF = """
struct channel {
lbcd rxfreq[4];
lbcd txfreq[4];
Expand All @@ -215,6 +215,8 @@ class UV17(baofeng_uv17Pro.UV17Pro):
scan:1;
u8 unknown4;
};
"""
MEM_DEFS = """
struct channelname {
char name[11];
};
Expand Down Expand Up @@ -320,7 +322,7 @@ class UV17(baofeng_uv17Pro.UV17Pro):
struct ani ani;
"""
MEM_FORMAT = MEM_DEFS + MEM_LAYOUT
MEM_FORMAT = CHANNEL_DEF + MEM_DEFS + MEM_LAYOUT

def _make_frame(self, cmd, addr, length, data=""):
"""Pack the info in the header format"""
Expand Down
2 changes: 1 addition & 1 deletion chirp/drivers/baofeng_uv17Pro.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ class UV17Pro(bfc.BaofengCommonHT):
u8 rpttailclear;
u8 rpttaildet;
u8 roger;
u8 unknown2;
u8 a_or_b_selected; // a=0, b=1
u8 fmenable;
u8 chbworkmode:4,
chaworkmode:4;
Expand Down
6 changes: 5 additions & 1 deletion chirp/drivers/btech.py
Original file line number Diff line number Diff line change
Expand Up @@ -2548,12 +2548,16 @@ def apply_dmtf_listvalue(setting, obj):
val]))
dtmf_dec_settings.append(line)
else:
if _mem.dtmf_settings.resettime > 0x4F:
val = 0x4F
else:
val = _mem.dtmf_settings.resettime
line = RadioSetting(
"dtmf_settings.resettime",
"Reset time",
RadioSettingValueList(LIST_5TONE_RESET,
LIST_5TONE_RESET[
_mem.dtmf_settings.resettime]))
val]))
dtmf_dec_settings.append(line)

if _mem.dtmf_settings.delayproctime > 0x27:
Expand Down
38 changes: 27 additions & 11 deletions chirp/drivers/ft4.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
RadioSettingValueList, RadioSettingValueString, RadioSettings

LOG = logging.getLogger(__name__)
COMM_DIRECTION_FROM = 0
COMM_DIRECTION_TO = 1


# Layout of Radio memory image.
Expand Down Expand Up @@ -301,7 +303,7 @@ def enter_clonemode(radio):
raise errors.RadioError("expected QX from radio.")


def startcomms(radio, way):
def startcomms(radio, direction):
"""
For either upload or download, put the radio into PROGRAM mode
and check the radio's ID. In this preliminary version of the driver,
Expand All @@ -310,8 +312,23 @@ def startcomms(radio, way):
send "PROGRAM" to command the radio into clone mode
read the initial string (version?)
"""

progress_messages = {
COMM_DIRECTION_FROM: _("Cloning from radio"),
COMM_DIRECTION_TO: _("Cloning to radio")
}

progressbar = chirp_common.Status()
progressbar.msg = "Cloning " + way + " radio"
if direction in progress_messages:
progressbar.msg = progress_messages[direction]
else:
LOG.debug(
f"direction parameter value is not recognised: {direction}"
)
raise errors.InvalidValueError(
f"Unexpected parameter received: {direction}"
)

progressbar.max = radio.numblocks
enter_clonemode(radio)
id_response = sendcmd(radio.pipe, b'\x02', None)
Expand Down Expand Up @@ -372,7 +389,7 @@ def do_download(radio):
"""
image = bytearray(radio.get_memsize())
pipe = radio.pipe # Get the serial port connection
progressbar = startcomms(radio, "from")
progressbar = startcomms(radio, COMM_DIRECTION_FROM)
for blocknum in range(radio.numblocks):
for i in range(0, 3):
if getblock(pipe, 16 * blocknum, image):
Expand Down Expand Up @@ -404,7 +421,7 @@ def do_upload(radio):
send "END"
"""
pipe = radio.pipe # Get the serial port connection
progressbar = startcomms(radio, "to")
progressbar = startcomms(radio, COMM_DIRECTION_TO)
data = get_mmap_data(radio)
for _i in range(1, radio.numblocks):
putblock(pipe, 16*_i, data[16*_i:16*(_i+1)])
Expand Down Expand Up @@ -698,16 +715,15 @@ def subtype(self, value):
@classmethod
def get_prompts(cls):
rp = chirp_common.RadioPrompts()
rp.experimental = (
'Tested and mostly works, but may give you issues\n'
'when using lesser common radio variants.\n'
'Proceed at your own risk, and let us know about issues!'
rp.experimental = _(
"Tested and mostly works, but may give you issues\n"
"when using lesser common radio variants.\n"
"Proceed at your own risk, and let us know about issues!"
)

rp.pre_download = "".join([
"1. Connect programming cable to MIC jack.\n",
rp.pre_download = _(
"1. Connect programming cable to MIC jack.\n"
"2. Press OK."
]
)
rp.pre_upload = rp.pre_download
return rp
Expand Down
2 changes: 1 addition & 1 deletion chirp/drivers/ft70.py
Original file line number Diff line number Diff line change
Expand Up @@ -569,7 +569,7 @@ def get_features(self):
rf.valid_bands = [(500000, 999900000)]
rf.valid_skips = SKIPS
rf.valid_power_levels = POWER_LEVELS
rf.valid_characters = "".join(CHARSET)
rf.valid_characters = "".join(CHARSET).upper()
rf.valid_name_length = 6
rf.memory_bounds = (1, 900)
rf.can_odd_split = True
Expand Down
22 changes: 21 additions & 1 deletion chirp/drivers/ga510.py
Original file line number Diff line number Diff line change
Expand Up @@ -1141,6 +1141,26 @@ class RadioddityGA510v2(baofeng_uv17.UV17):
LIST_MODE = ["Name", "Frequency"]
CHANNELS = 128

CHANNEL_DEF = """
struct channel {
lbcd rxfreq[4];
lbcd txfreq[4];
u8 unused1;
ul16 rxtone;
ul16 txtone;
u8 unknown1:1,
bcl:1,
pttid:2,
unknown2:1,
wide:1,
lowpower:2;
u8 scode:4,
unknown3:3,
scan:1;
u8 unknown4;
};
"""

MEM_LAYOUT = """
#seekto 0x1000;
struct settings settings;
Expand All @@ -1157,6 +1177,6 @@ class RadioddityGA510v2(baofeng_uv17.UV17):
#seekto 0x400B;
struct channelname names1[128];
"""
MEM_FORMAT = baofeng_uv17.UV17.MEM_DEFS + MEM_LAYOUT
MEM_FORMAT = CHANNEL_DEF + baofeng_uv17.UV17.MEM_DEFS + MEM_LAYOUT

_has_workmode_support = False
10 changes: 8 additions & 2 deletions chirp/drivers/icf.py
Original file line number Diff line number Diff line change
Expand Up @@ -1034,25 +1034,31 @@ def get_bank_model(self):
return None


def warp_byte_size(inbytes, obw=8, ibw=8):
def warp_byte_size(inbytes, obw=8, ibw=8, iskip=0, opad=0):
"""Convert between "byte sizes".
This will pack N-bit characters into a sequence of 8-bit bytes,
and perform the opposite.
ibw (input bit width) is the width of the storage
obw (output bit width) is the width of the characters to extract
iskip is the number of input padding bits to skip
opad is the number of output zero padding bits to add
ibw=8,obw=7 will pull seven-bit characters from a sequence of bytes
ibw=7,obw=8 will pack seven-bit characters into a sequence of bytes
"""
if isinstance(inbytes, str):
inbytes = [ord(x) for x in inbytes]
outbit = 0
outbit = opad
tmp = 0
stripmask = 1 << (ibw - 1)
for byte in inbytes:
inbit = 0
while iskip:
byte = (byte << 1) & 0xFF
inbit += 1
iskip -= 1
for i in range(0, max(obw, ibw - inbit)):
if inbit == ibw:
# Move to next char
Expand Down
4 changes: 4 additions & 0 deletions chirp/drivers/radtel_rt490.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,9 @@ class RT490Radio(chirp_common.CloneModeRadio):
(0x3FC0, 0x4000)
]

_valid_chars = chirp_common.CHARSET_ALPHANUMERIC + \
"`~!@#$%^&*()-=_+[]\\{}|;':\",./<>?"

if RT490_EXPERIMENTAL:
# Experimental driver (already heavily tested)
_ranges = [(0x0000, 0x2400), (0x3400, 0x3C40), (0x3F80, 0x4000)]
Expand Down Expand Up @@ -1298,6 +1301,7 @@ def get_features(self): # GOOD ?
rf.can_odd_split = True
rf.has_name = True
rf.valid_name_length = 12
rf.valid_characters = self._valid_chars
rf.valid_skips = ["", "S"]
rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"]
rf.valid_cross_modes = ["Tone->Tone", "DTCS->", "->DTCS", "Tone->DTCS",
Expand Down
27 changes: 23 additions & 4 deletions chirp/drivers/tdh8.py
Original file line number Diff line number Diff line change
Expand Up @@ -741,14 +741,12 @@

# AB CHANNEL
A_OFFSET = ["Off", "-", "+"]
A_TX_POWER = ["Low", "Mid", "High"]
A_BAND = ["Wide", "Narrow"]
A_BUSYLOCK = ["Off", "On"]
A_SPEC_QTDQT = ["Off", "On"]
A_WORKMODE = ["VFO", "VFO+CH", "CH Mode"]

B_OFFSET = ["Off", "-", "+"]
B_TX_POWER = ["Low", "Mid", "High"]
B_BAND = ["Wide", "Narrow"]
B_BUSYLOCK = ["Off", "On"]
B_SPEC_QTDQT = ["Off", "On"]
Expand Down Expand Up @@ -1719,9 +1717,15 @@ def _filter(name):
A_OFFSET, A_OFFSET[_vfoa.offset]))
abblock.append(rs)

try:
self._tx_power[_vfoa.lowpower]
cur_a_power = _vfoa.lowpower
except IndexError:
cur_a_power = 0
rs = RadioSetting("lowpower", "A TX Power",
RadioSettingValueList(
A_TX_POWER, A_TX_POWER[_vfoa.lowpower]))
[str(x) for x in self._tx_power],
str(self._tx_power[cur_a_power])))
abblock.append(rs)

rs = RadioSetting("wide", "A Band",
Expand Down Expand Up @@ -1781,9 +1785,15 @@ def _filter(name):
B_OFFSET, B_OFFSET[_vfob.offsetb]))
abblock.append(rs)

try:
self._tx_power[_vfob.lowpowerb]
cur_b_power = _vfob.lowpowerb
except IndexError:
cur_b_power = 0
rs = RadioSetting("lowpowerb", "B TX Power",
RadioSettingValueList(
B_TX_POWER, B_TX_POWER[_vfob.lowpowerb]))
[str(x) for x in self._tx_power],
str(self._tx_power[cur_b_power])))
abblock.append(rs)

rs = RadioSetting("wideb", "B Band",
Expand Down Expand Up @@ -2465,8 +2475,17 @@ class TDH8_HAM(TDH8):
MODEL = "TD-H8-HAM"
ident_mode = b'P31185\xff\xff'
_ham = True
_rxbands = [(136000000, 143999000), (149000001, 174000000),
(400000000, 419999000), (451000001, 521000000)]
_txbands = [(144000000, 149000000), (420000000, 451000000)]

def check_set_memory_immutable_policy(self, existing, new):
# Immutable duplex handling is done in set_memory, so no need
# to ever obsess over it here.
if 'duplex' in existing.immutable:
existing.immutable.remove('duplex')
super().check_set_memory_immutable_policy(existing, new)


@directory.register
@directory.detected_by(TDH8)
Expand Down
Loading

0 comments on commit 8fb525c

Please sign in to comment.