forked from baconwaifu/PyVCDS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathreal_test.py
More file actions
31 lines (24 loc) · 728 Bytes
/
real_test.py
File metadata and controls
31 lines (24 loc) · 728 Bytes
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
import can
import vwtp
import threading
#VWTP was architectured for an asynchronous socket
#so we need a thread to do that for us.
def recvthread(stack):
sock = stack.socket
while True:
msg = sock.recv()
if hasattr(msg,"data"):
stack._recv(msg)
else:
print(msg)
raise AttributeError("Not like a can.Message?")
sock = can.interface.Bus(channel='vcan0', bustype='socketcan')
stack = vwtp.VWTPStack(sock)
recv = threading.Thread(target=recvthread, args=(stack,))
recv.start()
conn = stack.connect(1) #"ECU"
with conn:
conn.send(b'\x10\x89')
assert conn.read() == b'\x50\x89' #positive response, same value.
conn.send(b'\x21\x01') #readDataByLocalIdentifier ID 1.
print(conn.read())