How to connect the console to a socket
How to connect the console to a socket
I am using the Console component for a serial command interface but want to also access it remotely. It seems the Console is hard-wired to UART i/o, is it possible to connect it to a network socket?
Re: How to connect the console to a socket
Yes. A while ago I wanted the same thing. So I created a TCP socket server on port 23 (telnet port)I am using the Console component for a serial command interface but want to also access it remotely. It seems the Console is hard-wired to UART i/o, is it possible to connect it to a network socket?
Basically, whenever I want to print to that socket in my app. I just use: printft("Hello World\r\n");
Attached are the files for that. However, it's for my app and you'll have to figure out the things that are hard coded in like
CONFIG_TELNET_PORT_NUMBER, which is defined as 23, and the header files that are needed.
You will also need this part to get it going.
Code: Select all
#ifdef CONFIG_TELNET_ENABLED
// Start telnet service for printf's
xTaskCreatePinnedToCore(
TaskTelnet, // Task function.
"TaskTelnet", // name of task.
8192, // Stack size of task
NULL, // parameter of the task
CONFIG_TELNET_PRIORITY, // priority of the task
&xTaskHandleList[xtaskListCounter++], // Task handle to keep track of created task
TELNET_CPU_CORE);
#endif // CONFIG_TELNET_ENABLED
- Attachments
-
- myTelnet_10_21_2023_232606.zip
- (1.65 KiB) Downloaded 592 times
Re: How to connect the console to a socket
So now I have a Console REPL session connected to a telnet session by reassigning stdin and stdout to the telnet socket. But problems remain. Foremost is not being able to detect when the connection is closed remotely. REPL blocks on line input and does not detect it. I tried recv(MSG_PEEK) in the socket thread which succeeds in detecting remote close, but corrupts the REPL stdin read, presumably because there are 2 threads asynchronously accessing the stream. I think a esp_console_new_repl_socket() is required, similar to esp_console_new_repl_uart() but with support to detect remote close and appropriate settings for socket io.
-
- Posts: 168
- Joined: Sun May 22, 2022 2:42 pm
Re: How to connect the console to a socket
Did you pursue this any further? I'm going to look into this soon, since I absolutely want this feature working for me.
Can you share what you did already?
Can you share what you did already?
Who is online
Users browsing this forum: Google [Bot] and 55 guests