What is the best/easiest/quickest method of sending data to the serial console ?
I mean the most direct method, with least overhead and no data manipulation.
I use putchar() for now but I find it does NL to CR+NL conversion and I would like to avoid such conversion if possible.
How to send data to the serial console
Re: How to send data to the serial console
Would printf() not be sufficient? If you need to absolutely minimize latency and simply send a byte ... then the serial API would be the lowest level ...
search for:
uart_write_bytes()
as the ESP-IDF function to use.
search for:
uart_write_bytes()
as the ESP-IDF function to use.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 13
- Joined: Tue Apr 24, 2018 9:14 pm
Re: How to send data to the serial console
Thank you, my main objective right now is to avoid the NL to CR+NL translation and keep the call as elementary as possible. Involving printf() for every character printed would clearly be too much overhead.
Thus I can assume the UART for the console is open and so I can just write to it. Can I read it too ?
What kind of buffering shall I expect in such case ?
Thus I can assume the UART for the console is open and so I can just write to it. Can I read it too ?
What kind of buffering shall I expect in such case ?
Re: How to send data to the serial console
Howdy,
Have a good read at this documentation page:
http://esp-idf.readthedocs.io/en/latest ... /uart.html
I think its quite well written and comprehensive. There is a lot there so take your time and read it a few times. If you have questions, post back.
If we were chatting, I'd probably clarify the notion of the "serial console". The ESP32 uses a serial port (also called UART) to read and write data into it. This is what is used by esptool when you flash the device. When you run an ESP32, the application contained within it "just runs" ... however, convention is that during development, we log messages to the UART which can then be read by an external terminal application (or make monitor in ESP-IDF). I'd suggest to stop thinking of the ESP32 as having a "console" but instead think of the ESP32 as having a UART serial port which can "act" as a console.
Yes you can both read and write to the serial port.
See also:
http://esp-idf.readthedocs.io/en/latest ... m/log.html
http://esp-idf.readthedocs.io/en/latest ... nsole.html
Have a good read at this documentation page:
http://esp-idf.readthedocs.io/en/latest ... /uart.html
I think its quite well written and comprehensive. There is a lot there so take your time and read it a few times. If you have questions, post back.
If we were chatting, I'd probably clarify the notion of the "serial console". The ESP32 uses a serial port (also called UART) to read and write data into it. This is what is used by esptool when you flash the device. When you run an ESP32, the application contained within it "just runs" ... however, convention is that during development, we log messages to the UART which can then be read by an external terminal application (or make monitor in ESP-IDF). I'd suggest to stop thinking of the ESP32 as having a "console" but instead think of the ESP32 as having a UART serial port which can "act" as a console.
Yes you can both read and write to the serial port.
See also:
http://esp-idf.readthedocs.io/en/latest ... m/log.html
http://esp-idf.readthedocs.io/en/latest ... nsole.html
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 13
- Joined: Tue Apr 24, 2018 9:14 pm
Re: How to send data to the serial console
Thank you again,
In my application, all works fine, when I use putchar() and the base call to send characters to the console.
But when I try to use UART library and I call uart_write_bytes(UART_NUM_0, ) then I receive stream of errors like:
uart: uart_write_bytes(1073): uart driver error
thus what am I doing wrong ?
Pawel.
In my application, all works fine, when I use putchar() and the base call to send characters to the console.
But when I try to use UART library and I call uart_write_bytes(UART_NUM_0, ) then I receive stream of errors like:
uart: uart_write_bytes(1073): uart driver error
thus what am I doing wrong ?
Pawel.
Re: How to send data to the serial console
Did you first call uart_driver_install() to install the driver?
See:
http://esp-idf.readthedocs.io/en/latest ... stallation
See:
http://esp-idf.readthedocs.io/en/latest ... stallation
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
-
- Posts: 13
- Joined: Tue Apr 24, 2018 9:14 pm
Re: How to send data to the serial console
No, but I am writing to the console UART, which is already setup and open, correct ?
I am communicating with the GPS UART and it all works fine, I set it up, etc.
But the console UART is already setup by the system I understand.
I am communicating with the GPS UART and it all works fine, I set it up, etc.
But the console UART is already setup by the system I understand.
Who is online
Users browsing this forum: No registered users and 205 guests