From db80ed21f140ebdd67ca4e15ae6064dd2345e35e Mon Sep 17 00:00:00 2001 From: Ben Hall Date: Fri, 29 Mar 2024 12:58:26 -0400 Subject: [PATCH 1/2] fixing proto file generation to allow for 64 bit integers --- flake.lock | 16 ++++++++-------- flake.nix | 2 +- .../py_data_acq/common/protobuf_helpers.py | 1 + py_dbc_proto_gen/dbc_to_proto.py | 19 +++++++++++++++++-- 4 files changed, 27 insertions(+), 11 deletions(-) diff --git a/flake.lock b/flake.lock index f52fdae..5c390d9 100644 --- a/flake.lock +++ b/flake.lock @@ -62,16 +62,16 @@ "utils": "utils_3" }, "locked": { - "lastModified": 1711056288, - "narHash": "sha256-jWWYVIlR6UXE3NNgSa1w/wcZOZWiwUWdWbg56OGTthc=", + "lastModified": 1711500166, + "narHash": "sha256-4wuBkKbl4wPq50+ODp/8+18u0C82YKkerv1r4ZPrSfg=", "owner": "hytech-racing", "repo": "ht_can", - "rev": "3c7682d8fed7f8999e1dc99e3b6d90846c21a787", + "rev": "2d0aedc0b25e2a90ec24d26ba1e35a3fffbe05b2", "type": "github" }, "original": { "owner": "hytech-racing", - "ref": "37", + "ref": "40", "repo": "ht_can", "type": "github" } @@ -198,16 +198,16 @@ }, "nixpkgs_3": { "locked": { - "lastModified": 1711124224, - "narHash": "sha256-l0zlN/3CiodvWDtfBOVxeTwYSRz93muVbXWSpaMjXxM=", + "lastModified": 1711523803, + "narHash": "sha256-UKcYiHWHQynzj6CN/vTcix4yd1eCu1uFdsuarupdCQQ=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "56528ee42526794d413d6f244648aaee4a7b56c0", + "rev": "2726f127c15a4cc9810843b96cad73c7eb39e443", "type": "github" }, "original": { "owner": "NixOS", - "ref": "nixos-23.11", + "ref": "nixos-unstable", "repo": "nixpkgs", "type": "github" } diff --git a/flake.nix b/flake.nix index 5641f7d..9b435bf 100644 --- a/flake.nix +++ b/flake.nix @@ -10,7 +10,7 @@ mcap.url = "github:RCMast3r/py_mcap_nix"; foxglove-websocket.url = "github:RCMast3r/py_foxglove_webserver_nix"; asyncudp.url = "github:RCMast3r/asyncudp_nix"; - ht_can_pkg_flake.url = "github:hytech-racing/ht_can/37"; + ht_can_pkg_flake.url = "github:hytech-racing/ht_can/40"; nix-proto = { url = "github:notalltim/nix-proto"; }; }; 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 From a90c7c2810015746f1083c86f47848b42fc11f71 Mon Sep 17 00:00:00 2001 From: Ben Hall Date: Fri, 29 Mar 2024 12:58:59 -0400 Subject: [PATCH 2/2] updating gitignore --- .gitignore | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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