tino / pyFirmata

Python interface for the Firmata (http://firmata.org/) protocol. It is compliant with Firmata 2.1. Any help with updating to 2.2 is welcome. The Capability Query is implemented, but the Pin State Query feature not yet.
MIT License
578 stars 191 forks source link

Support for Ping (pulseIn Firmata) and other improvements #45

Open NeoPolus opened 8 years ago

NeoPolus commented 8 years ago
tino commented 8 years ago

Hi, thanks for your extensive pull request. However, it is usually easier to implement features if they are small and contained. My reaction on these three proposals:

  1. I can't find this anywhere in the https://github.com/firmata/arduino library, is that correct? Because I would like to keep this a lean library, and not add code for every different sensor out there. Implementing this should be fairly easy by extending the Board class in your own code. Or did you run into things that made this hard?
  2. I really like the idea of running in a with block! However, to make it less "automagically" as you describe it somewhere I would be in favour of the following syntax, which is more explicit about what's happening:

    with Iterator(board):
       ...

    Which is probably easiest implemented with an _is_running attribute on the Iterator.

  3. Instead of raising a different error, wouldn't it be better to check for the length of self.sp.read() before passing it into ord alltogether? Or does this problem only occur when improperly exiting?

If you would like to move forward with one or more of these proposals, could you please do so in separate pull requests?

Also, please take PEP8 (https://www.python.org/dev/peps/pep-0008/) into account (use 4 spaces instead of tabs, etc.). I use flake8 to check this.

youssefhabri commented 5 years ago

So, what's the status on this? any chance that pyFirmata will get ping support at some point?

michaellee8 commented 2 years ago

This one would be really helpful, any chance we can provide pulse in through a special flag? without pulsein ultrasonic is not usable in firmata.

Kakcalu13 commented 9 months ago

What can we do to make this PR successful?