Hi,
I am writing a serial port communication application using Iron Python. Following is my code:
class serial:
def sendMessage( self, entity, command, endstring ):
try:
BaudRate = 9600
DataBits = 8
comPort = "COM1"
#create a serial port instance for the desired port as specified
serialPort = System.IO.Ports.SerialPort( comPort )
serialPort.BaudRate = BaudRate
serialPort.DataBits = DataBits
#open the port
serialPort.Close()
serialPort.Open()
serialPort.ReadTimeout = 30000
serialPort.Write( command )
returnValue = serialPort.ReadTo( endstring )
except:
print "error"
returnValue = ""
serialPort.Close()
serialPort.Dispose()
return returnValue
com1 = serial()
a = com1.sendMessage( "ABC", "2", "B" )
Here if i abort my application using Cntrl + C then i get ObjectDisposedException unhandled though i have provided an exception handler.
Can you please help me with the same.................