Comments (5)
Original comment by Brian Thorne (Bitbucket: hardbyte, GitHub: hardbyte):
Only other point I'll make is there are often multiple consumers attached to a bus. The Notifier/Listener api means that all consumers will receive the message.
from python-can.
Original comment by Mike Molt (Bitbucket: M_Molt, GitHub: Unknown):
Okay, I'm answering myself here with the hopes that someone else may benefit. A producer consumer type arrangement for getting and displaying the messages in the queue created by the BufferedReader subclass is the way to go here...particularly for GUI apps. For those learning like me, the author Mark Lutz covers this concept really well in the book 'Programming Python'.
from python-can.
Original comment by Mike Molt (Bitbucket: M_Molt, GitHub: Unknown):
Brian, thank you!
So let me make sure I have this straight.
- The notifier catches the event that something new has been placed on the bus, and then calls the designated listener to react to the event. In the case we're talking about, the listener puts the can message in a buffer. Is that correct so far?
- The BufferedReader subclass has a method get_message utilized to get the latest can message out of the buffer to do something with. This is pretty straight forward.
...here's what I'm not clear on, and this is probably my programming 'noobieness' showing.
I think I understand why using a method to get a can message as it is received is more efficient than continually 'checking' the bus with some sort of loop...so that is good I think. What I struggle with is figuring out a way to create an event in the rest of my program to actually get_message so I can do something with it.
from python-can.
Original comment by Brian Thorne (Bitbucket: hardbyte, GitHub: hardbyte):
Did you see the can.Notifier
class?
a_listener = can.BufferedReader()
notifier = can.Notifier(self.bus, [a_listener])
m = a_listener.get_message(TIMEOUT)
# m will be None or a Message
But yes there should be some tests and documentation for the Notifiers and Listeners.
from python-can.
Original comment by Mike Molt (Bitbucket: M_Molt, GitHub: Unknown):
I could use some examples as well for listeners. For instance, using the BufferedReader subclass. I'm not exactly sure how to properly access the messages put into the buffer.
from python-can.
Related Issues (20)
- gs_usb does not support set_bitrate() for some Candlelight devices HOT 2
- Mac OS: Deleting two separate PCAN buses simultaneously causes hard python script exit (assertion failed)
- Not able to send CANFD message in "pcan" interface HOT 5
- BLFWriter append messages to an existing log file does not take effect HOT 2
- Could not import vxlapi: function 'xlCanReceive' not found HOT 1
- SYSTEC: sending remote frame does not respect dlc value
- Issues with UdpMulticastBus and MacOS
- Could not import vxlapi: Could not find module 'vxlapi64' (or one of its dependencies). HOT 2
- Tx CANFD data sending Causes BUS-OFF State HOT 2
- CAN "Transmit Buffer Full" Error HOT 1
- Export signals from .trc files HOT 1
- Tx messages can not be received with AsyncBufferedReader()
- Listener.stop() method breaks API since declared abstract HOT 2
- How to stop the log recording using can.logger and blfWriter? HOT 2
- Single millisecond send resolution with python-can, Vector HOT 2
- ASCWriter not writing CAN Frames in Vector compatible format (and therefore ASCReader fails to read file back) HOT 3
- Align with the new CAN frame structure for socketcan adding optional DLC element
- CAN FD for Vector Hardware Interface HOT 1
- Is there any reason why the version installed by conda or pip is very old? HOT 1
- Crash in ASCReader HOT 2
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 python-can.