i want to add a timeout...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • maehhheeyy

    i want to add a timeout...

    I want to add a timeout so that when I pull out my gps from my serial
    port, it would wait for a bit then loop and then see if it's there. I
    also want to add a print statement saying that there is no GPS device
    found. However when I run my code and unplug my serial port, my code
    will just hang until I plug it back in.
    This is my code right now:

    def GetGPS():
    data = []
    #Open com1: 9600,8,N,1
    fi = serial.Serial(0 , timeout = 1)
    print '[gps module] SERIAL PORT OPEN ON COM1:'

    can anyone help me please? Thanks.
Working...