Check if serial port is listening
- by Hyposaurus
I have an Arduino sending and receiving instructions with a python script via a serial port.
The Arduino takes a button state and when it is pushed it will send a message via serial to a python script and await a response. (via Serial.available()). Works well enough.
However if the python script has crashed for whatever reason (ideally it will run in the background, so cant be easily checked) the Arduino will wait forever and even on a script restart will we unavailable.
Is there a way for my Arduino to check if there is something listening on the serial port? (and alert me with flashing lights etc if not) or is this not how serial works? Worst case I guess I could use a timeout, although that is not ideal.