Check if serial port is listening
        Posted  
        
            by Hyposaurus
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by Hyposaurus
        
        
        
        Published on 2008-10-12T10:15:19Z
        Indexed on 
            2010/03/29
            20:23 UTC
        
        
        Read the original article
        Hit count: 404
        
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.
© Stack Overflow or respective owner