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
Pin event timing (fixes #664) #665
Pin event timing (fixes #664) #665
Conversation
fa3137d
to
fec0d49
Compare
d7347ff
to
333ea4f
Compare
Had a chance to test some more of this today and I'm happy with it, though it'd be great if someone else could have a play too? The codecov fails can be ignored; they're largely down to lots of stuff changing in native which can't be tested on Travis (but the tests pass just fine on a real Pi - sometime in the new year I must set up a permanent gpiozero test bed). |
60f7b6c
to
ef6445f
Compare
Bah, no sooner do I rebase and I'm behind already! Right, I'm pretty much happy with this at this point; once Travis gives the thumbs up I'm going to have one more play with a variety of hardware then it's merge time. Last call for objections? |
In the case of both exported *and* unexported pins
The code to patch revision detection in concert with the API changes breaks those tests; trivial fix
ef6445f
to
c9ff335
Compare
Codecov Report
@@ Coverage Diff @@
## master #665 +/- ##
==========================================
- Coverage 86.84% 73.54% -13.3%
==========================================
Files 37 22 -15
Lines 7776 4136 -3640
Branches 0 589 +589
==========================================
- Hits 6753 3042 -3711
+ Misses 1023 1019 -4
- Partials 0 75 +75
Continue to review full report at Codecov.
|
Tested with GPIO inputs, outputs, and SPI under native, RPi.GPIO, and pigpio backends. All looking good. I've no doubt this'll break a few pending PRs though (given the amount it touches). Point me at any you want me to handle merging! |
f.write(str(pin).encode('ascii')) | ||
# Pin wasn't exported, so correct the ref-count | ||
self._pin_refs[pin] = 0 | ||
elif e.errno == errno.EACCES: | ||
sleep(i / 100) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be some kind of timeout code here (and also below), to prevent it sleep()-ing forever if/when something goes wrong?
else: | ||
try: | ||
with io.open(self.path('unexport'), 'w+b') as f: | ||
f.write(str(pin).encode('ascii')) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is this assuming that by the time the export
file is writeable, then the unexport
file must also be writeable at the same time?
Re-works the pins API to use timing information provided by underlying drivers (in particular pigpio) so that timing events from remote pins will be considerably more accurate (also seems to improve the accuracy of some local implementations too, probably because time sampling is done "closer" to the actual event).