Redirecting serial out to /dev/null when no serial connected

Hi,
my sketch has some contributed (#include) libs that I don't want to touch. My C skills are terrible anyway. Device is ESP32
During development, having Serial.begin(9600) in my sketch is OK, but once the sketch is "live" there won't be any serial connected at all.
My sketch crashes without serial open, and I don't have any serial open or writes in my sketch. Without hunting down hidden/obscure serial statements in libs, is there a way to redirect hidden serial activity with the Unix equivalent of " > /dev/null"? Once "live" I won't need any serial.
I tried Serial.end() and Serial.flush() but my program crashes, and of course, I cant see why because I can't see any serial debug because its deliberately closed!
I have seen some similar posts, typically the responses are "why do you want to do that" and redirect the asker. I hope I have explained why...

For me the first question is what do you see on the serial output if you include the Serial.begin(9600) in setup?

Second is what is 'Tools>>Core Debug Level' set to in the Arduino IDE? This should be 'None' for the final build.

Hi Riva,
There is no visible output to serial when serial is open; If I got some it would give me a clue where to look! I suspect there is a serial open somewhere, without any writes.
I tried serial monitor as well as putty (which is cool as you get ESP32 startup displays there).
My 'Tools>>Core Debug Level' is set to "none".

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.