469,327 Members | 1,226 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,327 developers. It's quick & easy.

i want to add a timeout to my code

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.
Jun 27 '08 #1
5 3692
On Apr 17, 1:10*pm, maehhheeyy <maehhhe...@gmail.comwrote:
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,
--
Miki <mi*********@gmail.com>
http://pythonwise.blogspot.com
Jun 27 '08 #2
On Apr 17, 4:24*pm, Miki <miki.teb...@gmail.comwrote:
On Apr 17, 1:10*pm,maehhheeyy<maehhhe...@gmail.comwrote:
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,
--
Miki <miki.teb...@gmail.com>http://pythonwise.blogspot.com
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'
Jun 27 '08 #3

On Tue, 2008-04-29 at 14:47 -0700, maehhheeyy wrote:
On Apr 17, 4:24 pm, Miki <miki.teb...@gmail.comwrote:
On Apr 17, 1:10 pm,maehhheeyy<maehhhe...@gmail.comwrote:
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,
--
Miki <miki.teb...@gmail.com>http://pythonwise.blogspot.com

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'
--
http://mail.python.org/mailman/listinfo/python-list
Are you writing your program on windows, or some other platform which is
not unix?

--
John Krukoff <jk******@ltgc.com>
Land Title Guarantee Company

Jun 27 '08 #4
On Apr 29, 3:29*pm, John Krukoff <jkruk...@ltgc.comwrote:
On Tue, 2008-04-29 at 14:47 -0700, maehhheeyy wrote:
On Apr 17, 4:24 pm, Miki <miki.teb...@gmail.comwrote:
On Apr 17, 1:10 pm,maehhheeyy<maehhhe...@gmail.comwrote:
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,
--
Miki <miki.teb...@gmail.com>http://pythonwise.blogspot.com
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'
--
http://mail.python.org/mailman/listinfo/python-list

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

--
John Krukoff <jkruk...@ltgc.com>
Land Title Guarantee Company- Hide quoted text -

- Show quoted text -
Yeah I'm using Windows 2000.
Jun 27 '08 #5
En Thu, 01 May 2008 17:06:20 -0300, maehhheeyy <ma********@gmail.com>
escribió:
On Apr 29, 3:29*pm, John Krukoff <jkruk...@ltgc.comwrote:
>On Tue, 2008-04-29 at 14:47 -0700, maehhheeyy wrote:
On Apr 17, 4:24 pm, Miki <miki.teb...@gmail.comwrote:
On Apr 17, 1:10 pm,maehhheeyy<maehhhe..@gmail.comwrote:
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:'
>http://docs.python.org/lib/node545.html
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...

--
Gabriel Genellina

Jun 27 '08 #6

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by DavidS | last post: by
3 posts views Thread by Mike | last post: by
3 posts views Thread by Kevin | last post: by
22 posts views Thread by Nick Craig-Wood | last post: by
25 posts views Thread by =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post: by
2 posts views Thread by Robin Becker | last post: by
1 post views Thread by Scorpion657 | last post: by
reply views Thread by maehhheeyy | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by Purva khokhar | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.