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

Serial (UART?) input #55

Open
mredig opened this issue Aug 22, 2024 · 1 comment
Open

Serial (UART?) input #55

mredig opened this issue Aug 22, 2024 · 1 comment

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

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

No branches or pull requests

2 participants