Hi John -
Thanks for the reply. I did find the source for that routine OK, but I was wondering why the linker isn't finding it in that library, as it does for the example program. I need to know more about the build system, I guess, but if it's in the library, and if my program needs it, why doesn't the linker extract it from that library?
(as a side note: I too am a fan of Notepad++, but IMO there are a couple of other tools that are even better for finding text strings. One is grepWin, a free one-window download that gives you excellent find/replace functionality. The other is the Qt Creator IDE. Even though I can't build for the esp32 with it (yet) I can edit, and it has a "follow symbol under cursor" command that is excellent in this regard.)
Also, I mentioned this elsewhere, but I'm having trouble getting the linker to recognize my app_main in main.cpp. I use the extern "C" around the definition of app_main, but I don't have an explicit declaration of it anywhere. Any ideas here would be very appreciated.
I need to read input from the user console
Re: I need to read input from the user console
I found the cause of those undefined references. It was indeed a C/C++ issue. I'm including a very helpful page for those who will inevitably trip over this in the future:
https://isocpp.org/wiki/faq/mixing-c-and-cpp#call-c
This is especially useful for those who want to program in C++ and also want to incorporate third-party code that is written in C (like linenoise) without modification.
https://isocpp.org/wiki/faq/mixing-c-and-cpp#call-c
This is especially useful for those who want to program in C++ and also want to incorporate third-party code that is written in C (like linenoise) without modification.
Re: I need to read input from the user console
Just as an FYI, I got around to trying the scanf and it didn't work - it returned immediately without waiting for input, and returns a (-1). I'll have to try something else.
Re: I need to read input from the user console
I added a reduced version of linenoise and glue that accomplishes a command line with history and editing.
I got rid of the completion and hints and file load/save of the history. The code I started from came from
esp-idf/components/console/linenoise/linenoise.c
My fork:
https://github.com/dashxdr/duktape-esp32
nkolban's usually quick to merge pull requests so most likely we'll be in sync again
I got rid of the completion and hints and file load/save of the history. The code I started from came from
esp-idf/components/console/linenoise/linenoise.c
My fork:
https://github.com/dashxdr/duktape-esp32
nkolban's usually quick to merge pull requests so most likely we'll be in sync again
Re: I need to read input from the user console
By default, UART I/O is implemented using simple routines (blocking output, non-blocking input). To use scanf and other functions which depend on blocking input behaviour, you need to tell the UART I/O to use UART driver instead.mzimmers wrote:Just as an FYI, I got around to trying the scanf and it didn't work - it returned immediately without waiting for input, and returns a (-1). I'll have to try something else.
(See https://docs.espressif.com/projects/esp ... out-stderr)
This is a snippet from the console example:
Code: Select all
/* Install UART driver for interrupt-driven reads and writes */
ESP_ERROR_CHECK( uart_driver_install(CONFIG_CONSOLE_UART_NUM,
256, 0, 0, NULL, 0) );
/* Tell VFS to use UART driver */
esp_vfs_dev_uart_use_driver(CONFIG_CONSOLE_UART_NUM);
Code: Select all
/* Disable buffering on stdin and stdout */
setvbuf(stdin, NULL, _IONBF, 0);
setvbuf(stdout, NULL, _IONBF, 0);
/* Minicom, screen, idf_monitor send CR when ENTER key is pressed */
esp_vfs_dev_uart_set_rx_line_endings(ESP_LINE_ENDINGS_CR);
/* Move the caret to the beginning of the next line on '\n' */
esp_vfs_dev_uart_set_tx_line_endings(ESP_LINE_ENDINGS_CRLF);
Re: I need to read input from the user console
Future people reading this thread, you might want to use the ESP-IDF console component.
Who is online
Users browsing this forum: No registered users and 187 guests