11-30-2007 06:06 AM
11-30-2007 10:09 AM
Have you tried this approach?
http://msdn2.microsoft.com/en-us/library/h90dkhs0(VS.80).aspx
12-03-2007 02:27 AM
Hello Garth,
thanks for the reply. Yes, I do use the memory mapped file approach described in the article. And this works just fine. The problem I face is , that the very same VISA session handle that I got in Process 1, seems not usable in Process 2.
In other words: The VISA handle seems only valid in the process it was created.
Thanks,
Greg
12-04-2007 12:28 PM
Hi Greg,
The method you are using to pass the session between the DLLs should be working. The error you are receiving basically implies that the session is somehow being closed out. In LabVIEW there is a setting that automatically closes a VISA session when the top level vi goes idle, resulting in an Invalid VISA Session Error. There might be a similar setting in the program you are using. My guess is that your program is somehow closing it out within the DLL or automatically closing the session when you access the other DLL.
What program are you using to call the DLLs? What is the exact error that you are receiving? What information are you passing between the DLLs? Some more specific information about what you are working with may help me figure out the issue.
Regards,
Lauren L.
12-05-2007 03:28 AM
Hello Lauren,
thanks for taking care of that issue. I have compiled a detailled description of the problem in the attached pdf.
Best Regards,
Greg
12-06-2007 06:04 PM
Hi Greg,
Thanks for the detailed description of your setup and problem. The DLL appears to make sense, so I have been trying to build it for further testing. In order to make it easier, could you include all the CVI project files including the .prj, .c, .h files as well as any other files needed to compile the DLL?
Regards,
Lauren L.
12-07-2007 02:05 AM
Hello Lauren,
sure, no problem. All the necessary files are zipped and attached.
In the DLL, I initialize and access a GPIB instrument. You will have to adapt the address and command to the hardware you use. The effect also shows with ASRLx if you prefer RS232.
Thanks!
Best Regards,
Greg
12-10-2007 10:07 AM
Lauren L wrote:
The method you are using to pass the session between the DLLs should be working.
12-10-2007 01:13 PM
I believe that JR is correct. After looking into this further I am not sure that it is possible to do using two different applications. It can be done in two different VI's (in LabVIEW) because they are located in the same application. In separate applications, however, Windows will make sure they have their own memory space, meaning the second application will not be able to access the VISA session.
You might need to consider other alternatives, such as calling everything within one application or opening and closing the session each time. I am sorry that there are not any better options. Good luck with everything!
Lauren L.
12-11-2007 01:50 AM
Hello Lauren,
Hello JR,
thanks for your help. However I don't want to give up so fast. After all, - we're only looking to access a bunch of bytes ![]()
I found a "DuplicateHandle" function in the SDK, that does exactly the thing I need to do, only with windows-, not with VISA handles.
However, isn't there either a equivalent function for VISA handles, or would anyone know how to implement such a function for VISA?
Thanks again,
Greg
The DuplicateHandle function duplicates an object handle. The duplicate handle refers to the same object as the original handle. Therefore, any changes to the object are reflected through both handles. For example, the current file mark for a file handle is always the same for both handles.
BOOL DuplicateHandle( HANDLE hSourceProcessHandle, // handle to source process HANDLE hSourceHandle, // handle to duplicate HANDLE hTargetProcessHandle, // handle to target process LPHANDLE lpTargetHandle, // duplicate handle DWORD dwDesiredAccess, // requested access BOOL bInheritHandle, // handle inheritance option DWORD dwOptions // optional actions );