How do I close an open instrument handle following an error?
I’m using MATLAB 2018a on Windows 10 Enterprise.
I’m writing code to talk to and read from instruments that are on a LAN interface.
I use commands similar to:
instrOfInterest_handle = visa(‘agilent’, sprintf(‘TCIP0::%s::instr0::INSTR, IpAddressStruct.instrOfInterest)
to find the instrument handle, and then commands similar to:
fopen(instrOfInterest_handle);
to open communication with the instrument.
I normally close the communication with a command similar to
fclose(instrOfInterest_handle);
However, since I’m writing / developing the code, sometimes I make mistakes and the program I’m developing halts in an error state, before running the command to close the communcations.
When that happens, I’m unable to re-open the communication channel to the instrument. Instead, I get an error similar to:
Warning: : Unsuccessful open: The specified configuration:
TCPIP0::IpAddressOfInterest::inst0::INSTR is not available
Use INSTRHWINFO for a list of available configurations. Use INSTRFIND to determine if other instrument objects are connected to the requested instrument.
If I was getting an error similar to this when trying to write to a file, I’d run the
fclose(‘all’);
command. However, there doesn’t appear to be anything similar when writing to instruments.
The only way I’ve figured out to be able to re-open the communications channel to the instrument is to kill off MATLAB and then restart it.
I figure there has to be a better way; I just don’t know what that better way is.I’m using MATLAB 2018a on Windows 10 Enterprise.
I’m writing code to talk to and read from instruments that are on a LAN interface.
I use commands similar to:
instrOfInterest_handle = visa(‘agilent’, sprintf(‘TCIP0::%s::instr0::INSTR, IpAddressStruct.instrOfInterest)
to find the instrument handle, and then commands similar to:
fopen(instrOfInterest_handle);
to open communication with the instrument.
I normally close the communication with a command similar to
fclose(instrOfInterest_handle);
However, since I’m writing / developing the code, sometimes I make mistakes and the program I’m developing halts in an error state, before running the command to close the communcations.
When that happens, I’m unable to re-open the communication channel to the instrument. Instead, I get an error similar to:
Warning: : Unsuccessful open: The specified configuration:
TCPIP0::IpAddressOfInterest::inst0::INSTR is not available
Use INSTRHWINFO for a list of available configurations. Use INSTRFIND to determine if other instrument objects are connected to the requested instrument.
If I was getting an error similar to this when trying to write to a file, I’d run the
fclose(‘all’);
command. However, there doesn’t appear to be anything similar when writing to instruments.
The only way I’ve figured out to be able to re-open the communications channel to the instrument is to kill off MATLAB and then restart it.
I figure there has to be a better way; I just don’t know what that better way is. I’m using MATLAB 2018a on Windows 10 Enterprise.
I’m writing code to talk to and read from instruments that are on a LAN interface.
I use commands similar to:
instrOfInterest_handle = visa(‘agilent’, sprintf(‘TCIP0::%s::instr0::INSTR, IpAddressStruct.instrOfInterest)
to find the instrument handle, and then commands similar to:
fopen(instrOfInterest_handle);
to open communication with the instrument.
I normally close the communication with a command similar to
fclose(instrOfInterest_handle);
However, since I’m writing / developing the code, sometimes I make mistakes and the program I’m developing halts in an error state, before running the command to close the communcations.
When that happens, I’m unable to re-open the communication channel to the instrument. Instead, I get an error similar to:
Warning: : Unsuccessful open: The specified configuration:
TCPIP0::IpAddressOfInterest::inst0::INSTR is not available
Use INSTRHWINFO for a list of available configurations. Use INSTRFIND to determine if other instrument objects are connected to the requested instrument.
If I was getting an error similar to this when trying to write to a file, I’d run the
fclose(‘all’);
command. However, there doesn’t appear to be anything similar when writing to instruments.
The only way I’ve figured out to be able to re-open the communications channel to the instrument is to kill off MATLAB and then restart it.
I figure there has to be a better way; I just don’t know what that better way is. fclose, instruments MATLAB Answers — New Questions