-
Notifications
You must be signed in to change notification settings - Fork 7
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
Implement "listen" subcommand (+ code structure) #9
Conversation
I am temporarily not able to test the latest commit with a physical board. By my logic, the code shouldn't fail, but you can never be too sure. I will update this comment when I do test it. (P.S. Also, there's an argument to be made that this commit isn't needed, as reuniting the streams doesn't actually serve any purpose. Though it can't hurt, right?) |
After some tests for this commit, it turns out that While creating a weak link to the writer fixes the panic, a button still needs to be pressed for the program to exit. I'm unsure if Looking at term, on windows system we MIGHT be able to send phony data to the console (WriteConsoleInput), but I am unsure if the same behavior could be replicated on unix systems (maybe this?). I'm unsure on how to proceed with this. |
I have implemented a possible solution to this - writing to stdin. I don't know how cross-platform compatible my solution is - it works under Windows and WSL, but I cannot say anything of MacOS. A proof of concept - where I write a single, predetermined letter to stdin to free up I'll try to bring up writing to stdin as a possible feature for We still need to figure out what to do in the meantime. |
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.