I use USB-devices that create virtual serial ports in Windows, for instance COM5. When MATLAB opens a connection with one of these devices and the device disconnects and reconnects, I am unable to use the device any more. What can I do to regain access to the device?
myComPort = serial('COM5');
fopen(myComPort);
% now disconnect the device
% now connect the device again, the following will be unsuccessful:
delete(myComPort)
clear myComPort
myComPort = serial('COM5');
fopen(myComPort);
Error using serial/fopen (line 72)
Open failed: Port: COM5 is not available. Available ports: COM1, COM3.
Use INSTRFIND to determine if other instrument objects are connected to the requested device.
Best Answer