[chirp_devel] [PATCH] [uv5r][RFC] Dynamically honor band limits
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1361832532 28800 # Node ID 8f7e6e07076f39efb3ecf87717fd50935b0b58c8 # Parent 680852fc3ef56aa6c3edeab17ea87924b241028a [uv5r][RFC] Dynamically honor band limits
Since we let the user set them arbitrarily, it seems weird to honor a second set of invisible limits. We have to be careful to support looking up these limits in the absence of an actual image, but we can substitute the original ones there.
diff -r 680852fc3ef5 -r 8f7e6e07076f chirp/uv5r.py --- a/chirp/uv5r.py Sun Feb 24 22:04:01 2013 -0800 +++ b/chirp/uv5r.py Mon Feb 25 14:48:52 2013 -0800 @@ -22,6 +22,7 @@ RadioSettingValueInteger, RadioSettingValueList, \ RadioSettingValueBoolean, RadioSettingValueString, \ InvalidValueError +from chirp.chirp_common import to_MHz
MEM_FORMAT = """ #seekto 0x0008; @@ -474,7 +475,15 @@ rf.valid_power_levels = UV5R_POWER_LEVELS rf.valid_duplexes = ["", "-", "+", "split", "off"] rf.valid_modes = ["FM", "NFM"] - rf.valid_bands = [(136000000, 174000000), (400000000, 520000000)] + if self._mmap is not None: + limits = self._get_limits() + rf.valid_bands = [ + (to_MHz(limits[0]), to_MHz(limits[1])), + (to_MHz(limits[2]), to_MHz(limits[3])), + ] + else: + rf.valid_bands = [(136000000, 174000000), (400000000, 520000000)] + rf.memory_bounds = (0, 127) return rf
@@ -711,6 +720,17 @@ return int(version_tag[idx:idx+3]) raise Exception("Unrecognized firmware version string")
+ def _get_limitobj(self): + if self._is_orig(): + return getattr(self._memobj, 'limits_old') + else: + return getattr(self._memobj, 'limits_new') + + def _get_limits(self): + limit = self._get_limitobj() + return (int(limit.vhf.lower), int(limit.vhf.upper), + int(limit.uhf.lower), int(limit.uhf.upper)) + def _get_settings(self): _settings = self._memobj.settings[0] basic = RadioSettingGroup("basic", "Basic Settings") @@ -871,37 +891,33 @@ PONMSG_LIST[_settings.ponmsg])) other.append(rs)
+ # FIXME: argh, fix this later (bitwise .name) if self._is_orig(): - limit = "limits_old" + limitname = "limits_old" else: - limit = "limits_new" - - vhf_limit = getattr(self._memobj, limit).vhf - rs = RadioSetting("%s.vhf.lower" % limit, "VHF Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - vhf_limit.lower)) + limitname = "limits_new" + limit = self._get_limitobj() + vhf_lo, vhf_hi, uhf_lo, uhf_hi = self._get_limits() + rs = RadioSetting("%s.vhf.lower" % limitname, "VHF Lower Limit (MHz)", + RadioSettingValueInteger(1, 1000, vhf_lo)) other.append(rs)
- rs = RadioSetting("%s.vhf.upper" % limit, "VHF Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - vhf_limit.upper)) + rs = RadioSetting("%s.vhf.upper" % limitname, "VHF Upper Limit (MHz)", + RadioSettingValueInteger(1, 1000, vhf_hi)) other.append(rs)
- rs = RadioSetting("%s.vhf.enable" % limit, "VHF TX Enabled", - RadioSettingValueBoolean(vhf_limit.enable)) + rs = RadioSetting("%s.vhf.enable" % limitname, "VHF TX Enabled", + RadioSettingValueBoolean(limit.vhf.enable)) other.append(rs)
- uhf_limit = getattr(self._memobj, limit).uhf - rs = RadioSetting("%s.uhf.lower" % limit, "UHF Lower Limit (MHz)", - RadioSettingValueInteger(1, 1000, - uhf_limit.lower)) + rs = RadioSetting("%s.uhf.lower" % limitname, "UHF Lower Limit (MHz)", + RadioSettingValueInteger(1, 1000, uhf_lo)) other.append(rs) - rs = RadioSetting("%s.uhf.upper" % limit, "UHF Upper Limit (MHz)", - RadioSettingValueInteger(1, 1000, - uhf_limit.upper)) + rs = RadioSetting("%s.uhf.upper" % limitname, "UHF Upper Limit (MHz)", + RadioSettingValueInteger(1, 1000, uhf_hi)) other.append(rs) - rs = RadioSetting("%s.uhf.enable" % limit, "UHF TX Enabled", - RadioSettingValueBoolean(uhf_limit.enable)) + rs = RadioSetting("%s.uhf.enable" % limitname, "UHF TX Enabled", + RadioSettingValueBoolean(limit.uhf.enable)) other.append(rs)
workmode = RadioSettingGroup("workmode", "Work Mode Settings")
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1361832532 28800 # Node ID 8f7e6e07076f39efb3ecf87717fd50935b0b58c8 # Parent 680852fc3ef56aa6c3edeab17ea87924b241028a [uv5r][RFC] Dynamically honor band limits
Since we let the user set them arbitrarily, it seems weird to honor a second set of invisible limits. We have to be careful to support looking up these limits in the absence of an actual image, but we can substitute the original ones there.
Jim, comments?
Jim, comments?
Heh, one more reply to myself here :)
I'm fine with whatever we decide, as far as whether to allow the user to go outside the stated limits of the radio, so we can throw this patch away if we decide that's the best plan. However, I do think it is confusing the allow the user to set one set of limits in the settings, and then honor another (invisible) set in the actual code. So, whatever we decide, I think we should be consistent in what we enforce. Either limit the UHF band limit in settings to the same thing that we enforce with radiofeatures, or make radiofeatures respect the setting the user has chosen.
In the kguv6 driver I respect the actual settings of VHF-UHF limits not only to be consistent but also because there are many submodels out there with the only difference of supported freq ranges.
I think it's we have to enforce acceptable ranges on limits setting and then onor them.
73 de IZ3GME Marco
On 26/02/2013 00:31, Dan Smith wrote:
Jim, comments?
Heh, one more reply to myself here :)
I'm fine with whatever we decide, as far as whether to allow the user to go outside the stated limits of the radio, so we can throw this patch away if we decide that's the best plan. However, I do think it is confusing the allow the user to set one set of limits in the settings, and then honor another (invisible) set in the actual code. So, whatever we decide, I think we should be consistent in what we enforce. Either limit the UHF band limit in settings to the same thing that we enforce with radiofeatures, or make radiofeatures respect the setting the user has chosen.
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel Developer docs: http://chirp.danplanet.com/projects/chirp/wiki/Developers
participants (2)
-
Dan Smith
-
IZ3GME Marco