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 packetry-cli wrapper program #154

Merged
merged 1 commit into from
Aug 5, 2024

Conversation

martinling
Copy link
Member

This is necessary on Windows, where we can't have the same binary serve as both a GUI and a console program, due to the constraints of the PE binary format. See e.g. this post by Raymond Chen, and this StackOverflow discussion.

Instead, we add a new packetry-cli console binary which simply acts as a wrapper around the main GUI binary.

The wrapper sets the PACKETRY_ATTACH_CONSOLE environment variable, which tells the main process to attach to the wrapping parent's console. The wrapper waits for the child to complete, and mirrors its exit code.

Thanks to @pointy56 for investigating and prototyping this solution.

This is necessary on Windows, where we can't have the same binary serve
as both a GUI and a console program, due to the constraints of the PE
binary format.

Instead, we add a new 'packetry-cli' console binary which simply acts as
a wrapper around the main GUI binary.

The wrapper sets the PACKETRY_ATTACH_CONSOLE environment variable, which
tells the main process to attach to the wrapping parent's console. The
wrapper waits for the child to complete, and mirrors its exit code.
@martinling
Copy link
Member Author

Note: Cargo doesn't currently support platform-specific binary targets. So we have to build packetry-cli on the other operating systems too, even though it's a no-op wrapper.

I think this is the right choice though, because it means that scripts and documentation can be written to always use packetry-cli for command line operations, and everything should then work unmodified on all systems.

Copy link
Member

@mossmann mossmann left a comment

Choose a reason for hiding this comment

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

I think this is a great solution! I tested on Linux, macOS, and Windows, and everything worked except that I found a bug with --test-cynthion --save-captures. On Windows I got:

Capture enabled, speed: High (480Mbps)
Starting read from test device
Read 4096 bytes from test device
Requesting capture stop
Capture disabled
thread 'main' panicked at src\test_cynthion.rs:28:64:
called `Result::unwrap()` on an `Err` value: The system cannot find the file specified. (os error 2)

On macOS I saw similar ("No such file or directory"). I retested on macOS with Packetry 0.1.0 from Homebrew, and --save-captures worked. I haven't tested --save-captures on Linux.

Copy link
Member

@mossmann mossmann left a comment

Choose a reason for hiding this comment

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

I reproduced the bug on Linux and with the main branch, so it was not introduced with this PR. I'll open an issue.

@martinling martinling merged commit 01e4185 into greatscottgadgets:main Aug 5, 2024
10 checks passed
@zi3m5f zi3m5f mentioned this pull request Oct 27, 2024
13 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a way to run the hardware-in-the-loop test from the UI
2 participants