From 02652148fc9648e258f091298d7fae6159069823 Mon Sep 17 00:00:00 2001 From: Petteri Aimonen Date: Fri, 3 Apr 2015 19:44:23 +0300 Subject: Generate #defines for plain message ids --- generator/nanopb_generator.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'generator/nanopb_generator.py') diff --git a/generator/nanopb_generator.py b/generator/nanopb_generator.py index 4673ac67..fc32e2c5 100755 --- a/generator/nanopb_generator.py +++ b/generator/nanopb_generator.py @@ -1005,9 +1005,8 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio yield '#define %-40s %s\n' % (identifier, msize) yield '\n' - yield '/* helper macros for message type ids if set with */\n' - yield '/* option (nanopb_msgopt).msgid = ; */\n\n' - + yield '/* Message IDs (where set with "msgid" option) */\n' + yield '#ifdef PB_MSGID\n' for msg in messages: if hasattr(msg,'msgid'): @@ -1026,6 +1025,11 @@ def generate_header(dependencies, headername, enums, messages, extensions, optio yield '\tPB_MSG(%d,%s,%s) \\\n' % (msg.msgid, m, msg.name) yield '\n' + for msg in messages: + if hasattr(msg,'msgid'): + yield '#define %s_msgid %d\n' % (msg.name, msg.msgid) + yield '\n' + yield '#endif\n\n' -- cgit 1.2.3-korg