Answer the question
In order to leave comments, you need to log in
How to close SerialPort if device is disabled?
An IOException is thrown when trying to send any data to a disconnected device. Further, with cport.close(), another IOException is triggered (The device does not recognize the command). Using Port.Dispose() throws the same exception.
/*Грубо вырезанный кусок кода*/
...
SerialPort cport;
...
try
{
...
cport.Write(a, 0, a.Length);
}
catch (Exception)
{
cport.close();
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question