Skip to content
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

Add support for passing Exit Return code from Target to Host #13

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cepawiel
Copy link

Adds support for receiving the return code passed to the exit() syscall that was added to KOS in KallistiOS/KallistiOS@596f2bc. The value will be passed back over the serial connection to the host program which will use it as its return code when exiting.

I also changed some other exit codes to help determine when a failure has actually occurred in order to avoid false positives when using this change to detect passing or failing of software on the target.

The return code passed to exit() on the target will be
transfered to the host and used as the exit code for the
host application.
Sometimes the tool would return a success code when an error
had occured. This change makes it so that invalid flags and other
errors return -1 to indicate failure.
@gyrovorbis
Copy link
Member

Thank you, thank you, THANK YOU!!!!

This was the last major missing piece in writing more testable, more easily automatable examples and test apps. This is what I've always wanted and needed for CI, and hopefully we can now go back and do a better job error checking in some of the examples and return error status codes upon failure, which can all become automated. :)

@gyrovorbis gyrovorbis added the enhancement New feature or request label May 20, 2023
@QuzarDC
Copy link
Member

QuzarDC commented May 20, 2023

Two things:

  1. It would, perhaps, be valuable to distinguish between 'exit code because someone scripted dc-tool wrong' (all the 'invalid commandline option' stuff) and 'exit code from the DC'. Maybe even something like assign one byte as different host error codes and leave the other 3 for target?
  2. This would likely have to be a second PR, but I don't know the code enough. It seems like it should also be possible to integrate the exception handler into this :)

Copy link
Member

@ljsebald ljsebald left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to make sure that this change doesn't break when used with an older dcload-serial cd, it should really use a new command byte for the communication between the two parts. Please assign a new command code (it looks like 22 is the next free one) to the new exit syscall that has an argument, and update the code accordingly, while retaining the old behavior for command 0.

The target need not support sending code 0 after these changes, but keeping it in the host code will ensure that older dcload-serial discs do not break with a new dc-tool.

@ljsebald ljsebald self-assigned this Jun 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants