473,396 Members | 2,024 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 3911
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: DavidS | last post by:
First: There are several ways to confuse one regarding session timeout. (1) web.config - <sessionState timeout="20"> (2) IIS Manager | Internet Information Services | ServerNode | Default Web Site...
2
by: Chris Langston | last post by:
I have a Web Server running IIS 5 or 6 on Windows 2K and Windows 2003 Server that is experiencing strange shutdown problems. We are using ASP.NET v1.1 and our application is written in VB.NET ...
3
by: Mike | last post by:
Timeout Calling Web Service I am calling a .NET 1.1 web service from an aspx page. The web service can take several minutes to complete its tasks before returning a message to the aspx page. ...
3
by: Kevin | last post by:
Hi How can i decrease the timeout on Socket.Connect?? Thanks =)
22
by: Nick Craig-Wood | last post by:
Did anyone write a contextmanager implementing a timeout for python2.5? I'd love to be able to write something like with timeout(5.0) as exceeded: some_long_running_stuff() if exceeded:...
25
by: =?Utf-8?B?RGF2aWQgVGhpZWxlbg==?= | last post by:
I tried: <sessionState timeout="1"> </sessionState> bounced IIS, and after 1 minute still had a session. ??? -- thanks - dave
2
by: Robin Becker | last post by:
While messing about with some deliberate socket timeout code I got an unexpected timeout after 20 seconds when my code was doing socket.setdefaulttimeout(120). Closer inspection revealed that...
1
by: Scorpion657 | last post by:
Hey I really need help. I have a Website coded using ASP.NET and VB and for some reason, i'm getting the following error when I try to upload or access a large file which is stored in the...
0
by: maehhheeyy | last post by:
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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.