[chirp_devel] [PATCH 1 of 2] [RFC] Convert the FT-857/897 driver to use named struct definitions
Marco Filippi IZ3GME
Wed Apr 11 04:30:50 PDT 2012
# HG changeset patch
# User Marco Filippi <iz3gme.marco at 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];
"""
More information about the chirp_devel
mailing list