Replies: 6 comments 6 replies
-
An other approach would be to automatically open and close the port for each call. This could be moderated by an extra optional parameter for the constructor. |
Beta Was this translation helpful? Give feedback.
-
I added a couple more options, option 4 adds a Long term you might think about using context managers for both serial and ethernet connections (similar to option 3). They are nice because if there is an exception raised when communicating it will always close the port at the end regardless of whether or not there was an exception. There is usually no problem opening / closing serial ports frequently similar to ethernet ports (unless you have two programs fighting over it). The downside to option 3 breaks the API significantly, removing the |
Beta Was this translation helpful? Give feedback.
-
I prefer option 5 as it takes all the burden away from the user to open/close ports. I re-implemented your idea using decorators, can you have a look at this branch? |
Beta Was this translation helpful? Give feedback.
-
Wouldn't you get the same effect when |
Beta Was this translation helpful? Give feedback.
-
I just submitted a small patch with some comments here. |
Beta Was this translation helpful? Give feedback.
-
I just made a branch in which subclasses are used to make things a bit clearer (hopefully). |
Beta Was this translation helpful? Give feedback.
-
Discussion on #5
Beta Was this translation helpful? Give feedback.
All reactions