Skip to content

Commit

Permalink
add IDE column to the CAN bus trace
Browse files Browse the repository at this point in the history
  • Loading branch information
danielhrisca committed Oct 23, 2023
1 parent 195d9b5 commit 9a1ff00
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/asammdf/gui/widgets/mdi_area.py
Original file line number Diff line number Diff line change
Expand Up @@ -1108,6 +1108,7 @@ def _add_can_bus_trace_window(self, ranges=None):
"timestamps": df_index,
"Bus": np.full(count, "Unknown", dtype="O"),
"ID": np.full(count, 0xFFFFFFFF, dtype="u4"),
"IDE": np.zeros(count, dtype="u1"),
"Direction": np.full(count, "", dtype="O"),
"Name": np.full(count, "", dtype="O"),
"Event Type": np.full(count, "CAN Frame", dtype="O"),
Expand Down Expand Up @@ -1143,13 +1144,16 @@ def _add_can_bus_trace_window(self, ranges=None):
if frame_map:
columns["Name"] = [frame_map.get(_id, "") for _id in vals.tolist()]

if "CAN_DataFrame.IDE" in names:
columns["IDE"] = data["CAN_DataFrame.IDE"].astype("u1")

columns["DLC"] = data["CAN_DataFrame.DLC"].astype("u1")
data_length = data["CAN_DataFrame.DataLength"].astype("u1").tolist()
data_length = data["CAN_DataFrame.DataLength"].astype("u1")
columns["Data Length"] = data_length

vals = csv_bytearray2hex(
pd.Series(list(data["CAN_DataFrame.DataBytes"])),
data_length,
data_length.tolist(),
)
columns["Data Bytes"] = vals

Expand Down Expand Up @@ -1189,8 +1193,11 @@ def _add_can_bus_trace_window(self, ranges=None):
if frame_map:
columns["Name"] = [frame_map.get(_id, "") for _id in vals.tolist()]

if "CAN_RemoteFrame.IDE" in names:
columns["IDE"] = data["CAN_RemoteFrame.IDE"].astype("u1")

columns["DLC"] = data["CAN_RemoteFrame.DLC"].astype("u1")
data_length = data["CAN_RemoteFrame.DataLength"].astype("u1").tolist()
data_length = data["CAN_RemoteFrame.DataLength"].astype("u1")
columns["Data Length"] = data_length
columns["Event Type"] = "Remote Frame"

Expand Down Expand Up @@ -1219,11 +1226,14 @@ def _add_can_bus_trace_window(self, ranges=None):
if frame_map:
columns["Name"] = [frame_map.get(_id, "") for _id in vals.tolist()]

if "CAN_ErrorFrame.IDE" in names:
columns["IDE"] = data["CAN_ErrorFrame.IDE"].astype("u1")

if "CAN_ErrorFrame.DLC" in names:
columns["DLC"] = data["CAN_ErrorFrame.DLC"].astype("u1")

if "CAN_ErrorFrame.DataLength" in names:
columns["Data Length"] = data["CAN_ErrorFrame.DataLength"].astype("u1").tolist()
columns["Data Length"] = data["CAN_ErrorFrame.DataLength"].astype("u1")

columns["Event Type"] = "Error Frame"

Expand Down

0 comments on commit 9a1ff00

Please sign in to comment.