[chirp_devel] [PATCH 0 of 2] After last Dan's RFC
This patches are to be applied over the yesterday RFC patches from Dan to make use of the new structure feature and a bug correction in bitwise module.
So ... Yes I like it!
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1334143076 -7200 # Node ID 72aaa91c7f1c6b0cdddfb1423eec4cead3fc211f # Parent d8f2d8194dc28af2f9a62ceb167a84decb047ce2 [RFC] Convert the FT-857/897 driver to use named struct definitions
This is an example usage of the previous patch which makes the definition of the FT-857/897 memory format significantly simpler. The diff doesn't do it justice, so look at the before and after files to see the difference.
#93
diff --git a/chirp/ft857.py b/chirp/ft857.py --- a/chirp/ft857.py +++ b/chirp/ft857.py @@ -17,8 +17,8 @@ from chirp import ft817, chirp_common, errors, directory from chirp import bitwise
-mem_struct = """ -struct { +mem_format = """ +struct mem_struct{ u8 tag_on_off:1, tag_default:1, unknown1:3, @@ -53,21 +53,14 @@ u32 freq; u32 offset; u8 name[8]; -} -""" +};
-# there is a bug in bitwise_grammar that prevent the definition of single structures -# qmb should be only one mem_struct followed by -#""" + mem_struct + """ mtqmb; -# but both qmb and qmb[1] raise an exception so I had to define it as qmb[2] - -mem_format = """ #seekto 0x54; -""" + mem_struct + """ vfoa[16]; -""" + mem_struct + """ vfob[16]; -""" + mem_struct + """ home[4]; -""" + mem_struct + """ qmb[2]; -""" + mem_struct + """ mtune; +struct mem_struct vfoa[16]; +struct mem_struct vfob[16]; +struct mem_struct home[4]; +struct mem_struct qmb[2]; +struct mem_struct mtune;
#seekto 0x4a9; u8 visible[25]; @@ -78,11 +71,11 @@ u16 pmsfilled;
#seekto 0x4df; -""" + mem_struct + """ memory[200]; -""" + mem_struct + """ pms[10]; +struct mem_struct memory[200]; +struct mem_struct pms[10];
#seekto 0x1CAD; -""" + mem_struct + """ sixtymeterchannels[5]; +struct mem_struct sixtymeterchannels[5];
"""
# HG changeset patch # User Marco Filippi iz3gme.marco@gmail.com # Date 1334143404 -7200 # Node ID ecaf89696dfda8a52263c13f4e67e848e35843ca # Parent 72aaa91c7f1c6b0cdddfb1423eec4cead3fc211f [RFC] After the fix of the bug we can now use structures of only one element
Both driver has to be changed at once.
#93
diff --git a/chirp/ft817.py b/chirp/ft817.py --- a/chirp/ft817.py +++ b/chirp/ft817.py @@ -148,7 +148,8 @@ struct mem_struct vfoa[15]; struct mem_struct vfob[15]; struct mem_struct home[4]; -struct mem_struct qmb[2]; +struct mem_struct qmb; +struct mem_struct mtqmb; struct mem_struct mtune;
#seekto 0x3FD; @@ -322,7 +323,7 @@ immutable = ["number", "skip", "rtone", "ctone", "extd_number", "dtcs_polarity", "power", "comment"] elif mem.number == -1: - _mem = self._memobj.qmb[0] + _mem = self._memobj.qmb immutable = ["number", "skip", "rtone", "ctone", "extd_number", "name", "dtcs_polarity", "power", "comment"] else: @@ -350,7 +351,7 @@ elif mem.number in range(-2, -6, -1): _mem = self._memobj.home[5 + mem.number] elif mem.number == -1: - _mem = self._memobj.qmb[0] + _mem = self._memobj.qmb else: raise Exception("Sorry, special memory index %i unknown you hit a bug!!" % mem.number)
diff --git a/chirp/ft857.py b/chirp/ft857.py --- a/chirp/ft857.py +++ b/chirp/ft857.py @@ -59,7 +59,8 @@ struct mem_struct vfoa[16]; struct mem_struct vfob[16]; struct mem_struct home[4]; -struct mem_struct qmb[2]; +struct mem_struct qmb; +struct mem_struct mtqmb; struct mem_struct mtune;
#seekto 0x4a9;
This patches are to be applied over the yesterday RFC patches from Dan to make use of the new structure feature and a bug correction in bitwise module.
Applied, thanks!
So ... Yes I like it!
Me too, I'm pretty happy with it. It makes things much cleaner :)
participants (2)
-
Dan Smith
-
Marco Filippi IZ3GME