i want to add a timeout to my code

M

maehhheeyy

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.
 
M

Miki

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.

http://docs.python.org/lib/node545.html

HTH,
 
M

maehhheeyy

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.

http://docs.python.org/lib/node545.html

HTH,

I tried the code onto my codes but what came out was that in the line
signal.signal(signal.SIGSLRM, handler), an attributeError appeared
reading that 'module' object has no attribute 'SIGALRM'
 
J

John Krukoff

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.

http://docs.python.org/lib/node545.html

HTH,

I tried the code onto my codes but what came out was that in the line
signal.signal(signal.SIGSLRM, handler), an attributeError appeared
reading that 'module' object has no attribute 'SIGALRM'

Are you writing your program on windows, or some other platform which is
not unix?
 
M

maehhheeyy

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.
http://docs.python.org/lib/node545.html
HTH,
I tried the code onto my codes but what came out was that in the line
signal.signal(signal.SIGSLRM, handler), an attributeError appeared
reading that 'module' object has no attribute 'SIGALRM'

Are you writing your program on windows, or some other platform which is
not unix?

--
John Krukoff <[email protected]>
Land Title Guarantee Company- Hide quoted text -

- Show quoted text -

Yeah I'm using Windows 2000.
 
G

Gabriel Genellina

On Apr 17, 1:10 pm,maehhheeyy<[email protected]> wrote:
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:'

I tried the code onto my codes but what came out was that in the line
signal.signal(signal.SIGSLRM, handler), an attributeError appeared
reading that 'module' object has no attribute 'SIGALRM'
--
Are you writing your program on windows, or some other platform which is
not unix?
Yeah I'm using Windows 2000.

signal doesn't work on Windows. The timeout parameter to Serial should
suffice...
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top