-
Notifications
You must be signed in to change notification settings - Fork 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
Refactor printcore.py #1346
Merged
rockstorm101
merged 11 commits into
kliment:master
from
rockstorm101:pr-refactor-printcore
Dec 25, 2023
Merged
Refactor printcore.py #1346
rockstorm101
merged 11 commits into
kliment:master
from
rockstorm101:pr-refactor-printcore
Dec 25, 2023
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
Split `printcore.py` into two. All the functionality related to directly communicating with serial ports or TCP sockets is moved into `device.py`. This way this logic is abstracted from `printcore.py`, which is now independent of the underlying connection type. This reduces the complexity of `printcore.py` and increases code modularity. Plus it has the advantage of making it simple to add more connection types in the future (if any).
Serial.readline() is blocking in itself, but since Serial was opened with timeout=0.25 it won't block anyway. Plus it already returns b'' when timed out. The use of Serial.in_waiting was counterproductive here.
Try to connect to https://github.com/kliment/Printrun/blob/master/testtools/mock-printer.py |
Of course, thanks! I forgot about that. It communicates without issues with that mock-up on my machine, yey! \o/ |
* connect function no longer accepts a `dtr` argument. Is is now an instance-wide configurable option called `force_dtr`. * Added `parity_workaround` option to instance to allow switching it on and off.
* Device.connect does no longer accept a "dtr" argument * When `parity_workaround` is enabled, Serial.open and Serial.close are called twice on each connection attempt instead of just once. Therefore the previous test code failed on platforms where `parity_workaround` is enabled by default.
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.
Split
printcore.py
into two. All the functionality related to directly communicating with serial ports or TCP sockets is moved intodevice.py
. This way this logic is abstracted fromprintcore.py
, which is now independent of the underlying connection type.This reduces the complexity of
printcore.py
and increases code modularity. Plus it has the advantage of making it simple to add more connection types in the future (if any).Notes:
test_printcore.py
(with a very slight adjustment), so (in theory) merging this PR this does not change/break current API.device.py
andDevice
as the main class but I'm open to suggestions since I'm not entirely happy with the naming.As always, any comments/suggestions are appreciated and I'll be happy to address them.