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):
35 f.write(" header[%d] = htonl(h->%s);\n" % (index, name))
39 def do64(name, mask, index):
41 f.write(" header[%d] = htonl((uint32_t)((h->%s >> 32) & 0xffffffff));\n" % (index, name))
42 f.write(" header[%d] = htonl((uint32_t)((h->%s >> 0) & 0xffffffff));\n" % (index+1, name))
47 f.write(" *n32_bit_words_header = %d;\n"%index)
49 def dotrailer(name, mask):
51 f.write(" trailer[%d] = htonl(h->%s);\n" % (0, name))
52 f.write(" *n32_bit_words_trailer = 1;\n")
55 f.write(" *n32_bit_words_trailer = 0;\n")
58 f.write(" case %d:\n" % (cw,))
61 index += do32("stream_id", HAS_STREAM_ID, index)
62 index += do64("class_id", HAS_CLASS_ID, index)
63 index += do32("integer_secs", HAS_INTEGER_SECS, index)
64 index += do64("fractional_secs", HAS_FRACTIONAL_SECS, index)
66 dotrailer("trailer", HAS_TRAILER)
68 f.write(" break;\n\n")
78 if __name__ == '__main__':