Skip to content

Serial (UART?) input #55

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

Open
mredig opened this issue Aug 22, 2024 · 2 comments
Open

Serial (UART?) input #55

mredig opened this issue Aug 22, 2024 · 2 comments
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@mredig
Copy link
Contributor

mredig commented Aug 22, 2024

I've found that I'm able to print via Swift on my esp32c*, but I cannot figure out how to read serial input.

Is this built into Swift at all, or do I need to drop into c calls?

@kubamracek
Copy link
Collaborator

kubamracek commented Aug 23, 2024

Even UART output is not really built into Embedded Swift -- the standard Swift functions that produce text output like print() are currently just redirected to putchar() calls, and we expect that the underlaying platform provides that. IIUC, the ESP SDK routes putchar into the JTAG-forwarded UART (on JTAG enabled boards).

So I think the solution here is to manually operate a UART from your code, especially if you want to use a different UART than the one that's used for normal logging from the various subsystems in ESP SDK. So, probably you're looking at library calls to the ESP SDK, or alternatively accessing the UART HW directly similarly to how this STM32 example code is set up: https://github.com/apple/swift-embedded-examples/blob/main/stm32-uart-echo/Sources/Application/Application.swift

@rauhul
Copy link
Collaborator

rauhul commented May 18, 2025

We could update the STM32 UART example to use readLine and implement _swift_stdlib_readLine_stdin over UART RX. Maybe that would be a good addition

@rauhul rauhul added enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed labels May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

3 participants