08-22-2023 01:46 PM
This has been asked before by people using LabView, and apparently there is some sort of solution in LabView. I need a solution that works in CVI/LabWindows 2020.
I have a device (power supply, but that doesn't matter) that's connected to a computer's native COM3 connector. If I use the device identifier "ASRL3::INSTR" I can find it in NI/MAX and talk to the device. Consider the following C program:
//get the instrument identification
sprintf(instr_cmd,"*IDN?\r\n");
// Look for and interpret a reply...
---------
On the machine where I need this to work, I can make the first call and get the default RM. On the second call, the viOpen() fails and returns a VI_ERROR_RSRC_BUSY error. If plug in a USB serial port instead of the port built into the computer, it works fine. In essence, it appears that the IVI serial drivers do something different for native ports (Microsoft drivers) than they do with a USB serial port (FTDI driver). This happens any time I start the program on one particular computer. On another computer with similar hardware, it seems to run okay. It always works with the USB serial port.
Is there any explanation for this and is there a workaround using LabWindows and C?
Thanks!
Howard
08-23-2023 01:39 AM
Any chance some other software has grabbed that port already?
08-23-2023 08:18 AM
I'm pretty sure that's not it. If I make a test case with "Hello World" where a program launches, establishes the VI session and then tries to open the port to send "Hello World", it will work fine on a USB serial port or on some desktop (actually rackmount) machine built-in ports.
My only guess is that it must have something to do with Windows managing the built-in ports using the Microsoft driver, but the USB ports use the FTDI driver. If it were possible somehow to open up the session and ask it which instruments were in use, I could loop through them and maybe make sure they're released. I see a call like that in PyVisa but not in the C version.
08-23-2023 12:17 PM
One thing I did notice is that the machine had VISA version 20.0 and there are updates. I applied the latest 23.5.0. CVI no longer reports VI_ERROR_RSRC_BUSY but it still fails with a bad status and says the resource cannot be accessed.
08-23-2023 03:21 PM
And I think the culprit has been found. I reapplied the Windows driver settings and the problem went away. The port was in fact, in use but I couldn't tell how.
I'd still love a way of querying a session to see what devices have been identified and opened...
08-25-2023 07:45 AM
@HowardE wrote:
I'd still love a way of querying a session to see what devices have been identified and opened...
That requires communicating with the Windows SetupAPI to find your device port and then from there depending on what type of device it is, to try to communicate with it accordingly. It's doable but the SetupAPI is a pita to work with.