I just discovered the console_example today while searching for a way to turn off console. What a hidden gem the console is! My original goal to turn off console print is to focus on using the UART0 as a UART so I can send things from PC to ESP32. But if I can make use of the console feature that takes and parses commands, I can do so much more!
So I have some questions:
1) In order to have PC interact with the console, I'd like to disable prompt and echo. Are these things possible? If not, I will have to make my PC Python script strip off the echo and prompt so it would be able to analyze the response to its command.
2) Why does the console_example code initialize UART0 and install its driver? Aren't those steps already taken otherwise how would ESP_LOGx() and printf() work without the main initializing UART0 before printing to console?
https://github.com/espressif/esp-idf/bl ... main.c#L82
IDF console example code questions
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: IDF console example code questions
Can't answer 1, but for 2: the 'normal' (ROM) driver you get on startup is a driver that does polling to figure out if it can send more data or if data is already received; in an interactive system like this, it would be inefficient as one task is only polling the UART over and over again to see if a key has been pressed on the console. The IDF driver is a 'blocking' one: if something like getch() is called, the driver will suspend the task until an UART receive interrupt has been received.
Re: IDF console example code questions
Thank you!
Your information on how bootloader handles UART is precise and appreciated. So once the app starts running and we're using printf and ESP_LOGx(), are we still using polling or has the buffer-driven UART0 mechanism been set up already say be the second-stage bootloader? Why would this sample code have to install the UART driver manually?
By the way, I've decided to not disable echo because I can handle it if I have a specific prompt that can be searched by the PC host so it knows that the device has entered the command line and can accept commands. Then after sending a command, the PC can wait until another prompt is received to know the command has finished. It's all useful now. I just have to disable all possible printf() from say wifi and rest part of my app to make the command line quiet enough.
What I'm trying to do is to incorporate this terminal command line into an existing project. Do I really need to install UART0?
Your information on how bootloader handles UART is precise and appreciated. So once the app starts running and we're using printf and ESP_LOGx(), are we still using polling or has the buffer-driven UART0 mechanism been set up already say be the second-stage bootloader? Why would this sample code have to install the UART driver manually?
By the way, I've decided to not disable echo because I can handle it if I have a specific prompt that can be searched by the PC host so it knows that the device has entered the command line and can accept commands. Then after sending a command, the PC can wait until another prompt is received to know the command has finished. It's all useful now. I just have to disable all possible printf() from say wifi and rest part of my app to make the command line quiet enough.
What I'm trying to do is to incorporate this terminal command line into an existing project. Do I really need to install UART0?
Re: IDF console example code questions
Is there any reason the wifi commands aren't turned into their own components like the nvs and system commands?
-
- Posts: 9727
- Joined: Thu Nov 26, 2015 4:08 am
Re: IDF console example code questions
I'm not too familiar with the console code, but I'll answer what I can: It may work with the ROM driver as well, but if it does, it's pretty certain you'll get better performance out of it if you install the (interrupt-driven) driver. Note that this driver isn't installed until your program explicitly calls uart_driver_install, if it never does (and lots of programs don't) the ESP32 will keep on using the ROM driver.
Re: IDF console example code questions
I see! So I've been not doing the efficient way all along! Maybe some example code has installed driver on UART0 but I missed them because I didn't go through as many as I should and dived in head first. ESP-IDF is so extensive. I bet if I put down everything I'm working on and just keep learning it, it will take me months to get through the hardware reference manual of ESP32, data sheet of WROVER, then ESP-IDF doc with every example out there.
I'm glad that people like you are here to provide guidance.
I'm glad that people like you are here to provide guidance.
Re: IDF console example code questions
I use VS code with PlatformIO to comply ESP-IDF example(esp-idf-master\examples\system\console\basic\main.c), but no success. Please share your comments to fix it.
Why the original example(demo) has an error in compile?
BR
Who is online
Users browsing this forum: No registered users and 102 guests