06-17-2014 09:52 PM
I am using a LabWindows/CVI created DLL to control a NI-2593 coax switch card from one application and would like to access the switch card from a second applicaiton written in LabView that will act as a standalone panel to monitor the switch resource.
I have no problem controlling/monitoring the coax switch card with either applicaiton alone but when using both applications the first one to access the switch card is the one that gets it and locks out the second applicaiton.
using MAX it appears that I can access the coax switch with my DLL and MAX will work fine as a monitor if I understand what I am seeing correctly. How can one do this in their own applicaitons?
Thanks
06-18-2014 12:21 AM - edited 06-18-2014 12:23 AM
Hi,
If I had this problem I would start by trying to share the session handle between applications.
If you find a way to pass the handle (output by _init function) to the second application maybe it will let you operate within the same session but from two applications.
If you want to see how NI does it, you can spy on it 😉
There is a tool for that. It was named NI-Spy previously and was used to monitor the 488.2 bus.
Now it is called NI IO Trace and it is extended to monitor specific library function calls.
It is under the Tools menu in NI MAX.
From the IO Trace settings you can choose which APIs to monitor.
First start with your DLL and then open NI MAX and IO Trace and try to access the switch card while monitoring the NI Switch API.
Probably it has a way of discovering the currently open sessions and uses the same session to monitor/operate the hardware.
I'll be glad if you share the results. I am curious, too..
Regards,
Edit: this is my 666th post in NI forums. Hope it does not bring bad luck 😄
06-18-2014 05:07 PM
Hello,
You can't have two separate tasks on the same device; that will cause a resource error. You could try using the sames session ID, as the ebalci above suggested. It seems like having two applications controlling the same device could run into some race condition issues.
06-18-2014 05:29 PM
Ok, Then how come it appears that when my application is running and I step through it I can see it on MAX?
Is this an illusion that makes MAX appear to be showing the state of the coax switch card while we command it from our applicaiton?
I might not have made it clear in my earlier post that the second applicaiton is to just monitor the state of the coax switch card while the first applicaiton controls it. The second application is more for a debugging tool so we have a more detailed view of what is actually happening in the system. The only situation we can think of right now in which the second applicaiton would send any control commands to the coax switch card would be if our first applicaiton terminated without clearing any switch settings before exiting. Both of these cases I don't see as creating any race conditions so we think it will be ok
Thanks,
06-18-2014 07:02 PM
I don't have the NI-SWITCH driver on my computer, but typically with our other drivers, like DAQmx and VISA, MAX Test Panels and a separate application cannot access the same resource at the same time. For example, if I run a continuous DAQ example and then try to run a Test Panel in MAX with the same board, I get error -50103 specified resource is reserved. Do you not get this error in MAX when running a Test Panel while the application has a session open with the hardware? If not, the NI I/O Trace is not a bad idea to see what the driver is doing.
Also, this is the LabWindows/CVI Discussion Board, perhaps you can get better assistance about switches specifically on the Switch Hardware and Software discussion board.
06-18-2014 07:20 PM
Thanks Taylor,
I will try this and get back to you.
I post here because my applications are written in LabWindows/CVI and figure this might be a place to ask if someone else has had a similar problem and solved.
Thanks,
06-18-2014 10:54 PM