Index: lib/MsgUtils/CMakeLists.txt =================================================================== diff -u -rdfe875a4159529de072df08b6c500707e9312d96 -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- lib/MsgUtils/CMakeLists.txt (.../CMakeLists.txt) (revision dfe875a4159529de072df08b6c500707e9312d96) +++ lib/MsgUtils/CMakeLists.txt (.../CMakeLists.txt) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -15,7 +15,7 @@ find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Core) find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Core Network SerialBus) -set(MSGUTILS_SCRIPTS_DIR ${CMAKE_CURRENT_SOURCE_DIR}/scripts) +set(MSGUTILS_SCRIPTS_DIR ${CMAKE_SOURCE_DIR}/scripts/MsgUtils) # Create a build-local venv so pip install works on distros that enforce PEP 668 # (Debian/Ubuntu with Python 3.11+, etc.) without polluting system or user site-packages. Index: lib/MsgUtils/MsgUtilsConfig.cmake.in =================================================================== diff -u -rcfc0df719cb5033078d0cac45ce0f6243810f2e7 -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- lib/MsgUtils/MsgUtilsConfig.cmake.in (.../MsgUtilsConfig.cmake.in) (revision cfc0df719cb5033078d0cac45ce0f6243810f2e7) +++ lib/MsgUtils/MsgUtilsConfig.cmake.in (.../MsgUtilsConfig.cmake.in) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -7,7 +7,7 @@ # Compute paths get_filename_component(MSGUTILS_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH) set(MSGUTILS_INCLUDE_DIRS "@CONF_INCLUDE_DIRS@") -set(MSGUTILS_SCRIPTS_DIR "${MSGUTILS_SOURCE_DIR}/scripts") +set(MSGUTILS_SCRIPTS_DIR "${CMAKE_SOURCE_DIR}/scripts/MsgUtils") # Our library dependencies (contains definitions for IMPORTED targets) if(NOT TARGET MsgUtils AND NOT MsgUtils_BINARY_DIR) Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/GenerateMsgDefsCpp.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/GenerateProtobuf.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/msgutils/MsgCpp.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/msgutils/MsgData.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/msgutils/MsgProtobuf.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/msgutils/__init__.py'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/msgutils/templates/MsgDefs_cpp.jinja'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/msgutils/templates/MsgDefs_h.jinja'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/msgutils/templates/MsgDefs_proto.jinja'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag fd9c43b00259567ff49a3d9b31b98df75b47bc52 refers to a dead (removed) revision in file `lib/MsgUtils/scripts/pyproject.toml'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/MsgUtils/GenerateMsgDefsCpp.py =================================================================== diff -u -r402926738e7394ee2d3dc7add2e6d755f06a289d -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/GenerateMsgDefsCpp.py (.../GenerateMsgDefsCpp.py) (revision 402926738e7394ee2d3dc7add2e6d755f06a289d) +++ scripts/MsgUtils/GenerateMsgDefsCpp.py (.../GenerateMsgDefsCpp.py) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -30,11 +30,8 @@ if args.source_dir is not None: os.makedirs(args.source_dir, exist_ok=True) if args.device_name is not None: - msg_cpp.write_msg_defs_header(f"{args.device_name}", args.header_dir, args.namespace) - msg_cpp.write_msg_defs_source(f"{args.device_name}", args.source_dir, args.namespace) - if args.proto: - msg_cpp.write_msg_proto_utils_header(f"{args.device_name}", args.header_dir, args.namespace) - msg_cpp.write_msg_proto_utils_source(f"{args.device_name}", args.source_dir, args.namespace) + msg_cpp.write_msg_defs_header(f"{args.device_name}", args.header_dir, args.namespace, args.proto) + msg_cpp.write_msg_defs_source(f"{args.device_name}", args.source_dir, args.namespace, args.proto) except Exception as e: print('Error: %s' % e) sys.exit(1) Fisheye: Tag a3922489de43e8452249c720d624e86be57dfa7e refers to a dead (removed) revision in file `scripts/MsgUtils/msgutils.egg-info/PKG-INFO'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3922489de43e8452249c720d624e86be57dfa7e refers to a dead (removed) revision in file `scripts/MsgUtils/msgutils.egg-info/SOURCES.txt'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3922489de43e8452249c720d624e86be57dfa7e refers to a dead (removed) revision in file `scripts/MsgUtils/msgutils.egg-info/dependency_links.txt'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3922489de43e8452249c720d624e86be57dfa7e refers to a dead (removed) revision in file `scripts/MsgUtils/msgutils.egg-info/entry_points.txt'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3922489de43e8452249c720d624e86be57dfa7e refers to a dead (removed) revision in file `scripts/MsgUtils/msgutils.egg-info/requires.txt'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag a3922489de43e8452249c720d624e86be57dfa7e refers to a dead (removed) revision in file `scripts/MsgUtils/msgutils.egg-info/top_level.txt'. Fisheye: No comparison available. Pass `N' to diff? Index: scripts/MsgUtils/msgutils/MsgCpp.py =================================================================== diff -u -r402926738e7394ee2d3dc7add2e6d755f06a289d -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/msgutils/MsgCpp.py (.../MsgCpp.py) (revision 402926738e7394ee2d3dc7add2e6d755f06a289d) +++ scripts/MsgUtils/msgutils/MsgCpp.py (.../MsgCpp.py) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -37,12 +37,14 @@ # \param[in] device_name name of the device used to name the output message definitions header file # \param[in] output_dir directory where the output header file will be written # \param[in] namespace namespace to use in the header file, if namespace is blank then no namespace will be added - def write_msg_defs_header(self, device_name, output_dir, namespace=None): + # \param[in] proto flag to add protobuf utility function to generated header file + def write_msg_defs_header(self, device_name, output_dir, namespace=None, proto=False): env = Environment(loader = FileSystemLoader(f'{Path(__file__).parent.absolute()}/templates')) template = env.get_template('MsgDefs_h.jinja') render = template.render({ 'msg_cpp': self, 'cpp_namespace': namespace, + 'proto': proto, 'device_name': device_name }) header_path = Path(output_dir).joinpath(f"{device_name}MsgDefs.h") @@ -56,13 +58,15 @@ # \param[in] device_name name of the device used to name the output message definitions source file # \param[in] output_dir directory where the output header file will be written # \param[in] namespace namespace to use in the header file, if namespace is blank then no namespace will be added - def write_msg_defs_source(self, device_name, output_dir, namespace=None): + # \param[in] proto flag to add protobuf utility function to generated header file + def write_msg_defs_source(self, device_name, output_dir, namespace=None, proto=False): env = Environment(loader = FileSystemLoader(f'{Path(__file__).parent.absolute()}/templates')) template = env.get_template('MsgDefs_cpp.jinja') render = template.render({ 'msg_cpp': self, 'msg_defs_header': f"{device_name}MsgDefs.h", 'cpp_namespace': namespace, + 'proto': proto, }) srcPath = Path(output_dir).joinpath(f"{device_name}MsgDefs.cpp") with open(srcPath, mode='w', encoding='utf-8', newline='\n') as out_file: @@ -71,44 +75,6 @@ print(f"Wrote C++ message definitions source file {srcPath}") - # \brief Write the protobuf utility C++ header file (struct <-> protobuf conversions) - # \param[in] device_name name of the device used to name the output files - # \param[in] output_dir directory where the output header file will be written - # \param[in] namespace namespace to use in the header file, if blank then no namespace - def write_msg_proto_utils_header(self, device_name, output_dir, namespace=None): - env = Environment(loader = FileSystemLoader(f'{Path(__file__).parent.absolute()}/templates')) - template = env.get_template('MsgProtoUtils_h.jinja') - render = template.render({ - 'msg_cpp': self, - 'cpp_namespace': namespace, - 'device_name': device_name - }) - header_path = Path(output_dir).joinpath(f"{device_name}MsgProtoUtils.h") - with open(header_path, mode='w', encoding='utf-8', newline='\n') as out_file: - out_file.write(render) - out_file.close() - print(f"Wrote C++ protobuf utilities header file {header_path}") - - - # \brief Write the protobuf utility C++ source file (struct <-> protobuf conversions) - # \param[in] device_name name of the device used to name the output files - # \param[in] output_dir directory where the output source file will be written - # \param[in] namespace namespace to use in the source file, if blank then no namespace - def write_msg_proto_utils_source(self, device_name, output_dir, namespace=None): - env = Environment(loader = FileSystemLoader(f'{Path(__file__).parent.absolute()}/templates')) - template = env.get_template('MsgProtoUtils_cpp.jinja') - render = template.render({ - 'msg_cpp': self, - 'msg_proto_utils_header': f"{device_name}MsgProtoUtils.h", - 'cpp_namespace': namespace, - }) - srcPath = Path(output_dir).joinpath(f"{device_name}MsgProtoUtils.cpp") - with open(srcPath, mode='w', encoding='utf-8', newline='\n') as out_file: - out_file.write(render) - out_file.close() - print(f"Wrote C++ protobuf utilities source file {srcPath}") - - def write_log_parser(self, basename, header_dir, source_dir, namespace, msg_defs_header): with open((header_dir.rstrip('/') + "/" if header_dir else "") + basename + '.h', mode='w', encoding='utf-8', newline='\n') as out_file: includes = set() Index: scripts/MsgUtils/msgutils/MsgData.py =================================================================== diff -u -r088513e6ea7bad08b4fb7862127c726eabad18fd -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/msgutils/MsgData.py (.../MsgData.py) (revision 088513e6ea7bad08b4fb7862127c726eabad18fd) +++ scripts/MsgUtils/msgutils/MsgData.py (.../MsgData.py) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -35,7 +35,7 @@ # \return hex string representation of the inputted value @staticmethod def value_to_hex_string(value): - return f"0x{f'{value:04x}'.upper()}" + return f"0x{f'{value:x}'.upper()}" # \brief Print all loaded data to the console @@ -117,7 +117,7 @@ 'type': result[0], }) if msg_id_value in self.data: - print(f"WARNING: found MesgIDs ({self.data[msg_id_value]['msg_id_hex_string']}) with same value, {self.data[msg_id_value]['msg_id']} will be replaced by {row_data['msg_id']} for value {row_data['msg_id_hex_string']}") + print(f"WARNING: found MesgIDs with same value, {self.data[msg_id_value]['msg_id']} will be replaced by {row_data['msg_id']} for value {row_data['msg_id_hex_string']}") self.data[msg_id_value] = row_data in_file.close() # sort the collected entries @@ -133,7 +133,7 @@ # otherwise new data will be added to the existing data # \return none def loadConf(self, filename, clear=True): - name_regex = re.compile(r'^[a-zA-Z](?:[a-zA-Z0-9_]*[a-zA-Z0-9])?$') + name_regex = re.compile(r'[a-zA-Z][a-zA-Z0-9_]*') filename = Path(filename).resolve() if clear: self.data = { } @@ -146,14 +146,18 @@ if not line and row_data is not None: # check to see if data has already been collected for this msg_id_value if row_data['msg_id_value'] in self.data: - print(f"WARNING: found message with same ID ({self.data[row_data['msg_id_value']]['msg_id_hex_string']}) - {self.data[row_data['msg_id_value']]['msg_id']} will be replaced by {row_data['msg_id']} for value {row_data['msg_id_hex_string']}") + print(f"WARNING: found MesgIDs with same value, {self.data[row_data['msg_id_value']]['msg_id']} will be replaced by {row_data['msg_id']} for value {row_data['msg_id_hex_string']}") for item in self.data.values(): if item['msg_name'] == row_data['msg_name']: - print(f"WARNING: found message {item['msg_id_hex_string']} with same name ({row_data['msg_name']}) as new message{row_data['msg_id_hex_string']}, skipping message") + print(f"WARNING: found MesgIDs with same name, {row_data['msg_name']}, skipping message") row_data = None break if row_data is not None: - if row_data['msg_id'] != '' and row_data['msg_name'] != '': + if row_data['msg_id'] == '': + print(f"WARNING: message with ID {row_data['msg_id_hex_string']} contains blank msg_id, skipping message") + elif row_data['msg_name'] == '': + print(f"WARNING: message with ID {row_data['msg_id_hex_string']} contains blank msg_name, skipping message") + else: self.data[row_data['msg_id_value']] = row_data entry_count += 1 row_data = None @@ -176,13 +180,10 @@ 'raw': line + '\n', } # message name (first line of message section) - elif row_data is not None and row_data['msg_id'] == '': + elif row_data is not None and row_data['msg_id'] == '' and re.fullmatch(name_regex, line): row_data['raw'] += line + '\n' - row_data['msg_id'] = line - if re.fullmatch(name_regex, line): - row_data['msg_name'] = self.__message_name(row_data['msg_id']) - else: - print(f"WARNING: message {row_data['msg_id_hex_string']} contains invalid message name ({line})") + row_data['msg_id'] = 'MSG_ID_' + '_'.join(word.upper() for word in line.split('_')) + row_data['msg_name'] = self.__message_name(row_data['msg_id']) # payload parameter elif row_data is not None and '=' in line: row_data['raw'] += line + '\n' Index: scripts/MsgUtils/msgutils/__init__.py =================================================================== diff -u -rccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/msgutils/__init__.py (.../__init__.py) (revision ccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f) +++ scripts/MsgUtils/msgutils/__init__.py (.../__init__.py) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -1,4 +1,3 @@ from .MsgData import MsgData from .MsgCpp import MsgCpp from .MsgProtobuf import MsgProtobuf -from .MsgHandlingIni import MsgHandlingIni Index: scripts/MsgUtils/msgutils/templates/MsgDefs_cpp.jinja =================================================================== diff -u -rccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/msgutils/templates/MsgDefs_cpp.jinja (.../MsgDefs_cpp.jinja) (revision ccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f) +++ scripts/MsgUtils/msgutils/templates/MsgDefs_cpp.jinja (.../MsgDefs_cpp.jinja) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -1,24 +1,29 @@ {%- if msg_defs_header | length -%} +#include #include "{{ msg_defs_header }}" {%- endif %} - -#include {%- if cpp_namespace is defined and cpp_namespace is not none %} namespace {{ cpp_namespace }} { {%- endif %} +{%- for (msg_id_value, msg) in msg_cpp.data.items() %} +{%- if proto is defined %} -QString msgIdString(const MsgId msgId) +// {{ msg['msg_id'] }} ({{ msg['msg_id_hex_string'] }}) +// payload: {{ msg_cpp.field_list(msg_id_value) | join(", ") }} +void {{ msg['msg_name'] }}Payload::fromProtobuf([[maybe_unused]] const messages::{{ msg['msg_name'] }} &src) { - switch (msgId) { -{%- for (msg_id_value, msg) in msg_cpp.data.items() %} - case {{ msg['msg_id'] }}: return QStringLiteral("{{ msg['msg_id'] }}"); -{%- endfor %} - default: return QStringLiteral("0x%1").arg(static_cast(msgId), 4, 16, QChar('0')); - } +{%- for field in msg['payload'] %} +{%- if field['type'] != "union" %} + // {{ field['type'] ~ "-" ~ field['name'] }} + {{ field['name'] }}.value = src.{{ field['name'].lower() }}(); +{%- else %} + // TODO: {{ field['type'] ~ "-" ~ field['name'] }} +{%- endif %} +{%- endfor %} } -{%- for (msg_id_value, msg) in msg_cpp.data.items() %} +{%- endif %} // {{ msg['msg_id'] }} ({{ msg['msg_id_hex_string'] }}) // payload: {{ msg_cpp.field_list(msg_id_value) | join(", ") }} @@ -51,9 +56,27 @@ return true; {%- endif %} } +{%- if proto is defined %} // {{ msg['msg_id'] }} ({{ msg['msg_id_hex_string'] }}) // payload: {{ msg_cpp.field_list(msg_id_value) | join(", ") }} +messages::{{ msg['msg_name'] }} {{ msg['msg_name'] }}Payload::toProtobuf() const +{ + messages::{{ msg['msg_name'] }} protoMsg; +{%- for field in msg['payload'] %} +{%- if field['type'] != "union" %} + // {{ field['type'] ~ "-" ~ field['name'] }} + protoMsg.set_{{ field['name'].lower() }}({{ field['name'] }}.value); +{%- else %} + // TODO: {{ field['type'] ~ "-" ~ field['name'] }} +{%- endif %} +{%- endfor %} + return protoMsg; +} +{%- endif %} + +// {{ msg['msg_id'] }} ({{ msg['msg_id_hex_string'] }}) +// payload: {{ msg_cpp.field_list(msg_id_value) | join(", ") }} void {{ msg['msg_name'] }}Payload::toQByteArray([[maybe_unused]] QByteArray &dst) const { {%- if msg['payload'] | length %} @@ -70,15 +93,54 @@ void {{ msg['msg_name'] }}Payload::dump() const { - QStringList paramList; + QStringList params; {%- for field in msg['payload'] %} {%- if field['type'] != "union" %} - paramList << QString("{{ field['name'] }}=%1").arg({{ field['name'] }}.value); + params << QString("{{ field['name'] }}=%1").arg({{ field['name'] }}.value); {%- endif %} {%- endfor %} - qDebug().noquote() << QString("{{ msg['msg_name'] }}Payload: %1").arg(paramList.count() ? paramList.join(", ") : ""); + qDebug().noquote() << QString("{{ msg['msg_name'] }}Payload: %1").arg(params.count() ? params.join(", ") : ""); } {%- endfor %} + +QByteArray canMessageToProtobufByteArray(const QDateTime ×tamp, const QString &deviceSerialNum, const Can::Message &msg) +{ + static const auto updateHeader = [&](messages::Header *header) { + if (header) { + const auto msecs = timestamp.toMSecsSinceEpoch(); + header->set_deviceserialnum(deviceSerialNum.toStdString()); + auto proto_timestamp = header->mutable_timestamp(); + if (proto_timestamp) { + proto_timestamp->set_seconds(msecs / 1000); + proto_timestamp->set_nanos((msecs % 1000) * 1000000); + } + header->set_msgid(msg.msgId); + header->set_sequence(msg.sequence); + } + }; + + switch (msg.msgId) { +{%- for (msg_id_value, msg) in msg_cpp.data.items() %} + case {{ msg['msg_id'] }}: { + {{ msg['msg_name'] }}Payload payload; + if (payload.fromQByteArray(msg.data) == false) { + qDebug().noquote() << "ERROR: could not convert CAN message with MsgId={{ msg['msg_name'] }} to struct"; + } + payload.dump(); + auto proto = payload.toProtobuf(); + updateHeader(proto.mutable_header()); + std::ostringstream out; + (void)proto.SerializeToOstream(&out); + return out.str().c_str(); + break; + } +{%- endfor %} + default: + qDebug().noquote() << QString("WARNING: MsgId=0x%1 not handled").arg(msg.msgId, 4, 16, QChar('0')); + break; + } + return QByteArray(); +} {%- if cpp_namespace is defined and cpp_namespace is not none %} } // namespace {{ cpp_namespace }} Index: scripts/MsgUtils/msgutils/templates/MsgDefs_h.jinja =================================================================== diff -u -rccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/msgutils/templates/MsgDefs_h.jinja (.../MsgDefs_h.jinja) (revision ccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f) +++ scripts/MsgUtils/msgutils/templates/MsgDefs_h.jinja (.../MsgDefs_h.jinja) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -10,6 +10,9 @@ #include "CanMessage.h" #include "types.h" +{%- if proto is defined %} +#include "{{ device_name }}MsgDefs.pb.h" +{%- endif %} {%- if cpp_namespace is defined and cpp_namespace is not none %} @@ -23,8 +26,6 @@ {%- endfor %} }; -QString msgIdString(const MsgId msgId); - enum ParamType { {%- for type in msg_cpp.paramTypes %} {{ type }}, @@ -64,20 +65,32 @@ // payload: {{ msg_cpp.field_list(msg_id_value) | join(", ") }} struct {{ msg['msg_name'] }}Payload { {%- for field in msg['cpp_struct']['payload'] %} -{%- if field['type'] == "union" %} - union {{ field['name'] }}; -{%- else %} - Types::{{ field['type'] }} {{ field['name'] }}; -{%- endif %} + {{ field['cpp_type'] }} {{ field['name'] }}; {%- endfor %} {%- if msg['cpp_struct']['payload'] | length %} {% endif %} +{%- if proto is defined %} +{%- if cpp_namespace is defined and cpp_namespace is not none %} + void fromProtobuf(const {{ cpp_namespace }}::messages::{{ msg['msg_name'] }} &src); +{%- else %} + void fromProtobuf(const messages::{{ msg['msg_name'] }} &src); +{%- endif %} +{%- endif %} bool fromQByteArray(const QByteArray &src); +{%- if proto is defined %} +{%- if cpp_namespace is defined and cpp_namespace is not none %} + {{ cpp_namespace }}::messages::{{ msg['msg_name'] }} toProtobuf() const; +{%- else %} + messages::{{ msg['msg_name'] }} toProtobuf() const; +{%- endif %} +{%- endif %} void toQByteArray(QByteArray &dst) const; void dump() const; }; {%- endfor %} {%- if cpp_namespace is defined and cpp_namespace is not none %} +QByteArray canMessageToProtobufByteArray(const QDateTime ×tamp, const QString &deviceSerialNumber, const Can::Message &msg); + } // namespace {{ cpp_namespace }} {%- endif %} Index: scripts/MsgUtils/msgutils/templates/MsgDefs_proto.jinja =================================================================== diff -u -r088513e6ea7bad08b4fb7862127c726eabad18fd -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/msgutils/templates/MsgDefs_proto.jinja (.../MsgDefs_proto.jinja) (revision 088513e6ea7bad08b4fb7862127c726eabad18fd) +++ scripts/MsgUtils/msgutils/templates/MsgDefs_proto.jinja (.../MsgDefs_proto.jinja) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -7,19 +7,12 @@ import "google/protobuf/timestamp.proto"; -// Header is required as the first field (i.e. 'Header header = 1;') of every message. message Header { string deviceSerialNum = 1; google.protobuf.Timestamp timestamp = 2; uint32 msgId = 3; - int32 sequence = 4; + uint32 sequence = 4; } - -// Envelope is a minimal wrapper used to extract the Header from serialized messages without knowing the -// concrete message type at parse time. Every message requires Header at field 1. -message Envelope { - Header header = 1; -} {%- for (msg_id, msg) in msg_proto.data.items() %} // {{ msg['msg_id'] }} ({{ msg['msg_id_hex_string'] }}) Index: scripts/MsgUtils/pyproject.toml =================================================================== diff -u -rccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- scripts/MsgUtils/pyproject.toml (.../pyproject.toml) (revision ccc40a7e73e9ee5d2a5fb56f3f2bea4f8294900f) +++ scripts/MsgUtils/pyproject.toml (.../pyproject.toml) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -6,13 +6,12 @@ name = "msgutils" version = "1.0.0" description = "Diality Message Utilities" -requires-python = ">=3.8" +requires-python = ">=3.9" dependencies = ["jinja2"] [project.scripts] GenerateMsgDefsCpp = "GenerateMsgDefsCpp:main" GenerateProtobuf = "GenerateProtobuf:main" -GenerateMsgHandlingIni = "GenerateMsgHandlingIni:main" [tool.setuptools.packages.find] exclude = ["test*"] Index: tools/CMakeLists.txt =================================================================== diff -u -r27dc39287f88d012536b4869b343e1770655d217 -rfd9c43b00259567ff49a3d9b31b98df75b47bc52 --- tools/CMakeLists.txt (.../CMakeLists.txt) (revision 27dc39287f88d012536b4869b343e1770655d217) +++ tools/CMakeLists.txt (.../CMakeLists.txt) (revision fd9c43b00259567ff49a3d9b31b98df75b47bc52) @@ -1,4 +1,3 @@ -add_subdirectory(AgentSim) if(UNIX AND NOT APPLE) add_subdirectory(CANDumpPlayer) endif()