[chirp_devel] [PATCH 0 of 1] [ts2000] Adds Kenwood TS-2000 support
I have attempted to write a Kenwood TS-2000 driver based on my reading of the TS-2000 manual, which includes the serial command spec. I don't have a TS-2000. I would appreciate if someone would test this for me, at least try a read. The split stuff is completely unimplemented in this patch. I don't understand how the radio sends the split information, so someone with a radio will have to add that functionality. I expect this patch will have many small bugs. Please test!
Pinging Tom Wilson :-)
Tom KD7LXL
# HG changeset patch # User Tom Hayward tom@tomh.us # Date 1339448552 21600 # Node ID 6e9c0aaceccaa4c903c7042dd8b519c1395df84b # Parent cd4dcc250069ca173704d34b46b6e45b289b1f35 [ts2000] Adds Kenwood TS-2000 support
diff -r cd4dcc250069 -r 6e9c0aacecca chirp/kenwood_live.py --- a/chirp/kenwood_live.py Sun Jun 10 12:09:47 2012 -0600 +++ b/chirp/kenwood_live.py Mon Jun 11 15:02:32 2012 -0600 @@ -1084,6 +1084,190 @@ def _cmd_set_memory_name(self, number, name): return "MN", "%03i,%s" % (number, name)
+ +TS2000_SSB_STEPS = [1.0, 2.5, 5.0, 10.0] +TS2000_FM_STEPS = [5.0, 6.25, 10.0, 12.5, 15.0, 20.0, 25.0, 30.0, 50.0, 100.0] +TS2000_DUPLEX = dict(DUPLEX) +TS2000_DUPLEX[3] = "=" +TS2000_DUPLEX[4] = "split" +TS2000_MODES = ["?", "LSB", "USB", "CW", "FM", "AM", + "FSK", "CR-R", "?", "FSK-R"] +TS2000_TMODES = ["", "Tone", "TSQL", "DTCS"] +TS2000_TONES = list(OLD_TONES) +TS2000_TONES.remove(69.3) + +@directory.register +class TS2000Radio(KenwoodLiveRadio): + """Kenwood TS-2000""" + MODEL = "TS-2000" + + _upper = 289 + _kenwood_split = True + _kenwood_valid_tones = list(TS2000_TONES) + + def get_features(self): + rf = chirp_common.RadioFeatures() + rf.has_dtcs_polarity = False + rf.has_bank = False + rf.can_odd_split = True + rf.valid_modes = ["LSB", "USB", "CW", "FM", "AM"] + rf.valid_tmodes = list(TS2000_TMODES) + rf.valid_tuning_steps = set(TS2000_SSB_STEPS + TS2000_FM_STEPS) + rf.valid_bands = [(1000, 1300000000)] + rf.valid_skips = ["", "S"] + rf.valid_duplexes = TS2000_DUPLEX.values() + rf.valid_characters = chirp_common.CHARSET_ALPHANUMERIC + rf.valid_name_length = 7 + rf.memory_bounds = (0, self._upper) + return rf + + def _cmd_set_memory(self, number, spec): + return "MW0%03i%s;" % (number, spec) + + def _cmd_get_memory(self, number): + return "MR0%03i;" % number + + def _cmd_get_split(self, number): + return "MR1%03i;" % number + + def _cmd_set_split(self, number, spec): + return "MW1%03i%s;" % (number, spec) + + def get_memory(self, number): + if number < 0 or number > self._upper: + raise errors.InvalidMemoryLocation( \ + "Number must be between 0 and %i" % self._upper) + if self.__memcache.has_key(number) and not NOCACHE: + return self.__memcache[number] + + result = command(self.pipe, *self._cmd_get_memory(number)) + if result == "N": + mem = chirp_common.Memory() + mem.number = number + mem.empty = True + self.__memcache[mem.number] = mem + return mem + + spec = result[2:] + + mem = self._parse_mem_spec(result) + self.__memcache[mem.number] = mem + + # FIXME + if mem.duplex == "" and self._kenwood_split: + result = command(self.pipe, *self._cmd_get_split(number)) + if " " in result: + value = result.split(" ", 1)[1] + self._parse_split_spec(mem, value.split(",")) + + return mem + + def _parse_mem_spec(self, spec): + mem = chirp_common.Memory() + + # pad string so indexes match Kenwood docs + spec = " " + spec + + # use the same variable names as the Kenwood docs + _p1 = spec[3] + _p2 = spec[4] + _p3 = spec[5:7] + _p4 = spec[7:18] + _p5 = spec[18] + _p6 = spec[19] + _p7 = spec[20] + _p8 = spec[21:23] + _p9 = spec[23:25] + _p10 = spec[25:28] + _p11 = spec[28] + _p12 = spec[29] + _p13 = spec[30:39] + _p14 = spec[39:41] + _p15 = spec[41] + _p16 = spec[42:49] + + mem.number = int(_p2 + _p3) # concat bank num and chan num + mem.freq = int(_p4) + mem.mode = TS2000_MODES[int(_p5)] + mem.skip = ["", "S"][int(_p6)] + mem.tmode = TS2000_TMODES[int(_p7)] + mem.rtone = self._kenwood_valid_tones[int(_p8) - 1] + mem.ctone = self._kenwood_valid_tones[int(_p9) - 1] + mem.dtcs = chirp_common.DTCS_CODES[int(_p10) - 1] + mem.duplex = TS2000_DUPLEX[int(_p12)] + mem.offset = int(_p13) # 9-digit + if mem.mode in ["AM", "FM"]: + mem.tuning_step = TS2000_FM_STEPS[int(_p14)] + else: + mem.tuning_step = TS2000_SSB_STEPS[int(_p14)] + mem.name = _p16 + + return mem + + def set_memory(self, memory): + if memory.number < 0 or memory.number > self._upper: + raise errors.InvalidMemoryLocation( \ + "Number must be between 0 and %i" % self._upper) + + spec = self._make_mem_spec(memory) + spec = "".join(spec) + r1 = command(self.pipe, *self._cmd_set_memory(memory.number, spec)) + if not iserr(r1): + time.sleep(0.5) + r2 = command(self.pipe, *self._cmd_set_memory_name(memory.number, + memory.name)) + if not iserr(r2): + memory.name = memory.name.rstrip() + self.__memcache[memory.number] = memory + else: + raise errors.InvalidDataError("Radio refused name %i: %s" %\ + (memory.number, + repr(memory.name))) + else: + raise errors.InvalidDataError("Radio refused %i" % memory.number) + + # FIXME + if memory.duplex == "split" and self._kenwood_split: + spec = "".join(self._make_split_spec(memory)) + result = command(self.pipe, *self._cmd_set_split(memory.number, + spec)) + if iserr(result): + raise errors.InvalidDataError("Radio refused %i" % \ + memory.number) + + def _make_mem_spec(self, mem): + if mem.duplex in " +-": + duplex = util.get_dict_rev(TS2000_DUPLEX, mem.duplex) + offset = mem.offset + elif mem.duplex == "split": + duplex = 0 + offset = 0 + else: + print "Bug: unsupported duplex `%s'" % mem.duplex + if mem.mode in ["AM", "FM"]: + step = TS2000_FM_STEPS.index(mem.tuning_step) + else: + step = TS2000_SSB_STEPS.index(mem.tuning_step) + spec = ( \ + "0", + "%03i" % mem.number + "%011i" % mem.freq, + "%i" % (TS2000_MODES.index(mem.mode)), + "%i" % (mem.skip == "S"), + "%i" % TS2000_TMODES.index(mem.tmode), + "%02i" % (self._kenwood_valid_tones.index(mem.rtone)), + "%02i" % (self._kenwood_valid_tones.index(mem.ctone)), + "%03i" % (chirp_common.DTCS_CODES.index(mem.dtcs)), + "0", # REVERSE status + "%i" % duplex, + "%09i" % offset, + "%i" % step, + "0", # Memory Group number (0-9) + "%s" % mem.name, + ) + + return spec + def do_test(): """Dev test""" mem = chirp_common.Memory()
Thanks. I will check it out.
Split is odd. No pun intended. There are two different ways to program split, but one of them doesn't work on my unit. The working method sends the whole channel twice: once for rx and once for tx. There is one byte different to distinguish the two.
Thanks for the update. I'll try to check it out tonight.
--- Tom Wilson Sent from my Motorola Droid On Jun 11, 2012 2:10 PM, "Tom Hayward" esarfl@gmail.com wrote:
I have attempted to write a Kenwood TS-2000 driver based on my reading of the TS-2000 manual, which includes the serial command spec. I don't have a TS-2000. I would appreciate if someone would test this for me, at least try a read. The split stuff is completely unimplemented in this patch. I don't understand how the radio sends the split information, so someone with a radio will have to add that functionality. I expect this patch will have many small bugs. Please test!
Pinging Tom Wilson :-)
Tom KD7LXL _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
Tom H, I have been playing with the latest daily, and I can't figure out how to access the TS-2000. Can you give me a hint on how to load and/or use this module?
Thanks
On Mon, Jun 11, 2012 at 2:22 PM, Tom Wilson wilsontp@gmail.com wrote:
Thanks. I will check it out.
Split is odd. No pun intended. There are two different ways to program split, but one of them doesn't work on my unit. The working method sends the whole channel twice: once for rx and once for tx. There is one byte different to distinguish the two.
Thanks for the update. I'll try to check it out tonight.
Tom Wilson Sent from my Motorola Droid On Jun 11, 2012 2:10 PM, "Tom Hayward" esarfl@gmail.com wrote:
I have attempted to write a Kenwood TS-2000 driver based on my reading of the TS-2000 manual, which includes the serial command spec. I don't have a TS-2000. I would appreciate if someone would test this for me, at least try a read. The split stuff is completely unimplemented in this patch. I don't understand how the radio sends the split information, so someone with a radio will have to add that functionality. I expect this patch will have many small bugs. Please test!
Pinging Tom Wilson :-)
Tom KD7LXL _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
You'll need to apply the patch I mailed. It hasn't been applied to the daily builds.
Tom KD7LXL On Jun 16, 2012 1:09 PM, "Tom Wilson" wilsontp@gmail.com wrote:
Tom H, I have been playing with the latest daily, and I can't figure out how to access the TS-2000. Can you give me a hint on how to load and/or use this module?
Thanks
On Mon, Jun 11, 2012 at 2:22 PM, Tom Wilson wilsontp@gmail.com wrote:
Thanks. I will check it out.
Split is odd. No pun intended. There are two different ways to program split, but one of them doesn't work on my unit. The working method sends the whole channel twice: once for rx and once for tx. There is one byte different to distinguish the two.
Thanks for the update. I'll try to check it out tonight.
Tom Wilson Sent from my Motorola Droid On Jun 11, 2012 2:10 PM, "Tom Hayward" esarfl@gmail.com wrote:
I have attempted to write a Kenwood TS-2000 driver based on my reading of the TS-2000 manual, which includes the serial command spec. I don't have a TS-2000. I would appreciate if someone would test this for me, at least try a read. The split stuff is completely unimplemented in this patch. I don't understand how the radio sends the split information, so someone with a radio will have to add that functionality. I expect this patch will have many small bugs. Please test!
Pinging Tom Wilson :-)
Tom KD7LXL _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
-- Tom Wilson wilsontp@gmail.com (619)940-6311 K6ABZ
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
Oh. So that means I have to figure out how to use the source control tools. XD All right; I know I'll have some time soon to sit down for a day and figure this stuff out; unfortunately, I have people coming over in another couple of hours.
Thanks, tho -Tom
On Sat, Jun 16, 2012 at 1:37 PM, Tom Hayward esarfl@gmail.com wrote:
You'll need to apply the patch I mailed. It hasn't been applied to the daily builds.
Tom KD7LXL On Jun 16, 2012 1:09 PM, "Tom Wilson" wilsontp@gmail.com wrote:
Tom H, I have been playing with the latest daily, and I can't figure out how to access the TS-2000. Can you give me a hint on how to load and/or use this module?
Thanks
On Mon, Jun 11, 2012 at 2:22 PM, Tom Wilson wilsontp@gmail.com wrote:
Thanks. I will check it out.
Split is odd. No pun intended. There are two different ways to program split, but one of them doesn't work on my unit. The working method sends the whole channel twice: once for rx and once for tx. There is one byte different to distinguish the two.
Thanks for the update. I'll try to check it out tonight.
Tom Wilson Sent from my Motorola Droid On Jun 11, 2012 2:10 PM, "Tom Hayward" esarfl@gmail.com wrote:
I have attempted to write a Kenwood TS-2000 driver based on my reading of the TS-2000 manual, which includes the serial command spec. I don't have a TS-2000. I would appreciate if someone would test this for me, at least try a read. The split stuff is completely unimplemented in this patch. I don't understand how the radio sends the split information, so someone with a radio will have to add that functionality. I expect this patch will have many small bugs. Please test!
Pinging Tom Wilson :-)
Tom KD7LXL _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
-- Tom Wilson wilsontp@gmail.com (619)940-6311 K6ABZ
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
Well, you are on the dev list ;-)
But you could just use the Load Module option to add the attached file to Chirp.
Tom KD7LXL
On Jun 16, 2012 1:51 PM, "Tom Wilson" wilsontp@gmail.com wrote:
Oh. So that means I have to figure out how to use the source control
tools. XD All right; I know I'll have some time soon to sit down for a day and figure this stuff out; unfortunately, I have people coming over in another couple of hours.
Thanks, tho -Tom
On Sat, Jun 16, 2012 at 1:37 PM, Tom Hayward esarfl@gmail.com wrote:
You'll need to apply the patch I mailed. It hasn't been applied to the
daily builds.
Tom KD7LXL
On Jun 16, 2012 1:09 PM, "Tom Wilson" wilsontp@gmail.com wrote:
Tom H, I have been playing with the latest daily, and I can't figure
out how to access the TS-2000. Can you give me a hint on how to load and/or use this module?
Thanks
On Mon, Jun 11, 2012 at 2:22 PM, Tom Wilson wilsontp@gmail.com wrote:
Thanks. I will check it out.
Split is odd. No pun intended. There are two different ways to program
split, but one of them doesn't work on my unit. The working method sends the whole channel twice: once for rx and once for tx. There is one byte different to distinguish the two.
Thanks for the update. I'll try to check it out tonight.
Tom Wilson Sent from my Motorola Droid
On Jun 11, 2012 2:10 PM, "Tom Hayward" esarfl@gmail.com wrote:
I have attempted to write a Kenwood TS-2000 driver based on my
reading of the
TS-2000 manual, which includes the serial command spec. I don't have
a TS-2000.
I would appreciate if someone would test this for me, at least try a
read. The
split stuff is completely unimplemented in this patch. I don't
understand how
the radio sends the split information, so someone with a radio will
have to add
that functionality. I expect this patch will have many small bugs.
Please test!
Pinging Tom Wilson :-)
Tom KD7LXL _______________________________________________ chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
-- Tom Wilson wilsontp@gmail.com (619)940-6311 K6ABZ
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
-- Tom Wilson wilsontp@gmail.com (619)940-6311 K6ABZ
chirp_devel mailing list chirp_devel@intrepid.danplanet.com http://intrepid.danplanet.com/mailman/listinfo/chirp_devel
participants (2)
-
Tom Hayward
-
Tom Wilson