Refactor for readability and reuse and other improvements.#67
Merged
haydenroche5 merged 1 commit intoblues:mainfrom Aug 30, 2023
Merged
Refactor for readability and reuse and other improvements.#67haydenroche5 merged 1 commit intoblues:mainfrom
haydenroche5 merged 1 commit intoblues:mainfrom
Conversation
- Add comments explaining some of the delays used in serial and I2C comms. - Refactor internal functions (those with a leading _) to be snake_case. Not changing external functions to preserve backwards compatibility. - Change some variable names in _send_payload to improve readability. Also, fix a bug in this function where we weren't sleeping properly between segments (looks to be an indentation error). Finally, sleep 20ms between writing I2C chunks in this function, which is what we document on blues.dev as the "right way" to do it. - Factor out reading from the Notecard over I2C into a new internal function, _receive. This is used both by Transaction and Reset. There was also a bug in Transaction that's fixed in this new function. There was a `continue` statement that was preempting both our timeout check and delaying between chunks. - Use the transaction manager in the Command functions for I2C and serial. Also, use try/finally where appropriate so that the transaction manager always stops the transaction, even if an exception gets raised.
19bc18c to
e9cc262
Compare
m-mcgowan
approved these changes
Jul 28, 2023
| if sent_in_seg > CARD_REQUEST_SEGMENT_MAX_LEN: | ||
| sent_in_seg -= CARD_REQUEST_SEGMENT_MAX_LEN | ||
| time.sleep(CARD_REQUEST_SEGMENT_DELAY_MS / 1000) | ||
| time.sleep(CARD_REQUEST_SEGMENT_DELAY_MS / 1000) |
| """Reset the Notecard.""" | ||
| chunk_len = 0 | ||
|
|
||
| while not self.lock(): |
Collaborator
Author
There was a problem hiding this comment.
Hmm, there was no timeout before these changes, so I was trying to keep it that way. I don't think there's a need for one, but perhaps I'm missing something that you're seeing?
haydenroche5
added a commit
to haydenroche5/note-python
that referenced
this pull request
Aug 30, 2023
This file contains hidden or 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
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.
continuestatement that was preempting both our timeout check and delaying between chunks.