13 Feb
2016
13 Feb
'16
6:02 p.m.
No. These messages cannot be edited by the user. CHIRP is making the changes, not the user. I want to prevent this behavior.
Right, I get that CHIRP is breaking things on its own. Ah, I see from your code that mutable is set false. Got it.
How that done? This is what is there now.
def _filter(name): filtered = "" for char in str(name): if char in chirp_common.CHARSET_ASCII: filtered += char else: filtered += " " return filtered _msg = self._memobj.firmware_msg val = RadioSettingValueString(0, 7, _filter(_msg.line1)) val.set_mutable(False) rs = RadioSetting("firmware_msg.line1", "Firmware Message 1", val) other.append(rs) val = RadioSettingValueString(0, 7, _filter(_msg.line2)) val.set_mutable(False) rs = RadioSetting("firmware_msg.line2", "Firmware Message 2", val) other.append(rs)
The "0xFF"s in "firmware_msg.line2" get changed to " " by the filter helper and then the changes are written to the image. I need to keep the "0xFF" bytes from getting changed.
So it sounds like we should be skipping any immutable fields during set_settings(). So around here:
if element.has_apply_callback(): LOG.debug("Using apply callback") element.run_apply_callback() else: LOG.debug("Setting %s = %s" % (setting, element.value)) setattr(obj, setting, element.value)
What if we changed that else to "elif setting._mutable:" ?
Then it would never run the "set" on immutable fields, which is probably what we should have done in the first place.
Does that work?
--Dan