•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the Python section within the Software Development category of DaniWeb, a massive community of 456,549 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,369 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our Python advertiser: Programming Forums
Views: 1015 | Replies: 4 | Solved
![]() |
•
•
Join Date: Oct 2006
Posts: 19
Reputation:
Rep Power: 3
Solved Threads: 0
Hi everyone!
Im stuck...
I'm currently writing a GUI program to control a piece of machinery. I am using wxPython along with a few other bits and bobs including USPP for serial access.
My problem is that i need some way of 'pinging' the machine. ie I want to be able to regularly send an 'are you still there' message to the on board hardware, receive a simple yes or no and not really know it has done anything (must not interrupt the usability of the program)
Ive done some searching and i think threads must be the answer here but that is totally new territory for me...
Any help would be greatly appreciated :-)
Thanks,
Mark :mrgreen:
Im stuck...
I'm currently writing a GUI program to control a piece of machinery. I am using wxPython along with a few other bits and bobs including USPP for serial access.
My problem is that i need some way of 'pinging' the machine. ie I want to be able to regularly send an 'are you still there' message to the on board hardware, receive a simple yes or no and not really know it has done anything (must not interrupt the usability of the program)
Ive done some searching and i think threads must be the answer here but that is totally new territory for me...
Any help would be greatly appreciated :-)
Thanks,
Mark :mrgreen:
•
•
Join Date: Oct 2006
Posts: 19
Reputation:
Rep Power: 3
Solved Threads: 0
sure...
clearly there will be a little more to it in the end... lol, but that seems to do the trick.
Starts a new thread that repeats an action every 'x' seconds. The rest of the progam can continue as normal. Jobs-a-goodun :-)
One thing to note is that its a good idea to close the thread when the program exits...
Not sure how it would work with more than 1 thread but 1 is all i need :-)
Mark
python Syntax (Toggle Plain Text)
import thread import time def RunPing(self): while 1: time.sleep(5) print "PING!" thread.start_new_thread(RunPing,())
clearly there will be a little more to it in the end... lol, but that seems to do the trick.
Starts a new thread that repeats an action every 'x' seconds. The rest of the progam can continue as normal. Jobs-a-goodun :-)
One thing to note is that its a good idea to close the thread when the program exits...
python Syntax (Toggle Plain Text)
def OnClose(self, event): thread.exit()
Not sure how it would work with more than 1 thread but 1 is all i need :-)
Mark
Last edited by MarkWalker84 : Jan 25th, 2007 at 6:45 am.
You might take a look at:
http://www.daniweb.com/techtalkforum...224921-62.html
http://www.daniweb.com/techtalkforum...224921-62.html
![]() |
•
•
•
•
•
•
•
•
DaniWeb Python Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
- New Thread button hard to find? (DaniWeb Community Feedback)
- [Member of the Month - Feb '04] Popular Thread challenge! (Geeks' Lounge)
- Quote Thread (Geeks' Lounge)
Other Threads in the Python Forum
- Previous Thread: Dr.Python: running same output again
- Next Thread: Sorting



Linear Mode