[chirp_devel] [PATCH 0 of 3] Updates to Cross Tone support
This set updates the cross tone mode lingo, and enables it on Wouxun radios.
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1333148982 25200 # Node ID ad1cf47a08349f459581eddbe53bce44a7101029 # Parent a3d397d29b3cfd84e3e42d283c452a42fe30f22b Fix the terminology in the Cross Modes definition so that it's more consistent. It was added to support Kenwood radios, which use DCS instead of DTCS and CTCSS instead of TSQL. This changes it to just "Tone" or "DTCS" for the transmit and receive modes. Related to Bug #65
diff -r a3d397d29b3c -r ad1cf47a0834 chirp/chirp_common.py --- a/chirp/chirp_common.py Fri Mar 30 16:20:10 2012 -0600 +++ b/chirp/chirp_common.py Fri Mar 30 16:09:42 2012 -0700 @@ -52,12 +52,12 @@ DTCS_EXTRA_CODES = [ 17, ]
CROSS_MODES = [ - "DCS->Off", - "Tone->DCS", - "DCS->CTCSS", - "Tone->CTCSS", - "Off->Tone", - "Off->DCS", + "Tone->Tone", + "Tone->DTCS", + "DTCS->Tone", + "DTCS->", + "->Tone", + "->DTCS", ]
MODES = ["WFM", "FM", "NFM", "AM", "NAM", "DV", "USB", "LSB", "CW", "RTTY", "DIG", "PKT", "NCW", "NCWR", "CWR"] @@ -204,7 +204,7 @@ ctone = 88.5 dtcs = 23 tmode = "" - cross_mode = "DCS->Off" + cross_mode = "Tone->Tone" dtcs_polarity = "NN" skip = "" power = None @@ -229,7 +229,7 @@ self.ctone = 88.5 self.dtcs = 23 self.tmode = "" - self.cross_mode = "DCS->Off" + self.cross_mode = "Tone->Tone" self.dtcs_polarity = "NN" self.skip = "" self.power = None diff -r a3d397d29b3c -r ad1cf47a0834 chirpui/memedit.py --- a/chirpui/memedit.py Fri Mar 30 16:20:10 2012 -0600 +++ b/chirpui/memedit.py Fri Mar 30 16:09:42 2012 -0700 @@ -88,7 +88,7 @@ _("ToneSql") : 88.5, _("DTCS Code") : 23, _("DTCS Pol") : "NN", - _("Cross Mode"): "DCS->Off", + _("Cross Mode"): "Tone->Tone", _("Duplex") : "", _("Offset") : 0, _("Mode") : "FM",
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1333148989 25200 # Node ID 388a9711c7a30dbd7ced6b9005c9813ef22443af # Parent ad1cf47a08349f459581eddbe53bce44a7101029 Update FT857 driver to handle the changed Cross Modes definitions Bug #65
diff -r ad1cf47a0834 -r 388a9711c7a3 chirp/ft857.py --- a/chirp/ft857.py Fri Mar 30 16:09:42 2012 -0700 +++ b/chirp/ft857.py Fri Mar 30 16:09:49 2012 -0700 @@ -123,19 +123,19 @@ }
CROSS_MODES = { - 0x08 : "DCS->Off", - 0x06 : "Tone->DCS", - 0x09 : "DCS->CTCSS", - 0x01 : "Off->Tone", - 0x02 : "Off->DCS", + 0x08 : "DTCS->", + 0x06 : "Tone->DTCS", + 0x09 : "DTCS->Tone", + 0x01 : "->Tone", + 0x02 : "->DTCS", }
CROSS_MODES_REV = { - "DCS->Off" : 0x08, - "Tone->DCS" : 0x06, - "DCS->CTCSS" : 0x09, - "Off->Tone" : 0x01, - "Off->DCS" : 0x02, + "DTCS->" : 0x08, + "Tone->DTCS" : 0x06, + "DTCS->Tone" : 0x09, + "->Tone" : 0x01, + "->DTCS" : 0x02, }
_model = ""
# HG changeset patch # User Dan Smith dsmith@danplanet.com # Date 1333149040 25200 # Node ID 87712944bf8524e45a0c9b1b936f2967056171ea # Parent 388a9711c7a30dbd7ced6b9005c9813ef22443af Add cross tone support for the wouxun driver. This allows you to use different tones for transmit and receive, as well as do things like Tone on transmit and DTCS on receive. It does not allow using different DTCS codes for transmit and receive. Mostly addresses Bug #65
diff -r 388a9711c7a3 -r 87712944bf85 chirp/wouxun.py --- a/chirp/wouxun.py Fri Mar 30 16:09:49 2012 -0700 +++ b/chirp/wouxun.py Fri Mar 30 16:10:40 2012 -0700 @@ -166,14 +166,15 @@
def get_features(self): rf = chirp_common.RadioFeatures() - rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS"] + rf.valid_tmodes = ["", "Tone", "TSQL", "DTCS", "Cross"] rf.valid_modes = ["FM", "NFM"] rf.valid_power_levels = POWER_LEVELS rf.valid_bands = [(136000000, 174000000), (216000000, 520000000)] rf.valid_characters = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" rf.valid_name_length = 6 rf.valid_duplexes = ["", "+", "-", "split"] - rf.has_ctone = False + rf.has_ctone = True + rf.has_cross = True rf.has_tuning_step = False rf.has_bank = False rf.memory_bounds = (1, 128) @@ -183,6 +184,46 @@ def get_raw_memory(self, number): return repr(self._memobj.memory[number - 1])
+ def get_tone(self, _mem, mem): + def get_dcs(val): + code = int("%03o" % (val & 0x07FF)) + pol = (val & 0x8000) and "R" or "N" + return code, pol + + if _mem.tx_tone != 0xFFFF and _mem.tx_tone > 0x2800: + tcode, tpol = get_dcs(_mem.tx_tone) + mem.dtcs = tcode + txmode = "DTCS" + elif _mem.tx_tone != 0xFFFF: + mem.rtone = _mem.tx_tone / 10.0 + txmode = "Tone" + else: + txmode = "" + + if _mem.rx_tone != 0xFFFF and _mem.rx_tone > 0x2800: + rcode, rpol = get_dcs(_mem.rx_tone) + mem.dtcs = rcode + rxmode = "DTCS" + elif _mem.rx_tone != 0xFFFF: + mem.ctone = _mem.rx_tone / 10.0 + rxmode = "Tone" + else: + rxmode = "" + + if txmode == "Tone" and not rxmode: + mem.tmode = "Tone" + elif txmode == rxmode: + mem.tmode = txmode + else: + mem.tmode = "Cross" + mem.cross_mode = "%s->%s" % (txmode, rxmode) + + if mem.tmode == "DTCS": + mem.dtcs_polarity = "%s%s" % (tpol, rpol) + + print "TX %s (%i) RX %s (%i)" % (txmode, _mem.tx_tone, + rxmode, _mem.rx_tone) + def get_memory(self, number): _mem = self._memobj.memory[number - 1] _nam = self._memobj.names[number - 1] @@ -214,22 +255,7 @@ if not _mem.iswide: mem.mode = "NFM"
- def get_dcs(val): - code = int("%03o" % (val & 0x07FF)) - pol = (val & 0x8000) and "R" or "N" - return code, pol - - if _mem.tx_tone == 0xFFFF or _mem.tx_tone == 0x0000: - pass # No tone - elif _mem.tx_tone > 0x2800 and _mem.rx_tone > 0x2800: - tcode, tpol = get_dcs(_mem.tx_tone) - rcode, rpol = get_dcs(_mem.rx_tone) - mem.dtcs = tcode - mem.tmode = "DTCS" - mem.dtcs_polarity = "%s%s" % (tpol, rpol) - else: - mem.rtone = _mem.tx_tone / 10.0 - mem.tmode = _mem.tx_tone == _mem.rx_tone and "TSQL" or "Tone" + self.get_tone(_mem, mem)
mem.power = POWER_LEVELS[not _mem.power_high]
@@ -243,6 +269,40 @@ def wipe_memory(self, _mem, byte): _mem.set_raw(byte * (_mem.size() / 8))
+ def set_tone(self, mem, _mem): + def set_dcs(code, pol): + val = int("%i" % code, 8) + 0x2800 + if pol == "R": + val += 0xA000 + return val + + if mem.tmode == "Cross": + tx_mode, rx_mode = mem.cross_mode.split("->") + elif mem.tmode == "Tone": + tx_mode = mem.tmode + rx_mode = None + else: + tx_mode = rx_mode = mem.tmode + + + if tx_mode == "DTCS": + _mem.tx_tone = set_dcs(mem.dtcs, mem.dtcs_polarity[0]) + elif tx_mode: + _mem.tx_tone = tx_mode == "Tone" and \ + int(mem.rtone * 10) or int(mem.ctone * 10) + else: + _mem.tx_tone = 0xFFFF + + if rx_mode == "DTCS": + _mem.rx_tone = set_dcs(mem.dtcs, mem.dtcs_polarity[1]) + elif rx_mode: + _mem.rx_tone = int(mem.ctone * 10) + else: + _mem.rx_tone = 0xFFFF + + print "TX %s (%i) RX %s (%i)" % (tx_mode, _mem.tx_tone, + rx_mode, _mem.rx_tone) + def set_memory(self, mem): _mem = self._memobj.memory[mem.number - 1] _nam = self._memobj.names[mem.number - 1] @@ -267,21 +327,7 @@ _mem.skip = mem.skip != "S" _mem.iswide = mem.mode != "NFM"
- def set_dcs(code, pol): - val = int("%i" % code, 8) + 0x2800 - if pol == "R": - val += 0xA000 - return val - - if mem.tmode == "DTCS": - _mem.tx_tone = set_dcs(mem.dtcs, mem.dtcs_polarity[0]) - _mem.rx_tone = set_dcs(mem.dtcs, mem.dtcs_polarity[1]) - elif mem.tmode: - _mem.tx_tone = int(mem.rtone * 10) - _mem.rx_tone = mem.tmode == "TSQL" and _mem.tx_tone or 0xFFFF - else: - _mem.rx_tone = 0xFFFF - _mem.tx_tone = 0xFFFF + self.set_tone(mem, _mem)
if mem.power: _mem.power_high = not POWER_LEVELS.index(mem.power)
participants (1)
-
Dan Smith