-
Notifications
You must be signed in to change notification settings - Fork 7.4k
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
std::cin should be implemented in terms of linenoise (IDFGH-8199) #9692
Comments
Hi @0xb00b, Applications which require a blocking While I agree that it's annoying that std::cin doesn't work "out of the box", it is unlikely that we will be modifying the standard library to perform such initialization automatically. |
@igrr thanks, that almost works. I can't see my input while typing in serial console, but otherwise it works. I suggest adding this information from your comment, to documentation as a highlighted note for others like me. |
@0xb00b did you figure out how to get the input to show when typing (when using std::cin / std::getline / etc.)? |
No, i didn't bother with it. Perhaps you can print out characters manually as you recieve them one at a time. There must be some low level function to read serial input in realtime without needing to press enter key. |
Yea I ended up using char c;
while (in.get(c)) {
line += c;
cli::Cli::cout() << c;
if (c == '\n')
break;
} instead of the simpler |
After using the linked code, local echo works fine as long as the dev is configured properly and a simple client such as
I think the "echo" properties there are important. The loop I'm using is straightforward and does use std::string s;
std::cout << "Prompt: ";
while (std::getline(std::cin, s)) {
std::cout << "Read: '" << s << "'\nPrompt:";
}
std::cout << "Bye bye!" << s; With pyserial's |
I am having the same problem with unblocking stdin but with preferable 'usb-serial-jtag' (and ESP-BOX-3). I have tried the example init from "esp_zigbee_gateway.c", but without any blocking. IGRR code snippet from </examples/common_components/protocol_examples_common/stdin_out.c> together with "CONFIG_ESP_CONSOLE_UART_DEFAULT=y" failed with: |
@Bobobel if you are using usb_serial_jtag interface, my suggestion doesn't apply literally, as it was written for the UART interface. Instead, you need to select the USB_SERIAL_JTAG as the primary console output in menuconfig, initialize the usb_serial_jtag driver and then call esp_vfs_usb_serial_jtag_use_driver. |
Dear Ivan, |
I'm sorry, I'm failing to understand what you are trying to achieve. Please open a new issue and describe the original problem you want to solve, as well as mention the IDF version you are using. |
Is your feature request related to a problem?
std::cin doesn't work. it doesn't read anything from serial console. everyone says "use linenoise", but why not just implement std::cin using linenoise ? if std::cout works over serial, then std::cin should also work over serial.
Describe the solution you'd like.
std::cin should be implemented in terms of linenoise.
Describe alternatives you've considered.
No response
Additional context.
No response
The text was updated successfully, but these errors were encountered: