[chirp_devel] [PATCH 0 of 1 ] Wouxun KGUV6D/X support
Here we are!
Please note that: - this patch has to be applied over the repository version NOT on my cross tone patch, we'll merge the two later - it works fine here but it has been tested on only one radio, please test test test test - the menu lock settings _has not been tested_ use at your own risk as it's just a guess, I don't have access to original software up to next monday and I can't risk the testing radio because it's not mine, someone with original sw please set/unset that bit and check that chirp recognise the two states correctly - the D and X model have been separated because they have different freq ranges - we could recognize wouxun model and KG-UV6 submodel automatically but I prefere to keep things simple now, this can be done later
Please let me know of your test results
73 de IZ3GME Marco
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1338041503 -7200 # Node ID 683fcbd9ed1f7dc879364618eb49eaa9fd8df61a # Parent 3f840fd7177985446b33fe14d1e002c9d8de2dd6 [KG-UV6D/X] Initial support implements feature #53
diff --git a/chirp/wouxun.py b/chirp/wouxun.py --- a/chirp/wouxun.py +++ b/chirp/wouxun.py @@ -25,6 +25,11 @@ DEBUG = False
WOUXUN_MEM_FORMAT = """ +struct settings { + u8 unknown_flag1:7, + menu_available:1; +}; + #seekto 0x0010; struct { lbcd rx_freq[4]; @@ -40,37 +45,46 @@ iswide:1, _2_unknown_2:4; u8 unknown[2]; -} memory[128]; +} memory[199];
#seekto 0x0E5C; -u8 unknown_flag1:7, - menu_available:1; +struct settings v1settings; + +#seekto 0x0F5C; +struct settings v6settings;
#seekto 0x1008; struct { u8 unknown[8]; u8 name[6]; u8 pad[2]; -} names[128]; +} names[199]; """
-def wouxun_identify(radio): +def _wouxun_identify(radio, string): """Do the original wouxun identification dance""" for _i in range(0, 5): - radio.pipe.write("HiWOUXUN\x02") + radio.pipe.write(string) resp = radio.pipe.read(9) if len(resp) != 9: + print "Got:\n%s" % util.hexprint(r) print "Retrying identification..." time.sleep(1) continue if resp[2:8] != radio._model: - raise Exception("I can't talk to this model") + raise Exception("I can't talk to this model (%s)" % util.hexprint(resp)) return if len(resp) == 0: raise Exception("Radio not responding") else: raise Exception("Unable to identify radio")
+def wouxun_identify(radio): + return _wouxun_identify(radio, "HiWOUXUN\x02") + +def wouxun6_identify(radio): + return _wouxun_identify(radio, "HiWXUVD1\x02") + def wouxun_start_transfer(radio): """Tell the radio to go into transfer mode""" radio.pipe.write("\x02\x06") @@ -153,6 +167,28 @@ except Exception, e: raise errors.RadioError("Failed to communicate with radio: %s" % e)
+def wouxun6_download(radio): + """Talk to an original wouxun and do a download""" + try: + wouxun6_identify(radio) + wouxun_start_transfer(radio) + return do_download(radio, 0x0000, 0x2000, 0x0040) + except errors.RadioError: + raise + except Exception, e: + raise errors.RadioError("Failed to communicate with radio: %s" % e) + +def wouxun6_upload(radio): + """Talk to an original wouxun and do an upload""" + try: + wouxun6_identify(radio) + wouxun_start_transfer(radio) + return do_upload(radio, 0x0000, 0x2000, 0x0010) + except errors.RadioError: + raise + except Exception, e: + raise errors.RadioError("Failed to communicate with radio: %s" % e) + CHARSET = list("0123456789") + [chr(x + ord("A")) for x in range(0, 26)] + \ list("?+ ")
@@ -212,7 +248,7 @@ group = RadioSettingGroup("top", "All Settings")
rs = RadioSetting("menu_available", "Menu Available", - RadioSettingValueBoolean(self._memobj.menu_available)) + RadioSettingValueBoolean(self._memobj.v1settings.menu_available)) group.append(rs)
return group @@ -223,7 +259,7 @@ self.set_settings(element) continue try: - setattr(self._memobj, element.get_name(), element.value) + setattr(self._memobj.v1settings, element.get_name(), element.value) except Exception, e: print element.get_name() raise @@ -397,7 +433,11 @@ @classmethod def match_model(cls, filedata, filename): # New-style image (CHIRP 0.1.12) - if len(filedata) == 8192 and filedata[0x60:0x64] != "2009": + if len(filedata) == 8192 and \ + filedata[0x60:0x64] != "2009" and \ + filedata[0xf00:0xf05] != "KGUV6": + # TODO Must find an == test to avoid + # collision with future supported radios return True # Old-style image (CHIRP 0.1.11) if len(filedata) == 8200 and \ @@ -405,6 +445,67 @@ return True return False
+@directory.register +class KGUV6DRadio(KGUVD1PRadio): + MODEL = "KG-UV6D" + + def get_features(self): + rf = KGUVD1PRadio.get_features(self) + rf.valid_bands = [(136000000, 175000000), (350000000, 471000000)] + rf.memory_bounds = (1, 199) + return rf + + def get_settings(self): + group = RadioSettingGroup("top", "All Settings") + + rs = RadioSetting("menu_available", "Menu Available", + RadioSettingValueBoolean(self._memobj.v6settings.menu_available)) + group.append(rs) + + return group + + def set_settings(self, settings): + for element in settings: + if not isinstance(element, RadioSetting): + self.set_settings(element) + continue + try: + setattr(self._memobj.v6settings, element.get_name(), element.value) + except Exception, e: + print element.get_name() + raise + + def sync_in(self): + self._mmap = wouxun6_download(self) + self.process_mmap() + + def sync_out(self): + wouxun6_upload(self) + + @classmethod + def match_model(cls, filedata, filename): + if len(filedata) == 8192 and \ + filedata[0xf00:0xf06] == "KGUV6D": + return True + return False + +@directory.register +class KGUV6XRadio(KGUV6DRadio): + MODEL = "KG-UV6X" + + def get_features(self): + rf = KGUV6DRadio.get_features(self) + rf.valid_bands = [(136000000, 175000000), (370000000, 513000000)] + return rf + + @classmethod + def match_model(cls, filedata, filename): + if len(filedata) == 8192 and \ + filedata[0xf00:0xf06] == "KGUV6X": + return True + return False + + def _puxing_prep(radio): radio.pipe.write("\x02PROGRA") ack = radio.pipe.read(1) diff --git a/tests/images/Wouxun_KG-UV6D.img b/tests/images/Wouxun_KG-UV6D.img new file mode 100644 index 0000000000000000000000000000000000000000..b1a779514010bab1e083c307f9fb264345c8135f GIT binary patch literal 8192 zc%1FoJ4?e*6bJBgo7Up1i^UFgDoD33qC*#jv^c0#2W=-iyG5d26Wit+NFRu_LO_~Y zK}!%sozzLcKo>Wi+=OV0Zt<oy(CVOzL*e{RAo=Iy0ohKjX?6pMdjXcbrg_f6wv`DF z;Nx3a05B0k2qA<JLI|NAG&j4vG8KtO=lR$|`?!0=1t%dKi~wQ95Y7o45SJBL2OMB+ ztyU*?HM`e+Z#AuXI^LeAKkRv$@OJ)9v6wCGx0JF)N~xyldbxbaly!||X-oGM&O*;m z{?Undmg{e<jJlCDlFek3QiX0_-iYH`)g#J^tV*&f`=#KH&))yfS49XRgb+dqA%uF% zN%g3fNhz{GCAv;m!$10z%53bG_b8t>s7T!dLMp9XiBd*jr^AW^pbt8h%?S`Iw|_YN z;r)e!((sTgpI6nKr7-A#+UaqnqJ7!u&s|?U`o<<-XOg?OcWW=xtQvtvAj&EcO2i_z M#mIvc6u&?J6O<3^)c^nh
diff --git a/tests/images/Wouxun_KG-UV6X.img b/tests/images/Wouxun_KG-UV6X.img new file mode 100644 index 0000000000000000000000000000000000000000..48bff422a837670b4630548e263ab208272a8afe GIT binary patch literal 8192 zc%1FnO-lkn7zgm#H{VJ_7rO`*LI;UDC<GdGF)^q}f;0%abrTY$hMm&wBSaBefgr63 zMlJ<Wu!oL)4il<V)XAgGib`vTx)#rGd1mLoGdpvhX|;?{EaBEm?>A}1T>gk&-3$N# z00000008_&3(?j1^xFJpGP#Au+K^$KMP`OW9AfCh(uU*pAkZ$$Gqgd-j1a@@BLg~- z{%d+fY-}ar)=OUty&BKcdj5&UBJe{T<7mSem&=NxsOovCRI8O}mUdLf(e>0z-7_3$ z(j4%MGh(n2tb3-OybX+HynXkO8CNO}nGjNxNRfCXSGuadcX7Jfzu)Mf&F%h@NBS}V z000000002+A6-^1u5vb+q_9L}yb<~~jxnLfZgPyn*$<q-W?O16E8l0NT#9}U$(;*< z-uzBZL>9x#OTXCvggVXV?RJxe=XpUmFbNzxVC~&B;H+xR7j7q?#o71h+<M%n`Lu~M XP1C%GZ#P~|6P;ZVXF+nw{p)`MiE-Gr
participants (1)
-
Marco Filippi IZ3GME