Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error message for tuning step failure #1168

Merged
merged 3 commits into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions chirp/chirp_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1783,9 +1783,12 @@ def required_step(freq, allowed=None):
}

# Try the above "standard" steps first in order
required_step = None
for step, validate in steps.items():
if step in allowed and validate(freq):
return step
elif validate(freq) and required_step is None:
required_step = step

# Try any additional steps in the allowed list
for step in allowed:
Expand All @@ -1797,8 +1800,14 @@ def required_step(freq, allowed=None):
step, format_freq(freq)))
return step

raise errors.InvalidDataError("Unable to find a supported " +
"tuning step for %s" % format_freq(freq))
if required_step is not None:
raise errors.InvalidDataError((
'Frequency %s requires step %.2f, '
'which is not supported') % (
format_freq(freq), required_step))
else:
raise errors.InvalidDataError("Unable to find a supported " +
"tuning step for %s" % format_freq(freq))


def fix_rounded_step(freq):
Expand Down
2 changes: 1 addition & 1 deletion chirp/drivers/ft70.py
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@

MODES = ["FM", "AM", "NFM"]

STEPS = [0, 5, 6.25, 10, 12.5, 15, 20, 25, 50, 100] # 0 = auto
STEPS = [5, 6.25, 0, 10, 12.5, 15, 20, 25, 50, 100] # 0 = auto?
RFSQUELCH = ["OFF", "S1", "S2", "S3", "S4", "S5", "S6", "S7", "S8"]

SKIPS = ["", "S", "P"]
Expand Down
21 changes: 10 additions & 11 deletions chirp/drivers/icv80.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def get_features(self):
rf.memory_bounds = (0, 199)
rf.valid_modes = MODES
rf.valid_tmodes = TMODES
rf.valid_duplexes = DUPLEXES
rf.valid_duplexes = DUPLEXES + ['off']
rf.valid_tuning_steps = TUNING_STEPS
rf.valid_power_levels = POWER_LEVELS
rf.valid_skips = SKIPS
Expand Down Expand Up @@ -410,7 +410,10 @@ def _get_memory(self, number, extd_number=None):
if mem.extd_number == "":
mem.name = str(_mem.name).rstrip()
mem.skip = (_skip & bit) and "S" or ""
mem.duplex = DUPLEXES[_mem.duplex]
if _mem.tx_inhibit:
mem.duplex = 'off'
else:
mem.duplex = DUPLEXES[_mem.duplex]
mem.power = POWER_LEVELS[_mem.power]
mem.tuning_step = TUNING_STEPS[_mem.tuning_step]
mem.mode = MODES[_mem.mode]
Expand All @@ -427,13 +430,6 @@ def _get_memory(self, number, extd_number=None):
rev.set_doc("Reverse duplex")
mem.extra.append(rev)

# Tx inhibit
tx_inhibit = RadioSetting("tx_inhibit", "TX inhibit",
RadioSettingValueBoolean(
bool(not _mem.tx_inhibit)))
tx_inhibit.set_doc("TX inhibit")
mem.extra.append(tx_inhibit)

return mem

def get_memory(self, number):
Expand Down Expand Up @@ -497,7 +493,10 @@ def set_memory(self, mem):
_mem.freq = mem.freq // mult
_mem.offset = int(mem.offset) // mult
_mem.name = str(mem.name).ljust(5)
_mem.duplex = DUPLEXES.index(mem.duplex)
try:
_mem.duplex = DUPLEXES.index(mem.duplex)
except ValueError:
_mem.duplex = 0
power = mem.power or POWER_LEVELS[0]
_mem.power = POWER_LEVELS.index(power)
_mem.tuning_step = TUNING_STEPS.index(mem.tuning_step)
Expand All @@ -507,6 +506,7 @@ def set_memory(self, mem):
_mem.ctone = chirp_common.TONES.index(mem.ctone)
_mem.dtcs = chirp_common.DTCS_CODES.index(mem.dtcs)
_mem.dtcs_polarity = DTCS_POLARITY.index(mem.dtcs_polarity)
_mem.tx_inhibit = mem.duplex == 'off'

# Set used
_unused &= ~bit
Expand All @@ -519,7 +519,6 @@ def set_memory(self, mem):
_skip &= ~bit

if mem.extra:
_mem.tx_inhibit = not mem.extra['tx_inhibit'].value
_mem.reverse_duplex = mem.extra['reverse_duplex'].value

def get_raw_memory(self, number):
Expand Down
Loading