<DIV>Hello,</DIV> <DIV>I'm getting in a bit over my head here and need some help. I'm running a simple wxpython application that runs a thread in the background. The thread is supposed to read and write data to/from an OPC server - which I use to communicate to a PLC (programmable logic controller, for process automation). My OPC module works well for just reading and writing to the OPC server; however when I try to read and write to the OPC server from within the thread it doesn't work. I get this error:</DIV> <DIV> </DIV> <DIV>Here's the snippet from my thread:</DIV> <DIV># connect to server </DIV> <DIV>opcServerName = 'the server name goes here'</DIV> <DIV>opcItemName = 'the opc item goes here'</DIV> <DIV>(server, group) = myOPC.connectServer(opcServerName)</DIV> <DIV>item = myOPC.addItem(opcItemName, group)</DIV> <DIV>value = myOPC.readItemValue(item)</DIV> <DIV># the value return a tuple of info including a value and timestamp and quality<BR></DIV>
<DIV>Here's the error that's returned:</DIV> <DIV>line 124, in readItemValue<BR> return opcItem.Read(0x1)<BR> File "<COMObject AddItem>", line 3, in Read<BR> File "C:\Python25\lib\site-packages\win32com\client\dynamic.py", line 258, in _ApplyTypes_<BR> result = self._oleobj_.InvokeTypes(*(dispid, LCID, wFlags, retType, argTypes) + args)<BR>com_error: (-2147352567, 'Exception occurred.', (0, None, None, None, 0, -2147221008), None)</DIV> <DIV> </DIV> <DIV>I attached my OPC module, if its important to include the wxapp I can do that to, but it's pretty apparent that the problem only happens when I call my OPC funcitons from within a thread... </DIV> <DIV> </DIV> <DIV>I suppose its also worthwhile to mention that I need to access the OPC module from within a thread (thats not the main applications thread) because I'm trying to aquire data from a PLC and I want to do that continuously and not lock
up my program.</DIV> <DIV> </DIV> <DIV>Any ideas on how I might get this thing to work within the thread? Thanks!</DIV> <DIV> </DIV> <DIV> </DIV> <DIV>Jeff</DIV><p> 
<hr size=1>Get easy, one-click access to your favorites.
<a href="http://us.rd.yahoo.com/evt=51443/*http://www.yahoo.com/r/hs"> Make Yahoo! your homepage.</a>