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.
This series of patches was created to be able to use minimalmodbus asynchronously without breaking the current interface. It was taking care of that tests are green at every commit.
When working asynchronous we do not want to wait for the data after sending the request. We will most of the time wait for a select to return later.
To make this work the write and read operations had to be separated up to the _genericCommand method.
If the switch asynchron is set the _genericCommand method will return after sending the request without waiting for the response.
When changing large methods I seized the moment to break them into hand able peaces. This sometime leads to many parameters moved around. In my opinion we should think about a shared object holding at least some of the data that is moved around frequently.
Example:
In my case I am now able to inherit from Instrument overwriting the constructor and setting my parameters as needed. Especially I am setting a transport object as serial.
On write I call the _genericCommand method and save the parameters.
In the data_received callback I call _extractPayload and _calculateReturn as normally used in _genericCommand when working synchronously.