-
Notifications
You must be signed in to change notification settings - Fork 0
/
run_plot.py
47 lines (29 loc) · 810 Bytes
/
run_plot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
from src.utils import *
from matplotlib.animation import FuncAnimation
import can
import pandas as pd
def animate(i):
# start sniffing
msg = can0.recv(30.0)
# filtering
Id = msg.arbitration_id
if Id == selected_id:
data = msg.data
dlc = msg.dlc
ts = msg.timestamp
hex_data = []
for i in range(dlc):
hex_data.append(data[i])
plt.cla()
for i in range(dlc):
plt.plot(ts, hex_data[i])
def main():
init_can()
global can0
can0 = can.interface.Bus(channel = 'can0', bustype = 'socketcan_ctypes')
# select id
global selected_id
selected_id = input('enter selected id to be plotted in rt')
anim = FuncAnimation(plt.gcf() , animate)
if __name__ == "__main__":
main()