diff --git a/.gitignore b/.gitignore index ebe6bba..93546ba 100644 --- a/.gitignore +++ b/.gitignore @@ -5,4 +5,5 @@ result result/ .env .idea/ -*.mat \ No newline at end of file +*.mat +*.log \ No newline at end of file diff --git a/py_data_acq/py_data_acq/common/protobuf_helpers.py b/py_data_acq/py_data_acq/common/protobuf_helpers.py index 7a612c0..00038b2 100644 --- a/py_data_acq/py_data_acq/common/protobuf_helpers.py +++ b/py_data_acq/py_data_acq/common/protobuf_helpers.py @@ -25,6 +25,7 @@ def pack_protobuf_msg(cantools_dict: dict, msg_name: str, message_classes): pb_msg = message_classes[msg_name]() for key in cantools_dict.keys(): if(type(cantools_dict[key]) is namedsignalvalue.NamedSignalValue): + print(msg_name) setattr(pb_msg, key, str(cantools_dict[key].value)) else: setattr(pb_msg, key, cantools_dict[key]) diff --git a/py_dbc_proto_gen/dbc_to_proto.py b/py_dbc_proto_gen/dbc_to_proto.py index f2284e4..95b3934 100644 --- a/py_dbc_proto_gen/dbc_to_proto.py +++ b/py_dbc_proto_gen/dbc_to_proto.py @@ -61,7 +61,7 @@ def append_proto_message_from_CAN_message(file, can_msg: can.message.Message): + str(line_index) + ";" ) - elif sig.length > 1: + elif (sig.length > 1 and sig.length <=32): line = ( " int32 " + create_field_name(sig.name) @@ -69,8 +69,23 @@ def append_proto_message_from_CAN_message(file, can_msg: can.message.Message): + str(line_index) + ";" ) + elif (sig.length >= 32 and not sig.is_signed): + line = ( + " uint64 " + + create_field_name(sig.name) + + " = " + + str(line_index) + + ";" + ) else: - print("ERROR") + line = ( + " int64 " + + create_field_name(sig.name) + + " = " + + str(line_index) + + ";" + ) + file.write(line + "\n") file.write("}\n\n") return file