[IronPython] Serial Port Commn: unhandled ObjectDisposedException though exception handler provided

Sheetal.Pawar at lntinfotech.com Sheetal.Pawar at lntinfotech.com
Wed Nov 19 06:41:00 CET 2008


Hi,
I am writing a serial port communication application using Iron Python. 
Following is a sample code:
         try:
            BaudRate = 9600
            DataBits = 8           
           
#create a serial port instance for the desired port as specified
            serialPort = System.IO.Ports.SerialPort( "COM1")
           
            serialPort.BaudRate = BaudRate 

            serialPort.DataBits = DataBits 
#open the port
            serialPort.Close()
            serialPort.Open()
            serialPort.ReadTimeout = 30000
            returnValue = serialPort.ReadTo( "xx" )
        except:
            print "error"
            returnValue = ""
        serialPort.Close()
        serialPort.Dispose()
 
Here if i abort my application using Cntrl + C on the iron python console, 
then i get ObjectDisposedException unhandled though i have provided an 
exception handler.
I tried to abort the application while it was waiting for some data to be 
read and the timeout had not occured. The application exits and I get the 
exception after it exits.
Stack Trace: 

   at Microsoft.Win32.Win32Native.SetEvent(SafeWaitHandle handle)
   at System.Threading.EventWaitHandle.Set()
   at System.IO.Ports.SerialStream.AsyncFSCallback(UInt32 errorCode, 
UInt32 numBytes, NativeOverlapped* pOverlapped)
   at 
System.Threading._IOCompletionCallback.PerformIOCompletionCallback(UInt32 
errorCode, UInt32 numBytes, NativeOverlapped* pOVERLAP)

Please let me know what can be the issue.

Thanks & regards,
Sheetal





______________________________________________________________________
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20081119/c1db59b7/attachment.html>


More information about the Ironpython-users mailing list