LabWindows/CVI

cancel
Showing results for 
Search instead for 
Did you mean: 

viFindRsrc opens & closes my virtual COM port, but viOpen returns VI_ERROR_RSRC_BUSY

Hello,
 
I have a virtual serial COM port which quite happily shows up in MAX as ASRL5::INSTR.
I can also open a HyperTerminal session to it.
 
When I do a viFindRsrc, my 'Open' routine of my virtual COM port gets called, followed by the 'Close' routine.
So I know that VISA can open and close the device. Great.
This is also what happens when I open the HyperTerminal session.
 
However when I try a viOpen with the string that viFindRsrc gave me ("ASRL5::INSTR"),
VISA returns with VI_ERROR_RSRC_BUSY.
 
Nevertheless I can then open a HyperTerminal session (which calls my 'Open' routine)
and do a find with MAX which does the same thing.
 
Please don't tell me that another piece of software has the COM port already open or busy.
If vIFindRsrc can open it and close it - or HyperTerminal, then I would like to be able to do the same thing with viOpen.
Changing the AccessMode for viOpen gives me no success.
 
I have VISA 3.6 and am running XP with SP2
 
So the bottom line? viFindRsrc opens & closes my port, but viOpen returns VI_ERROR_RSRC_BUSY.
 
Any help would be much appreciated.
 
Thanks.
TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 1 of 8
(5,217 Views)
When do you try the same things on the PC's standard COM port (such as COM1, if your PC has any), do you see the same symptom? If the symptom only happens on the virtual COM port, its device driver may be concerning.
0 Kudos
Message 2 of 8
(5,199 Views)

It is difficult to try it out on another COM port. But either way, I can establish a connection to my virtual COM port with any other terminal program (Hyperterm etc.), and as I said even MAX opens & closes my COM port when I run MAX and click on Devices & Interfaces. At that moment the Open & Close routines of my virtual COM port are called.

So why will viOpen not succeed when viFindRsrc does?

What does viFindRsrc do in order that the Open & Close routines are called?

NI please help me out here.

 

TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 3 of 8
(5,177 Views)
Hey,
Try viClose after viFindRsrc with the same string i,e ASRL5::INSTR, and then use viOpen. This will close any reference of that COM port and will start a new session. I am sure this will help. Let me know how it goes.
Regards
Nikhil A.
0 Kudos
Message 4 of 8
(5,157 Views)
Thanks for the suggestion, but viClose takes an unsigned int, and not a string. viClose takes the resource ID returned by VISA when a viOpen is successful.
TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
Message 5 of 8
(5,153 Views)

When you call viClose() for a valid VISA session, it requires you already have the session (ViSession) acquired from a successful viOpen().  Passing an invalid session to viClose() just generates an error.

But there is another viClose() call concerning viFindRsrc().  If you have called viFindRsrc() and viFindNext(), you must close the "find list" session acquired from viFindRsrc().  Likely forgetting viClose() for this situation may prevent to open the COM port.

このメッセージは 04-04-2007 10:41 AMに Makoto が編集しています。

0 Kudos
Message 6 of 8
(5,138 Views)

"Likely forgetting viClose() for this situation may prevent to open the COM port.".

Yes - and I had checked this especially.

So I can run my routine with the viFindRsrc in it over and over, and each time it will faithfully open and close my COM port.

When viFindRsrc is called, NI SPY logs this as viFindRsrc and the breakpoint for objVPort_OnOpened() is hit in my virtual COM port followed by objVPort_OnClosed(). This all takes places for one viFindRsrc call logged on one line of SPY.exe.

I'd love to know what the source code for viFindRsrc is, because I think it must not use viOpen to do it's "Open".

Does anyone know the inner workings of viFindRsrc? Could someone from NI shed some light on this please?

 

 

TestStand 4.2.1, LabVIEW 2009, LabWindows/CVI 2009
0 Kudos
Message 7 of 8
(5,111 Views)
Hey,
I have tired  that but found out that viFindRscr doesnot use viOpen.vi.
Thanks,
Nikhil A.

0 Kudos
Message 8 of 8
(5,089 Views)