Using Hardware Serial with Interrupt

What does "critical code" mean? It should not be in an ISR, which should be as short and fast as possible.

Clearly, you understand the issue (an ISR should NOT have much inside) and I was NOT clear about what I actually do in the code. I should have said that all the code controlling the robot's performance should be interruptable in case of critical situations such as emergencies. Typing input is so slow and potentially unclear, sorry.

OK.

I think most people on this forum would understand the term "critical code" as meaning "time critical", i.e. code that can't be interrupted or it will fail to perform some action that must be precisely timed.

My only excuse is that I am a newbie on this forum but now I am aware of the protocol and jargon. Thank you again.

You could put a Serial.peek() inside your ISR, just to test the first character in the buffer.

if it’s not your special character, just leave it alone and process your serial inout when you have time,

What an excellent suggestion. I had ChatGPT suggest code to test this out. Given it is based on Serial.available(), I think I can get the responsiveness I need for my robot cart project. Many thanks to all who have replied.