Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old August 3rd, 2006, 12:05 AM
Tom Brown
Guest
 
Posts: n/a
Default serial ports, threads and windows

Hey people,

I've written a python app that r/w eight serial ports to control eight devices
using eight threads. This all works very nicely in Linux. I even put a GUI on
it using PyQt4. Still works nicely.

Then I put the app on on a virtual Windows machine running inside of vmware on
the same Linux box. Vmware only lets me have four serial ports so I run the
app against four serial ports using four threads. The app did not respond
quick enough to data from the serial ports and eventually hung.

So, I tried one serial port and the app still did not respond quick enough to
the single serial port. It eventually hangs.

When the app hung, in each case, it was not hogging the cpu nor reading any
data off the serial ports. The task manager didn't show it was doing anything
at all.

When it runs on Windows, could it be:

1) Just struggling to run inside of VMware?

2) Using threads with Qt on Windows is a problem?

3) Threads in python on Windows is a problem?

Any ideas?

Thanks,
Tom
  #2  
Old August 3rd, 2006, 01:25 AM
placid
Guest
 
Posts: n/a
Default Re: serial ports, threads and windows


Tom Brown wrote:
Quote:
When it runs on Windows, could it be:
>
1) Just struggling to run inside of VMware?
i have gut feeling that it could be that this is the problem.

  #3  
Old August 3rd, 2006, 04:25 AM
Grant Edwards
Guest
 
Posts: n/a
Default Re: serial ports, threads and windows

On 2006-08-02, Tom Brown <brown@esteem.comwrote:
Quote:
When it runs on Windows, could it be:
>
1) Just struggling to run inside of VMware?
Could be.

Virtual machines are rather tricky things on broken
architectures that don't really permit true virtualization.
Quote:
2) Using threads with Qt on Windows is a problem?
Doubt it.
Quote:
3) Threads in python on Windows is a problem?
No.

--
Grant Edwards grante Yow! I'LL get it!! It's
at probably a FEW of my
visi.com ITALIAN GIRL-FRIENDS!!
  #4  
Old August 3rd, 2006, 10:45 AM
Pekka Niiranen
Guest
 
Posts: n/a
Default Re: serial ports, threads and windows

Tom Brown wrote:
Quote:
Hey people,
>
I've written a python app that r/w eight serial ports to control eight devices
using eight threads. This all works very nicely in Linux. I even put a GUI on
it using PyQt4. Still works nicely.
>
Then I put the app on on a virtual Windows machine running inside of vmware on
the same Linux box. Vmware only lets me have four serial ports so I run the
app against four serial ports using four threads. The app did not respond
quick enough to data from the serial ports and eventually hung.
>
So, I tried one serial port and the app still did not respond quick enough to
the single serial port. It eventually hangs.
>
When the app hung, in each case, it was not hogging the cpu nor reading any
data off the serial ports. The task manager didn't show it was doing anything
at all.
>
When it runs on Windows, could it be:
>
1) Just struggling to run inside of VMware?
>
2) Using threads with Qt on Windows is a problem?
>
3) Threads in python on Windows is a problem?
>
Any ideas?
>
Thanks,
Tom
Hi,

I have been using wxpython myself with pyserial in Windows 2000/XP.
No problems. Below are (edited) code segments. The "self.jam" is
used for stopping serial port processing without stopping the thread.

-------- thread example starts --------------------

class T1Thread(Thread):
def __init__(self, inport):
Thread.__init__(self)
self._want_abort = 0
self.inprt = inport # COMx
self.inprt.flushInput()
self.run_count = 0
#
self.jam = false
#
self.start()

def run(self):
while self._want_abort == 0:
if not self.jam:
self.read_simulations()
sleep(1)

def abort(self):
self._want_abort = 1 # Stop from GUI


def read_simulations(self):
..blah..blah..
self.inprt.flushInput()
sleep(5)

-------- thread example ends --------------------

-------- Wxpython code starts --------------------

def OnRun(self, event):
if self.in_port != "No" and not self.T1worker:
self.T1worker = T1Thread(self.inprt)
if self.out_port != "No" and not self.T2worker:
self.T2worker = T2Thread(self.outprt)
if self.in2_port != "No" and not self.T3worker:
self.T3worker = T3Thread(self.in2prt)


def OnStop(self, event):
if self.T1worker:
self.T1worker.abort()
if self.T2worker:
self.T2worker.abort()
if self.T3worker:
self.T3worker.abort()
sleep(3)
self.T1worker= None
self.T2worker= None
self.T3worker= None
print "\nSTOPPED\n"

-------- Wxpython code ends --------------------

-pekka-
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles