# HG changeset patch
# User Vernon Mauery <vernon@mauery.org>
# Date 1292630275 28800
# Node ID 9a9f8893c74bafe0bb2a7a4e3976154e651ee569
# Parent  1de49e5a12da08aa4e3b52f9d572ba4795cf38e0
Add ul32 data type to bitwise parser

The TH-D72 radio stores frequencies as LE 32-bit ints.  This
adds that type as a subclass of the u32 data type.

Signed-off-by: Vernon Mauery <vernon@mauery.org>

diff -r 1de49e5a12da -r 9a9f8893c74b chirp/bitwise.py
--- a/chirp/bitwise.py	Sat Dec 04 23:41:13 2010 -0500
+++ b/chirp/bitwise.py	Fri Dec 17 15:57:55 2010 -0800
@@ -354,12 +354,16 @@
 
 class u32DataElement(intDataElement):
     _size = 4
+    _endianess = ">"
 
     def _get_value(self, data):
-        return struct.unpack(">I", data)[0]
+        return struct.unpack(self._endianess + "I", data)[0]
 
     def set_value(self, value):
-        self._data[self._offset] = struct.pack(">I", value)
+        self._data[self._offset] = struct.pack(self._endianess + "I", value)
+
+class ul32DataElement(u32DataElement):
+    _endianess = "<"
 
 class charDataElement(DataElement):
     _size = 1
@@ -500,6 +504,7 @@
         "ul16" : ul16DataElement,
         "u24"  : u24DataElement,
         "u32"  : u32DataElement,
+        "ul32" : ul32DataElement,
         "char" : charDataElement,
         "lbcd" : lbcdDataElement,
         "bbcd" : bbcdDataElement,
diff -r 1de49e5a12da -r 9a9f8893c74b chirp/bitwise_grammar.py
--- a/chirp/bitwise_grammar.py	Sat Dec 04 23:41:13 2010 -0500
+++ b/chirp/bitwise_grammar.py	Fri Dec 17 15:57:55 2010 -0800
@@ -18,7 +18,7 @@
 import re
 from chirp.pyPEG import keyword, parseLine
 
-TYPES = ["u8", "u16", "ul16", "u24", "u32", "char", "lbcd", "bbcd"]
+TYPES = ["u8", "u16", "ul16", "u24", "u32", "ul32", "char", "lbcd", "bbcd"]
 DIRECTIVES = ["seekto", "seek", "printoffset"]
 
 def string():
# HG changeset patch
# User Vernon Mauery <vernon@mauery.org>
# Date 1292630408 28800
# Node ID ad8798508a1b7fe3c4860bba09dbe570ef417e1f
# Parent  9a9f8893c74bafe0bb2a7a4e3976154e651ee569
Allow lowercase hex digits in bitwise grammars

This was a real bugger for me to track down.  I wrote
a grammar that had lowercase hex digits and it would
explode spectacularly.  This allows lowercase digits
since they are technically valid hex digits.

Signed-off-by: Vernon Mauery <vernon@mauery.org>

diff -r 9a9f8893c74b -r ad8798508a1b chirp/bitwise_grammar.py
--- a/chirp/bitwise_grammar.py	Fri Dec 17 15:57:55 2010 -0800
+++ b/chirp/bitwise_grammar.py	Fri Dec 17 16:00:08 2010 -0800
@@ -28,7 +28,7 @@
     return re.compile(r"\w+")
 
 def count():
-    return re.compile(r"([1-9][0-9]*|0x[0-9A-F]+)")
+    return re.compile(r"([1-9][0-9]*|0x[0-9a-fA-F]+)")
 
 def bitdef():
     return symbol, ":", count, -1
# HG changeset patch
# User Vernon Mauery <vernon@mauery.org>
# Date 1292630666 28800
# Node ID 9bbf1f65723bb8cd812bb3dcfe6bb7ccac1dcd01
# Parent  ad8798508a1b7fe3c4860bba09dbe570ef417e1f
Add TH-D72 radio support

The TH-D72 radio is a clone radio similar to the TMV71
but it had enough differences that it merited a separate
driver.  In addition to those differences, I also used
the new bitwise parser to deal with the raw memory data.

I have tested adding, modifying, deleting, upload,
download, writing to file, and reading from file.

Signed-off-by: Vernon Mauery <vernon@mauery.org>

diff -r ad8798508a1b -r 9bbf1f65723b chirp/chirp_common.py
--- a/chirp/chirp_common.py	Fri Dec 17 16:00:08 2010 -0800
+++ b/chirp/chirp_common.py	Fri Dec 17 16:04:26 2010 -0800
@@ -54,6 +54,13 @@
     731, 732, 734, 743, 754,
      ]
 
+CROSS_MODES = [
+    "DCS->Off",
+    "Tone->DCS",
+    "DCS->CTCSS",
+    "Tone->CTCSS",
+]
+
 MODES = ["WFM", "FM", "NFM", "AM", "NAM", "DV", "USB", "LSB", "CW", "RTTY"]
 
 STD_2M_OFFSETS = [
@@ -81,6 +88,7 @@
     "DTCS",
     "DTCS-R",
     "TSQL-R",
+    "Cross",
 ]
 
 TUNING_STEPS = [
@@ -99,6 +107,7 @@
     ctone = 88.5
     dtcs = 23
     tmode = ""
+    cross_mode = "DCS->Off"
     dtcs_polarity = "NN"
     skip = ""
 
@@ -118,6 +127,7 @@
         "dtcs"          : DTCS_CODES,
         "tmode"         : TONE_MODES,
         "dtcs_polarity" : ["NN", "NR", "RN", "RR"],
+		"cross_mode"    : CROSS_MODES,
         "mode"          : MODES,
         "duplex"        : ["", "+", "-", "split"],
         "skip"          : SKIP_VALUES,
@@ -435,6 +445,7 @@
         "has_tuning_step"     : BOOLEAN,
         "has_name"            : BOOLEAN,
         "has_ctone"           : BOOLEAN,
+        "has_cross"           : BOOLEAN,
 
         # Attributes
         "valid_modes"         : [],
@@ -483,6 +494,7 @@
         self.has_bank = True
         self.has_tuning_step = True
         self.has_ctone = True
+        self.has_cross = False
 
         self.valid_modes = list(MODES)
         self.valid_tmodes = []
diff -r ad8798508a1b -r 9bbf1f65723b chirp/detect.py
--- a/chirp/detect.py	Fri Dec 17 16:00:08 2010 -0800
+++ b/chirp/detect.py	Fri Dec 17 16:04:26 2010 -0800
@@ -16,7 +16,7 @@
 import serial
 
 from chirp import chirp_common, errors, idrp, util, icf, directory, ic9x_ll
-from chirp import kenwood_live, tmv71, tmv71_ll, icomciv
+from chirp import kenwood_live, tmv71, tmv71_ll, icomciv, thd72
 
 def _icom_model_data_to_rclass(md):
     for rtype, rclass in directory.DRV_TO_RADIO.items():
@@ -99,10 +99,11 @@
     s.close()
 
     if not r_id:
-        raise errors.RadioError("Unale to probe radio model")
+        raise errors.RadioError("Unable to probe radio model")
 
     models = {
         "TH-D7"   : kenwood_live.THD7Radio,
+        "TH-D72"  : thd72.THD72Radio,
         "TH-D7G"   : kenwood_live.THD7Radio,
         "TM-D700" : kenwood_live.TMD700Radio,
         "TM-V7"   : kenwood_live.TMV7Radio,
diff -r ad8798508a1b -r 9bbf1f65723b chirp/directory.py
--- a/chirp/directory.py	Fri Dec 17 16:00:08 2010 -0800
+++ b/chirp/directory.py	Fri Dec 17 16:04:26 2010 -0800
@@ -19,7 +19,7 @@
 from chirp import id800, id880, ic2820, ic2200, ic9x, icx8x, ic2100
 from chirp import icq7, icomciv, idrp, icf, ic9x_icf
 from chirp import vx6, vx7, vx8, ft7800, ft50
-from chirp import kenwood_live, tmv71
+from chirp import kenwood_live, tmv71, thd72
 from chirp import xml, chirp_common, convert_icf, csv
 
 DRV_TO_RADIO = {
@@ -48,6 +48,7 @@
 
     # Kenwood
     "thd7"           : kenwood_live.THD7Radio,
+    "thd72"          : thd72.THD72Radio,
     "tmd700"         : kenwood_live.TMD700Radio,
     "tmv7"           : kenwood_live.TMV7Radio,
     "v71a"           : tmv71.TMV71ARadio,
diff -r ad8798508a1b -r 9bbf1f65723b chirpui/memedit.py
--- a/chirpui/memedit.py	Fri Dec 17 16:00:08 2010 -0800
+++ b/chirpui/memedit.py	Fri Dec 17 16:04:26 2010 -0800
@@ -66,6 +66,7 @@
         ("ToneSql"   , TYPE_FLOAT,  gtk.CellRendererCombo, ),
         ("DTCS Code" , TYPE_INT,    gtk.CellRendererCombo, ),
         ("DTCS Pol"  , TYPE_STRING, gtk.CellRendererCombo, ),
+        ("Cross Mode", TYPE_STRING, gtk.CellRendererCombo, ),
         ("Duplex"    , TYPE_STRING, gtk.CellRendererCombo, ),
         ("Offset"    , TYPE_FLOAT,  gtk.CellRendererText,  ),
         ("Mode"      , TYPE_STRING, gtk.CellRendererCombo, ),
@@ -82,6 +83,7 @@
         "ToneSql"   : 88.5,
         "DTCS Code" : 23,
         "DTCS Pol"  : "NN",
+        "Cross Mode": "DCS->Off",
         "Duplex"    : "",
         "Offset"    : 0.0,
         "Mode"      : "FM",
@@ -101,7 +103,7 @@
         "Duplex" : ["", "-", "+", "split"],
         "Tune Step" : chirp_common.TUNING_STEPS,
         "Tone Mode" : ["", "Tone", "TSQL", "DTCS"],
-        "Skip" : chirp_common.SKIP_VALUES,
+        "Cross Mode" : chirp_common.CROSS_MODES,
         }
     
     def ed_name(self, _, __, new, ___):
@@ -515,6 +517,7 @@
                        self.col("ToneSql"), memory.ctone,
                        self.col("DTCS Code"), memory.dtcs,
                        self.col("DTCS Pol"), memory.dtcs_polarity,
+                       self.col("Cross Mode"), memory.cross_mode,
                        self.col("Duplex"), memory.duplex,
                        self.col("Offset"), memory.offset,
                        self.col("Mode"), memory.mode,
@@ -589,6 +592,7 @@
         mem.ctone = vals[self.col("ToneSql")]
         mem.dtcs = vals[self.col("DTCS Code")]
         mem.tmode = vals[self.col("Tone Mode")]
+        mem.cross_mode = vals[self.col("Cross Mode")]
         mem.dtcs_polarity = vals[self.col("DTCS Pol")]
         mem.duplex = vals[self.col("Duplex")]
         mem.offset = vals[self.col("Offset")]
@@ -721,6 +725,7 @@
         self.choices["Bank"] = gtk.ListStore(TYPE_STRING, TYPE_STRING)
         self.choices["Mode"] = features["valid_modes"]
         self.choices["Tone Mode"] = features["valid_tmodes"]
+        self.choices["Skip"] = features["valid_skips"]
 
         job = common.RadioJob(self.set_bank_list, "get_banks")
         job.set_desc("Getting bank list")
@@ -751,6 +756,7 @@
             ("has_tuning_step", "Tune Step"),
             ("has_name", "Name"),
             ("has_ctone", "ToneSql"),
+            ("has_cross", "Cross Mode"),
             ("valid_tmodes", "Tone Mode"),
             ("valid_tmodes", "Tone"),
             ("valid_duplexes", "Duplex"),
