[chirp_devel] [PATCH] [UV-5R] Add support for editing the 15 PTT ID Codes
# HG changeset patch # User Jim Unroe rock.unroe@gmail.com # Date 1360457827 18000 # Node ID cee9b13d3842a257da6e1de6362dad02d88638d2 # Parent 2b2d547074f2b177447b39cbf4dd67f02a775a92 [UV-5R] Add support for editing the 15 PTT ID Codes add supporting structure for PTT ID Codes add DTMF Settings tab add PTT ID Code 1-15 settings #539
diff -r 2b2d547074f2 -r cee9b13d3842 chirp/uv5r.py --- a/chirp/uv5r.py Fri Feb 08 16:20:22 2013 -0800 +++ b/chirp/uv5r.py Sat Feb 09 19:57:07 2013 -0500 @@ -44,6 +44,40 @@ pttidbot:1; } memory[128];
+#seekto 0x0B08; +struct { + u8 code0[5]; + u8 unused1[11]; + u8 code1[5]; + u8 unused2[11]; + u8 code2[5]; + u8 unused3[11]; + u8 code3[5]; + u8 unused4[11]; + u8 code4[5]; + u8 unused5[11]; + u8 code5[5]; + u8 unused6[11]; + u8 code6[5]; + u8 unused7[11]; + u8 code7[5]; + u8 unused8[11]; + u8 code8[5]; + u8 unused9[11]; + u8 code9[5]; + u8 unused10[11]; + u8 codea[5]; + u8 unused11[11]; + u8 codeb[5]; + u8 unused12[11]; + u8 codec[5]; + u8 unused13[11]; + u8 coded[5]; + u8 unused14[11]; + u8 codee[5]; + u8 unused15[11]; +} pttid; + #seekto 0x0CB2; struct { u8 code[5]; @@ -962,6 +996,204 @@ STEP_LIST[self._memobj.vfob.step])) workmode.append(rs)
+ dtmf = RadioSettingGroup("dtmf", "DTMF Settings") + group.append(dtmf) + + try: + _code = self._memobj.pttid.code0 + rs = RadioSetting("pttid.code0", "PTT ID Code 1", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code1 + rs = RadioSetting("pttid.code1", "PTT ID Code 2", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code2 + rs = RadioSetting("pttid.code2", "PTT ID Code 3", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code3 + rs = RadioSetting("pttid.code3", "PTT ID Code 4", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code4 + rs = RadioSetting("pttid.code4", "PTT ID Code 5", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code5 + rs = RadioSetting("pttid.code5", "PTT ID Code 6", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code6 + rs = RadioSetting("pttid.code6", "PTT ID Code 7", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code7 + rs = RadioSetting("pttid.code7", "PTT ID Code 8", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code8 + rs = RadioSetting("pttid.code8", "PTT ID Code 9", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.code9 + rs = RadioSetting("pttid.code9", "PTT ID Code 10", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.codea + rs = RadioSetting("pttid.codea", "PTT ID Code 11", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.codeb + rs = RadioSetting("pttid.codeb", "PTT ID Code 12", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.codec + rs = RadioSetting("pttid.codec", "PTT ID Code 13", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.coded + rs = RadioSetting("pttid.coded", "PTT ID Code 14", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + + try: + _code = self._memobj.pttid.codee + rs = RadioSetting("pttid.codee", "PTT ID Code 15", + RadioSettingValueInteger(0, 9, _code[0]), + RadioSettingValueInteger(0, 9, _code[1]), + RadioSettingValueInteger(0, 9, _code[2]), + RadioSettingValueInteger(0, 9, _code[3]), + RadioSettingValueInteger(0, 9, _code[4])) + dtmf.append(rs) + except Exception: + print ("Your PTD ID code is not five digits, which is not currently" + " supported in CHIRP.") + return group
def get_settings(self):
On Feb 9, 2013 5:01 PM, "Jim Unroe" rock.unroe@gmail.com wrote:
# HG changeset patch # User Jim Unroe rock.unroe@gmail.com # Date 1360457827 18000 # Node ID cee9b13d3842a257da6e1de6362dad02d88638d2 # Parent 2b2d547074f2b177447b39cbf4dd67f02a775a92 [UV-5R] Add support for editing the 15 PTT ID Codes add supporting structure for PTT ID Codes add DTMF Settings tab add PTT ID Code 1-15 settings #539
diff -r 2b2d547074f2 -r cee9b13d3842 chirp/uv5r.py --- a/chirp/uv5r.py Fri Feb 08 16:20:22 2013 -0800 +++ b/chirp/uv5r.py Sat Feb 09 19:57:07 2013 -0500 @@ -44,6 +44,40 @@ pttidbot:1; } memory[128];
+#seekto 0x0B08; +struct {
- u8 code0[5];
- u8 unused1[11];
- u8 code1[5];
- u8 unused2[11];
- u8 code2[5];
- u8 unused3[11];
- u8 code3[5];
- u8 unused4[11];
- u8 code4[5];
- u8 unused5[11];
- u8 code5[5];
- u8 unused6[11];
- u8 code6[5];
- u8 unused7[11];
- u8 code7[5];
- u8 unused8[11];
- u8 code8[5];
- u8 unused9[11];
- u8 code9[5];
- u8 unused10[11];
- u8 codea[5];
- u8 unused11[11];
- u8 codeb[5];
- u8 unused12[11];
- u8 codec[5];
- u8 unused13[11];
- u8 coded[5];
- u8 unused14[11];
- u8 codee[5];
- u8 unused15[11];
+} pttid;
Wouldn't this be simpler as an array?
Tom
Get me started in the right direction. Do you know of somewhere I can see an example?
Wouldn't this be simpler as an array?
Tom
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
On Sat, Feb 9, 2013 at 5:34 PM, Jim Unroe rock.unroe@gmail.com wrote:
Get me started in the right direction. Do you know of somewhere I can see an example?
Like this: http://chirp.danplanet.com/projects/chirp/repository/entry/chirp/vx5.py#L26
So it would be something like this (untested): #seekto 0x0B08; struct { struct { u8 code[5]; u8 unused[11]; } pttid[15]; } pttid_set;
It's just like what you've done already, but nested to avoid pasting. Then down below you can add each setting inside a loop, again avoiding copy/pasting. Usually if you're copy/pasting code you're doing something wrong and there's an easier way (writing a loop, creating a function, etc.)
Tom
On Sat, Feb 9, 2013 at 6:27 PM, Tom Hayward esarfl@gmail.com wrote:
So it would be something like this (untested): #seekto 0x0B08; struct { struct { u8 code[5]; u8 unused[11]; } pttid[15]; } pttid_set;
Oops, I over-complicated that. Try this: struct { u8 code[5]; u8 unused[11]; } pttid[15];
Now instead of calling pttid.code0, call pttid[0].code. Or:
for pttid in self._memobj.pttid: _code = pttid.code ... # create setting, etc
Tom
Tom, Thanks. The thing that scares me is that I think I understand what you are suggesting here.
After sleeping on it (and I mean it literally, it's just before 3am), here's what concerns me about this vs. what I submitted.
My first try was all of the settings were inside a singe try: except Exception: During my testing, if any code was not 5 digits, then all codes were all rejected. Splitting it out like I did, only the less than 5 digit codes were missing.
So I think some of this discussion needs to be how to eliminate the CHIRP requirement for each code to be 5 digits since the OEM software and UV-5R accept any number of digits including no digits. Jim
On Sat, Feb 9, 2013 at 9:33 PM, Tom Hayward esarfl@gmail.com wrote:
On Sat, Feb 9, 2013 at 6:27 PM, Tom Hayward esarfl@gmail.com wrote:
So it would be something like this (untested): #seekto 0x0B08; struct { struct { u8 code[5]; u8 unused[11]; } pttid[15]; } pttid_set;
Oops, I over-complicated that. Try this: struct { u8 code[5]; u8 unused[11]; } pttid[15];
Now instead of calling pttid.code0, call pttid[0].code. Or:
for pttid in self._memobj.pttid: _code = pttid.code ... # create setting, etc
Tom _______________________________________________ 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
So I think some of this discussion needs to be how to eliminate the CHIRP requirement for each code to be 5 digits since the OEM software and UV-5R accept any number of digits including no digits.
We just need to pad the value appropriately. What are the un-used digits set to? 0xff or something?
On Sun, Feb 10, 2013 at 9:08 AM, Dan Smith dsmith@danplanet.com wrote:
So I think some of this discussion needs to be how to eliminate the CHIRP requirement for each code to be 5 digits since the OEM software and UV-5R accept any number of digits including no digits.
We just need to pad the value appropriately. What are the un-used digits set to? 0xff or something?
I just checked. ANI requires a minimum of 3 digits. The unused digits are
set to 0xff The 15 PTT IDs can all be set to null and the unused digits are also set to 0xff
Tom's suggestion of revising the structure works great. I should have realized that from looking at the structure for the alpha tags. :(
Jim
On Sun, Feb 10, 2013 at 9:44 AM, Jim Unroe rock.unroe@gmail.com wrote:
On Sun, Feb 10, 2013 at 9:08 AM, Dan Smith dsmith@danplanet.com wrote:
So I think some of this discussion needs to be how to eliminate the CHIRP requirement for each code to be 5 digits since the OEM software and UV-5R accept any number of digits including no digits.
We just need to pad the value appropriately. What are the un-used digits set to? 0xff or something?
I just checked. ANI requires a minimum of 3 digits. The unused digits are
set to 0xff The 15 PTT IDs can all be set to null and the unused digits are also set to 0xff
Anyone have any thoughts on this? I have a few things that I want to do
that depend on what I do here.
Thinking about it this morning, I am wondering if this could be done similarly to name (channel names) except using a charset that is limited to "0123456789".
Jim
Anyone have any thoughts on this? I have a few things that I want to do that depend on what I do here.
Sorry if we left you hanging. How about I take your patch and swizzle it a bit and send it back? Might be easier than me trying to articulate how I think it should be done...
Sorry if we left you hanging. How about I take your patch and swizzle it a bit and send it back? Might be easier than me trying to articulate how I think it should be done...
How about this?
It's a little messy, but it works. I forget, are we still going to commit that patch of mine that adds the callback function to the setting object? That could help make this less ugly.
On Sat, Feb 16, 2013 at 11:21 AM, Dan Smith dsmith@danplanet.com wrote:
Sorry if we left you hanging. How about I take your patch and swizzle it a bit and send it back? Might be easier than me trying to articulate how I think it should be done...
How about this?
I'll take a look at it.
It's a little messy, but it works. I forget, are we still going to commit that patch of mine that adds the callback function to the setting object? That could help make this less ugly.
I believe the you were going to commit the UI parts float_setting_callback_example.patch so I could separate out my part of the VFO presets stuff that I have been working on.
Jim
I believe the you were going to commit the UI parts float_setting_callback_example.patch so I could separate out my part of the VFO presets stuff that I have been working on.
Okay, I just committed that. I added an "apply callback" which lets you add a callback function to the setting to be run at "set_settings" time to actually apply the setting. I'm attaching an updated change against the UV5 pttid patch so you can see how I use it. Makes the set_settings code much easier I think.
Oops, I over-complicated that. Try this: struct { u8 code[5]; u8 unused[11]; } pttid[15];
This I will definitely do. I've seen it before but I guess until now I didn't realize what it was doing or why. Now I do. Thanks.
Now instead of calling pttid.code0, call pttid[0].code. Or:
for pttid in self._memobj.pttid: _code = pttid.code ... # create setting, etc
I'll try this out today as well. Thanks, Jim
participants (3)
-
Dan Smith
-
Jim Unroe
-
Tom Hayward