Implement "listen" subcommand (+ code structure) #9
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 PR is an extension of PR #2 and PR #8 .
I've always felt that the prototype of the listen subcommand shouldn't be merged. While it was mostly functional, it had no room for modifications or expansion later down the road. Overall, it wasn't clean code. This version of "listen" aims to answer that issue. Also, as a small difference between this and the prototype, this version does not:
The issues that caused these "hacks" have been fixed within the kernel.
PR #8 was meant to propose a structure to the project so that features would be simple to add. This PR exemplifies this, and makes use of the aforementioned structure, even though #8 hasn't been merged in yet. I am happy with it as-is, and I would suggest PR #8 be merged first (if everyone is okay with it) before this is.
I know this PR is quite large, but reviews would be greatly appreciated. I've tried to cut down on repetitive and unnecessary code, but there is so much I can do whilst implementing a core function of the app, and I don't know if this could be split up into multiple pull requests (besides #8).
Help Wanted
There is a part of this code I am not entirely happy with:
To explain why I did this, I wanted to make sure the user gets a message when an error is encountered, and the default behavior was to use the Debug print. I could copy the code from Display to Debug, but there still needs to be an implementation of Display for us to implement Error. (Do we really need to implement error?). Plus, it might still be useful to have that debug implementation, especially for those nested errors:
TODO
Compared to the python version, this still doesn't have all the bells and whistles, but I think this can be merged for now, and later on we can worry about those. A list is still present in #2.
A note on testing:
Run
cargo run -- listen --serial
The
--serial
flag is now needed, as I've decided to maintain the priority given to OpenOCD in the original version of tockloader.