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

Pin event timing (fixes #664) #665

Merged
merged 18 commits into from Jan 24, 2019

Conversation

waveform80
Copy link
Member

@waveform80 waveform80 commented Sep 14, 2018

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).

@waveform80
Copy link
Member Author

waveform80 commented Dec 24, 2018

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).

gpiozero/pins/native.py Outdated Show resolved Hide resolved
@bennuttall bennuttall added this to the v1.5 milestone Jan 14, 2019
@waveform80
Copy link
Member Author

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?

@codecov-io
Copy link

codecov-io commented Jan 23, 2019

Codecov Report

Merging #665 into master will decrease coverage by 13.29%.
The diff coverage is 46.38%.

Impacted file tree graph

@@            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
Impacted Files Coverage Δ
gpiozero/pins/rpigpio.py 3.17% <ø> (ø) ⬆️
gpiozero/pins/rpio.py 3.2% <ø> (ø) ⬆️
gpiozero/pins/pigpio.py 1.36% <0%> (-0.02%) ⬇️
gpiozero/pins/pi.py 87.09% <100%> (+10.48%) ⬆️
gpiozero/pins/local.py 93.93% <100%> (-0.3%) ⬇️
gpiozero/pins/mock.py 92.15% <100%> (-5.13%) ⬇️
gpiozero/boards.py 91.72% <14.28%> (-0.71%) ⬇️
gpiozero/pins/native.py 37.13% <32.48%> (+0.59%) ⬆️
gpiozero/internal_devices.py 55.44% <50%> (-10.9%) ⬇️
gpiozero/pins/__init__.py 71.31% <50%> (-1.57%) ⬇️
... and 32 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e8f806e...c9ff335. Read the comment docs.

@bennuttall
Copy link
Member

:shipit:

@waveform80
Copy link
Member Author

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!

@waveform80 waveform80 merged commit 415568c into gpiozero:master Jan 24, 2019
@waveform80 waveform80 deleted the pin-event-timing branch January 24, 2019 00:41
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)
Copy link
Contributor

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'))
Copy link
Contributor

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?

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

Successfully merging this pull request may close these issues.

None yet

4 participants