forked from micropython/micropython
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Issue #4661 - Wrap pulsein values when maxlen is exceeded. #4683
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Update from adafruit main
tannewt
reviewed
Apr 29, 2021
Hmmm. Yes, I have pre-commit installed and it didn't complain. I'll fix up
the
indentation.
…On Thu, Apr 29, 2021 at 10:48 AM Scott Shawcroft ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In ports/raspberrypi/common-hal/pulseio/PulseIn.c
<#4683 (comment)>
:
> @@ -141,9 +141,16 @@ void common_hal_pulseio_pulsein_interrupt() {
}
// ignore pulses that are too short
if (result <= MAX_PULSE && result > MIN_PULSE) {
- self->buffer[buf_index] = (uint16_t) result;
- buf_index++;
- self->len++;
+ self->buffer[buf_index] = (uint16_t) result;
+ if (self->len < self->maxlen) {
+ self->len++;
+ }
+ if (buf_index < self->maxlen) {
+ buf_index++;
+ } else {
+ self->start = 0;
+ buf_index = 0;
Do you have pre-commit installed? I wouldn't expect this uneven
indentation to pass the code formatting check.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#4683 (review)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AFNJKEQUDRLCJTSJY4WCAATTLF5TDANCNFSM43XNZXFA>
.
|
jepler
added a commit
to jepler/circuitpython
that referenced
this pull request
Apr 30, 2021
In adafruit#4683, tannewt noticed that uncrustify was not running on some file in common-hal. I investigated and found that it was not being run on a bunch of paths. Rather than make incremental changes, I rewrote list_files to work bsaed on regular expressions; these regular expressions are created from the same git-style glob patterns. I spot-checked some specific filenames after this change, and all looks good: ``` $ python3 tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c tools/codeformat.py -v --dry-run tests/basics/int_small.py ports/raspberrypi/common-hal/pulseio/PulseIn.c extmod/virtpin.c tests/thread/thread_exit1.py ports/raspberrypi/background.h extmod/re1.5/recursiveloop.c uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup extmod/virtpin.c ports/raspberrypi/background.h ports/raspberrypi/common-hal/pulseio/PulseIn.c black --fast --line-length=99 -v tests/thread/thread_exit1.py ``` recursiveloop and int_small are excluded, while PulseIn, virtpin, and background are included. Testing running from a subdirectory (not _specifically_ supported though): ``` (cd ports && python3 ../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c) ../tools/codeformat.py -v --dry-run raspberrypi/common-hal/pulseio/PulseIn.c ../extmod/virtpin.c uncrustify -c /home/jepler/src/circuitpython/tools/uncrustify.cfg -lC --no-backup ../extmod/virtpin.c raspberrypi/common-hal/pulseio/PulseIn. ``` As a side-effect, a bunch more files are re-formatted now. :-P
Thanks! Looks like the code formatter was missing some files. |
tannewt
approved these changes
Apr 30, 2021
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Wrap values from pulsein when the maxlen is exceeded. No error is raised - this in accordance with the PulseIn documentation.