But I’ve been thinking and I would like to know if the following could be a workaround:
The idea is to modify Arduino Mega 2560 Bootloader and AVR-STUB definitions to use UART3 instead of UART0 for debugging
i.e. using RX3-TX3 with an FTDI for debugging and keeping RX0-TX0 printing functionality at the same time
Does anyone have tried something similar? And if yes, would you guide me on how to do it?
Why do I need avr-stub debugging instead of serial prints?
This project has 8 custom made libraries and uses another 10 open source libraries. As you could imagine the code is getting bigger. Serial prints for debugging are no longer pretty nor useful choice
Why I would like to keep functionality on Serial Port 0?
As I mentioned before I use third party libraries that already use Serial port printing (a lot)
some of them are mentioned here:
I could comment out Serial.prints in the whole code but it would be a real pain and not sustainable at all, there are more than 500 usages in the mentioned libraries
And last, the aim of my device is to connect with a computer through serial port 0 and send data to a python app, so the idea is to use built in USB host port for this. I could add an FTDI over another serial port but I think it would be a waste and will not solve the previous mentioned issues
Sorry for the late reply, I couldn’t test it until today.
My original idea was to modify Arduino bootloader to use UART3 also for program uploading but it was not necessary, I realize there are two different parameters inside of platformio.ini, upload_port and debug_port, that allowed me to run those options separately
So I ended up using built in Arduino USB host (UART0) for program uploading, and, at the same time, USB to Serial TTL CP2102 connected on RX3 TX3 (UART3) for program debugging
In case that someone is struggling with this, here it is my setup:
I put avr8-stub in libraries folder, in my case, ~/Arduino/libraries and included that path on lib_extra_dirs
thanks for the information on the solutions on how to allow the Serial.println() estatements while debugging.
Unfortunatelly, I am pretty new to the PlatformIO world, so I am missing a step by step description on how to enable the println estatements.
My use case is that I installed Visual Studio Code on windows, and the PlatformIO extension, because I wanted to debug some simple code for ArduinoUNO, but I found I am not allowed to print the estatements. I have no idea on
how to use GIT to update the avr_debug library in windows I assume (is the possibility of downloading the zip from somwwhere and manually exchange the files that are located somewhere?)
or where I can find the files that I would need modify for the other solution of using UART3 instead of UART0
So if somebody could invest some time on either of both solutions I would be grateful