3 # Copyright 2009 Free Software Foundation, Inc.
5 # This file is part of GNU Radio
7 # GNU Radio is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 3, or (at your option)
12 # GNU Radio is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License along
18 # with this program; if not, write to the Free Software Foundation, Inc.,
19 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 # dispatch codeword bits
25 HAS_STREAM_ID = 1 << 0;
26 HAS_CLASS_ID = 1 << 1;
27 HAS_INTEGER_SECS = 1 << 2;
28 HAS_FRACTIONAL_SECS = 1 << 3;
33 def do32(name, mask, index):
36 f.write("h->%s = ntohl(p[%d]);\n" % (name, index))
39 f.write("h->%s = 0;\n" % (name,))
42 def do64(name, mask, index):
45 f.write("h->%s = ((uint64_t)(ntohl(p[%d])) << 32) | ntohl(p[%d]);\n" % (name, index, index+1))
48 f.write("h->%s = 0;\n" % (name,))
52 f.write(" n32_bit_words_header = %d;\n"%index)
54 def dotrailer(name, mask):
56 f.write(" h->%s = ntohl(p[len-1]);\n" % (name,))
57 f.write(" n32_bit_words_trailer = 1;\n")
60 f.write(" h->%s = 0;\n" % (name,))
61 f.write(" n32_bit_words_trailer = 0;\n")
64 f.write(" case %d:\n" % (cw,))
67 index += do32("stream_id", HAS_STREAM_ID, index)
68 index += do64("class_id", HAS_CLASS_ID, index)
69 index += do32("integer_secs", HAS_INTEGER_SECS, index)
70 index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index)
72 dotrailer("trailer", HAS_TRAILER)
74 f.write(" break;\n\n")
84 if __name__ == '__main__':