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

Demo of the full Greentea protocol flow on Unix PTY #31

Merged
merged 2 commits into from
Jun 9, 2021

Conversation

LDong-Arm
Copy link
Contributor

@LDong-Arm LDong-Arm commented Jun 2, 2021

Add a demo which creates a PTY (pseudo-terminals) device node which the host (htrun) can talk to like a serial device. To run it, two shells are required: one for the device running greentea-client, one for the host.

Notes:

  • Given that htrun currently doesn't provide a generic way (e.g. stdio) to interact with another process running greentea-client, PTY is the easiest way to demo the full Greentea protocol without requiring an embedded device or Mbed OS.
  • PTY requires a Unix-like OS. Windows has a different API to access terminals, so this example is excluded on Windows and only the client library itself is built.

Also remove the CMake cache variable BUILD_EXAMPLES. Its intention was to offer an option to not build the examples when greentea-client is embedded in another project, but now we already have the check if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME) which does it more elegantly.

@LDong-Arm LDong-Arm force-pushed the pty branch 3 times, most recently from 55ee660 to 27ea603 Compare June 2, 2021 10:36
@LDong-Arm LDong-Arm requested a review from a team June 2, 2021 10:41
@LDong-Arm LDong-Arm changed the title Full device (greentea-client) & host (htrun) demo Demo for the full Greentea protocol flow (greentea-client & htrun) Jun 2, 2021
@LDong-Arm LDong-Arm changed the title Demo for the full Greentea protocol flow (greentea-client & htrun) Demo of the full Greentea protocol flow (greentea-client & htrun) Jun 2, 2021
@LDong-Arm LDong-Arm changed the title Demo of the full Greentea protocol flow (greentea-client & htrun) Demo of the full Greentea protocol flow on Unix PTY Jun 2, 2021
examples/pty/CMakeLists.txt Outdated Show resolved Hide resolved
@LDong-Arm
Copy link
Contributor Author

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

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

"This replaces the file-based custom_io example, as there is no point
maintaining two examples to demonstrate how to override the default
IO."

The PTY example is more complex, so less good of an example for custom_io. I'd recommend keeping both for at least that reason.

examples/pty/CMakeLists.txt Show resolved Hide resolved
@LDong-Arm
Copy link
Contributor Author

"This replaces the file-based custom_io example, as there is no point
maintaining two examples to demonstrate how to override the default
IO."

The PTY example is more complex, so less good of an example for custom_io. I'd recommend keeping both for at least that reason.

Thanks for the suggestions, I've brought back custom_io and updated the README.

CMakeLists.txt Outdated Show resolved Hide resolved
@LDong-Arm LDong-Arm requested a review from Patater June 9, 2021 11:09
@rwalton-arm
Copy link
Contributor

Pseudoconsole on Windows:
https://docs.microsoft.com/en-us/windows/console/creating-a-pseudoconsole-session

Should we also add Windows support to this demo, or is that not feasible?

@LDong-Arm
Copy link
Contributor Author

Should we also add Windows support to this demo, or is that not feasible?

@rwalton-arm I don't have a Windows environment to develop and test it, but if anyones wants to add support for Windows, they can raise another PR.

The long-term solution @Patater suggests is adding an option in htrun to use stdio or files: ARMmbed/greentea#305 which doesn't quite depend on the OS.

@rwalton-arm
Copy link
Contributor

Should we also add Windows support to this demo, or is that not feasible?

@rwalton-arm I don't have a Windows environment to develop and test it, but if anyones wants to add support for Windows, they can raise another PR.

The long-term solution @Patater suggests is adding an option in htrun to use stdio or files: ARMmbed/greentea#305 which doesn't quite depend on the OS.

Yes, an "attach to process" feature, where htrun would read the process's stdout, would be useful. Sounds like the right solution to me.

Copy link
Contributor

@Patater Patater left a comment

Choose a reason for hiding this comment

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

The renaming of the stdio example should be its own commit.

The pty example commit sill says "This commit also removes the CMake cache variable BUILD_EXAMPLES.", but that isn't the case anymore and should be removed from the commit message.

LDong-Arm added 2 commits June 9, 2021 16:35
Previously we used the same name `greentea-client-example` for both
the stdio and custom_io examples, and relied on the switch
`GREENTEA_CLIENT_STDIO` to control which one gets built. But as
different examples, each one should have its own precise name for
clarity and to allow multiple examples to be built in the future.
Add a demo which creates a PTY (pseudo-terminals) device node which
the host (htrun) can talk to like a serial device. To run it, two
shells are required: one for the device running greentea-client, one
for the host.

Notes:
* Given that htrun currently doesn't provide a generic way
(e.g. stdio) to interact with another process running greentea-client,
PTY is the easiest way to demo the full Greentea protocol without
requiring an embedded device or Mbed OS.
* PTY requires a Unix-like OS. Windows has a different API to access
terminals, so this example is excluded on Windows.
@LDong-Arm
Copy link
Contributor Author

The renaming of the stdio example should be its own commit.

The pty example commit sill says "This commit also removes the CMake cache variable BUILD_EXAMPLES.", but that isn't the case anymore and should be removed from the commit message.

@Patater Both are resolved now, thanks

@LDong-Arm LDong-Arm requested a review from Patater June 9, 2021 15:38
@Patater Patater merged commit ef685c0 into ARMmbed:master Jun 9, 2021
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.

3 participants