-
Notifications
You must be signed in to change notification settings - Fork 20
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
cmd: migrate from getopt to argp #73
base: main
Are you sure you want to change the base?
Conversation
ab2ead5
to
29b192a
Compare
@amboar I don't have an AST2600 system on-hand to test the coprocessor stuff. Could you please test if the command still works as before? |
9acb55b
to
cb6c555
Compare
Looks like the argument processing is a bit off:
It should instead look like:
|
Found the issue. That was a leftover when I made the subcommand stuff easier 😄 New commit pushed where the argument processing for |
afd6f36
to
7338760
Compare
Currently:
🙂 I suspect there's a stray two arguments being passed to |
I'll migrate all commands and then implement a generic struct for the access stuff that's being used in like every command. That should make it easier I'd say instead of fiddling with argc and argv shit again like it has been done before. |
The argument handling is quite hard to make it good when using `getopt` with help and usage messages. The `argp` library is a better choice for this task. As there are several commands which have subcommands, a new helper function called `parse_subcommand` has been added to simplify the migration to `argp`. It'll take care of moving the subcommand to `argv[0]` and updating `argc` and `argv` accordingly, but also do `argp_parse`. Signed-off-by: Tan Siewert <[email protected]>
This is the first command that's being reworked for argp. Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
This subcommand differs from the others a bit in regards to sub-subcommands. `read` and `write` are handled in `parse_opt` directly instead of creating two new subcommands, because the actual handling for reading and writing is done in ast_ahb_access, where it checks if argv[0] is the operation to be performed. Signed-off-by: Tan Siewert <[email protected]>
The Debug UART inside the BMC can be brought into a stuck state by sending a lot of requests quickly or after sending a broken command. Sending 2 exit commands at 115200 baud before trying to enter debug mode again seems to mitigate this issue. Co-authored-by: Tan Siewert <[email protected]> Signed-off-by: Sarah Maedel <[email protected]> Signed-off-by: Tan Siewert <[email protected]>
The debug command now has two separate methods for read and write. While the functionality is almost the same, the code is now more readable and maintainable. Signed-off-by: Tan Siewert <[email protected]>
Similar to the devmem command, the determination of read/write is done in parse_opt, mainly because ast_ahb_access is doing shenanigans. Signed-off-by: Tan Siewert <[email protected]>
The JTAG argument handling is very special compared to the other commands. This command spawns a network server for remote bitbang. There's definitely a bit rework needed because the new implementation does wild things for host_init. Signed-off-by: Tan Siewert <[email protected]>
Commit 7db29d2 added the devcontainer manifests that are used in IDEs like Visual Studio Code. Unfortunately, VSC creates user configs in the workspace (project in this case). Subprojects are being pulled by meson in the `subprojects` directory and should not be checked in Git. Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
7338760
to
916ddbf
Compare
Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
Signed-off-by: Tan Siewert <[email protected]>
e08ed15
to
ea17f51
Compare
All commands now use I will work on resolving these inconsistencies and aim to make the implementation more generic. For readers and contributors, I’d appreciate your feedback on the documentation for the commands! Some commands are based on guesses regarding their functionality, so it would be helpful to ensure the documentation is accurate. |
@sinuscosinustan something I have been idly considering for a while is to require a keyword like
or maybe even with the bridge name:
What do you think? This might help where there are other positional arguments, such as in the case of the For the record, I plan to tag a release of culvert immediately prior to merging your changes. I think it's reasonable that we can break the command line behaviour a bit subsequent to the tag, in the process of cleaning up the implementation. Thanks again for your effort here. I'm honestly not sure how you've motivated yourself through it, because I was certainly struggling to motivate myself 😅 |
I was thinking about a generic set of options like
Awesome! At least some breakage possible 😄
Holiday, a lot of caffeine and suffering from the broken parsing 😂 |
Signed-off-by: Tan Siewert <[email protected]>
Sorry for the delay; after a quick look I think I prefer the |
Sounds good! I've tried to take a look into implementing my approach but for some reason argp doesn't want me to use the
If you have a small prototype of how it should look like I'd be happy to implement it! In the meanwhile I'll rework the |
Reopened because of fail in #71 / #70
The argument handling is quite hard to make it good when using
getopt
with help and usage messages. Theargp
library is a better choice for this task.Note: cleanup of dirty code or unwanted redundancies will be done from time to time in this PR. If you notice anything that bothers you, please add a comment directly. Thanks!
Checklist:
host_init
andast_ahb_access
for standardised flags