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

Projects
None yet
4 participants
@waveform80
Copy link
Member

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

@bennuttall bennuttall force-pushed the RPi-Distro:master branch from f9b5b2e to 7a1776f Sep 22, 2018

@waveform80 waveform80 force-pushed the waveform-computing:pin-event-timing branch from fa3137d to fec0d49 Sep 23, 2018

@waveform80 waveform80 force-pushed the waveform-computing:pin-event-timing branch from d7347ff to 333ea4f Nov 4, 2018

@waveform80

This comment has been minimized.

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

Show resolved Hide resolved gpiozero/pins/native.py Outdated

@bennuttall bennuttall added this to the v1.5 milestone Jan 14, 2019

@waveform80 waveform80 force-pushed the waveform-computing:pin-event-timing branch from 60f7b6c to ef6445f Jan 23, 2019

@waveform80

This comment has been minimized.

Copy link
Member Author

waveform80 commented Jan 23, 2019

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?

@waveform80 waveform80 force-pushed the waveform-computing:pin-event-timing branch from ef6445f to c9ff335 Jan 23, 2019

@codecov-io

This comment has been minimized.

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

This comment has been minimized.

Copy link
Member

bennuttall commented Jan 23, 2019

:shipit:

@waveform80

This comment has been minimized.

Copy link
Member Author

waveform80 commented Jan 24, 2019

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 RPi-Distro:master Jan 24, 2019

1 of 3 checks passed

codecov/patch 46.38% of diff hit (target 86.84%)
Details
codecov/project 73.54% (-13.3%) compared to e8f806e
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details

@waveform80 waveform80 deleted the waveform-computing:pin-event-timing branch Jan 24, 2019

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)

This comment has been minimized.

@lurch

lurch Feb 11, 2019

Contributor

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

This comment has been minimized.

@lurch

lurch Feb 11, 2019

Contributor

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
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.