[chirp_devel] Issue with Baofeng Firmware Version
There is an issue with some recent Baofeng radios where the firmware version isn't padded with spaces like is usually is. Instead the they are 0xff.
The problem is when CHIRP displays the firmware version, the firmware version gets sanitized so it can be displayed. This changes the 0xFF values to spaces. Then when the user modifies any settings, the sanitized firmware version gets written to the image. Since the firmware of the image no longer matches the firmware version of the radio, CHIRP aborts the upload.
Is there a way to display the firmware version as read only text (as it is now) but not alter the characters stored in the image?
I am referring to the uv5r.py driver
Thanks, Jim KC9HI
The problem is when CHIRP displays the firmware version, the firmware version gets sanitized so it can be displayed. This changes the 0xFF values to spaces. Then when the user modifies any settings, the sanitized firmware version gets written to the image. Since the firmware of the image no longer matches the firmware version of the radio, CHIRP aborts the upload.
Hmm, are we letting people alter the firmware version that gets stored back into the image? Is that a good idea?
Is there a way to display the firmware version as read only text (as it is now) but not alter the characters stored in the image?
I would think we should change that to a label instead of an entry so that it's visible but not alterable by the user...
--Dan
On Sat, Feb 13, 2016 at 8:11 PM, Dan Smith via chirp_devel chirp_devel@intrepid.danplanet.com wrote:
The problem is when CHIRP displays the firmware version, the firmware version gets sanitized so it can be displayed. This changes the 0xFF values to spaces. Then when the user modifies any settings, the sanitized firmware version gets written to the image. Since the firmware of the image no longer matches the firmware version of the radio, CHIRP aborts the upload.
Hmm, are we letting people alter the firmware version that gets stored back into the image? Is that a good idea?
No. These messages cannot be edited by the user. CHIRP is making the changes, not the user. I want to prevent this behavior.
Is there a way to display the firmware version as read only text (as it is now) but not alter the characters stored in the image?
I would think we should change that to a label instead of an entry so that it's visible but not alterable by the user...
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.
--Dan
Jim
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
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?
Makes sense. I will have the person with the issue test it.
Thanks, Jim
On Sat, Feb 13, 2016 at 9:24 PM, Jim Unroe rock.unroe@gmail.com wrote:
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:" ?
My tester reported back "I just tried it and when I edit the squelch/service settings, I get an error message that says, "Error in setting value: 'str' object has no attribute'_mutable'""
Jim
My 5 Cents:
Change that else for:
elif not "firmware_msg" in obj:
That will refuse to change the setting in the firmware_msg setting, both lines.
73
El 13/02/16 a las 22:17, Jim Unroe via chirp_devel escribió:
On Sat, Feb 13, 2016 at 9:24 PM, Jim Unroe rock.unroe@gmail.com wrote:
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:" ?
My tester reported back "I just tried it and when I edit the squelch/service settings, I get an error message that says, "Error in setting value: 'str' object has no attribute'_mutable'""
Jim _______________________________________________ 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
What if we changed that else to "elif setting._mutable:" ?
My tester reported back "I just tried it and when I edit the squelch/service settings, I get an error message that says, "Error in setting value: 'str' object has no attribute'_mutable'""
Sorry, should be element._mutable I think.
You can test it locally by editing that field and seeing if you see "Setting ..." in the console output.
--Dan
On Sat, Feb 13, 2016 at 11:20 PM, Dan Smith via chirp_devel chirp_devel@intrepid.danplanet.com wrote:
What if we changed that else to "elif setting._mutable:" ?
My tester reported back "I just tried it and when I edit the squelch/service settings, I get an error message that says, "Error in setting value: 'str' object has no attribute'_mutable'""
Sorry, should be element._mutable I think.
When using "elif element._mutable:", it get the following.
DEBUG: squelch ERROR: Exception running RadioJob: '_mutable' DEBUG: Reporting exception ERROR: -- Exception: -- ERROR: Traceback (most recent call last): File "C:\Users\Root\chirp.hg\chirp\ui\common.py", line 116, in _execute result = func(*self.args, **self.kwargs) File "C:\Users\Root\Documents\UV-5R\uv5r.py", line 1554, in se t_settings self.set_settings(element) File "C:\Users\Root\Documents\UV-5R\uv5r.py", line 1578, in se t_settings elif element._mutable: File "C:\Users\Root\chirp.hg\chirp\settings.py", line 350, in __getattr__ return self.__dict__[name] KeyError: '_mutable'
Pavel's method does work, but I see what you are wanting to do Dan. That would all new elements that have mutable set to False to be supported without needing to alter this section of code any further. I would like to see about make yours work.
Jim
When using "elif element._mutable:", it get the following.
Sorry, I'm firing from the hip here and not looking at the real code and testing.
Pavel's method does work, but I see what you are wanting to do Dan.
Yeah, but it's too specific, IMHO. Any immutable elements shouldn't be re-set on the image.
That would all new elements that have mutable set to False to be supported without needing to alter this section of code any further. I would like to see about make yours work.
Try this:
diff -r 9752a42d4a0d chirp/drivers/uv5r.py --- a/chirp/drivers/uv5r.py Mon Feb 08 14:14:28 2016 +0000 +++ b/chirp/drivers/uv5r.py Sun Feb 14 07:53:08 2016 -0800 @@ -1574,7 +1574,7 @@ if element.has_apply_callback(): LOG.debug("Using apply callback") element.run_apply_callback() - else: + elif element.value.get_mutable(): LOG.debug("Setting %s = %s" % (setting, element.value)) setattr(obj, setting, element.value) except Exception, e:
--Dan
Try this:
diff -r 9752a42d4a0d chirp/drivers/uv5r.py --- a/chirp/drivers/uv5r.py Mon Feb 08 14:14:28 2016 +0000 +++ b/chirp/drivers/uv5r.py Sun Feb 14 07:53:08 2016 -0800 @@ -1574,7 +1574,7 @@ if element.has_apply_callback(): LOG.debug("Using apply callback") element.run_apply_callback()
else:
elif element.value.get_mutable(): LOG.debug("Setting %s = %s" % (setting,
element.value)) setattr(obj, setting, element.value) except Exception, e:
Thanks Dan. Exactly what I was looking for. Works great. I will submit a patch for this soon.
Jim
Excellent solution,
This is a baofeng issue (now), but may be it can be expanded to cover other models.
As good practice, non mutable settings must be non editable directly or indirectly.
I will check my drivers to look for this...
73
El 14/02/16 a las 16:01, Jim Unroe via chirp_devel escribió:
Try this:
diff -r 9752a42d4a0d chirp/drivers/uv5r.py --- a/chirp/drivers/uv5r.py Mon Feb 08 14:14:28 2016 +0000 +++ b/chirp/drivers/uv5r.py Sun Feb 14 07:53:08 2016 -0800 @@ -1574,7 +1574,7 @@ if element.has_apply_callback(): LOG.debug("Using apply callback") element.run_apply_callback()
else:
elif element.value.get_mutable(): LOG.debug("Setting %s = %s" % (setting,
element.value)) setattr(obj, setting, element.value) except Exception, e:
Thanks Dan. Exactly what I was looking for. Works great. I will submit a patch for this soon.
Jim _______________________________________________ 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 (3)
-
Dan Smith
-
Jim Unroe
-
Pavel Milanes (CO7WT)