Comments (1)
So I had another go:
#!/usr/bin/env python3
import threading
from multiprocessing import Queue
from pyvit.hw import socketcan
from pyvit.dispatch import Dispatcher
from pyvit.proto.isotp import IsotpInterface
dev = socketcan.SocketCanDev("vcan0")
disp = Dispatcher(dev)
recv_queue = Queue()
disp.add_receiver(recv_queue)
# set up an isotp interface Sender/Receiver arb id
sender = IsotpInterface(disp, 0x7DF, 0x7E8)
receiver = IsotpInterface(disp, 0x7E8, 0x7DF)
disp.start()
def vin():
payload = [0x49, 0x02, 0x01, 0x31, 0x41, 0x31, 0x4A, 0x43, 0x35, 0x34, 0x34, 0x34, 0x52, 0x37, 0x32, 0x35, 0x32, 0x33, 0x36, 0x37]
tx_thread = threading.Thread(target=sender.send, args=(payload,))
tx_thread.start()
resp = receiver.recv()
print(resp)
# resp
# tx_thread.join()
resp = []
print("finished")
while True:
CanFrameRecv = IsotpInterface.recv(receiver) # This works
print(CanFrameRecv)
if CanFrameRecv == [0x09, 0x02]:
print("It is!")
vin()
So the above "sort of" works, but still a tad buggy.
If I have tx_thread.join()
in the function, and send VIN Req but no Control Frame, then it holds up the while loop from all other received frames until the thread control frame timeout.
The other issue, is that if you send a control frame, followed by the Vin Req, it'll immediately send the follow up frames. I tried adding resp = []
into the function in hope that it would clear the queue, but after playing around, I see this doesn't appear to make a difference.
Anyone able to give me a hand with this?
Thanks,
Matt
from pyvit.
Related Issues (20)
- Baud rate settings wrong HOT 1
- Json database parser doesn't accept floats for 'factor'
- Decoder support for big(?) endian values HOT 2
- ISOTP protocol frame control message HOT 7
- Relicensing part of the code as MIT. HOT 2
- getting started example fails HOT 3
- Test fialures
- implement-uds - CAN11 CAN29 HOT 3
- Clean Up Old Examples HOT 2
- Support additional CAN hardware HOT 1
- Additional COMs except CAN
- pyvit doesn't show any CAN frame HOT 1
- How can I use tthe pyvit.proto uds library with a socketCAN device? HOT 1
- attribute '__version__'
- Win error
- log_frame() only can handle frames with 8 data bytes
- cannot import name 'can' HOT 1
- Project living?
- Infinite recursion when sending frame HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyvit.