I am in the process of rewriting some of the production test software for the company that I am working for. The development dictates that I rewrite all of the instrument drivers placing them into a DLL. Next, I will rewrite all of the test functions placing them into another DLL. The addition to what they were doing is to add TestStand to call the test functions in the desired sequence. The old code used the old LabWindows sequencer from years ago. They insist on using the GPIB function calls rather than allow me to use the generic viWrite, viRead, etc.
I have developed the instrument drivers so that the driver keeps track of the handles. That worked find when I test the LabWindows test functions calling the instrument functions. However, I am having issues when calling the test functions through TestStand. I put MessagePopups within my instrument driver code to see what is going on. I see that the handle is there sometimes and not others. I would assume that perhaps TestStand creates different instances of the DLL code (???). Anyway, I did add a pragma to see if that would cure the issue.
struct AC_Power_Config
{
int ACPower_Device;
int ACPower_GPIB_BoardIndex;
int ACPower_GPIB_PrimaryAddress;
int ACPower_GPIB_SecondaryAddress;
int ACPower_GPIB_IOtimeout;
int ACPower_GPIB_EOImode;
int ACPower_GPIB_EOScharacter;
};
//
#if defined(__AC_POWER_SUPPLY__)
#pragma data_seg("AC_POWER_SHARED")
//
int ACPower_GPIB_Handle = -1;
struct AC_Power_Config AC_Power_Configuration;
//
#pragma data_seg()
#pragma comment(linker, "/section:AC_POWER_SHARED,RWS")
#endif
It did not. I am not sure if I passed the handle back to TestStand allowing it to keep track of the handles, if the handles would still work.
Are there some instructions that I can put into my LabWindows code or some link options that I can use to make sure that the handles are kept in the DLL memory area and that all function calls reference this memory? Any thoughts on the best method to handle this would be appreciated. Although changing the overall design (TestStand to DLL to DLL) cannot be done.
Thank you