Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't read analog messages via a handler #1

Open
anber500 opened this issue Sep 28, 2013 · 0 comments
Open

Can't read analog messages via a handler #1

anber500 opened this issue Sep 28, 2013 · 0 comments

Comments

@anber500
Copy link

I'm trying to get the values from analog 0.

This works:

#--------------------------------------------------
from pyfirmata import Arduino, util
import pyfirmata

board = Arduino("COM7")
it = util.Iterator(board)
it.start()

board.analog[0].enable_reporting()

while True:
print board.analog[0].read()
#--------------------------------------------------

But why doesn't this work?

#--------------------------------------------------
from pyfirmata import Arduino, util
import pyfirmata

board = Arduino("COM7")
it = util.Iterator(board)
it.start()

def _analogHandler(*args):
    print board.analog[0].read()

board.analog[0].enable_reporting()
board.add_cmd_handler(pyfirmata.pyfirmata.ANALOG_MESSAGE, _analogHandler)
#--------------------------------------------------

Even though the tests.py passes the analog tests, it doesn't seem like you can receive messages when relying on the handler.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant