Skip to content

Commit

Permalink
Merge pull request #16 from RCMast3r/proto_gen_hotfix
Browse files Browse the repository at this point in the history
Proto gen hotfix
  • Loading branch information
RCMast3r authored Apr 2, 2024
2 parents dfab592 + a90c7c2 commit b2c2c05
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ result
result/
.env
.idea/
*.mat
*.mat
*.log
1 change: 1 addition & 0 deletions py_data_acq/py_data_acq/common/protobuf_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])
Expand Down
19 changes: 17 additions & 2 deletions py_dbc_proto_gen/dbc_to_proto.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,31 @@ 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)
+ " = "
+ 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
Expand Down

0 comments on commit b2c2c05

Please sign in to comment.