Git Product home page Git Product logo

Comments (5)

hardbyte avatar hardbyte commented on June 9, 2024

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.

hardbyte avatar hardbyte commented on June 9, 2024

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.

hardbyte avatar hardbyte commented on June 9, 2024

Original comment by Mike Molt (Bitbucket: M_Molt, GitHub: Unknown):


Brian, thank you!

So let me make sure I have this straight.

  1. 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?
  2. 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.

hardbyte avatar hardbyte commented on June 9, 2024

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.

hardbyte avatar hardbyte commented on June 9, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.