Skip to content

Commit

Permalink
Basic Repository Template Checked In
Browse files Browse the repository at this point in the history
  • Loading branch information
Kiran Jojare committed Jul 9, 2024
1 parent 0dce273 commit edac489
Show file tree
Hide file tree
Showing 5 changed files with 68 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Build Status

on: [push, pull_request]
Expand Down
1 change: 1 addition & 0 deletions .github/workflows/code_quality.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@

name: Code Quality

on: [push, pull_request]
Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@

__pycache__/
*.pyc
*.pyo
*.pyd
*.log
56 changes: 56 additions & 0 deletions src/canalyzer_mimic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import pandas as pd
import matplotlib.pyplot as plt
from tkinter import *
from tkinter import filedialog

class CANLogAnalyzer:
def __init__(self, root):
self.root = root
self.root.title("CANalyzer Mimic Pro")
self.root.geometry("400x200")

self.log_file = ""
self.df = pd.DataFrame()

self.create_widgets()

def create_widgets(self):
self.select_file_btn = Button(self.root, text="Select CAN Log File", command=self.load_file)
self.select_file_btn.pack(pady=10)

self.id_label = Label(self.root, text="Enter CAN ID:")
self.id_label.pack()

self.id_entry = Entry(self.root)
self.id_entry.pack(pady=5)

self.plot_btn = Button(self.root, text="Plot Data", command=self.plot_data)
self.plot_btn.pack(pady=10)

def load_file(self):
self.log_file = filedialog.askopenfilename(title="Select CAN Log File", filetypes=(("Text files", "*.txt"), ("All files", "*.*")))
if self.log_file:
self.df = pd.read_csv(self.log_file, delim_whitespace=True, names=['Timestamp', 'ID', 'DLC', 'Data'])
self.df['Timestamp'] = self.df['Timestamp'].astype(float)

def plot_data(self):
can_id = self.id_entry.get()
if not can_id:
return

df_filtered = self.df[self.df['ID'] == can_id]

plt.figure(figsize=(10, 6))
for i in range(8):
plt.plot(df_filtered['Timestamp'], df_filtered['Data'].str[i], label=f'Byte {i}')

plt.xlabel('Timestamp')
plt.ylabel('Data')
plt.title(f'CAN Data for ID {can_id}')
plt.legend()
plt.show()

if __name__ == "__main__":
root = Tk()
app = CANLogAnalyzer(root)
root.mainloop()
4 changes: 4 additions & 0 deletions src/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@

pandas
matplotlib
tk

0 comments on commit edac489

Please sign in to comment.