Has any had any success using this? linenoise library on USB JTAG/serial console on ESP32-S3?
I only want to use linenoise, not the whole esp_console shebang, I have my own command parser which is more complex than esp_console can offer.
What am I doing:
- added "console" component
- include "linenoise/linenoise.h"
- call linenoise(" >"), nothing else
- this runs on the USB JTAG/serial console of the S3, which is the main console port and the secondary console port (UART) has been disabled.
What I expect:
- using idf.py monitor
- a line editor that sends my edited line to my application
What I am experiencing:
- linenoise continuously returning with NULL or small fragments that look like colour escape codes, but may be small bits of logging too.
- when I make a small test loop that only reads from input fd (0) en writes to output fd (1), it just works. No editing though, of course. So I guess there should be no technical reason why this couldn't work.
Looking at the source code of linenoise it seems it mainly returns for not being able to allocate memory (calloc) which will not be the issue here, because I have 2200 kB available for malloc/calloc.
linenoise library on USB JTAG/serial console on ESP32-S3
Re: linenoise library on USB JTAG/serial console on ESP32-S3
I am now making my own, even more basic, replacement of linenoise for this purpose and I'd like to share my experiences.
- the linenoise library does one byte read() calls, this is also what I am doing (but my stuff does work)
- the linenoise library sets the input (fileno(stdin) == 0) and the output (fileno(stdout) == 1) to non blocking (O_NONBLOCK). I think this is not supported in either newlib or the USB serial driver, because it doesn't matter whether nonblocking is activated or not.
- this might be the reason why linenoise doesn't work for me
- whenever I have read one byte successfully, the next few calls to read() for one byte return unsuccessfully (returning length == 0, which means end-of-file which is kind of strange)
- this might also be the reason why linenoise doesn't work for me
- I have workarounded this by keeping retrying the read after a short pause (task delay) and then it works quite well.
Looks to me like a small bug/omission in the USB-JTAG/serial driver on the ESP32-S3, could that be possible?
- the linenoise library does one byte read() calls, this is also what I am doing (but my stuff does work)
- the linenoise library sets the input (fileno(stdin) == 0) and the output (fileno(stdout) == 1) to non blocking (O_NONBLOCK). I think this is not supported in either newlib or the USB serial driver, because it doesn't matter whether nonblocking is activated or not.
- this might be the reason why linenoise doesn't work for me
- whenever I have read one byte successfully, the next few calls to read() for one byte return unsuccessfully (returning length == 0, which means end-of-file which is kind of strange)
- this might also be the reason why linenoise doesn't work for me
- I have workarounded this by keeping retrying the read after a short pause (task delay) and then it works quite well.
Looks to me like a small bug/omission in the USB-JTAG/serial driver on the ESP32-S3, could that be possible?
Who is online
Users browsing this forum: No registered users and 80 guests