[chirp_devel] [PATCH 2 of 2] [RFC] Convert the FT-817 driver to use named struct definitions
Dan Smith
Tue Apr 10 20:07:41 PDT 2012
# HG changeset patch
# User Dan Smith <dsmith at danplanet.com>
# Date 1334113627 25200
# Node ID 2921c559d78ef63031ac6a19b6a0c8d805e52d2e
# Parent ce7239963bc4dd7bef2b8dc1a3bdb6fbe26aab75
[RFC] Convert the FT-817 driver to use named struct definitions
This is an example usage of the previous patch which makes the definition of
the FT-817 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 -r ce7239963bc4 -r 2921c559d78e chirp/ft817.py
--- a/chirp/ft817.py Tue Apr 10 20:00:55 2012 -0700
+++ b/chirp/ft817.py Tue Apr 10 20:07:07 2012 -0700
@@ -110,8 +110,8 @@
print "Clone completed in %i seconds" % (time.time() - start)
-mem_struct = """
-struct {
+mem_format = """
+struct mem_struct {
u8 tag_on_off:1,
tag_default:1,
unknown1:3,
@@ -142,33 +142,26 @@
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]
+#seekto 0x2A;
+struct mem_struct vfoa[15];
+struct mem_struct vfob[15];
+struct mem_struct home[4];
+struct mem_struct qmb[2];
+struct mem_struct mtune;
-mem_format = """
-#seekto 0x2a;
-""" + mem_struct + """ vfoa[15];
-""" + mem_struct + """ vfob[15];
-""" + mem_struct + """ home[4];
-""" + mem_struct + """ qmb[2];
-""" + mem_struct + """ mtune;
-
-#seekto 0x3fd;
+#seekto 0x3FD;
u8 visible[25];
#seekto 0x417;
u8 filled[25];
#seekto 0x431;
-""" + mem_struct + """ memory[200];
+struct mem_struct memory[200];
#seekto 0x1979;
-""" + mem_struct + """ sixtymeterchannels[5];
+struct mem_struct sixtymeterchannels[5];
"""
@directory.register
More information about the chirp_devel
mailing list